From 5d28ef29fabd52c0842098b234be5d5db51ac886 Mon Sep 17 00:00:00 2001 From: albert Date: Thu, 30 May 2024 05:51:54 +0200 Subject: [PATCH 1/3] chore: add tested insert aggkey script --- scripts/insert_aggkey_sc.py | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 scripts/insert_aggkey_sc.py diff --git a/scripts/insert_aggkey_sc.py b/scripts/insert_aggkey_sc.py new file mode 100644 index 00000000..8d04c7f4 --- /dev/null +++ b/scripts/insert_aggkey_sc.py @@ -0,0 +1,46 @@ +import sys +import os + +sys.path.append(os.path.abspath("tests")) +from shared_tests import * +from utils import prompt_user_continue_or_break +from consts import * +from brownie import accounts, KeyManager, network + +AUTONOMY_SEED = os.environ["SEED"] +DEPLOY_ARTEFACT_ID = os.environ.get("DEPLOY_ARTEFACT_ID") +cf_accs = accounts.from_mnemonic(AUTONOMY_SEED, count=10) +DEPLOYER_ACCOUNT_INDEX = int(os.environ.get("DEPLOYER_ACCOUNT_INDEX") or 0) + +DEPLOYER = cf_accs[DEPLOYER_ACCOUNT_INDEX] +print(f"DEPLOYER = {DEPLOYER}") + + +def main(): + print() + + +# This is to be used manually to insert the sc generated agg key for testnets +def insert_agg_key_from_sc(): + network.priority_fee("1 gwei") + KEY_MANAGER_ADDRESS = os.environ["KEY_MANAGER_ADDRESS"] + keyManager = KeyManager.at(KEY_MANAGER_ADDRESS) + + # Assumption that this is a long hex string without 0x + x = os.environ["X_AGG_KEY"] + parity = os.environ["PARITY"] + + # parity should be a "Odd" or "Even" otherwise it will fail + assert parity in ["Even", "Odd"], "Parity should be Even or Odd" + parity = "00" if parity == "Even" else "01" + newAggKey = [int(x, 16), int(parity, 16)] + + print(f"Setting the aggregate key to {newAggKey}") + prompt_user_continue_or_break("", False) + + tx = keyManager.setAggKeyWithGovKey( + newAggKey, {"from": DEPLOYER, "required_confs": 1} + ) + + tx.info() + print(f"Succesfullly updated the aggregate key to {newAggKey}") From 54d74b08cc64ea0319a827fb8db8216f5869d5bf Mon Sep 17 00:00:00 2001 From: albert Date: Thu, 30 May 2024 07:20:36 +0200 Subject: [PATCH 2/3] chore: remove unnecessary line --- scripts/insert_aggkey_sc.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/insert_aggkey_sc.py b/scripts/insert_aggkey_sc.py index 8d04c7f4..c2cbf5f4 100644 --- a/scripts/insert_aggkey_sc.py +++ b/scripts/insert_aggkey_sc.py @@ -8,7 +8,6 @@ from brownie import accounts, KeyManager, network AUTONOMY_SEED = os.environ["SEED"] -DEPLOY_ARTEFACT_ID = os.environ.get("DEPLOY_ARTEFACT_ID") cf_accs = accounts.from_mnemonic(AUTONOMY_SEED, count=10) DEPLOYER_ACCOUNT_INDEX = int(os.environ.get("DEPLOYER_ACCOUNT_INDEX") or 0) From b92810dfd2a743ebbf024287391c6b5ff3de390b Mon Sep 17 00:00:00 2001 From: albert Date: Thu, 30 May 2024 12:42:22 +0200 Subject: [PATCH 3/3] chore: address comments --- scripts/insert_aggkey_sc.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/scripts/insert_aggkey_sc.py b/scripts/insert_aggkey_sc.py index c2cbf5f4..8e682ad3 100644 --- a/scripts/insert_aggkey_sc.py +++ b/scripts/insert_aggkey_sc.py @@ -16,11 +16,6 @@ def main(): - print() - - -# This is to be used manually to insert the sc generated agg key for testnets -def insert_agg_key_from_sc(): network.priority_fee("1 gwei") KEY_MANAGER_ADDRESS = os.environ["KEY_MANAGER_ADDRESS"] keyManager = KeyManager.at(KEY_MANAGER_ADDRESS) @@ -42,4 +37,4 @@ def insert_agg_key_from_sc(): ) tx.info() - print(f"Succesfullly updated the aggregate key to {newAggKey}") + print(f"Succesfully updated the aggregate key to {newAggKey}")