Skip to content

Commit

Permalink
fix verificator
Browse files Browse the repository at this point in the history
  • Loading branch information
bulbozaur committed Oct 23, 2023
1 parent e51b6e2 commit 69beab4
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 65 deletions.
2 changes: 2 additions & 0 deletions bytecode-verificator/SHA256SUMS
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
d619d4f5d8fd988bc63262407e749e905ccc8d8ab1ccf0280da1d12b918894ce ./compilers/solc-darwin-0.8.9
f851f11fad37496baabaf8d6cb5c057ca0d9754fddb7a351ab580d7fd728cb94 ./compilers/solc-linux-0.8.9
86ee99f64fc7e36bfa046169b6a4d4c10eb35017ed11e0c970f01223b2f5db36 ./compilers/solc-darwin-0.8.6
abd5c4f3f262bc3ed7951b968c63f98e83f66d9a5c3568ab306eac49250aec3e ./compilers/solc-linux-0.8.6
7034c4048bc713d5c14cdd6681953c736e2adbdb9174f8bfbfb6a097109ffaaa ./compilers/solc-darwin-0.4.24
665675b9e0431c2572d59d6a7112afbdc752732ea0ce9aecf1a1855f28e02a09 ./compilers/solc-linux-0.4.24
26 changes: 8 additions & 18 deletions bytecode-verificator/bytecode_verificator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ placeholder_padding=$(printf '%0.1s' "-"{1..64})
prerequisites=(jq yarn awk curl shasum uname bc nc)

# Environment vailable required
envs=(WEB3_INFURA_PROJECT_ID ETHERSCAN_TOKEN)
envs=(ETHERSCAN_TOKEN)

# Commandline args required
cmdargs=(solc_version remote_rpc_url contract config_json)
Expand Down Expand Up @@ -186,7 +186,7 @@ function start_fork() {
cat <<-_EOF_ | xargs | sed 's/ / /g'
yarn ganache --chain.vmErrorsOnRPCResponse true
--wallet.totalAccounts 10 --chain.chainId 1
--fork.url https://mainnet.infura.io/v3/${WEB3_INFURA_PROJECT_ID}
--fork.url ${remote_rpc_url}
--miner.blockGasLimit 92000000
--server.host 127.0.0.1 --server.port ${local_rpc_port}
--hardfork istanbul -d
Expand Down Expand Up @@ -301,21 +301,11 @@ function endode_solidity_calldata_placeholder() {
}

function compile_contract() {
if [[ "$solc_version" =~ ^0.[678].[0-9]+$ ]]; then
rm -rf "${PWD}/build"
cd "${PWD}/.."
./bytecode-verificator/"$solc" @openzeppelin/contracts-v4.4=./node_modules/@openzeppelin/contracts-v4.4 contracts/"$solc_version"/**/*.sol contracts/"$solc_version"/*.sol -o ./bytecode-verificator/build --bin --overwrite --optimize --optimize-runs 200 1>>./logs 2>&1
./bytecode-verificator/"$solc" @openzeppelin/contracts-v4.4=./node_modules/@openzeppelin/contracts-v4.4 contracts/"$solc_version"/**/*.sol contracts/"$solc_version"/*.sol -o ./bytecode-verificator/build --abi --overwrite --optimize --optimize-runs 200 1>>./logs 2>&1
cd - &>/dev/null
elif [[ "$solc_version" == "0.4.24" ]]; then
rm -rf "${PWD}/build"
cd "${PWD}/.."
./bytecode-verificator/"$solc" @aragon=./node_modules/@aragon openzeppelin-solidity/contracts=./node_modules/openzeppelin-solidity/contracts contracts/"$solc_version"/**/*.sol contracts/"$solc_version"/*.sol --allow-paths "$(pwd)" -o ./bytecode-verificator/build --bin --overwrite --optimize --optimize-runs 200 --evm-version constantinople 1>>./logs 2>&1
./bytecode-verificator/"$solc" @aragon=./node_modules/@aragon openzeppelin-solidity/contracts=./node_modules/openzeppelin-solidity/contracts contracts/"$solc_version"/**/*.sol contracts/"$solc_version"/*.sol --allow-paths "$(pwd)" -o ./bytecode-verificator/build --abi --overwrite --optimize --optimize-runs 200 --evm-version constantinople 1>>./logs 2>&1
cd - &>/dev/null
else
_err "Unknown solidity version '$solc_version'"
fi
rm -rf "${PWD}/build"
cd "${PWD}/.."
./bytecode-verificator/"$solc" OpenZeppelin/openzeppelin-contracts@4.3.2/contracts=./node_modules/@openzeppelin/contracts-v4.3.2 contracts/**/*.sol contracts/*.sol -o ./bytecode-verificator/build --allow-paths "$PWD" --bin --overwrite --optimize --optimize-runs 200 1>>./logs 2>&1
./bytecode-verificator/"$solc" OpenZeppelin/openzeppelin-contracts@4.3.2/contracts=./node_modules/@openzeppelin/contracts-v4.3.2 contracts/**/*.sol contracts/*.sol -o ./bytecode-verificator/build --allow-paths "$PWD" --abi --overwrite --optimize --optimize-runs 200 1>>./logs 2>&1
cd - &>/dev/null
}

function deploy_contract_on_fork() {
Expand Down Expand Up @@ -444,7 +434,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'
}

Expand Down
Empty file modified bytecode-verificator/compilers/solc-darwin-0.8.6
100644 → 100755
Empty file.
Empty file modified bytecode-verificator/compilers/solc-linux-0.8.6
100644 → 100755
Empty file.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"husky": "^6.0.0",
"prettier": "^2.3.0",
"prettier-plugin-solidity": "^1.0.0-beta.10",
"pretty-quick": "^3.1.0"
"pretty-quick": "^3.1.0",
"@openzeppelin/contracts-v4.3.2": "npm:@openzeppelin/contracts@4.3.2"
},
"scripts": {
"lint": "pretty-quick --pattern '**/*.*(sol|json)' --verbose",
Expand Down
159 changes: 113 additions & 46 deletions scripts/deploy_simple_dvt_factories.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
from brownie import chain

from utils.config import (
get_is_live,
get_deployer_account,
prompt_bool,
get_network_name,
)
from utils import lido, log
import json
import os

from brownie import (
chain,
AddNodeOperators,
ActivateNodeOperators,
DeactivateNodeOperators,
Expand All @@ -21,6 +14,14 @@
web3,
)

from utils import lido, log
from utils.config import (
get_is_live,
get_deployer_account,
prompt_bool,
get_network_name,
)


def get_trusted_caller():
if "TRUSTED_CALLER" not in os.environ:
Expand All @@ -38,10 +39,12 @@ def main():

deployer = get_deployer_account(get_is_live(), network=network_name)
trusted_caller = get_trusted_caller()
simple_dvt = contracts.simple_dvt.address
acl = contracts.aragon.acl.address

log.br()

log.nb("Current network", network_name(), color_hl=log.color_magenta)
log.nb("Current network", network_name, color_hl=log.color_magenta)
log.nb("Using deployed addresses for", network_name, color_hl=log.color_yellow)
log.nb("chain id", chain.id)

Expand All @@ -51,8 +54,9 @@ def main():

log.br()

log.ok("Simple DVT module address", contracts.simple_dvt)
log.ok("ACL", contracts.aragon.acl)

log.ok("Simple DVT module address", simple_dvt)
log.ok("ACL", acl)
log.ok("Trusted caller", trusted_caller)

log.br()
Expand All @@ -67,58 +71,121 @@ def main():

log.br()

add_node_operator_address = AddNodeOperators.deploy(
trusted_caller, contracts.simple_dvt, contracts.aragon.acl, tx_params
deployment_artifacts = {}

# AddNodeOperators
add_node_operator = AddNodeOperators.deploy(
trusted_caller, simple_dvt, acl, tx_params
)
activate_node_operators_address = ActivateNodeOperators.deploy(
trusted_caller, contracts.simple_dvt, contracts.aragon.acl, tx_params
deployment_artifacts["AddNodeOperators"] = {
"contract": "AddNodeOperators",
"address": add_node_operator.address,
"constructorArgs": [trusted_caller, simple_dvt, acl],
}

# ActivateNodeOperators
activate_node_operators = ActivateNodeOperators.deploy(
trusted_caller, simple_dvt, acl, tx_params
)
deactivate_node_operators_address = DeactivateNodeOperators.deploy(
trusted_caller, contracts.simple_dvt, contracts.aragon.acl, tx_params
deployment_artifacts["ActivateNodeOperators"] = {
"contract": "ActivateNodeOperators",
"address": activate_node_operators.address,
"constructorArgs": [trusted_caller, simple_dvt, acl],
}

# DeactivateNodeOperators
deactivate_node_operators = DeactivateNodeOperators.deploy(
trusted_caller, simple_dvt, acl, tx_params
)
set_vetted_validators_limits_address = SetVettedValidatorsLimits.deploy(
trusted_caller, contracts.simple_dvt, tx_params
deployment_artifacts["DeactivateNodeOperators"] = {
"contract": "DeactivateNodeOperators",
"address": deactivate_node_operators.address,
"constructorArgs": [trusted_caller, simple_dvt, acl],
}

# SetVettedValidatorsLimits
set_vetted_validators_limits = SetVettedValidatorsLimits.deploy(
trusted_caller, simple_dvt, tx_params
)
set_node_operator_names_address = SetNodeOperatorNames.deploy(
trusted_caller, contracts.simple_dvt, tx_params
deployment_artifacts["SetVettedValidatorsLimits"] = {
"contract": "SetVettedValidatorsLimits",
"address": set_vetted_validators_limits.address,
"constructorArgs": [trusted_caller, simple_dvt],
}

# SetNodeOperatorNames
set_node_operator_names = SetNodeOperatorNames.deploy(
trusted_caller, simple_dvt, tx_params
)
set_node_operator_reward_address_address = SetNodeOperatorRewardAddresses.deploy(
trusted_caller, contracts.simple_dvt, tx_params
deployment_artifacts["SetNodeOperatorNames"] = {
"contract": "SetNodeOperatorNames",
"address": set_node_operator_names.address,
"constructorArgs": [trusted_caller, simple_dvt],
}

# SetNodeOperatorRewardAddresses
set_node_operator_reward = SetNodeOperatorRewardAddresses.deploy(
trusted_caller, simple_dvt, tx_params
)
update_tareget_validator_limits_address = UpdateTargetValidatorLimits.deploy(
trusted_caller, contracts.simple_dvt, tx_params
deployment_artifacts["SetNodeOperatorRewardAddresses"] = {
"contract": "SetNodeOperatorRewardAddresses",
"address": set_node_operator_reward.address,
"constructorArgs": [trusted_caller, simple_dvt],
}

# UpdateTargetValidatorLimits
update_tareget_validator_limits = UpdateTargetValidatorLimits.deploy(
trusted_caller, simple_dvt, tx_params
)
change_node_operator_manager_address = ChangeNodeOperatorManagers.deploy(
trusted_caller, contracts.simple_dvt, contracts.aragon.acl, tx_params
deployment_artifacts["UpdateTargetValidatorLimits"] = {
"contract": "UpdateTargetValidatorLimits",
"address": update_tareget_validator_limits.address,
"constructorArgs": [trusted_caller, simple_dvt],
}

# ChangeNodeOperatorManagers
change_node_operator_manager = ChangeNodeOperatorManagers.deploy(
trusted_caller, simple_dvt, acl, tx_params
)

log.ok("Deployed AddNodeOperators", add_node_operator_address)
log.ok("Deployed ActivateNodeOperators", activate_node_operators_address)
log.ok("Deployed DeactivateNodeOperators", deactivate_node_operators_address)
log.ok("Deployed SetVettedValidatorsLimits", set_vetted_validators_limits_address)
log.ok("Deployed SetNodeOperatorNames", set_node_operator_names_address)
deployment_artifacts["ChangeNodeOperatorManagers"] = {
"contract": "ChangeNodeOperatorManagers",
"address": change_node_operator_manager.address,
"constructorArgs": [trusted_caller, simple_dvt, acl],
}

log.ok("Deployed AddNodeOperators", add_node_operator)
log.ok("Deployed ActivateNodeOperators", activate_node_operators.address)
log.ok("Deployed DeactivateNodeOperators", deactivate_node_operators.address)
log.ok("Deployed SetVettedValidatorsLimits", set_vetted_validators_limits.address)
log.ok("Deployed SetNodeOperatorNames", set_node_operator_names.address)
log.ok(
"Deployed SetNodeOperatorRewardAddresses",
set_node_operator_reward_address_address,
set_node_operator_reward.address,
)
log.ok(
"Deployed UpdateTargetValidatorLimits", update_tareget_validator_limits_address
"Deployed UpdateTargetValidatorLimits", update_tareget_validator_limits.address
)
log.ok("Deployed ChangeNodeOperatorManagers", change_node_operator_manager_address)
log.ok("Deployed ChangeNodeOperatorManagers", change_node_operator_manager.address)

log.br()
log.nb("All factories have been deployed. Starting code verification")
log.nb("All factories have been deployed.")
log.nb("Saving atrifacts...")

with open("deployed-" + network_name + ".json", "w") as outfile:
json.dump(deployment_artifacts, outfile)

log.nb("Starting code verification.")
log.br()

AddNodeOperators.publish_source(add_node_operator_address)
ActivateNodeOperators.publish_source(activate_node_operators_address)
DeactivateNodeOperators.publish_source(deactivate_node_operators_address)
SetVettedValidatorsLimits.publish_source(set_vetted_validators_limits_address)
SetNodeOperatorNames.publish_source(set_node_operator_names_address)
AddNodeOperators.publish_source(add_node_operator)
ActivateNodeOperators.publish_source(activate_node_operators.address)
DeactivateNodeOperators.publish_source(deactivate_node_operators.address)
SetVettedValidatorsLimits.publish_source(set_vetted_validators_limits.address)
SetNodeOperatorNames.publish_source(set_node_operator_names.address)
SetNodeOperatorRewardAddresses.publish_source(
set_node_operator_reward_address_address
set_node_operator_reward.address
)
UpdateTargetValidatorLimits.publish_source(update_tareget_validator_limits_address)
ChangeNodeOperatorManagers.publish_source(change_node_operator_manager_address)
UpdateTargetValidatorLimits.publish_source(update_tareget_validator_limits.address)
ChangeNodeOperatorManagers.publish_source(change_node_operator_manager.address)

log.br()
1 change: 1 addition & 0 deletions scripts/verify_simple_dvt_factories.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./bytecode-verificator/bytecode_verificator.sh --solc-version 0.8.6 --remote-rpc-url $REMOTE_RPC --config-json ../deployed-holesky.json --contract AddNodeOperators
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# yarn lockfile v1


"@openzeppelin/contracts-v4.3.2@npm:@openzeppelin/contracts@4.3.2":
version "4.3.2"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.3.2.tgz#ff80affd6d352dbe1bbc5b4e1833c41afd6283b6"
integrity sha512-AybF1cesONZStg5kWf6ao9OlqTZuPqddvprc0ky7lrUVOjXeKpmQ2Y9FK+6ygxasb+4aic4O5pneFBfwVsRRRg==

"@solidity-parser/parser@^0.14.2":
version "0.14.3"
resolved "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.14.3.tgz"
Expand Down

0 comments on commit 69beab4

Please sign in to comment.