diff --git a/.github/workflows/manual-deploy-contract.yml b/.github/workflows/manual-deploy-contract.yml index 2bf12c28..97e4878e 100644 --- a/.github/workflows/manual-deploy-contract.yml +++ b/.github/workflows/manual-deploy-contract.yml @@ -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: @@ -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 @@ -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 @@ -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 }} diff --git a/scripts/verify-shielder-testnet.sh b/scripts/verify-shielder.sh similarity index 58% rename from scripts/verify-shielder-testnet.sh rename to scripts/verify-shielder.sh index 8740c1f4..5a7dc406 100755 --- a/scripts/verify-shielder-testnet.sh +++ b/scripts/verify-shielder.sh @@ -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