Skip to content

Commit

Permalink
fix: ET for simple dvt + helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
krogla committed Jan 31, 2024
1 parent b533491 commit 2aacab5
Show file tree
Hide file tree
Showing 15 changed files with 283 additions and 8 deletions.
9 changes: 9 additions & 0 deletions configs/config_mainnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@

EASYTRACK_EVMSCRIPT_EXECUTOR = "0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977"
EASYTRACK_INCREASE_NOP_STAKING_LIMIT_FACTORY = "0xFeBd8FAC16De88206d4b18764e826AF38546AfE0"
EASYTRACK_SIMPLE_DVT_TRUSTED_CALLER = "0x08637515E85A4633E23dfc7861e2A9f53af640f7"
EASYTRACK_SIMPLE_DVT_ADD_NODE_OPERATORS_FACTORY = "0xcAa3AF7460E83E665EEFeC73a7a542E5005C9639"
EASYTRACK_SIMPLE_DVT_ACTIVATE_NODE_OPERATORS_FACTORY = "0xCBb418F6f9BFd3525CE6aADe8F74ECFEfe2DB5C8"
EASYTRACK_SIMPLE_DVT_DEACTIVATE_NODE_OPERATORS_FACTORY = "0x8B82C1546D47330335a48406cc3a50Da732672E7"
EASYTRACK_SIMPLE_DVT_SET_VETTED_VALIDATORS_LIMITS_FACTORY = "0xD75778b855886Fc5e1eA7D6bFADA9EB68b35C19D"
EASYTRACK_SIMPLE_DVT_SET_NODE_OPERATOR_NAMES_FACTORY = "0x7d509BFF310d9460b1F613e4e40d342201a83Ae4"
EASYTRACK_SIMPLE_DVT_SET_NODE_OPERATOR_REWARD_ADDRESSES_FACTORY = "0x589e298964b9181D9938B84bB034C3BB9024E2C0"
EASYTRACK_SIMPLE_DVT_UPDATE_TARGET_VALIDATOR_LIMITS_FACTORY = "0x41CF3DbDc939c5115823Fba1432c4EC5E7bD226C"
EASYTRACK_SIMPLE_DVT_CHANGE_NODE_OPERATOR_MANAGERS_FACTORY = "0xE31A0599A6772BCf9b2bFc9e25cf941e793c9a7D"

# Multisigs
FINANCE_MULTISIG = "0x48F300bD3C52c7dA6aAbDE4B683dEB27d38B9ABb"
Expand Down
1 change: 1 addition & 0 deletions interfaces/ActivateNodeOperators.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[{"internalType":"address","name":"_trustedCaller","type":"address"},{"internalType":"address","name":"_nodeOperatorsRegistry","type":"address"},{"internalType":"address","name":"_acl","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"acl","outputs":[{"internalType":"contract IACL","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_creator","type":"address"},{"internalType":"bytes","name":"_evmScriptCallData","type":"bytes"}],"name":"createEVMScript","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_evmScriptCallData","type":"bytes"}],"name":"decodeEVMScriptCallData","outputs":[{"components":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"address","name":"managerAddress","type":"address"}],"internalType":"struct ActivateNodeOperators.ActivateNodeOperatorInput[]","name":"","type":"tuple[]"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"nodeOperatorsRegistry","outputs":[{"internalType":"contract INodeOperatorsRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"trustedCaller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
1 change: 1 addition & 0 deletions interfaces/AddNodeOperators.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[{"internalType":"address","name":"_trustedCaller","type":"address"},{"internalType":"address","name":"_nodeOperatorsRegistry","type":"address"},{"internalType":"address","name":"_acl","type":"address"},{"internalType":"address","name":"_lido","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"acl","outputs":[{"internalType":"contract IACL","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_creator","type":"address"},{"internalType":"bytes","name":"_evmScriptCallData","type":"bytes"}],"name":"createEVMScript","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_evmScriptCallData","type":"bytes"}],"name":"decodeEVMScriptCallData","outputs":[{"internalType":"uint256","name":"nodeOperatorsCount","type":"uint256"},{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"address","name":"rewardAddress","type":"address"},{"internalType":"address","name":"managerAddress","type":"address"}],"internalType":"struct AddNodeOperators.AddNodeOperatorInput[]","name":"nodeOperators","type":"tuple[]"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"lido","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nodeOperatorsRegistry","outputs":[{"internalType":"contract INodeOperatorsRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"trustedCaller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
1 change: 1 addition & 0 deletions interfaces/ChangeNodeOperatorManagers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[{"internalType":"address","name":"_trustedCaller","type":"address"},{"internalType":"address","name":"_nodeOperatorsRegistry","type":"address"},{"internalType":"address","name":"_acl","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"acl","outputs":[{"internalType":"contract IACL","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_creator","type":"address"},{"internalType":"bytes","name":"_evmScriptCallData","type":"bytes"}],"name":"createEVMScript","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_evmScriptCallData","type":"bytes"}],"name":"decodeEVMScriptCallData","outputs":[{"components":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"address","name":"oldManagerAddress","type":"address"},{"internalType":"address","name":"newManagerAddress","type":"address"}],"internalType":"struct ChangeNodeOperatorManagers.ChangeNodeOperatorManagersInput[]","name":"","type":"tuple[]"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"nodeOperatorsRegistry","outputs":[{"internalType":"contract INodeOperatorsRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"trustedCaller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
1 change: 1 addition & 0 deletions interfaces/DeactivateNodeOperators.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[{"internalType":"address","name":"_trustedCaller","type":"address"},{"internalType":"address","name":"_nodeOperatorsRegistry","type":"address"},{"internalType":"address","name":"_acl","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"acl","outputs":[{"internalType":"contract IACL","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_creator","type":"address"},{"internalType":"bytes","name":"_evmScriptCallData","type":"bytes"}],"name":"createEVMScript","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_evmScriptCallData","type":"bytes"}],"name":"decodeEVMScriptCallData","outputs":[{"components":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"address","name":"managerAddress","type":"address"}],"internalType":"struct DeactivateNodeOperators.DeactivateNodeOperatorInput[]","name":"","type":"tuple[]"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"nodeOperatorsRegistry","outputs":[{"internalType":"contract INodeOperatorsRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"trustedCaller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
1 change: 1 addition & 0 deletions interfaces/SetNodeOperatorNames.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[{"internalType":"address","name":"_trustedCaller","type":"address"},{"internalType":"address","name":"_nodeOperatorsRegistry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"_creator","type":"address"},{"internalType":"bytes","name":"_evmScriptCallData","type":"bytes"}],"name":"createEVMScript","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_evmScriptCallData","type":"bytes"}],"name":"decodeEVMScriptCallData","outputs":[{"components":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"string","name":"name","type":"string"}],"internalType":"struct SetNodeOperatorNames.SetNameInput[]","name":"","type":"tuple[]"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"nodeOperatorsRegistry","outputs":[{"internalType":"contract INodeOperatorsRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"trustedCaller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
1 change: 1 addition & 0 deletions interfaces/SetNodeOperatorRewardAddresses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[{"internalType":"address","name":"_trustedCaller","type":"address"},{"internalType":"address","name":"_nodeOperatorsRegistry","type":"address"},{"internalType":"address","name":"_lido","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"_creator","type":"address"},{"internalType":"bytes","name":"_evmScriptCallData","type":"bytes"}],"name":"createEVMScript","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_evmScriptCallData","type":"bytes"}],"name":"decodeEVMScriptCallData","outputs":[{"components":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"address","name":"rewardAddress","type":"address"}],"internalType":"struct SetNodeOperatorRewardAddresses.SetRewardAddressInput[]","name":"","type":"tuple[]"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"lido","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nodeOperatorsRegistry","outputs":[{"internalType":"contract INodeOperatorsRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"trustedCaller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
1 change: 1 addition & 0 deletions interfaces/SetVettedValidatorsLimits.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[{"internalType":"address","name":"_trustedCaller","type":"address"},{"internalType":"address","name":"_nodeOperatorsRegistry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"_creator","type":"address"},{"internalType":"bytes","name":"_evmScriptCallData","type":"bytes"}],"name":"createEVMScript","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_evmScriptCallData","type":"bytes"}],"name":"decodeEVMScriptCallData","outputs":[{"components":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"uint256","name":"stakingLimit","type":"uint256"}],"internalType":"struct SetVettedValidatorsLimits.VettedValidatorsLimitInput[]","name":"","type":"tuple[]"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"nodeOperatorsRegistry","outputs":[{"internalType":"contract INodeOperatorsRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"trustedCaller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
1 change: 1 addition & 0 deletions interfaces/SimpleDVT.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions interfaces/UpdateTargetValidatorLimits.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[{"internalType":"address","name":"_trustedCaller","type":"address"},{"internalType":"address","name":"_nodeOperatorsRegistry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"_creator","type":"address"},{"internalType":"bytes","name":"_evmScriptCallData","type":"bytes"}],"name":"createEVMScript","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_evmScriptCallData","type":"bytes"}],"name":"decodeEVMScriptCallData","outputs":[{"components":[{"internalType":"uint256","name":"nodeOperatorId","type":"uint256"},{"internalType":"bool","name":"isTargetLimitActive","type":"bool"},{"internalType":"uint256","name":"targetLimit","type":"uint256"}],"internalType":"struct UpdateTargetValidatorLimits.TargetValidatorsLimit[]","name":"","type":"tuple[]"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"nodeOperatorsRegistry","outputs":[{"internalType":"contract INodeOperatorsRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"trustedCaller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
8 changes: 7 additions & 1 deletion tests/acceptance/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@

from utils.test.helpers import ETH
from utils.test.oracle_report_helpers import oracle_report
from utils.test.simple_dvt_helpers import fill_simple_dvt_ops_vetted_keys
from brownie import chain

ENV_REPORT_AFTER_VOTE = "REPORT_AFTER_VOTE"
ENV_FILL_SIMPLE_DVT = "FILL_SIMPLE_DVT"


@pytest.fixture(scope="function", autouse=is_there_any_vote_scripts() or is_there_any_upgrade_scripts())
def autoexecute_vote(helpers, vote_ids_from_env, accounts):
def autoexecute_vote(helpers, vote_ids_from_env, accounts, stranger):
if vote_ids_from_env:
helpers.execute_votes(accounts, vote_ids_from_env, contracts.voting, topup="0.5 ether")
else:
start_and_execute_votes(contracts.voting, helpers)
if os.getenv(ENV_FILL_SIMPLE_DVT):
print(f"Prefilling SimpleDVT...")
fill_simple_dvt_ops_vetted_keys(stranger)

if os.getenv(ENV_REPORT_AFTER_VOTE):
oracle_report(cl_diff=ETH(523), exclude_vaults_balances=False)
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def parse_events_from_local_abi():
"LidoExecutionLayerRewardsVault": [EXECUTION_LAYER_REWARDS_VAULT],
"Kernel": [ARAGON_KERNEL_IMPL],
"NodeOperatorsRegistry": [NODE_OPERATORS_REGISTRY, NODE_OPERATORS_REGISTRY_IMPL],
"SimpleDVT": [SIMPLE_DVT, SIMPLE_DVT_IMPL],
"OracleDaemonConfig": [ORACLE_DAEMON_CONFIG],
"OracleReportSanityChecker": [ORACLE_REPORT_SANITY_CHECKER],
"Repo": [ARAGON_COMMON_REPO_IMPL],
Expand Down
9 changes: 8 additions & 1 deletion tests/regression/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@

from utils.test.helpers import ETH
from utils.test.oracle_report_helpers import oracle_report
from utils.test.simple_dvt_helpers import fill_simple_dvt_ops_vetted_keys
from brownie import chain

ENV_REPORT_AFTER_VOTE = "REPORT_AFTER_VOTE"
ENV_FILL_SIMPLE_DVT = "FILL_SIMPLE_DVT"


@pytest.fixture(scope="function", autouse=is_there_any_vote_scripts() or is_there_any_upgrade_scripts())
def autoexecute_vote(helpers, vote_ids_from_env, accounts):
def autoexecute_vote(helpers, vote_ids_from_env, accounts, stranger):
if vote_ids_from_env:
helpers.execute_votes(accounts, vote_ids_from_env, contracts.voting, topup="0.5 ether")
else:
start_and_execute_votes(contracts.voting, helpers)

if os.getenv(ENV_FILL_SIMPLE_DVT):
print(f"Prefilling SimpleDVT...")
fill_simple_dvt_ops_vetted_keys(stranger)

if os.getenv(ENV_REPORT_AFTER_VOTE):
oracle_report(cl_diff=ETH(523), exclude_vaults_balances=False)
101 changes: 95 additions & 6 deletions tests/regression/test_easy_track.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
from eth_abi.abi import encode_single
from brownie import accounts, chain, interface # type: ignore
from utils.config import contracts, EASYTRACK_INCREASE_NOP_STAKING_LIMIT_FACTORY
from brownie import accounts, chain, interface
from utils.config import (
contracts,
EASYTRACK_INCREASE_NOP_STAKING_LIMIT_FACTORY,
EASYTRACK_SIMPLE_DVT_TRUSTED_CALLER,
EASYTRACK_SIMPLE_DVT_ADD_NODE_OPERATORS_FACTORY,
EASYTRACK_SIMPLE_DVT_SET_VETTED_VALIDATORS_LIMITS_FACTORY,
)
from utils.test.simple_dvt_helpers import simple_dvt_add_keys, simple_dvt_add_node_operators
from utils.test.easy_track_helpers import _encode_calldata

NODE_OPERATOR_ID = 0


def _encode_calldata(signature, values):
return "0x" + encode_single(signature, values).hex()


def test_increase_nop_staking_limit(
stranger,
):
Expand Down Expand Up @@ -48,3 +52,88 @@ def test_increase_nop_staking_limit(
updated_node_operator = contracts.node_operators_registry.getNodeOperator(NODE_OPERATOR_ID, False)

assert updated_node_operator["totalVettedValidators"] == new_staking_limit


def test_simple_dvt_add_node_operators(
stranger,
):
NEW_OPERATOR_NAMES = [
"New Name 1",
"New Name 2",
]

NEW_REWARD_ADDRESSES = [
"0x1110000000000000000000000000000000001111",
"0x1110000000000000000000000000000000002222",
]

NEW_MANAGERS = [
"0x1110000000000000000000000000000011111111",
"0x1110000000000000000000000000000022222222",
]

input_params = [
(NEW_OPERATOR_NAMES[0], NEW_REWARD_ADDRESSES[0], NEW_MANAGERS[0]),
(NEW_OPERATOR_NAMES[1], NEW_REWARD_ADDRESSES[1], NEW_MANAGERS[1]),
]
(node_operators_count_before, node_operator_count_after) = simple_dvt_add_node_operators(
contracts.simple_dvt, stranger, input_params
)

assert node_operator_count_after == node_operators_count_before + len(input_params)


def test_simple_dvt_set_vetted_validators_limits(
stranger,
):
NEW_OPERATOR_NAMES = [
"New Name 1",
]

NEW_REWARD_ADDRESSES = [
"0x1110000000000000000000000000000000001111",
]

NEW_MANAGERS = [
"0x1110000000000000000000000000000011111111",
]

input_params = [
(NEW_OPERATOR_NAMES[0], NEW_REWARD_ADDRESSES[0], NEW_MANAGERS[0]),
]

(_, node_operator_count_after) = simple_dvt_add_node_operators(contracts.simple_dvt, stranger, input_params)

no_id = node_operator_count_after - 1

factory = interface.SetVettedValidatorsLimits(EASYTRACK_SIMPLE_DVT_SET_VETTED_VALIDATORS_LIMITS_FACTORY)
trusted_caller = accounts.at(EASYTRACK_SIMPLE_DVT_TRUSTED_CALLER, force=True)

node_operator = contracts.simple_dvt.getNodeOperator(no_id, False)
new_staking_limit = node_operator["totalVettedValidators"] + 1

if node_operator["totalAddedValidators"] < new_staking_limit:
simple_dvt_add_keys(contracts.simple_dvt, no_id, 1)

calldata = _encode_calldata("((uint256,uint256)[])", [[(no_id, new_staking_limit)]])

motions_before = contracts.easy_track.getMotions()

tx = contracts.easy_track.createMotion(factory, calldata, {"from": trusted_caller})

assert len(contracts.easy_track.getMotions()) == len(motions_before) + 1

chain.sleep(60 * 60 * 24 * 3)
chain.mine()

motions = contracts.easy_track.getMotions()

contracts.easy_track.enactMotion(
motions[-1][0],
tx.events["MotionCreated"]["_evmScriptCallData"],
{"from": stranger},
)

updated_node_operator = contracts.simple_dvt.getNodeOperator(no_id, False)

assert updated_node_operator["totalVettedValidators"] == new_staking_limit
Loading

0 comments on commit 2aacab5

Please sign in to comment.