Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
kroist committed Dec 12, 2024
1 parent 5329a34 commit b331a54
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 32 deletions.
52 changes: 27 additions & 25 deletions .github/workflows/manual-deploy-contract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ on:
environment:
description: "Environment to deploy to"
required: true
default: "testnet-dev"
default: "dev"
type: choice
options:
- "testnet-dev"
- "testnet-stage"
- "mainnet-prod"
- "dev"
- "stage"
- "prod"

jobs:
deploy-contracts:
Expand Down Expand Up @@ -44,17 +44,35 @@ jobs:
- name: Install deps
run: make deps

# for "testnet-dev" we use default owner address, as it's not important
# for "dev" we use default owner address, as it's not important
- name: Set environment-specific variables
run: |
if [ "${{ github.event.inputs.environment }}" == "testnet-dev" ]; then
if [ "${{ github.event.inputs.environment }}" == "dev" ]; then
echo "PRIVATE_KEY=${{ secrets.CI_TESTNET_DEPLOYER_PRIVATE_KEY }}" >> $GITHUB_ENV
elif [ "${{ github.event.inputs.environment }}" == "testnet-stage" ]; then
echo "NETWORK=https://rpc.alephzero-testnet.gelato.digital" >> $GITHUB_ENV
echo "EXPLORER_URL=https://evm-explorer-testnet.alephzero.org/api" >> $GITHUB_ENV
echo "ADDRESSES_S3_PATH=testnet/dev.json" >> $GITHUB_ENV
echo "AWS_ACCESS_KEY_ID=${{ secrets.CONTRACTS_ZKOS_ADDRESSES_TESTNET_DEV_RW_AWS_ACCESS_KEY_ID }}" >> $GITHUB_ENV
echo "AWS_SECRET_ACCESS_KEY=${{ secrets.CONTRACTS_ZKOS_ADDRESSES_TESTNET_DEV_RW_AWS_SECRET_ACCESS_KEY }}" >> $GITHUB_ENV
elif [ "${{ github.event.inputs.environment }}" == "stage" ]; then
echo "OWNER_ADDRESS=${{ vars.CI_TESTNET_STAGE_OWNER_ADDRESS }}" >> $GITHUB_ENV
echo "PRIVATE_KEY=${{ secrets.CI_TESTNET_DEPLOYER_PRIVATE_KEY }}" >> $GITHUB_ENV
elif [ "${{ github.event.inputs.environment }}" == "mainnet-prod" ]; then
echo "NETWORK=https://rpc.alephzero-testnet.gelato.digital" >> $GITHUB_ENV
echo "EXPLORER_URL=https://evm-explorer-testnet.alephzero.org/api" >> $GITHUB_ENV
echo "ADDRESSES_S3_PATH=testnet/stage.json" >> $GITHUB_ENV
echo "AWS_ACCESS_KEY_ID=${{ secrets.CONTRACTS_ZKOS_ADDRESSES_TESTNET_STAGE_RW_AWS_ACCESS_KEY_ID }}" >> $GITHUB_ENV
echo "AWS_SECRET_ACCESS_KEY=${{ secrets.CONTRACTS_ZKOS_ADDRESSES_TESTNET_STAGE_RW_AWS_SECRET_ACCESS_KEY }}" >> $GITHUB_ENV
elif [ "${{ github.event.inputs.environment }}" == "prod" ]; then
echo "OWNER_ADDRESS=${{ vars.MAINNET_PROD_OWNER_ADDRESS }}" >> $GITHUB_ENV
echo "PRIVATE_KEY=${{ secrets.CI_MAINNET_DEPLOYER_PRIVATE_KEY }}" >> $GITHUB_ENV
echo "NETWORK=https://rpc.alephzero.raas.gelato.cloud" >> $GITHUB_ENV
echo "EXPLORER_URL=https://evm-explorer.alephzero.org/api" >> $GITHUB_ENV
echo "ADDRESSES_S3_PATH=mainnet/prod.json" >> $GITHUB_ENV
echo "AWS_ACCESS_KEY_ID=${{ secrets.CONTRACTS_ZKOS_ADDRESSES_MAINNET_PROD_RW_AWS_ACCESS_KEY_ID }}" >> $GITHUB_ENV
echo "AWS_SECRET_ACCESS_KEY=${{ secrets.CONTRACTS_ZKOS_ADDRESSES_MAINNET_PROD_RW_AWS_SECRET_ACCESS_KEY }}" >> $GITHUB_ENV
else
echo "Invalid environment selected!" >&2
exit 1
Expand All @@ -65,11 +83,10 @@ jobs:

- name: Deploy contracts
run: |
NETWORK=https://rpc.alephzero-testnet.gelato.digital \
make deploy-contracts
- name: Verify Shielder contract
run: ./scripts/verify-shielder-testnet.sh
run: ./scripts/verify-shielder.sh

- name: Upload Shielder abi to artifacts
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -110,25 +127,10 @@ jobs:
cat contract_spec_with_block_numbers.json
- name: Determine address to store
run: |
if [ "${{ github.event.inputs.environment }}" == "testnet-dev" ]; then
echo "ADDRESSES_S3_PATH=testnet/dev.json" >> $GITHUB_ENV
elif [ "${{ github.event.inputs.environment }}" == "testnet-stage" ]; then
echo "ADDRESSES_S3_PATH=testnet/stage.json" >> $GITHUB_ENV
elif [ "${{ github.event.inputs.environment }}" == "mainnet-prod" ]; then
echo "ADDRESSES_S3_PATH=mainnet/prod.json" >> $GITHUB_ENV
else
echo "Invalid environment selected!" >&2
exit 1
fi
# yamllint disable rule:line-length
- name: Store addresses in S3 bucket
shell: bash
env:
AWS_ACCESS_KEY_ID: ${{ secrets.CONTRACTS_ZKOS_ADDRESSES_TESTNET_DEV_RW_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CONTRACTS_ZKOS_ADDRESSES_TESTNET_DEV_RW_AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.CONTRACTS_S3BUCKET_REGION }}
run: |
aws s3 cp contract_spec_with_block_numbers.json s3://${{ secrets.CONTRACTS_S3BUCKET_NAME }}/zkos/addresses/${{ env.ADDRESSES_S3_PATH }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@

set -euo pipefail

LIBRARIES=$(cat broadcast/Shielder.s.sol/2039/run-latest.json | jq -r '.libraries | map("--libraries " + .) | join(" ")')
IMPL_CONTRACT_ADDRESS=$(cat broadcast/Shielder.s.sol/2039/run-latest.json \
CHAIN_ID=$(cast chain-id --rpc-url ${NETWORK})

LIBRARIES=$(cat broadcast/Shielder.s.sol/${CHAIN_ID}/run-latest.json | jq -r '.libraries | map("--libraries " + .) | join(" ")')
IMPL_CONTRACT_ADDRESS=$(cat broadcast/Shielder.s.sol/${CHAIN_ID}/run-latest.json \
| jq -r '.transactions | .[] | select(.transactionType=="CREATE") | select(.contractName=="Shielder") | .contractAddress')
PROXY_CONTRACT_ADDRESS=$(cat broadcast/Shielder.s.sol/2039/run-latest.json \
PROXY_CONTRACT_ADDRESS=$(cat broadcast/Shielder.s.sol/${CHAIN_ID}/run-latest.json \
| jq -r '.transactions | .[] | select(.transactionType=="CREATE") | select(.contractName=="ERC1967Proxy") | .contractAddress')
PROXY_DEPLOYMENT_TX_HASH=$(cat broadcast/Shielder.s.sol/2039/run-latest.json \
PROXY_DEPLOYMENT_TX_HASH=$(cat broadcast/Shielder.s.sol/${CHAIN_ID}/run-latest.json \
| jq '.transactions | .[] | select(.transactionType=="CREATE") | select(.contractName=="ERC1967Proxy") | .hash')
PROXY_BLOCK_NUMBER=$(cast to-dec $(cat broadcast/Shielder.s.sol/2039/run-latest.json \
PROXY_BLOCK_NUMBER=$(cast to-dec $(cat broadcast/Shielder.s.sol/${CHAIN_ID}/run-latest.json \
| jq -r ".receipts | .[] | select(.transactionHash==${PROXY_DEPLOYMENT_TX_HASH}) | .blockNumber"))

echo ${PROXY_CONTRACT_ADDRESS} > shielder_address.txt
echo ${PROXY_BLOCK_NUMBER} > shielder_block_number.txt

forge verify-contract --rpc-url https://rpc.alephzero-testnet.gelato.digital \
--verifier blockscout --verifier-url https://evm-explorer-testnet.alephzero.org/api \
forge verify-contract --rpc-url ${NETWORK} \
--verifier blockscout --verifier-url ${EXPLORER_URL} \
${LIBRARIES} \
${IMPL_CONTRACT_ADDRESS} \
contracts/Shielder.sol:Shielder

0 comments on commit b331a54

Please sign in to comment.