From 02542a6c22ba7153c08f1419ae92da4f558d4d16 Mon Sep 17 00:00:00 2001 From: mrekucci Date: Tue, 10 Dec 2024 09:18:42 -0300 Subject: [PATCH] fix: add etherscan_api_key to profiles.yml --- infrastructure/nomad/cluster.sh | 34 +++++++++++++------ .../jobs/contracts-deployer.nomad.j2 | 2 +- .../nomad/playbooks/variables/profiles.yml | 1 + 3 files changed, 25 insertions(+), 12 deletions(-) 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 4ecbc4039..e898faaae 100644 --- a/infrastructure/nomad/playbooks/templates/jobs/contracts-deployer.nomad.j2 +++ b/infrastructure/nomad/playbooks/templates/jobs/contracts-deployer.nomad.j2 @@ -111,7 +111,6 @@ job "{{ job.name }}" { KEYSTORE_DIR="/local/data-{{ env "NOMAD_ALLOC_INDEX" }}/keystore" KEYSTORE_FILENAME="{{ with secret "secret/data/mev-commit" }}{{ .Data.data.{% endraw %}{{ job.artifacts | selectattr('keystores', 'defined') | map(attribute='keystores') | first | list | first }}{% raw %}_filename }}{{ end }}" KEYSTORE_PASSWORD="{{ with secret "secret/data/mev-commit" }}{{ .Data.data.{% endraw %}{{ job.artifacts | selectattr('keystores', 'defined') | map(attribute='keystores') | first | list | first }}{% raw %}_password }}{{ end }}" - ETHERSCAN_API_KEY="{{ with secret "secret/data/etherscan" }}{{ .Data.data.etherscan_api_key }}{{ end }}" {% endraw %} CHAIN_ID="{{ job.env['chain-id'] }}" SCRIPT_PATH_PREFIX="local/contracts/scripts" @@ -218,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..868b81f57 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 }}" mev_commit_dashboard: &mev_commit_dashboard_job name: mev-commit-dashboard