From 7c51c7113d1291be9ae559c422e94c4dd277d159 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+shaspitz@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:33:39 -0800 Subject: [PATCH] chore: verify l1 gateway (#519) Co-authored-by: mrekucci --- contracts/entrypoint.sh | 5 +++ infrastructure/nomad/cluster.sh | 34 +++++++++++++------ .../jobs/contracts-deployer.nomad.j2 | 1 + .../nomad/playbooks/variables/profiles.yml | 1 + 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/contracts/entrypoint.sh b/contracts/entrypoint.sh index bdd5d4e67..6ccfd07c6 100755 --- a/contracts/entrypoint.sh +++ b/contracts/entrypoint.sh @@ -14,6 +14,10 @@ KEYSTORE_FILENAME=${KEYSTORE_FILENAME:-*} KEYSTORE_PASSWORD=${KEYSTORE_PASSWORD:-"pwd"} CONTRACT_REPO_ROOT_PATH=${CONTRACT_REPO_ROOT_PATH:-$PWD} +if [ -n "${ETHERSCAN_API_KEY}" ]; then + VERIFY_OPTION="--verify" +fi + if [ "${DEPLOY_TYPE}" = "core" ]; then if [ -z "$ORACLE_KEYSTORE_ADDRESS" ]; then echo "ORACLE_KEYSTORE_ADDRESS not specified" @@ -65,5 +69,6 @@ elif [ "${DEPLOY_TYPE}" = "l1-gateway" ]; then --use 0.8.26 \ --broadcast \ --json \ + ${VERIFY_OPTION} \ --via-ir fi diff --git a/infrastructure/nomad/cluster.sh b/infrastructure/nomad/cluster.sh index f5d69ce0f..ef548229a 100755 --- a/infrastructure/nomad/cluster.sh +++ b/infrastructure/nomad/cluster.sh @@ -15,6 +15,7 @@ environment_name="devenv" profile_name="devnet" datadog_key="" l1_rpc_urls="mock" +etherscan_api_key="" otel_collector_endpoint_url="" genesis_file_url="" geth_bootnode_url="" @@ -22,7 +23,7 @@ geth_bootnode_url="" help() { echo "Usage:" echo "$0 [init [--environment ] [--skip-certificates-setup] [--debug]]" - echo "$0 [deploy [version=HEAD] [--environment ] [--profile ] [--force-build-templates] [--no-logs-collection] [--datadog-key ] [--l1-rpc-urls ] [--otel-collector-endpoint-url ] [--genesis-file-url ] [--geth-bootnode-url ] [--release] [--debug]]" + echo "$0 [deploy [version=HEAD] [--environment ] [--profile ] [--force-build-templates] [--no-logs-collection] [--datadog-key ] [--l1-rpc-urls ] [--etherscan-api-key ] [--otel-collector-endpoint-url ] [--genesis-file-url ] [--geth-bootnode-url ] [--release] [--debug]]" echo "$0 [destroy [--environment ] [--debug]]" echo "$0 --help" echo @@ -33,15 +34,16 @@ help() { echo " --debug Enable debug mode for detailed output." echo echo " deploy [version=HEAD] Deploy the specified artifact version (a git commit hash or an existing AWS S3 tag). If not specified or set to HEAD, a local build is triggered." - echo " --environment ] Specify the environment to use (default is devenv)." - echo " --profile ] Specify the profile to use (default is devnet)." + echo " --environment Specify the environment to use (default is devenv)." + echo " --profile Specify the profile to use (default is devnet)." echo " --force-build-templates Force the build of all job templates before deployment." echo " --no-logs-collection Disable the collection of logs from deployed jobs." - echo " --datadog-key ] Datadog API key, cannot be empty." - echo " --l1-rpc-urls ] Comma separated list of L1 RPC URLs, cannot be empty." - echo " --otel-collector-endpoint-url ] OpenTelemetry Collector Endpoint URL, cannot be empty." - echo " --genesis-file-url ] URL to the genesis file, cannot be empty." - echo " --geth-bootnode-url ] URL to the Geth bootnode, cannot be empty." + echo " --datadog-key Datadog API key, cannot be empty." + echo " --l1-rpc-urls Comma separated list of L1 RPC URLs, cannot be empty." + echo " --etherscan-api-key Etherscan API key, cannot be empty." + echo " --otel-collector-endpoint-url OpenTelemetry Collector Endpoint URL, cannot be empty." + echo " --genesis-file-url URL to the genesis file, cannot be empty." + echo " --geth-bootnode-url URL to the Geth bootnode, cannot be empty." echo " --release It will ignore the specified deployment version and use the current HEAD tag as the build version." echo " --debug Enable debug mode for detailed output." echo @@ -61,7 +63,7 @@ help() { usage() { echo "Usage:" echo "$0 [init [--environment ] [--skip-certificates-setup] [--debug]]" - echo "$0 [deploy [version=HEAD] [--environment ] [--profile ] [--force-build-templates] [--no-logs-collection] [--datadog-key ] [--l1-rpc-urls ] [--otel-collector-endpoint-url ] [--genesis-file-url ] [--geth-bootnode-url ] [--release] [--debug]]" + echo "$0 [deploy [version=HEAD] [--environment ] [--profile ] [--force-build-templates] [--no-logs-collection] [--datadog-key ] [--l1-rpc-urls ] [--etherscan-api-key ] [--otel-collector-endpoint-url ] [--genesis-file-url ] [--geth-bootnode-url ] [--release] [--debug]]" echo "$0 [destroy [--environment ] [--debug]]" echo "$0 --help" exit 1 @@ -123,8 +125,8 @@ check_deps() { parse_args() { while [[ $# -gt 0 ]]; do if $init_flag || $deploy_flag || $destroy_flag; then - echo "Error: Only one of 'init', 'deploy', or 'destroy' can be specified." - usage + echo "Error: Only one of 'init', 'deploy', or 'destroy' can be specified." + usage fi key="$1" @@ -201,6 +203,15 @@ parse_args() { usage fi fi + if [[ $# -gt 0 && $1 == "--etherscan-api-key" ]]; then + if [[ $# -gt 1 && ! $2 =~ ^-- ]]; then + etherscan_api_key="$2" + shift 2 + else + echo "Error: --etherscan-api-key requires a value." + usage + fi + fi if [[ $# -gt 0 && $1 == "--otel-collector-endpoint-url" ]]; then if [[ $# -gt 1 && ! $2 =~ ^-- ]]; then otel_collector_endpoint_url="$2" @@ -293,6 +304,7 @@ main() { [[ "${force_build_templates_flag}" == true ]] && flags+=("--extra-vars" "build_templates=true") [[ -n "${datadog_key}" ]] && flags+=("--extra-vars" "datadog_key=${datadog_key}") [[ -n "${l1_rpc_urls}" ]] && flags+=("--extra-vars" "l1_rpc_urls=${l1_rpc_urls}") + [[ -n "${etherscan_api_key}" ]] && flags+=("--extra-vars" "etherscan_api_key=${etherscan_api_key}") [[ -n "${otel_collector_endpoint_url}" ]] && flags+=("--extra-vars" "otel_collector_endpoint_url=${otel_collector_endpoint_url}") [[ -n "${genesis_file_url}" ]] && flags+=("--extra-vars" "genesis_file_url=${genesis_file_url}") [[ -n "${geth_bootnode_url}" ]] && flags+=("--extra-vars" "geth_bootnode_url=${geth_bootnode_url}") diff --git a/infrastructure/nomad/playbooks/templates/jobs/contracts-deployer.nomad.j2 b/infrastructure/nomad/playbooks/templates/jobs/contracts-deployer.nomad.j2 index ce9d9c334..e898faaae 100644 --- a/infrastructure/nomad/playbooks/templates/jobs/contracts-deployer.nomad.j2 +++ b/infrastructure/nomad/playbooks/templates/jobs/contracts-deployer.nomad.j2 @@ -217,6 +217,7 @@ job "{{ job.name }}" { {% if profile == 'testnet' %} export RPC_URL="{{ job.env['l1_rpc_url'] }}" export CHAIN_ID="17000" + export ETHERSCAN_API_KEY="{{ job.env['etherscan_api_key'] }}" {% endif %} {%- raw %} diff --git a/infrastructure/nomad/playbooks/variables/profiles.yml b/infrastructure/nomad/playbooks/variables/profiles.yml index 2dd19cf56..bdaf451ff 100644 --- a/infrastructure/nomad/playbooks/variables/profiles.yml +++ b/infrastructure/nomad/playbooks/variables/profiles.yml @@ -183,6 +183,7 @@ jobs: env: chain-id: "{{ environments[env].chain_id }}" l1_rpc_url: "{{ resolved_l1_rpc_urls.split(',')[0] }}" + etherscan_api_key: "{{ (etherscan_api_key) if env == 'testnet' else '' }}" mev_commit_dashboard: &mev_commit_dashboard_job name: mev-commit-dashboard