From b8442edf28c7a29e80ff37b532ea46ed4f96a57a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20B=C4=99za?= Date: Wed, 14 Jan 2026 18:14:51 +0100 Subject: [PATCH 1/2] chore: remove dead Python code Fixes #1762 --- pytest/common_lib/ckd.py | 5 -- pytest/common_lib/contract_state.py | 9 ---- pytest/common_lib/contracts.py | 66 ------------------------- pytest/common_lib/shared/mpc_cluster.py | 11 ----- pytest/common_lib/shared/mpc_node.py | 20 -------- 5 files changed, 111 deletions(-) diff --git a/pytest/common_lib/ckd.py b/pytest/common_lib/ckd.py index ee4d72bba0..d78cc55499 100644 --- a/pytest/common_lib/ckd.py +++ b/pytest/common_lib/ckd.py @@ -36,11 +36,6 @@ def b58encode_g1(pk: G1Point) -> str: return BLS12381G1_PREFIX + base58.b58encode(pk_bytes).decode("ascii") -def b58encode_g2(pk: G2Point) -> str: - pk_bytes = bytes(pk.to_compressed_bytes()) - return BLS12381G2_PREFIX + base58.b58encode(pk_bytes).decode("ascii") - - def b58decode_g1(pk_encoded: str) -> G1Point: assert pk_encoded.startswith(BLS12381G1_PREFIX) pk_bytes = base58.b58decode(pk_encoded[len(BLS12381G1_PREFIX) :]) diff --git a/pytest/common_lib/contract_state.py b/pytest/common_lib/contract_state.py index 2fbcafaa6c..e51e4ac8b9 100644 --- a/pytest/common_lib/contract_state.py +++ b/pytest/common_lib/contract_state.py @@ -87,9 +87,6 @@ class Participants: def account_ids(self) -> set[str]: return {p.account_id for p in self.participants} - def ids(self) -> set[int]: - return {p.id for p in self.participants} - def is_participant(self, account_id: str) -> bool: return any(p.account_id == account_id for p in self.participants) @@ -99,12 +96,6 @@ def by_account(self, account_id: str) -> Participant: return participant raise KeyError(f"No participant found with account_id '{account_id}'") - def by_id(self, id: int) -> Participant: - for participant in self.participants: - if participant.id == id: - return participant - raise KeyError(f"No participant found with id '{id}'") - @staticmethod def from_json(data: dict): raw_participants = data.get("participants", []) diff --git a/pytest/common_lib/contracts.py b/pytest/common_lib/contracts.py index e004050aa3..f11b771ad0 100644 --- a/pytest/common_lib/contracts.py +++ b/pytest/common_lib/contracts.py @@ -1,5 +1,3 @@ -import json - from utils import load_binary_file from enum import Enum from borsh_construct import Vec, U8, CStruct, U64, Option @@ -29,22 +27,6 @@ def contract_compiled_file_name(contract_package_name: str) -> str: MPC_CONTRACT_PACKAGE_NAME ) -TESTNET_ACCOUNT_ID = "v1.signer-prod.testnet" -MAINNET_ACCOUNT_ID = "v1.signer" - - -def build_view_code_request(account_id: str) -> dict: - return { - "jsonrpc": "2.0", - "id": "dontcare", - "method": "query", - "params": { - "request_type": "view_code", - "finality": "final", - "account_id": account_id, - }, - } - def load_mpc_contract() -> bytearray: """ @@ -60,63 +42,15 @@ def load_parallel_sign_contract() -> bytearray: return load_binary_file(PARALLEL_CONTRACT_BINARY_PATH) -class ConfigV2: - def __init__(self, max_num_requests_to_remove, request_timeout_blocks): - self.max_num_requests_to_remove = max_num_requests_to_remove - self.request_timeout_blocks = request_timeout_blocks - - def dump_json(self): - return json.dumps( - { - "request_timeout_blocks": self.max_num_requests_to_remove, - "key_event_timeout_blocks": self.request_timeout_blocks, - } - ) - - def get(self): - return { - "max_num_requests_to_remove": self.max_num_requests_to_remove, - "request_timeout_blocks": self.request_timeout_blocks, - } - - ConfigV2Borsh = CStruct("key_event_timeout_blocks" / U64) ProposeUpdateArgsV2 = CStruct( "code" / Option(Vec(U8)), "config" / Option(ConfigV2Borsh) ) -class UpdateArgsV2: - def __init__(self, code_path=None, config=None): - self.code_path = code_path - self.config = config - self._code = None - - def borsh_serialize(self): - return ProposeUpdateArgsV2.build( - { - "code": self.code(), - "config": self.config.get() if self.config is not None else None, - } - ) - - def code(self): - if self.code_path is None: - return None - if self._code is None: - self._code = load_binary_file(self.code_path) - return self._code - - def dump_json(self): - assert self.config is not None - return self.config.dump_json() - - class ContractMethod(str, Enum): VOTE_NEW_PARAMETERS = "vote_new_parameters" VOTE_ADD_DOMAINS = "vote_add_domains" - PROPOSE_UPDATE = "propose_update" - VOTE_UPDATE = "vote_update" GET_TEE_ACCOUNTS = "get_tee_accounts" MIGRATION_INFO = "migration_info" STATE = "state" diff --git a/pytest/common_lib/shared/mpc_cluster.py b/pytest/common_lib/shared/mpc_cluster.py index b91b345558..7001f71353 100644 --- a/pytest/common_lib/shared/mpc_cluster.py +++ b/pytest/common_lib/shared/mpc_cluster.py @@ -42,10 +42,6 @@ class MpcCluster: """Helper class""" - def run_all(self): - for node in self.nodes: - node.run() - def kill_all(self): with ThreadPoolExecutor(max_workers=len(self.mpc_nodes)) as executor: executor.map(lambda node: node.kill(False), self.mpc_nodes) @@ -541,13 +537,6 @@ def send_and_await_ckd_requests( "ckd request", txs, ckd_verification ) - def get_config(self, node_id=0): - node = self.mpc_nodes[node_id] - res = self.call_contract_function_with_account_assert_success( - node, ContractMethod.CONFIG - ) - return json.dumps(res) - def register_backup_service_info( self, node_id: int, backup_service_info: BackupServiceInfo ): diff --git a/pytest/common_lib/shared/mpc_node.py b/pytest/common_lib/shared/mpc_node.py index c95f56498c..6ef6b847d8 100644 --- a/pytest/common_lib/shared/mpc_node.py +++ b/pytest/common_lib/shared/mpc_node.py @@ -7,7 +7,6 @@ from typing import cast from key import Key -from ruamel.yaml import YAML from common_lib.constants import LISTEN_BLOCKS_FILE, MPC_BINARY_PATH @@ -74,25 +73,6 @@ def __init__( self.metrics = MetricsTracker(near_node) self.backup_key = backup_key - def change_contract_id(self, new_contract_id: str): - yaml = YAML() - yaml.preserve_quotes = ( - True # optional: keeps any quotes if present in original file - ) - - path = pathlib.Path(self.home_dir) / "config.yaml" - with path.open("r") as f: - config = yaml.load(f) - - old_contract_id = config["indexer"]["mpc_contract_id"] - print( - f"changing contract_id from {old_contract_id} to {new_contract_id} for node {self.account_id()}" - ) - config["indexer"]["mpc_contract_id"] = new_contract_id - - with path.open("w") as f: - yaml.dump(config, f) - def print(self): if not self.is_running: return f"⛔\033[90m{self.account_id()}\033[0m" From 120d404e4e2b3bd113dcb723cefb793ab026ccb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20B=C4=99za?= Date: Wed, 14 Jan 2026 19:04:32 +0100 Subject: [PATCH 2/2] Address Copilot's code review --- pytest/common_lib/contracts.py | 7 ------- pytest/requirements.txt | 3 --- 2 files changed, 10 deletions(-) diff --git a/pytest/common_lib/contracts.py b/pytest/common_lib/contracts.py index f11b771ad0..718bdbbb13 100644 --- a/pytest/common_lib/contracts.py +++ b/pytest/common_lib/contracts.py @@ -1,6 +1,5 @@ from utils import load_binary_file from enum import Enum -from borsh_construct import Vec, U8, CStruct, U64, Option from .constants import MPC_REPO_DIR PARALLEL_CONTRACT_PACKAGE_NAME = "test-parallel-contract" @@ -42,12 +41,6 @@ def load_parallel_sign_contract() -> bytearray: return load_binary_file(PARALLEL_CONTRACT_BINARY_PATH) -ConfigV2Borsh = CStruct("key_event_timeout_blocks" / U64) -ProposeUpdateArgsV2 = CStruct( - "code" / Option(Vec(U8)), "config" / Option(ConfigV2Borsh) -) - - class ContractMethod(str, Enum): VOTE_NEW_PARAMETERS = "vote_new_parameters" VOTE_ADD_DOMAINS = "vote_add_domains" diff --git a/pytest/requirements.txt b/pytest/requirements.txt index fbc1ae5568..1f5f14c5eb 100644 --- a/pytest/requirements.txt +++ b/pytest/requirements.txt @@ -1,9 +1,6 @@ -r ../libs/nearcore/pytest/requirements.txt -e ./nearcore_pytest -borsh-construct blspy py-arkworks-bls12381 pytest==8.3.4 gitpython -pytest-rerunfailures -ruamel.yaml