Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WEB3-297: Add bash script to help verify contracts #393

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions contracts/script/verify
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

set -eo pipefail

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
CONTRACTS_DIR="${SCRIPT_DIR:?}/.."

if [ -z "$ETHERSCAN_API_KEY" ]; then
echo -n 'ETHERSCAN_API_KEY from deployment_secrets.toml: ' > /dev/stderr
export ETHERSCAN_API_KEY=$(yq eval -e ".chains[\"${CHAIN_KEY:?}\"].etherscan-api-key" $CONTRACTS_DIR/deployment_secrets.toml)
else
echo -n "ETHERSCAN_API_KEY from env $ETHERSCAN_API_KEY"
fi

export CHAIN_ID=$(yq eval -e ".chains[\"${CHAIN_KEY:?}\"].id" $CONTRACTS_DIR/deployment.toml)
export VERIFIER_ADDRESS=$(yq eval -e ".chains[\"${CHAIN_KEY:?}\"].verifiers[] | select(.selector == \"${VERIFIER_SELECTOR:?}\").verifier" $CONTRACTS_DIR/deployment.toml)
export ESTOP_ADDRESS=$(yq eval -e ".chains[\"${CHAIN_KEY:?}\"].verifiers[] | select(.selector == \"${VERIFIER_SELECTOR:?}\").estop" $CONTRACTS_DIR/deployment.toml)
export ADMIN_ADDRESS=$(yq eval -e ".chains[\"${CHAIN_KEY:?}\"].admin" $CONTRACTS_DIR/deployment.toml)

# NOTE: forge verify-contract seems to fail if an absolute path is used for the contract address.
cd $CONTRACTS_DIR

# TODO: Constructor args are the control root and bn254 control ID. These should be pulled from the relevant source files automatically.
# TODO: This only supports verifying the groth16 verifier and its estop. Support the set verifier as well.
forge verify-contract --watch \
--chain-id=${CHAIN_ID:?} \
--constructor-args "$(\
cast abi-encode 'constructor(bytes32,bytes32)' \
0x8cdad9242664be3112aba377c5425a4df735eb1c6966472b561d2855932c0469 \
0x04446e66d300eb7fb45c9726bb53c793dda407a62e9601618bb43c5c14657ac0 \
)" \
--etherscan-api-key=${ETHERSCAN_API_KEY:?} \
${VERIFIER_ADDRESS:?} \
./src/groth16/RiscZeroGroth16Verifier.sol:RiscZeroGroth16Verifier

forge verify-contract --watch \
--chain-id=${CHAIN_ID:?} \
--constructor-args "$(\
cast abi-encode 'constructor(address,address)' \
${VERIFIER_ADDRESS:?} \
${ADMIN_ADDRESS:?} \
)" \
--etherscan-api-key=${ETHERSCAN_API_KEY:?} \
${ESTOP_ADDRESS:?} \
./src/RiscZeroVerifierEmergencyStop.sol:RiscZeroVerifierEmergencyStop
Loading