Skip to content

Commit

Permalink
feat: Change vegawallet call
Browse files Browse the repository at this point in the history
  • Loading branch information
TomMcL committed Aug 30, 2023
1 parent 0d95417 commit 321b806
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 15 deletions.
2 changes: 2 additions & 0 deletions tests/integration/utils/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
8 changes: 5 additions & 3 deletions vega_sim/null_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ def manage_vega_processes(
subprocess.run(
[
vega_wallet_path,
"wallet",
"api-token",
"init",
f"--home={tmp_vega_home}",
Expand All @@ -507,6 +508,7 @@ def manage_vega_processes(
subprocess.run(
[
vega_wallet_path,
"wallet",
"create",
"--wallet",
DEFAULT_WALLET_NAME,
Expand All @@ -523,6 +525,7 @@ def manage_vega_processes(
subprocess.run(
[
vega_wallet_path,
"wallet",
"api-token",
"generate",
"--home=" + tmp_vega_home,
Expand All @@ -536,6 +539,7 @@ def manage_vega_processes(

wallet_args = [
vega_wallet_path,
"wallet",
"service",
"run",
"--network",
Expand Down Expand Up @@ -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"
)
Expand Down
70 changes: 60 additions & 10 deletions vega_sim/tools/load_binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,40 @@
import shutil
import tempfile
import zipfile
from typing import Optional

import requests

import vega_sim

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
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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
)
4 changes: 2 additions & 2 deletions vega_sim/vegahome/genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions vega_sim/wallet/vega_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def _load_token(self, wallet_name: str):
cmd = subprocess.run(
[
self._wallet_path,
"wallet",
"api-token",
"list",
"--home",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -163,6 +165,7 @@ def create_wallet(self, name: str) -> None:
subprocess.run(
[
self._wallet_path,
"wallet",
"create",
"--wallet",
name,
Expand All @@ -182,6 +185,7 @@ def create_wallet(self, name: str) -> None:
cmd = subprocess.run(
[
self._wallet_path,
"wallet",
"api-token",
"generate",
"--home",
Expand Down

0 comments on commit 321b806

Please sign in to comment.