From 321b806ca51b8cb670271bb85b17a287a3ecf283 Mon Sep 17 00:00:00 2001 From: Tom McLean Date: Wed, 30 Aug 2023 11:28:59 +0100 Subject: [PATCH] feat: Change vegawallet call --- tests/integration/utils/fixtures.py | 2 + vega_sim/null_service.py | 8 ++-- vega_sim/tools/load_binaries.py | 70 ++++++++++++++++++++++++----- vega_sim/vegahome/genesis.json | 4 +- vega_sim/wallet/vega_wallet.py | 4 ++ 5 files changed, 73 insertions(+), 15 deletions(-) diff --git a/tests/integration/utils/fixtures.py b/tests/integration/utils/fixtures.py index 0f88d6cc0..1273069d0 100644 --- a/tests/integration/utils/fixtures.py +++ b/tests/integration/utils/fixtures.py @@ -144,6 +144,7 @@ def vega_service(): retain_log_files=True, transactions_per_block=1, listen_for_high_volume_stream_updates=False, + use_full_vega_wallet=True, ) as vega: yield vega logging.debug("vega_service teardown") @@ -163,6 +164,7 @@ def vega_service_with_high_volume(): retain_log_files=True, transactions_per_block=1, listen_for_high_volume_stream_updates=True, + use_full_vega_wallet=True, ) as vega: yield vega logging.debug("vega_service_with_high_volume teardown") diff --git a/vega_sim/null_service.py b/vega_sim/null_service.py index 22ce9e166..ba5b243ad 100644 --- a/vega_sim/null_service.py +++ b/vega_sim/null_service.py @@ -496,6 +496,7 @@ def manage_vega_processes( subprocess.run( [ vega_wallet_path, + "wallet", "api-token", "init", f"--home={tmp_vega_home}", @@ -507,6 +508,7 @@ def manage_vega_processes( subprocess.run( [ vega_wallet_path, + "wallet", "create", "--wallet", DEFAULT_WALLET_NAME, @@ -523,6 +525,7 @@ def manage_vega_processes( subprocess.run( [ vega_wallet_path, + "wallet", "api-token", "generate", "--home=" + tmp_vega_home, @@ -536,6 +539,7 @@ def manage_vega_processes( wallet_args = [ vega_wallet_path, + "wallet", "service", "run", "--network", @@ -750,9 +754,7 @@ def __init__( ) self.vega_path = vega_path or path.join(vega_bin_path, "vega") self.data_node_path = data_node_path or path.join(vega_bin_path, "data-node") - self.vega_wallet_path = vega_wallet_path or path.join( - vega_bin_path, "vegawallet" - ) + self.vega_wallet_path = vega_wallet_path or path.join(vega_bin_path, "vega") self.vega_console_path = vega_console_path or path.join( vega_bin_path, "console" ) diff --git a/vega_sim/tools/load_binaries.py b/vega_sim/tools/load_binaries.py index 4a50eeae6..3ce2dcdbe 100644 --- a/vega_sim/tools/load_binaries.py +++ b/vega_sim/tools/load_binaries.py @@ -5,6 +5,7 @@ import shutil import tempfile import zipfile +from typing import Optional import requests @@ -12,21 +13,32 @@ logger = logging.getLogger(__name__) +URL_DEV_BASE = ( + "https://github.com/vegaprotocol/vega-dev-releases/releases/download/{version}/" +) URL_BASE = "https://github.com/vegaprotocol/vega/releases/download/{version}/" DATA_NODE = "data-node-{platform}-{chipset}64.zip" VEGA_CORE = "vega-{platform}-{chipset}64.zip" -VEGAWALLET = "vegawallet-{platform}-{chipset}64.zip" -FILES = [DATA_NODE, VEGA_CORE, VEGAWALLET] +FILES = [DATA_NODE, VEGA_CORE] BIN_NAMES = { DATA_NODE: "data-node", VEGA_CORE: "vega", - VEGAWALLET: "vegawallet", } -def download_binaries(force: bool = False, latest: bool = False): +def download_binaries( + force: bool = False, + latest: bool = False, + version: Optional[str] = None, + dev: bool = False, +): + if version is not None and latest: + raise Exception( + "Cannot specify both version and latest flag, please use only one" + ) + platf = platform.system().lower() # We have no Windows specific builds, so people have to use WSL to run @@ -41,9 +53,13 @@ def download_binaries(force: bool = False, latest: bool = False): if not os.path.exists(vega_sim.vega_bin_path): os.mkdir(vega_sim.vega_bin_path) - if latest: + if version: + vega_version = version + elif latest: vega_versions = requests.get( - "https://api.github.com/repos/vegaprotocol/vega/releases" + "https://api.github.com/repos/vegaprotocol/vega-dev-releases/releases" + if dev + else "https://api.github.com/repos/vegaprotocol/vega/releases" ).json() vega_version = vega_versions[0]["tag_name"] else: @@ -60,9 +76,13 @@ def download_binaries(force: bool = False, latest: bool = False): ) or force: logger.info(f"Downloading {file_name}") - url_base = URL_BASE.format(version=vega_version) + url_base = (URL_BASE if not dev else URL_DEV_BASE).format( + version=vega_version + ) url = url_base + file_name res = requests.get(url) + res.raise_for_status() + file_path = os.path.join(dir, f"{file_name}") with open(file_path, "wb") as f: @@ -78,8 +98,38 @@ def download_binaries(force: bool = False, latest: bool = False): logging.basicConfig(level=logging.INFO) parser = argparse.ArgumentParser() - parser.add_argument("-f", "--force", action="store_true") - parser.add_argument("--latest", action="store_true") + parser.add_argument( + "-f", + "--force", + action="store_true", + help="Force binaries to download even if some are already present", + ) + parser.add_argument( + "--latest", + action="store_true", + help=( + "Load the latest built version, either from main repo or the dev builds" + " depending on presence of dev flag" + ), + ) + parser.add_argument( + "--version", + required=False, + help=( + "Specify a specific version tag to use. Otherwise will be picked based on" + " either presence of latest flag or the default vega sim version" + ), + ) + parser.add_argument( + "--dev", + action="store_true", + help=( + "Flag to specify loading versions from the Vega dev process (built on every" + " release) vs main repo builds" + ), + ) args = parser.parse_args() - download_binaries(force=args.force, latest=args.latest) + download_binaries( + force=args.force, latest=args.latest, dev=args.dev, version=args.version + ) diff --git a/vega_sim/vegahome/genesis.json b/vega_sim/vegahome/genesis.json index 857ce1539..bb345968e 100644 --- a/vega_sim/vegahome/genesis.json +++ b/vega_sim/vegahome/genesis.json @@ -162,8 +162,8 @@ "spam.protection.delegation.min.tokens": "100000000000000000", "spam.protection.max.batchSize": "30", "spam.protection.max.delegations": "360", - "spam.protection.max.proposals": "3", - "spam.protection.max.votes": "3", + "spam.protection.max.proposals": "300", + "spam.protection.max.votes": "300", "spam.protection.maxUserTransfersPerEpoch": "20", "spam.protection.minimumWithdrawalQuantumMultiple": "10", "spam.protection.minMultisigUpdates": "100000000000000000000", diff --git a/vega_sim/wallet/vega_wallet.py b/vega_sim/wallet/vega_wallet.py index 38793f333..4493ac66c 100644 --- a/vega_sim/wallet/vega_wallet.py +++ b/vega_sim/wallet/vega_wallet.py @@ -86,6 +86,7 @@ def _load_token(self, wallet_name: str): cmd = subprocess.run( [ self._wallet_path, + "wallet", "api-token", "list", "--home", @@ -130,6 +131,7 @@ def create_key(self, name: str, wallet_name: Optional[str] = None) -> None: cmd = subprocess.run( [ self._wallet_path, + "wallet", "key", "generate", "--wallet", @@ -163,6 +165,7 @@ def create_wallet(self, name: str) -> None: subprocess.run( [ self._wallet_path, + "wallet", "create", "--wallet", name, @@ -182,6 +185,7 @@ def create_wallet(self, name: str) -> None: cmd = subprocess.run( [ self._wallet_path, + "wallet", "api-token", "generate", "--home",