Skip to content

Commit

Permalink
verification script
Browse files Browse the repository at this point in the history
  • Loading branch information
bulbozaur committed Oct 23, 2023
1 parent 69beab4 commit 112423f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 11 deletions.
26 changes: 16 additions & 10 deletions bytecode-verificator/bytecode_verificator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <arg>] [--remote-rpc-url <arg>] [--contract <arg>] [--config-json <arg>] [--constructor-calldata <arg>] [-h|--help]
$0 [--solc-version <arg>] [--remote-rpc-url <arg>] [--etherscan-api-url <arg>] [--contract <arg>] [--config-json <arg>] [--constructor-calldata <arg>] [-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_
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down
25 changes: 24 additions & 1 deletion scripts/verify_simple_dvt_factories.sh
Original file line number Diff line number Diff line change
@@ -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
#!/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

0 comments on commit 112423f

Please sign in to comment.