Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions pytest/common_lib/ckd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) :])
Expand Down
9 changes: 0 additions & 9 deletions pytest/common_lib/contract_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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", [])
Expand Down
73 changes: 0 additions & 73 deletions pytest/common_lib/contracts.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import json

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"
Expand All @@ -29,22 +26,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:
"""
Expand All @@ -60,63 +41,9 @@ 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"
Expand Down
11 changes: 0 additions & 11 deletions pytest/common_lib/shared/mpc_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
):
Expand Down
20 changes: 0 additions & 20 deletions pytest/common_lib/shared/mpc_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions pytest/requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Loading