From 112423f43574681d21bb611d87474fb935638a72 Mon Sep 17 00:00:00 2001 From: Aleksandr Tarelkin Date: Mon, 23 Oct 2023 06:57:07 +0300 Subject: [PATCH] verification script --- bytecode-verificator/bytecode_verificator.sh | 26 ++++++++++++-------- scripts/verify_simple_dvt_factories.sh | 25 ++++++++++++++++++- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/bytecode-verificator/bytecode_verificator.sh b/bytecode-verificator/bytecode_verificator.sh index 520a5025..438b41fb 100755 --- a/bytecode-verificator/bytecode_verificator.sh +++ b/bytecode-verificator/bytecode_verificator.sh @@ -27,7 +27,7 @@ prerequisites=(jq yarn awk curl shasum uname bc nc) envs=(ETHERSCAN_TOKEN) # Commandline args required -cmdargs=(solc_version remote_rpc_url contract config_json) +cmdargs=(solc_version remote_rpc_url etherscan_api_url contract config_json) sha256sum='shasum -a 256' # Vars @@ -45,15 +45,16 @@ function show_help() { CLI tool to validate contract bytecode at remote rpc node, etherscan and bytecode deployed from local source code - $0 [--solc-version ] [--remote-rpc-url ] [--contract ] [--config-json ] [--constructor-calldata ] [-h|--help] + $0 [--solc-version ] [--remote-rpc-url ] [--etherscan-api-url ] [--contract ] [--config-json ] [--constructor-calldata ] [-h|--help] Options: - --solc-version SOLC-VERSION version of solidity to compile contract with (e.g. 0.4.24, 0.8.9) - --remote-rpc-url REMOTE-RPC-URL Ethereum node URL that contains the comparating contract bytecode. e.g. https://mainnet.infura.io/v3/\$WEB3_INFURA_PROJECT_ID - --contract CONTRACT Contract name from config file. (e.g. app:lido, stakingRouter, lidoLocator ...) - --config-json CONFIG-JSON Path to JSON file. Artifacts of deployment (e.g './deployed-mainnet.json') - --constructor-calldata DATA (optional) Calldata that will be used for local contract deployment. Will be encoded from config file if does not provided. (hex data with no 0x prefix) - -h, --help Prints help. + --solc-version SOLC-VERSION version of solidity to compile contract with (e.g. 0.4.24, 0.8.9) + --remote-rpc-url REMOTE-RPC-URL Ethereum node URL that contains the comparating contract bytecode. e.g. https://mainnet.infura.io/v3/\$WEB3_INFURA_PROJECT_ID + --etherscan-api ETHERSCAN-API-URL Etherscan API URL e.g. https://api.etherscan.io/api + --contract CONTRACT Contract name from config file. (e.g. app:lido, stakingRouter, lidoLocator ...) + --config-json CONFIG-JSON Path to JSON file. Artifacts of deployment (e.g './deployed-mainnet.json') + --constructor-calldata DATA (optional) Calldata that will be used for local contract deployment. Will be encoded from config file if does not provided. (hex data with no 0x prefix) + -h, --help Prints help. _EOF_ } @@ -111,6 +112,12 @@ function parse_cmd_args() { shift shift ;; + --etherscan-api-url) + etherscan_api_url="$2" + [[ "$etherscan_api_url" =~ ^https ]] || { _err "Invalid Etherscan API URL: $remote_rpc_url"; } + shift + shift + ;; --contract) contract="$2" shift @@ -434,8 +441,7 @@ _get_code() { _get_code_etherscan() { local contract_address=$1 - echo "curl -sS -G -d address=$contract_address -d action=eth_getCode -d module=proxy -d tag=latest -d apikey=$ETHERSCAN_TOKEN https://api.etherscan.io/api" - curl -sS -G -d "address=$contract_address" -d "action=eth_getCode" -d "module=proxy" -d "tag=latest" -d "apikey=$ETHERSCAN_TOKEN" https://api.etherscan.io/api | jq -r '.result' + curl -sS -G -d "address=$contract_address" -d "action=eth_getCode" -d "module=proxy" -d "tag=latest" -d "apikey=$ETHERSCAN_TOKEN" "$etherscan_api_url" | jq -r '.result' } _get_account() { diff --git a/scripts/verify_simple_dvt_factories.sh b/scripts/verify_simple_dvt_factories.sh index b345e453..ba7dfe1e 100755 --- a/scripts/verify_simple_dvt_factories.sh +++ b/scripts/verify_simple_dvt_factories.sh @@ -1 +1,24 @@ -./bytecode-verificator/bytecode_verificator.sh --solc-version 0.8.6 --remote-rpc-url $REMOTE_RPC --config-json ../deployed-holesky.json --contract AddNodeOperators \ No newline at end of file +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail + +if [[ "${TRACE-0}" == "1" ]]; then + set -o xtrace +fi + +envs=(REMOTE_RPC) + +for e in "${envs[@]}"; do + [[ "${!e:+isset}" == "isset" ]] || { _err "${e} env var is required but is not set"; } +done + +./bytecode-verificator/bytecode_verificator.sh --solc-version 0.8.6 --remote-rpc-url $REMOTE_RPC --config-json ../deployed-holesky.json --contract AddNodeOperators --etherscan-api-url https://holesky.etherscan.io/api +./bytecode-verificator/bytecode_verificator.sh --solc-version 0.8.6 --remote-rpc-url $REMOTE_RPC --config-json ../deployed-holesky.json --contract ActivateNodeOperators --etherscan-api-url https://holesky.etherscan.io/api +./bytecode-verificator/bytecode_verificator.sh --solc-version 0.8.6 --remote-rpc-url $REMOTE_RPC --config-json ../deployed-holesky.json --contract DeactivateNodeOperators --etherscan-api-url https://holesky.etherscan.io/api +./bytecode-verificator/bytecode_verificator.sh --solc-version 0.8.6 --remote-rpc-url $REMOTE_RPC --config-json ../deployed-holesky.json --contract SetVettedValidatorsLimits --etherscan-api-url https://holesky.etherscan.io/api +./bytecode-verificator/bytecode_verificator.sh --solc-version 0.8.6 --remote-rpc-url $REMOTE_RPC --config-json ../deployed-holesky.json --contract SetNodeOperatorNames --etherscan-api-url https://holesky.etherscan.io/api +./bytecode-verificator/bytecode_verificator.sh --solc-version 0.8.6 --remote-rpc-url $REMOTE_RPC --config-json ../deployed-holesky.json --contract SetNodeOperatorRewardAddresses --etherscan-api-url https://holesky.etherscan.io/api +./bytecode-verificator/bytecode_verificator.sh --solc-version 0.8.6 --remote-rpc-url $REMOTE_RPC --config-json ../deployed-holesky.json --contract ChangeNodeOperatorManagers --etherscan-api-url https://holesky.etherscan.io/api +./bytecode-verificator/bytecode_verificator.sh --solc-version 0.8.6 --remote-rpc-url $REMOTE_RPC --config-json ../deployed-holesky.json --contract UpdateTargetValidatorLimits --etherscan-api-url https://holesky.etherscan.io/api \ No newline at end of file