Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
bulbozaur committed Apr 30, 2024
1 parent b6c6edc commit 4f03d2d
Show file tree
Hide file tree
Showing 58 changed files with 800 additions and 2,125 deletions.
64 changes: 16 additions & 48 deletions scripts/acceptance_test_full_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,11 @@
from utils import lido, deployed_easy_track, deployed_date_time, log, deployment
from hexbytes import HexBytes

ADD_RECIPIENT_TO_ALLOWED_LIST_ROLE = (
"0xec20c52871c824e5437859e75ac830e83aaaaeb7b0ffd850de830ddd3e385276"
)
REMOVE_RECIPIENT_FROM_ALLOWED_LIST_ROLE = (
"0x491d7752c25cfca0f73715cde1130022a9b815373f91a996bbb1ba8943efc99b"
)
SET_PARAMETERS_ROLE = (
"0x260b83d52a26066d8e9db550fa70395df5f3f064b50ff9d8a94267d9f1fe1967"
)
UPDATE_SPENT_AMOUNT_ROLE = (
"0xc5260260446719a726d11a6faece21d19daa48b4cbcca118345832d4cb71df99"
)
DEFAULT_ADMIN_ROLE = (
"0x0000000000000000000000000000000000000000000000000000000000000000"
)
ADD_RECIPIENT_TO_ALLOWED_LIST_ROLE = "0xec20c52871c824e5437859e75ac830e83aaaaeb7b0ffd850de830ddd3e385276"
REMOVE_RECIPIENT_FROM_ALLOWED_LIST_ROLE = "0x491d7752c25cfca0f73715cde1130022a9b815373f91a996bbb1ba8943efc99b"
SET_PARAMETERS_ROLE = "0x260b83d52a26066d8e9db550fa70395df5f3f064b50ff9d8a94267d9f1fe1967"
UPDATE_SPENT_AMOUNT_ROLE = "0xc5260260446719a726d11a6faece21d19daa48b4cbcca118345832d4cb71df99"
DEFAULT_ADMIN_ROLE = "0x0000000000000000000000000000000000000000000000000000000000000000"

GRANT_ROLE_EVENT = "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d"
REVOKE_ROLE_EVENT = "0xf6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b"
Expand Down Expand Up @@ -53,18 +43,10 @@ def main():

evm_script_executor = et_contracts.evm_script_executor

registry_address = tx.events["AllowedRecipientsRegistryDeployed"][
"allowedRecipientsRegistry"
]
top_up_address = tx.events["TopUpAllowedRecipientsDeployed"][
"topUpAllowedRecipients"
]
add_allowed_recipient_address = tx.events["AddAllowedRecipientDeployed"][
"addAllowedRecipient"
]
remove_allowed_recipient_address = tx.events["RemoveAllowedRecipientDeployed"][
"removeAllowedRecipient"
]
registry_address = tx.events["AllowedRecipientsRegistryDeployed"]["allowedRecipientsRegistry"]
top_up_address = tx.events["TopUpAllowedRecipientsDeployed"]["topUpAllowedRecipients"]
add_allowed_recipient_address = tx.events["AddAllowedRecipientDeployed"]["addAllowedRecipient"]
remove_allowed_recipient_address = tx.events["RemoveAllowedRecipientDeployed"]["removeAllowedRecipient"]

log.br()

Expand All @@ -91,9 +73,7 @@ def main():
registry = AllowedRecipientsRegistry.at(registry_address)
top_up_allowed_recipients = TopUpAllowedRecipients.at(top_up_address)
add_allowed_recipient = AddAllowedRecipient.at(add_allowed_recipient_address)
remove_allowed_recipient = RemoveAllowedRecipient.at(
remove_allowed_recipient_address
)
remove_allowed_recipient = RemoveAllowedRecipient.at(remove_allowed_recipient_address)

assert registry.bokkyPooBahsDateTimeContract() == date_time_contract
assert top_up_allowed_recipients.easyTrack() == et_contracts.easy_track
Expand All @@ -114,30 +94,22 @@ def main():
assert registryLimit == deploy_config.limit
assert registryPeriodDuration == deploy_config.period

assert (
registry.spendableBalance() == deploy_config.limit - deploy_config.spent_amount
)
assert registry.spendableBalance() == deploy_config.limit - deploy_config.spent_amount

assert registry.hasRole(ADD_RECIPIENT_TO_ALLOWED_LIST_ROLE, contracts.aragon.agent)
assert registry.hasRole(
REMOVE_RECIPIENT_FROM_ALLOWED_LIST_ROLE, contracts.aragon.agent
)
assert registry.hasRole(REMOVE_RECIPIENT_FROM_ALLOWED_LIST_ROLE, contracts.aragon.agent)
assert registry.hasRole(SET_PARAMETERS_ROLE, contracts.aragon.agent)
assert registry.hasRole(UPDATE_SPENT_AMOUNT_ROLE, contracts.aragon.agent)
assert registry.hasRole(DEFAULT_ADMIN_ROLE, contracts.aragon.agent)

assert registry.hasRole(ADD_RECIPIENT_TO_ALLOWED_LIST_ROLE, evm_script_executor)
assert registry.hasRole(
REMOVE_RECIPIENT_FROM_ALLOWED_LIST_ROLE, evm_script_executor
)
assert registry.hasRole(REMOVE_RECIPIENT_FROM_ALLOWED_LIST_ROLE, evm_script_executor)
assert registry.hasRole(UPDATE_SPENT_AMOUNT_ROLE, evm_script_executor)
assert not registry.hasRole(SET_PARAMETERS_ROLE, evm_script_executor)
assert not registry.hasRole(DEFAULT_ADMIN_ROLE, evm_script_executor)

assert not registry.hasRole(ADD_RECIPIENT_TO_ALLOWED_LIST_ROLE, registry_address)
assert not registry.hasRole(
REMOVE_RECIPIENT_FROM_ALLOWED_LIST_ROLE, registry_address
)
assert not registry.hasRole(REMOVE_RECIPIENT_FROM_ALLOWED_LIST_ROLE, registry_address)
assert not registry.hasRole(SET_PARAMETERS_ROLE, registry_address)
assert not registry.hasRole(UPDATE_SPENT_AMOUNT_ROLE, registry_address)
assert not registry.hasRole(DEFAULT_ADMIN_ROLE, registry_address)
Expand All @@ -153,13 +125,9 @@ def main():
for event in tx.logs:
# print(event["topics"][0])
if event["topics"][0] == HexBytes(GRANT_ROLE_EVENT):
registry_roles_holders[event["topics"][1].hex()].append(
"0x" + event["topics"][2].hex()[26:]
)
registry_roles_holders[event["topics"][1].hex()].append("0x" + event["topics"][2].hex()[26:])
elif event["topics"][0] == HexBytes(REVOKE_ROLE_EVENT):
registry_roles_holders[event["topics"][1].hex()].remove(
"0x" + event["topics"][2].hex()[26:]
)
registry_roles_holders[event["topics"][1].hex()].remove("0x" + event["topics"][2].hex()[26:])

log.br()

Expand Down
52 changes: 13 additions & 39 deletions scripts/acceptance_test_single_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,11 @@
from utils import lido, deployed_easy_track, deployed_date_time, log, deployment
from hexbytes import HexBytes

ADD_RECIPIENT_TO_ALLOWED_LIST_ROLE = (
"0xec20c52871c824e5437859e75ac830e83aaaaeb7b0ffd850de830ddd3e385276"
)
REMOVE_RECIPIENT_FROM_ALLOWED_LIST_ROLE = (
"0x491d7752c25cfca0f73715cde1130022a9b815373f91a996bbb1ba8943efc99b"
)
SET_PARAMETERS_ROLE = (
"0x260b83d52a26066d8e9db550fa70395df5f3f064b50ff9d8a94267d9f1fe1967"
)
UPDATE_SPENT_AMOUNT_ROLE = (
"0xc5260260446719a726d11a6faece21d19daa48b4cbcca118345832d4cb71df99"
)
DEFAULT_ADMIN_ROLE = (
"0x0000000000000000000000000000000000000000000000000000000000000000"
)
ADD_RECIPIENT_TO_ALLOWED_LIST_ROLE = "0xec20c52871c824e5437859e75ac830e83aaaaeb7b0ffd850de830ddd3e385276"
REMOVE_RECIPIENT_FROM_ALLOWED_LIST_ROLE = "0x491d7752c25cfca0f73715cde1130022a9b815373f91a996bbb1ba8943efc99b"
SET_PARAMETERS_ROLE = "0x260b83d52a26066d8e9db550fa70395df5f3f064b50ff9d8a94267d9f1fe1967"
UPDATE_SPENT_AMOUNT_ROLE = "0xc5260260446719a726d11a6faece21d19daa48b4cbcca118345832d4cb71df99"
DEFAULT_ADMIN_ROLE = "0x0000000000000000000000000000000000000000000000000000000000000000"

GRANT_ROLE_EVENT = "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d"
REVOKE_ROLE_EVENT = "0xf6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b"
Expand Down Expand Up @@ -46,12 +36,8 @@ def main():

evm_script_executor = et_contracts.evm_script_executor

registry_address = tx.events["AllowedRecipientsRegistryDeployed"][
"allowedRecipientsRegistry"
]
add_allowed_recipient_address = tx.events["TopUpAllowedRecipientsDeployed"][
"topUpAllowedRecipients"
]
registry_address = tx.events["AllowedRecipientsRegistryDeployed"]["allowedRecipientsRegistry"]
add_allowed_recipient_address = tx.events["TopUpAllowedRecipientsDeployed"]["topUpAllowedRecipients"]
log.br()

log.nb("tx of creation", deployment_tx_hash)
Expand Down Expand Up @@ -89,30 +75,22 @@ def main():
assert registryLimit == deploy_config.limit
assert registryPeriodDuration == deploy_config.period

assert (
registry.spendableBalance() == deploy_config.limit - deploy_config.spent_amount
)
assert registry.spendableBalance() == deploy_config.limit - deploy_config.spent_amount

assert registry.hasRole(ADD_RECIPIENT_TO_ALLOWED_LIST_ROLE, contracts.aragon.agent)
assert registry.hasRole(
REMOVE_RECIPIENT_FROM_ALLOWED_LIST_ROLE, contracts.aragon.agent
)
assert registry.hasRole(REMOVE_RECIPIENT_FROM_ALLOWED_LIST_ROLE, contracts.aragon.agent)
assert registry.hasRole(SET_PARAMETERS_ROLE, contracts.aragon.agent)
assert registry.hasRole(UPDATE_SPENT_AMOUNT_ROLE, contracts.aragon.agent)
assert registry.hasRole(DEFAULT_ADMIN_ROLE, contracts.aragon.agent)

assert not registry.hasRole(ADD_RECIPIENT_TO_ALLOWED_LIST_ROLE, evm_script_executor)
assert not registry.hasRole(
REMOVE_RECIPIENT_FROM_ALLOWED_LIST_ROLE, evm_script_executor
)
assert not registry.hasRole(REMOVE_RECIPIENT_FROM_ALLOWED_LIST_ROLE, evm_script_executor)
assert registry.hasRole(UPDATE_SPENT_AMOUNT_ROLE, evm_script_executor)
assert not registry.hasRole(SET_PARAMETERS_ROLE, evm_script_executor)
assert not registry.hasRole(DEFAULT_ADMIN_ROLE, evm_script_executor)

assert not registry.hasRole(ADD_RECIPIENT_TO_ALLOWED_LIST_ROLE, registry_address)
assert not registry.hasRole(
REMOVE_RECIPIENT_FROM_ALLOWED_LIST_ROLE, registry_address
)
assert not registry.hasRole(REMOVE_RECIPIENT_FROM_ALLOWED_LIST_ROLE, registry_address)
assert not registry.hasRole(SET_PARAMETERS_ROLE, registry_address)
assert not registry.hasRole(UPDATE_SPENT_AMOUNT_ROLE, registry_address)
assert not registry.hasRole(DEFAULT_ADMIN_ROLE, registry_address)
Expand All @@ -128,13 +106,9 @@ def main():
for event in tx.logs:
# print(event["topics"][0])
if event["topics"][0] == HexBytes(GRANT_ROLE_EVENT):
registry_roles_holders[event["topics"][1].hex()].append(
"0x" + event["topics"][2].hex()[26:]
)
registry_roles_holders[event["topics"][1].hex()].append("0x" + event["topics"][2].hex()[26:])
elif event["topics"][0] == HexBytes(REVOKE_ROLE_EVENT):
registry_roles_holders[event["topics"][1].hex()].remove(
"0x" + event["topics"][2].hex()[26:]
)
registry_roles_holders[event["topics"][1].hex()].remove("0x" + event["topics"][2].hex()[26:])

log.br()

Expand Down
14 changes: 3 additions & 11 deletions scripts/compare_bytecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,15 @@
def compare(orig_address, comparing_address):
orig_code = web3.eth.get_code(orig_address).hex()[2:]
comparing_code = web3.eth.get_code(comparing_address).hex()[2:]
print(
" {0:<{2}} {1:<{2}}\n".format(
orig_address, comparing_address, format_line_length
)
)
print(" {0:<{2}} {1:<{2}}\n".format(orig_address, comparing_address, format_line_length))

for i in range(max(len(orig_code), len(comparing_code)) // line_length + 1):
code_line = orig_code[i * line_length : (i + 1) * line_length]
comparing_code_line = comparing_code[i * line_length : (i + 1) * line_length]
is_equal = code_line == comparing_code_line
if is_equal:
print(
"{0:>5} {1:<{4}} {2:<4} {3:<{4}}".format(
i, code_line, "", comparing_code_line, format_line_length
)
"{0:>5} {1:<{4}} {2:<4} {3:<{4}}".format(i, code_line, "", comparing_code_line, format_line_length)
)
else:
color_flag = False
Expand All @@ -49,9 +43,7 @@ def compare(orig_address, comparing_address):
log_comparing_code = log_comparing_code + log_color_default

print(
"{0:>5} {1:<{4}} {2:<4} {3:<{4}}".format(
i, log_code, "neq", log_comparing_code, format_line_length
)
"{0:>5} {1:<{4}} {2:<4} {3:<{4}}".format(i, log_code, "neq", log_comparing_code, format_line_length)
)
print(
f"\n\nBytecode at addresses {orig_address} and {comparing_address} is {'NOT' if orig_code != comparing_code else ''} equal\n\n"
Expand Down
4 changes: 1 addition & 3 deletions scripts/contract_flattener.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
RemoveAllowedRecipient,
)

IMPORT_PATTERN = re.compile(
r"(?<=\n)?import(?P<prefix>.*)(?P<quote>[\"'])(?P<path>.*)(?P=quote)(?P<suffix>.*)(?=\n)"
)
IMPORT_PATTERN = re.compile(r"(?<=\n)?import(?P<prefix>.*)(?P<quote>[\"'])(?P<path>.*)(?P=quote)(?P<suffix>.*)(?=\n)")
PRAGMA_PATTERN = re.compile(r"^pragma.*;$", re.MULTILINE)
LICENSE_PATTERN = re.compile(r"^// SPDX-License-Identifier: (.*)$", re.MULTILINE)

Expand Down
23 changes: 7 additions & 16 deletions scripts/create_full_recipients_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@

deploy_config = deployment.AllowedRecipientsFullSetupDeployConfig(
token="",
limit=0,
limit=0,
period=1,
spent_amount=0,
trusted_caller="",
titles=[
],
trusted_caller="",
titles=[],
recipients=[],
)

Expand Down Expand Up @@ -65,18 +64,10 @@ def main():
tx_params,
)

allowed_recipients_registry_address = tx.events[
"AllowedRecipientsRegistryDeployed"
]["allowedRecipientsRegistry"]
top_up_allowed_recipients_address = tx.events["TopUpAllowedRecipientsDeployed"][
"topUpAllowedRecipients"
]
add_allowed_recipient_address = tx.events["AddAllowedRecipientDeployed"][
"addAllowedRecipient"
]
remove_allowed_recipient_address = tx.events["RemoveAllowedRecipientDeployed"][
"removeAllowedRecipient"
]
allowed_recipients_registry_address = tx.events["AllowedRecipientsRegistryDeployed"]["allowedRecipientsRegistry"]
top_up_allowed_recipients_address = tx.events["TopUpAllowedRecipientsDeployed"]["topUpAllowedRecipients"]
add_allowed_recipient_address = tx.events["AddAllowedRecipientDeployed"]["addAllowedRecipient"]
remove_allowed_recipient_address = tx.events["RemoveAllowedRecipientDeployed"]["removeAllowedRecipient"]

log.ok("Allowed recipients easy track contracts have been deployed...")
log.nb("Deployed AllowedRecipientsRegistry", allowed_recipients_registry_address)
Expand Down
4 changes: 1 addition & 3 deletions scripts/create_single_recipient_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ def main():
tx_params,
)

registryAddress = tx.events["AllowedRecipientsRegistryDeployed"][
"allowedRecipientsRegistry"
]
registryAddress = tx.events["AllowedRecipientsRegistryDeployed"]["allowedRecipientsRegistry"]
topUpAddress = tx.events["TopUpAllowedRecipientsDeployed"]["topUpAllowedRecipients"]

log.ok("Allowed recipients easy track contracts have been deployed...")
Expand Down
10 changes: 4 additions & 6 deletions scripts/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def main():

tx_params = {
"from": deployer,
"gas_price": "100 gwei"
"gas_price": "100 gwei",
# "priority_fee": "4 gwei",
}

Expand Down Expand Up @@ -80,11 +80,9 @@ def deploy_easy_tracks(
aragon_calls_script=lido_contracts.aragon.calls_script,
tx_params=tx_params,
)
increase_node_operators_staking_limit = (
deployment.deploy_increase_node_operator_staking_limit(
node_operators_registry=lido_contracts.node_operators_registry,
tx_params=tx_params,
)
increase_node_operators_staking_limit = deployment.deploy_increase_node_operator_staking_limit(
node_operators_registry=lido_contracts.node_operators_registry,
tx_params=tx_params,
)
top_up_lego_program = deployment.deploy_top_up_lego_program(
finance=lido_contracts.aragon.finance,
Expand Down
Loading

0 comments on commit 4f03d2d

Please sign in to comment.