From f8ff5620b8f7ef66994b7730ab4bf170e51f1b3e Mon Sep 17 00:00:00 2001 From: root Date: Sun, 7 Sep 2025 14:07:44 +0300 Subject: [PATCH 01/25] CI: Run one test --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aca407a24..5939f9b41 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -286,7 +286,7 @@ jobs: run: | source pytest/venv/bin/activate cd pytest - pytest -m "not ci_excluded" -s -x + pytest -vv -s tests/test_key_event.py::test_single_domain --non-reproducible tee-launcher-tests: name: "TEE Launcher: pytests" From effe21502b26f084172d5cabda451a7e721cd039 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 7 Sep 2025 16:28:19 +0300 Subject: [PATCH 02/25] update pytest --- .github/workflows/ci.yml | 2 +- pytest/common_lib/shared/__init__.py | 63 +++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5939f9b41..aca407a24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -286,7 +286,7 @@ jobs: run: | source pytest/venv/bin/activate cd pytest - pytest -vv -s tests/test_key_event.py::test_single_domain --non-reproducible + pytest -m "not ci_excluded" -s -x tee-launcher-tests: name: "TEE Launcher: pytests" diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index d46ea7d05..9e2a6238c 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -25,16 +25,73 @@ create_create_account_action, create_payment_action, create_full_access_key_action, + #create_mpc_function_call_access_key_action sign_transaction, serialize_transaction, ) + + + from key import Key dot_near = pathlib.Path.home() / ".near" SECRETS_JSON = "secrets.json" + +def create_function_call_access_key_action( + pk: str, contract_id: str, method_names: list[str], allowance: int | None = None +) -> "Action": + permission = AccessKeyPermission() + permission.enum = "functionCall" + + fc_perm = FunctionCallPermission() + fc_perm.allowance = allowance + fc_perm.receiverId = contract_id + fc_perm.methodNames = method_names + permission.functionCall = fc_perm + + access_key = AccessKey() + access_key.nonce = 0 + access_key.permission = permission + + public_key = PublicKey() + public_key.keyType = 0 + public_key.data = pk + + add_key = AddKey() + add_key.accessKey = access_key + add_key.publicKey = public_key + + action = Action() + action.enum = "addKey" + action.addKey = add_key + + return action + +def create_mpc_function_call_access_key_action(pk: str, contract, allowance: int | None = None) -> "Action": + """ + Create a restricted access key that only allows calling MPC-related contract methods. + """ + mpc_methods = [ + "respond", + "respond_ckd", + "vote_pk", + "start_keygen_instance", + "vote_reshared", + "start_reshare_instance", + "vote_abort_key_event_instance", + "verify_tee", + "submit_participant_info", + ] + return create_function_call_access_key_action( + pk=pk, + contract_id=contract, + method_names=mpc_methods, + allowance=allowance, + ) + # Output is deserializable into the rust type near_sdk::SecretKey def serialize_key(key: bytes) -> str: key_bytes = bytes(key) @@ -53,11 +110,13 @@ def sign_create_account_with_multiple_access_keys_tx( keys: List[Key], nonce, block_hash, + contract, ) -> bytes: create_account_action = create_create_account_action() payment_action = create_payment_action(100 * NEAR_BASE) access_key_actions = [ - create_full_access_key_action(key.decoded_pk()) for key in keys + #create_full_access_key_action(key.decoded_pk()) for key in keys + create_mpc_function_call_access_key_action(key.decoded_pk(), contract) for key in keys ] actions = [create_account_action, payment_action] + access_key_actions signed_tx = sign_transaction( @@ -278,6 +337,7 @@ def start_cluster_with_mpc( candidate.responder_keys, nonce, cluster.contract_node.last_block_hash(), + contract, ) txs.append(tx) candidate_account_id = candidate.signer_key.account_id @@ -301,6 +361,7 @@ def start_cluster_with_mpc( [candidate.signer_key] + pytest_signer_keys, nonce, cluster.contract_node.last_block_hash(), + contract, ) txs.append(tx) From 40b9b37a3ee582197985d3c3874511cb1532caf8 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 7 Sep 2025 16:38:01 +0300 Subject: [PATCH 03/25] update pytest2 --- pytest/common_lib/shared/__init__.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index 9e2a6238c..398e9dea6 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -25,21 +25,24 @@ create_create_account_action, create_payment_action, create_full_access_key_action, - #create_mpc_function_call_access_key_action + # create_mpc_function_call_access_key_action sign_transaction, serialize_transaction, + Action, + AccessKey, + AccessKeyPermission, + FunctionCallPermission, + PublicKey, + AddKey, ) - - from key import Key dot_near = pathlib.Path.home() / ".near" SECRETS_JSON = "secrets.json" - def create_function_call_access_key_action( pk: str, contract_id: str, method_names: list[str], allowance: int | None = None ) -> "Action": @@ -70,7 +73,10 @@ def create_function_call_access_key_action( return action -def create_mpc_function_call_access_key_action(pk: str, contract, allowance: int | None = None) -> "Action": + +def create_mpc_function_call_access_key_action( + pk: str, contract, allowance: int | None = None +) -> "Action": """ Create a restricted access key that only allows calling MPC-related contract methods. """ @@ -85,6 +91,7 @@ def create_mpc_function_call_access_key_action(pk: str, contract, allowance: int "verify_tee", "submit_participant_info", ] + return create_function_call_access_key_action( pk=pk, contract_id=contract, @@ -92,6 +99,7 @@ def create_mpc_function_call_access_key_action(pk: str, contract, allowance: int allowance=allowance, ) + # Output is deserializable into the rust type near_sdk::SecretKey def serialize_key(key: bytes) -> str: key_bytes = bytes(key) @@ -115,8 +123,9 @@ def sign_create_account_with_multiple_access_keys_tx( create_account_action = create_create_account_action() payment_action = create_payment_action(100 * NEAR_BASE) access_key_actions = [ - #create_full_access_key_action(key.decoded_pk()) for key in keys - create_mpc_function_call_access_key_action(key.decoded_pk(), contract) for key in keys + # create_full_access_key_action(key.decoded_pk()) for key in keys + create_mpc_function_call_access_key_action(key.decoded_pk(), contract) + for key in keys ] actions = [create_account_action, payment_action] + access_key_actions signed_tx = sign_transaction( From 855dc072b1d8ab6a41306a8c6ec8a2c57d36fc3d Mon Sep 17 00:00:00 2001 From: root Date: Sun, 7 Sep 2025 17:19:17 +0300 Subject: [PATCH 04/25] update pytest3 --- pytest/common_lib/shared/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index 398e9dea6..7a12fd682 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -118,13 +118,13 @@ def sign_create_account_with_multiple_access_keys_tx( keys: List[Key], nonce, block_hash, - contract, + contract_id, ) -> bytes: create_account_action = create_create_account_action() payment_action = create_payment_action(100 * NEAR_BASE) access_key_actions = [ # create_full_access_key_action(key.decoded_pk()) for key in keys - create_mpc_function_call_access_key_action(key.decoded_pk(), contract) + create_mpc_function_call_access_key_action(key.decoded_pk(), contract_id) for key in keys ] actions = [create_account_action, payment_action] + access_key_actions @@ -346,7 +346,7 @@ def start_cluster_with_mpc( candidate.responder_keys, nonce, cluster.contract_node.last_block_hash(), - contract, + cluster.mpc_contract_account, ) txs.append(tx) candidate_account_id = candidate.signer_key.account_id @@ -370,7 +370,7 @@ def start_cluster_with_mpc( [candidate.signer_key] + pytest_signer_keys, nonce, cluster.contract_node.last_block_hash(), - contract, + cluster.mpc_contract_account ) txs.append(tx) From 6b42c10bd8432e66ffc81a6fd6e0eeca41cfc76c Mon Sep 17 00:00:00 2001 From: root Date: Sun, 7 Sep 2025 17:30:21 +0300 Subject: [PATCH 05/25] update pytest4 --- pytest/common_lib/shared/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index 7a12fd682..8a0b66f36 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -75,7 +75,7 @@ def create_function_call_access_key_action( def create_mpc_function_call_access_key_action( - pk: str, contract, allowance: int | None = None + pk: str, contract_id: str, allowance: int | None = None ) -> "Action": """ Create a restricted access key that only allows calling MPC-related contract methods. @@ -94,7 +94,7 @@ def create_mpc_function_call_access_key_action( return create_function_call_access_key_action( pk=pk, - contract_id=contract, + contract_id=contract_id, method_names=mpc_methods, allowance=allowance, ) @@ -346,7 +346,7 @@ def start_cluster_with_mpc( candidate.responder_keys, nonce, cluster.contract_node.last_block_hash(), - cluster.mpc_contract_account, + cluster.mpc_contract_account(), ) txs.append(tx) candidate_account_id = candidate.signer_key.account_id @@ -370,7 +370,7 @@ def start_cluster_with_mpc( [candidate.signer_key] + pytest_signer_keys, nonce, cluster.contract_node.last_block_hash(), - cluster.mpc_contract_account + cluster.mpc_contract_account(), ) txs.append(tx) From 85449a740f008f27d41a4c71821c61b2c28c9cfd Mon Sep 17 00:00:00 2001 From: root Date: Sun, 7 Sep 2025 17:55:26 +0300 Subject: [PATCH 06/25] update pytest5 --- pytest/common_lib/shared/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index 8a0b66f36..c57f9f6e1 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -90,6 +90,7 @@ def create_mpc_function_call_access_key_action( "vote_abort_key_event_instance", "verify_tee", "submit_participant_info", + "vote_add_domains", ] return create_function_call_access_key_action( From 42f70e5476e9c955420fcadf47267f8d3a11c593 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 7 Sep 2025 18:12:59 +0300 Subject: [PATCH 07/25] update pytest6 --- pytest/common_lib/shared/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index c57f9f6e1..bf0e1e76e 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -91,6 +91,7 @@ def create_mpc_function_call_access_key_action( "verify_tee", "submit_participant_info", "vote_add_domains", + "vote_cancel_resharing", ] return create_function_call_access_key_action( From 2c419839de9846c924bd4c349636588ef0656de3 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 8 Sep 2025 15:58:21 +0300 Subject: [PATCH 08/25] update pytest6 --- pytest/common_lib/shared/__init__.py | 39 +++++++++++++++++++++------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index bf0e1e76e..54cf814a2 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -80,7 +80,7 @@ def create_mpc_function_call_access_key_action( """ Create a restricted access key that only allows calling MPC-related contract methods. """ - mpc_methods = [ + mpc_methods_used_by_node = [ "respond", "respond_ckd", "vote_pk", @@ -97,7 +97,7 @@ def create_mpc_function_call_access_key_action( return create_function_call_access_key_action( pk=pk, contract_id=contract_id, - method_names=mpc_methods, + method_names=mpc_methods_used_by_node, allowance=allowance, ) @@ -121,14 +121,19 @@ def sign_create_account_with_multiple_access_keys_tx( nonce, block_hash, contract_id, + fullAccess: bool, ) -> bytes: create_account_action = create_create_account_action() payment_action = create_payment_action(100 * NEAR_BASE) - access_key_actions = [ - # create_full_access_key_action(key.decoded_pk()) for key in keys - create_mpc_function_call_access_key_action(key.decoded_pk(), contract_id) - for key in keys - ] + if fullAccess: + access_key_actions = [ + create_full_access_key_action(key.decoded_pk()) for key in keys + ] + else: + access_key_actions = [ + create_mpc_function_call_access_key_action(key.decoded_pk(), contract_id) + for key in keys + ] actions = [create_account_action, payment_action] + access_key_actions signed_tx = sign_transaction( new_account_id, @@ -340,7 +345,7 @@ def start_cluster_with_mpc( txs = [] mpc_nodes = [] for near_node, candidate in zip(observers, candidates): - # add the nodes access key to the list + # add the nodes responder access key to the list nonce += 1 tx = sign_create_account_with_multiple_access_keys_tx( key, @@ -349,6 +354,7 @@ def start_cluster_with_mpc( nonce, cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), + False, ) txs.append(tx) candidate_account_id = candidate.signer_key.account_id @@ -366,13 +372,28 @@ def start_cluster_with_mpc( nonce += 1 # Observer nodes haven't started yet so we use cluster node to send txs + # add pytest_signer_keys that are used for voting, need to access + tx = sign_create_account_with_multiple_access_keys_tx( + key, + candidate_account_id, + pytest_signer_keys, + nonce, + cluster.contract_node.last_block_hash(), + cluster.mpc_contract_account(), + True, + ) + txs.append(tx) + + nonce += 1 + # add node access key tx = sign_create_account_with_multiple_access_keys_tx( key, candidate_account_id, - [candidate.signer_key] + pytest_signer_keys, + [candidate.signer_key], nonce, cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), + False, ) txs.append(tx) From cf76de6e556870ad1823a952abdde1946733a323 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 8 Sep 2025 16:43:45 +0300 Subject: [PATCH 09/25] update pytest7 --- pytest/common_lib/shared/__init__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index 54cf814a2..06f5f0cc8 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -122,9 +122,13 @@ def sign_create_account_with_multiple_access_keys_tx( block_hash, contract_id, fullAccess: bool, + createNewAccount: bool, ) -> bytes: - create_account_action = create_create_account_action() + actions = [] + if createNewAccount: + actions.append(create_create_account_action()) payment_action = create_payment_action(100 * NEAR_BASE) + actions.append(payment_action) if fullAccess: access_key_actions = [ create_full_access_key_action(key.decoded_pk()) for key in keys @@ -134,7 +138,7 @@ def sign_create_account_with_multiple_access_keys_tx( create_mpc_function_call_access_key_action(key.decoded_pk(), contract_id) for key in keys ] - actions = [create_account_action, payment_action] + access_key_actions + actions.extend(access_key_actions) signed_tx = sign_transaction( new_account_id, nonce, @@ -355,6 +359,7 @@ def start_cluster_with_mpc( cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), False, + True, ) txs.append(tx) candidate_account_id = candidate.signer_key.account_id @@ -381,10 +386,13 @@ def start_cluster_with_mpc( cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), True, + True ) txs.append(tx) nonce += 1 + + # add node access key tx = sign_create_account_with_multiple_access_keys_tx( key, @@ -394,6 +402,7 @@ def start_cluster_with_mpc( cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), False, + False ) txs.append(tx) From 95264ba13532b84f14a7d1a73403a6a4432774da Mon Sep 17 00:00:00 2001 From: root Date: Tue, 9 Sep 2025 09:38:21 +0300 Subject: [PATCH 10/25] update pytest8 --- pytest/common_lib/shared/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index 06f5f0cc8..725896da0 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -386,13 +386,12 @@ def start_cluster_with_mpc( cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), True, - True + False, ) txs.append(tx) nonce += 1 - # add node access key tx = sign_create_account_with_multiple_access_keys_tx( key, @@ -402,7 +401,7 @@ def start_cluster_with_mpc( cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), False, - False + False, ) txs.append(tx) From bd26a1829eb7839134621f1476ff1388af701501 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 9 Sep 2025 09:56:49 +0300 Subject: [PATCH 11/25] update pytest9 --- pytest/common_lib/shared/__init__.py | 39 +++++++++++++++++----------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index 725896da0..67d533af7 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -125,20 +125,26 @@ def sign_create_account_with_multiple_access_keys_tx( createNewAccount: bool, ) -> bytes: actions = [] + if createNewAccount: + # Only when creating a brand-new account actions.append(create_create_account_action()) - payment_action = create_payment_action(100 * NEAR_BASE) - actions.append(payment_action) + actions.append(create_payment_action(100 * NEAR_BASE)) + if fullAccess: + # Give full access to all keys access_key_actions = [ create_full_access_key_action(key.decoded_pk()) for key in keys ] else: + # Give restricted MPC-only access to all keys access_key_actions = [ create_mpc_function_call_access_key_action(key.decoded_pk(), contract_id) for key in keys ] + actions.extend(access_key_actions) + signed_tx = sign_transaction( new_account_id, nonce, @@ -352,15 +358,16 @@ def start_cluster_with_mpc( # add the nodes responder access key to the list nonce += 1 tx = sign_create_account_with_multiple_access_keys_tx( - key, - candidate.responder_keys[0].account_id, - candidate.responder_keys, + key, # cluster contract node key + "responder_0.test0", # new responder account + candidate.responder_keys, # responder keys nonce, cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), - False, - True, + fullAccess=False, # responder should have restricted access + createNewAccount=True, # new account creation ) + txs.append(tx) candidate_account_id = candidate.signer_key.account_id pytest_signer_keys = [] @@ -380,14 +387,15 @@ def start_cluster_with_mpc( # add pytest_signer_keys that are used for voting, need to access tx = sign_create_account_with_multiple_access_keys_tx( key, - candidate_account_id, - pytest_signer_keys, + "signer_0.test0", # operator account + pytest_signer_keys, # pytest keys (full access) nonce, cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), - True, - False, + fullAccess=True, # these keys can drive the operator + createNewAccount=True, # new account creation ) + txs.append(tx) nonce += 1 @@ -395,14 +403,15 @@ def start_cluster_with_mpc( # add node access key tx = sign_create_account_with_multiple_access_keys_tx( key, - candidate_account_id, - [candidate.signer_key], + "signer_0.test0", # same operator account + [candidate.signer_key], # the actual MPC node key nonce, cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), - False, - False, + fullAccess=False, # restricted (MPC-only) + createNewAccount=False, # account already exists ) + txs.append(tx) mpc_node = MpcNode( From b26ea589298453e72dfb24c7e19ca80e058a4194 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 9 Sep 2025 10:28:32 +0300 Subject: [PATCH 12/25] update pytest10 --- pytest/common_lib/shared/__init__.py | 46 ++++++++++++---------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index 67d533af7..1c51ef55e 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -355,63 +355,55 @@ def start_cluster_with_mpc( txs = [] mpc_nodes = [] for near_node, candidate in zip(observers, candidates): - # add the nodes responder access key to the list + # Tx1: create responder account nonce += 1 tx = sign_create_account_with_multiple_access_keys_tx( - key, # cluster contract node key - "responder_0.test0", # new responder account - candidate.responder_keys, # responder keys + key, # cluster.contract_node (parent test0) – valid for creating new account + candidate.responder_keys[0].account_id, + candidate.responder_keys, # include responder keys nonce, cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), - fullAccess=False, # responder should have restricted access - createNewAccount=True, # new account creation + True, # ✅ make sure responders get full access at creation + True, ) - txs.append(tx) + candidate_account_id = candidate.signer_key.account_id pytest_signer_keys = [] for i in range(0, 5): - # We add a signing key for pytest functions pytest_signing_key: SigningKey = SigningKey.generate() - candidate_account_id = candidate.signer_key.account_id pytest_signer_key: Key = Key.from_keypair( - candidate_account_id, - pytest_signing_key, + candidate_account_id, pytest_signing_key ) pytest_signer_keys.append(pytest_signer_key) + # Tx2: add pytest signer keys (for voting) – signed by parent nonce += 1 - - # Observer nodes haven't started yet so we use cluster node to send txs - # add pytest_signer_keys that are used for voting, need to access tx = sign_create_account_with_multiple_access_keys_tx( key, - "signer_0.test0", # operator account - pytest_signer_keys, # pytest keys (full access) + candidate_account_id, + pytest_signer_keys, nonce, cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), - fullAccess=True, # these keys can drive the operator - createNewAccount=True, # new account creation + True, + True, ) - txs.append(tx) + # Tx3: add node access key – signed by candidate itself nonce += 1 - - # add node access key tx = sign_create_account_with_multiple_access_keys_tx( - key, - "signer_0.test0", # same operator account - [candidate.signer_key], # the actual MPC node key + pytest_signer_keys[0], # ✅ signer_0.test0’s full-access key + candidate_account_id, + [candidate.signer_key], nonce, cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), - fullAccess=False, # restricted (MPC-only) - createNewAccount=False, # account already exists + False, + False, ) - txs.append(tx) mpc_node = MpcNode( From f0b107af69f1a33d1eade837f7b9b0984cdf46d1 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 9 Sep 2025 10:53:50 +0300 Subject: [PATCH 13/25] update pytest10 --- pytest/common_lib/shared/__init__.py | 74 +++++++++++++++++----------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index 1c51ef55e..0ef117744 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -352,33 +352,38 @@ def start_cluster_with_mpc( ) (key, nonce) = cluster.contract_node.get_key_and_nonce() - txs = [] + # --- Phase 1: create accounts + add pytest keys --- + txs_phase1 = [] mpc_nodes = [] + for near_node, candidate in zip(observers, candidates): - # Tx1: create responder account + candidate_account_id = candidate.signer_key.account_id + pytest_signer_keys = [] + + # Responder account (new account, responder access keys) nonce += 1 tx = sign_create_account_with_multiple_access_keys_tx( - key, # cluster.contract_node (parent test0) – valid for creating new account + key, candidate.responder_keys[0].account_id, - candidate.responder_keys, # include responder keys + candidate.responder_keys, nonce, cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), - True, # ✅ make sure responders get full access at creation - True, + False, # restricted access + True, # create new account ) - txs.append(tx) + txs_phase1.append(tx) - candidate_account_id = candidate.signer_key.account_id - pytest_signer_keys = [] - for i in range(0, 5): + # Generate pytest signing keys (local only, for later TXs) + for i in range(5): pytest_signing_key: SigningKey = SigningKey.generate() pytest_signer_key: Key = Key.from_keypair( - candidate_account_id, pytest_signing_key + candidate_account_id, + pytest_signing_key, ) pytest_signer_keys.append(pytest_signer_key) - # Tx2: add pytest signer keys (for voting) – signed by parent + # Add pytest keys to candidate account nonce += 1 tx = sign_create_account_with_multiple_access_keys_tx( key, @@ -387,25 +392,12 @@ def start_cluster_with_mpc( nonce, cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), - True, - True, + True, # full access + True, # new account ) - txs.append(tx) - - # Tx3: add node access key – signed by candidate itself - nonce += 1 - tx = sign_create_account_with_multiple_access_keys_tx( - pytest_signer_keys[0], # ✅ signer_0.test0’s full-access key - candidate_account_id, - [candidate.signer_key], - nonce, - cluster.contract_node.last_block_hash(), - cluster.mpc_contract_account(), - False, - False, - ) - txs.append(tx) + txs_phase1.append(tx) + # Build MPC node but don’t add node key yet mpc_node = MpcNode( near_node, candidate.signer_key, @@ -416,8 +408,30 @@ def start_cluster_with_mpc( mpc_node.set_block_ingestion(True) mpc_nodes.append(mpc_node) + # 🚀 Send + wait for Phase 1 TXs + cluster.contract_node.send_await_check_txs_parallel( + "phase1: create accounts + pytest keys", txs_phase1, assert_txn_success + ) + + # --- Phase 2: add node access key (signed by pytest key which now exists) --- + txs_phase2 = [] + + for mpc_node, candidate in zip(mpc_nodes, candidates): + nonce += 1 + tx = sign_create_account_with_multiple_access_keys_tx( + key, + candidate.signer_key.account_id, + [candidate.signer_key], + nonce, + cluster.contract_node.last_block_hash(), + cluster.mpc_contract_account(), + False, # restricted access + False, # account already exists + ) + txs_phase2.append(tx) + cluster.contract_node.send_await_check_txs_parallel( - "create account", txs, assert_txn_success + "phase2: add node keys", txs_phase2, assert_txn_success ) # Deploy the mpc contract From c3876468be389ae7b9547748d5eb3ae7c8f886c0 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 9 Sep 2025 12:29:51 +0300 Subject: [PATCH 14/25] update pytest11 --- pytest/common_lib/shared/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index 0ef117744..f668adffe 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -419,7 +419,7 @@ def start_cluster_with_mpc( for mpc_node, candidate in zip(mpc_nodes, candidates): nonce += 1 tx = sign_create_account_with_multiple_access_keys_tx( - key, + pytest_signer_keys[0], # any pytest key will do candidate.signer_key.account_id, [candidate.signer_key], nonce, From f28af4dd2165791847ec3f948befb9ddd4278afd Mon Sep 17 00:00:00 2001 From: root Date: Tue, 9 Sep 2025 13:02:59 +0300 Subject: [PATCH 15/25] update pytest12 --- pytest/common_lib/shared/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index f668adffe..2978f8935 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -412,6 +412,10 @@ def start_cluster_with_mpc( cluster.contract_node.send_await_check_txs_parallel( "phase1: create accounts + pytest keys", txs_phase1, assert_txn_success ) + # --- Wait for finality (make sure accounts exist) --- + cluster.contract_node.block_until_final_height( + cluster.contract_node.latest_block_height() + 2 + ) # --- Phase 2: add node access key (signed by pytest key which now exists) --- txs_phase2 = [] From 18b53909fc312d05a350d3493e711fa533487e05 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 9 Sep 2025 15:14:10 +0300 Subject: [PATCH 16/25] update pytest13 --- pytest/common_lib/shared/__init__.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index 2978f8935..4a73d5d2d 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -5,6 +5,7 @@ import sys from typing import List, Optional, Tuple, cast import typing +import time import base58 import yaml @@ -412,10 +413,7 @@ def start_cluster_with_mpc( cluster.contract_node.send_await_check_txs_parallel( "phase1: create accounts + pytest keys", txs_phase1, assert_txn_success ) - # --- Wait for finality (make sure accounts exist) --- - cluster.contract_node.block_until_final_height( - cluster.contract_node.latest_block_height() + 2 - ) + time.sleep(2*60) # --- Phase 2: add node access key (signed by pytest key which now exists) --- txs_phase2 = [] From 44afd8ec82d83cc2d04d85188f0b654eac875f45 Mon Sep 17 00:00:00 2001 From: Barakeinav1 Date: Tue, 9 Sep 2025 17:09:10 +0300 Subject: [PATCH 17/25] update pytest14 --- pytest/common_lib/shared/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index 4a73d5d2d..72a7b6d84 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -140,7 +140,9 @@ def sign_create_account_with_multiple_access_keys_tx( else: # Give restricted MPC-only access to all keys access_key_actions = [ - create_mpc_function_call_access_key_action(key.decoded_pk(), contract_id) + create_mpc_function_call_access_key_action( + key.decoded_pk(), contract_id, 10 + ) for key in keys ] @@ -370,7 +372,7 @@ def start_cluster_with_mpc( nonce, cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), - False, # restricted access + True, # full access True, # create new account ) txs_phase1.append(tx) @@ -413,7 +415,7 @@ def start_cluster_with_mpc( cluster.contract_node.send_await_check_txs_parallel( "phase1: create accounts + pytest keys", txs_phase1, assert_txn_success ) - time.sleep(2*60) + time.sleep(10) # --- Phase 2: add node access key (signed by pytest key which now exists) --- txs_phase2 = [] From 82ffc269695a3352d80e3a3c374d8612772fd186 Mon Sep 17 00:00:00 2001 From: Barakeinav1 Date: Tue, 9 Sep 2025 17:21:19 +0300 Subject: [PATCH 18/25] update pytest14 --- pytest/common_lib/shared/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index 72a7b6d84..d15a2cde2 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -429,7 +429,7 @@ def start_cluster_with_mpc( nonce, cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), - False, # restricted access + True, # full access False, # account already exists ) txs_phase2.append(tx) From 84c73b829c4f33ff52bb6ae6876c716873bbdf2f Mon Sep 17 00:00:00 2001 From: Barakeinav1 Date: Tue, 9 Sep 2025 17:46:04 +0300 Subject: [PATCH 19/25] update pytest14 --- pytest/common_lib/shared/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index d15a2cde2..a1d421f4f 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -141,7 +141,7 @@ def sign_create_account_with_multiple_access_keys_tx( # Give restricted MPC-only access to all keys access_key_actions = [ create_mpc_function_call_access_key_action( - key.decoded_pk(), contract_id, 10 + key.decoded_pk(), contract_id, 1 * NEAR_BASE ) for key in keys ] @@ -415,7 +415,7 @@ def start_cluster_with_mpc( cluster.contract_node.send_await_check_txs_parallel( "phase1: create accounts + pytest keys", txs_phase1, assert_txn_success ) - time.sleep(10) + time.sleep(1) # --- Phase 2: add node access key (signed by pytest key which now exists) --- txs_phase2 = [] @@ -423,7 +423,9 @@ def start_cluster_with_mpc( for mpc_node, candidate in zip(mpc_nodes, candidates): nonce += 1 tx = sign_create_account_with_multiple_access_keys_tx( - pytest_signer_keys[0], # any pytest key will do + mpc_node.pytest_signer_keys[ + 0 + ], # pytest_signer_keys[0], # any pytest key will do candidate.signer_key.account_id, [candidate.signer_key], nonce, From 685edc1e2609aec5d2e62c36723f4365136430b7 Mon Sep 17 00:00:00 2001 From: Barakeinav1 Date: Tue, 9 Sep 2025 17:58:59 +0300 Subject: [PATCH 20/25] update pytest14 --- pytest/common_lib/shared/__init__.py | 81 ++++++++++++---------------- 1 file changed, 33 insertions(+), 48 deletions(-) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index a1d421f4f..c88fe47b9 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -5,7 +5,6 @@ import sys from typing import List, Optional, Tuple, cast import typing -import time import base58 import yaml @@ -140,9 +139,7 @@ def sign_create_account_with_multiple_access_keys_tx( else: # Give restricted MPC-only access to all keys access_key_actions = [ - create_mpc_function_call_access_key_action( - key.decoded_pk(), contract_id, 1 * NEAR_BASE - ) + create_mpc_function_call_access_key_action(key.decoded_pk(), contract_id) for key in keys ] @@ -355,15 +352,10 @@ def start_cluster_with_mpc( ) (key, nonce) = cluster.contract_node.get_key_and_nonce() - # --- Phase 1: create accounts + add pytest keys --- - txs_phase1 = [] + txs = [] mpc_nodes = [] - for near_node, candidate in zip(observers, candidates): - candidate_account_id = candidate.signer_key.account_id - pytest_signer_keys = [] - - # Responder account (new account, responder access keys) + # add the nodes responder access key to the list nonce += 1 tx = sign_create_account_with_multiple_access_keys_tx( key, @@ -372,22 +364,26 @@ def start_cluster_with_mpc( nonce, cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), - True, # full access - True, # create new account + True, + True, ) - txs_phase1.append(tx) - - # Generate pytest signing keys (local only, for later TXs) - for i in range(5): + txs.append(tx) + candidate_account_id = candidate.signer_key.account_id + pytest_signer_keys = [] + for i in range(0, 5): + # We add a signing key for pytest functions pytest_signing_key: SigningKey = SigningKey.generate() + candidate_account_id = candidate.signer_key.account_id pytest_signer_key: Key = Key.from_keypair( candidate_account_id, pytest_signing_key, ) pytest_signer_keys.append(pytest_signer_key) - # Add pytest keys to candidate account nonce += 1 + + # Observer nodes haven't started yet so we use cluster node to send txs + # add pytest_signer_keys that are used for voting, need to access tx = sign_create_account_with_multiple_access_keys_tx( key, candidate_account_id, @@ -395,12 +391,26 @@ def start_cluster_with_mpc( nonce, cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), - True, # full access - True, # new account + True, + True, ) - txs_phase1.append(tx) + txs.append(tx) + + nonce += 1 + + # add node access key + tx = sign_create_account_with_multiple_access_keys_tx( + pytest_signer_keys[0], + candidate_account_id, + [candidate.signer_key], + nonce, + cluster.contract_node.last_block_hash(), + cluster.mpc_contract_account(), + True, + False, + ) + txs.append(tx) - # Build MPC node but don’t add node key yet mpc_node = MpcNode( near_node, candidate.signer_key, @@ -411,33 +421,8 @@ def start_cluster_with_mpc( mpc_node.set_block_ingestion(True) mpc_nodes.append(mpc_node) - # 🚀 Send + wait for Phase 1 TXs - cluster.contract_node.send_await_check_txs_parallel( - "phase1: create accounts + pytest keys", txs_phase1, assert_txn_success - ) - time.sleep(1) - - # --- Phase 2: add node access key (signed by pytest key which now exists) --- - txs_phase2 = [] - - for mpc_node, candidate in zip(mpc_nodes, candidates): - nonce += 1 - tx = sign_create_account_with_multiple_access_keys_tx( - mpc_node.pytest_signer_keys[ - 0 - ], # pytest_signer_keys[0], # any pytest key will do - candidate.signer_key.account_id, - [candidate.signer_key], - nonce, - cluster.contract_node.last_block_hash(), - cluster.mpc_contract_account(), - True, # full access - False, # account already exists - ) - txs_phase2.append(tx) - cluster.contract_node.send_await_check_txs_parallel( - "phase2: add node keys", txs_phase2, assert_txn_success + "create account", txs, assert_txn_success ) # Deploy the mpc contract From c0cf53c6b86342e125f5b72b3afd9f966cb83e2d Mon Sep 17 00:00:00 2001 From: Barakeinav1 Date: Wed, 10 Sep 2025 08:03:13 +0300 Subject: [PATCH 21/25] update pytest14 --- pytest/common_lib/shared/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index c88fe47b9..efb617d56 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -403,7 +403,7 @@ def start_cluster_with_mpc( pytest_signer_keys[0], candidate_account_id, [candidate.signer_key], - nonce, + 2, cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), True, From 1ad8d08dd0af4e9c456867c695ff820bb655a149 Mon Sep 17 00:00:00 2001 From: Barakeinav1 Date: Wed, 10 Sep 2025 08:12:50 +0300 Subject: [PATCH 22/25] update pytest15 --- pytest/common_lib/shared/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index efb617d56..953287884 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -129,7 +129,7 @@ def sign_create_account_with_multiple_access_keys_tx( if createNewAccount: # Only when creating a brand-new account actions.append(create_create_account_action()) - actions.append(create_payment_action(100 * NEAR_BASE)) + if fullAccess: # Give full access to all keys @@ -142,7 +142,7 @@ def sign_create_account_with_multiple_access_keys_tx( create_mpc_function_call_access_key_action(key.decoded_pk(), contract_id) for key in keys ] - + actions.append(create_payment_action(100 * NEAR_BASE)) actions.extend(access_key_actions) signed_tx = sign_transaction( @@ -403,7 +403,7 @@ def start_cluster_with_mpc( pytest_signer_keys[0], candidate_account_id, [candidate.signer_key], - 2, + nonce, cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), True, From eda0a86e4a37d999c61ac7213ad5ecb734c5b703 Mon Sep 17 00:00:00 2001 From: Barakeinav1 Date: Wed, 10 Sep 2025 08:56:24 +0300 Subject: [PATCH 23/25] update pytest15 --- pytest/common_lib/shared/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index 953287884..1bd3c79cf 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -396,14 +396,14 @@ def start_cluster_with_mpc( ) txs.append(tx) - nonce += 1 - + #nonce += 1 + candidate.signer_key # add node access key tx = sign_create_account_with_multiple_access_keys_tx( pytest_signer_keys[0], candidate_account_id, [candidate.signer_key], - nonce, + 0, cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), True, From 81f89218c4b7fd5374ee4d572d4cadd6f99e072d Mon Sep 17 00:00:00 2001 From: kevindeforth Date: Wed, 10 Sep 2025 10:44:11 +0200 Subject: [PATCH 24/25] init --- pytest/common_lib/shared/__init__.py | 77 +++++++++++++++---- pytest/common_lib/shared/near_account.py | 3 + .../common_lib/shared/transaction_status.py | 2 +- 3 files changed, 67 insertions(+), 15 deletions(-) diff --git a/pytest/common_lib/shared/__init__.py b/pytest/common_lib/shared/__init__.py index 1bd3c79cf..caea830d2 100644 --- a/pytest/common_lib/shared/__init__.py +++ b/pytest/common_lib/shared/__init__.py @@ -44,7 +44,7 @@ def create_function_call_access_key_action( - pk: str, contract_id: str, method_names: list[str], allowance: int | None = None + pk: bytes, contract_id: str, method_names: list[str], allowance: int | None = None ) -> "Action": permission = AccessKeyPermission() permission.enum = "functionCall" @@ -75,7 +75,7 @@ def create_function_call_access_key_action( def create_mpc_function_call_access_key_action( - pk: str, contract_id: str, allowance: int | None = None + pk: bytes, contract_id: str, allowance: int | None = None ) -> "Action": """ Create a restricted access key that only allows calling MPC-related contract methods. @@ -114,6 +114,20 @@ def deserialize_key(account_id: str, key: List[int]) -> Key: return Key.from_keypair(account_id, signing_key) +def dump(obj, indent=0): + pad = " " * indent + if hasattr(obj, "__dict__"): + for k, v in vars(obj).items(): + print(f"{pad}{k}:") + dump(v, indent + 1) + elif isinstance(obj, (list, tuple)): + for i, v in enumerate(obj): + print(f"{pad}[{i}]:") + dump(v, indent + 1) + else: + print(f"{pad}{obj}") + + def sign_create_account_with_multiple_access_keys_tx( creator_key: Key, new_account_id, @@ -129,7 +143,7 @@ def sign_create_account_with_multiple_access_keys_tx( if createNewAccount: # Only when creating a brand-new account actions.append(create_create_account_action()) - + actions.append(create_payment_action(100 * NEAR_BASE)) if fullAccess: # Give full access to all keys @@ -139,10 +153,13 @@ def sign_create_account_with_multiple_access_keys_tx( else: # Give restricted MPC-only access to all keys access_key_actions = [ - create_mpc_function_call_access_key_action(key.decoded_pk(), contract_id) + create_mpc_function_call_access_key_action( + key.decoded_pk(), contract_id, allowance=100 * NEAR_BASE + ) for key in keys ] - actions.append(create_payment_action(100 * NEAR_BASE)) + print("access key actions:", access_key_actions) + dump(access_key_actions) actions.extend(access_key_actions) signed_tx = sign_transaction( @@ -154,6 +171,12 @@ def sign_create_account_with_multiple_access_keys_tx( creator_key.decoded_pk(), creator_key.decoded_sk(), ) + + print("signed tx: ", signed_tx) + dump(signed_tx) + + # for name, value in vars(signed_tx).items(): + # print(name, "=", value) return serialize_transaction(signed_tx) @@ -352,8 +375,10 @@ def start_cluster_with_mpc( ) (key, nonce) = cluster.contract_node.get_key_and_nonce() - txs = [] + create_txs = [] + access_txs = [] mpc_nodes = [] + pytest_keys_per_node = [] for near_node, candidate in zip(observers, candidates): # add the nodes responder access key to the list nonce += 1 @@ -367,7 +392,7 @@ def start_cluster_with_mpc( True, True, ) - txs.append(tx) + create_txs.append(tx) candidate_account_id = candidate.signer_key.account_id pytest_signer_keys = [] for i in range(0, 5): @@ -394,22 +419,46 @@ def start_cluster_with_mpc( True, True, ) - txs.append(tx) + create_txs.append(tx) + pytest_keys_per_node.append(pytest_signer_keys) + + cluster.contract_node.send_await_check_txs_parallel( + "create account", create_txs, assert_txn_success + ) + + for near_node, candidate, pytest_signer_keys in zip( + observers, candidates, pytest_keys_per_node + ): + candidate_account_id = candidate.signer_key.account_id - #nonce += 1 - candidate.signer_key + print( + "ALL ACCESS KEYS:", + cluster.contract_node.near_node.get_access_key_list(candidate_account_id), + ) + creator_key = pytest_signer_keys[0] + print("my signer key:", creator_key.pk) + nonce = cluster.contract_node.near_node.get_nonce_for_pk( + candidate_account_id, creator_key.pk + ) + print("candidate signer key:", candidate.signer_key) + assert nonce is not None + print("found nonce: ", nonce) + # nonce = 0 # add node access key tx = sign_create_account_with_multiple_access_keys_tx( + # key, pytest_signer_keys[0], candidate_account_id, [candidate.signer_key], - 0, + nonce + 1, cluster.contract_node.last_block_hash(), cluster.mpc_contract_account(), - True, + False, False, ) - txs.append(tx) + access_txs.append(tx) + print("access key tx:") + dump(tx) mpc_node = MpcNode( near_node, @@ -422,7 +471,7 @@ def start_cluster_with_mpc( mpc_nodes.append(mpc_node) cluster.contract_node.send_await_check_txs_parallel( - "create account", txs, assert_txn_success + "access keys", access_txs, assert_txn_success ) # Deploy the mpc contract diff --git a/pytest/common_lib/shared/near_account.py b/pytest/common_lib/shared/near_account.py index 6bc044fe2..1de47ee96 100644 --- a/pytest/common_lib/shared/near_account.py +++ b/pytest/common_lib/shared/near_account.py @@ -65,8 +65,11 @@ def send_await_check_txs_parallel( txns: list[bytes], verification_callback: Callable[[dict[str, Any]], None], ): + print("sending") tx_hashes = self.send_txs_parallel_returning_hashes(txns, label) + print("awaiting") results = self.await_txs(tx_hashes) + print("received", results) verify_txs(results, verification_callback) def get_tx(self, tx_hash): diff --git a/pytest/common_lib/shared/transaction_status.py b/pytest/common_lib/shared/transaction_status.py index fc6b0791c..57cbd0a19 100644 --- a/pytest/common_lib/shared/transaction_status.py +++ b/pytest/common_lib/shared/transaction_status.py @@ -31,7 +31,7 @@ def verify_txs(results, verification_callback, verbose=False): total_tgas += gas_tx / TGAS total_receipts += n_rcpts_tx verification_callback(res) - if verbose: + if True: # verbose: print( f"number of txs: {num_txs}\n max gas used (Tgas):{max_tgas_used}\n average receipts: {total_receipts / num_txs}\n average gas used (Tgas): {total_tgas / num_txs}\n" ) From 5eb112193d01be6e7a1772c4859eaa9e4122cd21 Mon Sep 17 00:00:00 2001 From: Barakeinav1 Date: Thu, 11 Sep 2025 10:22:14 +0300 Subject: [PATCH 25/25] fix devid by zero issue --- pytest/common_lib/shared/transaction_status.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pytest/common_lib/shared/transaction_status.py b/pytest/common_lib/shared/transaction_status.py index 57cbd0a19..da59283b0 100644 --- a/pytest/common_lib/shared/transaction_status.py +++ b/pytest/common_lib/shared/transaction_status.py @@ -32,9 +32,16 @@ def verify_txs(results, verification_callback, verbose=False): total_receipts += n_rcpts_tx verification_callback(res) if True: # verbose: - print( - f"number of txs: {num_txs}\n max gas used (Tgas):{max_tgas_used}\n average receipts: {total_receipts / num_txs}\n average gas used (Tgas): {total_tgas / num_txs}\n" - ) + if verbose: + if num_txs == 0: + print("number of txs: 0\n no gas or receipts to report") + else: + print( + f"number of txs: {num_txs}\n" + f" max gas used (Tgas):{max_tgas_used}\n" + f" average receipts: {total_receipts / num_txs}\n" + f" average gas used (Tgas): {total_tgas / num_txs}\n" + ) def assert_txn_success(result: dict[str, Any]):