Skip to content

Commit

Permalink
Merge pull request #226 from multiversx/hotfix-testnet-14
Browse files Browse the repository at this point in the history
Fix "mxpy testnet" upon release of Polaris
  • Loading branch information
andreibancioiu authored Feb 14, 2023
2 parents d4ead2a + 749bbbd commit 46f9994
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion multiversx_sdk_cli/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "5.3.1"
__version__ = "5.3.2"
2 changes: 1 addition & 1 deletion multiversx_sdk_cli/testnet/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def default(cls):
config['networking'] = {
'host': '127.0.0.1',
'port_seednode': 9999,
'p2p_id_seednode': '16Uiu2HAkw5SNNtSvH1zJiQ6Gc3WoGNSxiyNueRKe6fuAuh57G3Bk',
'p2p_id_seednode': '16Uiu2HAkx4QqgXXDdHdUWbLu5kxhd3Uo2hqB2FfCxmxH5Sd7bZFk',
'port_proxy': 7950,
'port_first_observer': 21100,
'port_first_observer_rest_api': 10000,
Expand Down
8 changes: 4 additions & 4 deletions multiversx_sdk_cli/testnet/core.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
import logging
from pathlib import Path
import traceback
from pathlib import Path
from typing import Any, Coroutine, List

from multiversx_sdk_cli.testnet.config import TestnetConfiguration
Expand Down Expand Up @@ -106,16 +106,16 @@ async def _read_stream(stream: Any, pid: int):
def _patch_loglevel(loglevel: str) -> str:
loglevel = loglevel or "*:DEBUG"

if "arwen:" not in loglevel:
loglevel += ",arwen:TRACE"
if "vm:" not in loglevel:
loglevel += ",vm:TRACE"
if "process/smartcontract:" not in loglevel:
loglevel += ",process/smartcontract:TRACE"

return loglevel


LOGLINE_GENESIS_THRESHOLD_MARKER = "started committing block"
LOGLINE_AFTER_GENESIS_INTERESTING_MARKERS = ["started committing block", "ERROR", "WARN", "arwen", "smartcontract"]
LOGLINE_AFTER_GENESIS_INTERESTING_MARKERS = ["started committing block", "ERROR", "WARN", "vm", "smartcontract"]
# We ignore SC calls on genesis.
LOGLINE_ON_GENESIS_INTERESTING_MARKERS = ["started committing block", "ERROR", "WARN"]

Expand Down
4 changes: 2 additions & 2 deletions multiversx_sdk_cli/testnet/node_config_toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ def patch_config(data: ConfigDict, testnet_config: TestnetConfiguration):
# Always use the latest VM
virtual_machine: Dict[str, Any] = dict()
virtual_machine['Execution'] = dict()
virtual_machine['Execution']['ArwenVersions'] = [{'StartEpoch': 0, 'Version': '*'}]
virtual_machine['Execution']['WasmVMVersions'] = [{'StartEpoch': 0, 'Version': '*'}]
virtual_machine['Querying'] = dict()
virtual_machine['Querying']['NumConcurrentVMs'] = 1
virtual_machine['Querying']['ArwenVersions'] = [{'StartEpoch': 0, 'Version': '*'}]
virtual_machine['Querying']['WasmVMVersions'] = [{'StartEpoch': 0, 'Version': '*'}]

data['VirtualMachine'].update(virtual_machine)

Expand Down
4 changes: 4 additions & 0 deletions multiversx_sdk_cli/testnet/seednode_p2pKey.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-----BEGIN PRIVATE KEY for 16Uiu2HAkx4QqgXXDdHdUWbLu5kxhd3Uo2hqB2FfCxmxH5Sd7bZFk-----
NTM2Mjk0Zjk2Zjk5YjdlOTUzNWVkOTRmNDAzOGEyOTY2ZGY0ZDkwOTQ4MDU5YTNi
MDM4MjI4NzNjZjBkYjRlMw==
-----END PRIVATE KEY for 16Uiu2HAkx4QqgXXDdHdUWbLu5kxhd3Uo2hqB2FfCxmxH5Sd7bZFk-----
30 changes: 19 additions & 11 deletions multiversx_sdk_cli/testnet/setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import logging
import shutil
from os import path
from pathlib import Path
from typing import Any

import multiversx_sdk_cli.utils as utils
from multiversx_sdk_cli import dependencies, myprocess, workstation
from multiversx_sdk_cli.dependencies.install import install_module
from multiversx_sdk_cli.testnet import (genesis_json, genesis_smart_contracts_json,
node_config_toml, nodes_setup_json, p2p_toml,
wallets)
from multiversx_sdk_cli.testnet import (genesis_json,
genesis_smart_contracts_json,
node_config_toml, nodes_setup_json,
p2p_toml, wallets)
from multiversx_sdk_cli.testnet.config import TestnetConfiguration

logger = logging.getLogger("testnet")
Expand Down Expand Up @@ -64,6 +66,7 @@ def configure(args: Any):
# Seed node
copy_config_to_seednode(testnet_config)
patch_seednode_p2p_config(testnet_config)
copy_seednode_p2p_key(testnet_config)

# Proxy
copy_config_to_proxy(testnet_config)
Expand Down Expand Up @@ -151,6 +154,11 @@ def patch_seednode_p2p_config(testnet_config: TestnetConfiguration):
utils.write_toml_file(seednode_config_file, data)


def copy_seednode_p2p_key(testnet_config: TestnetConfiguration):
p2p_key_path = Path(__file__).parent / "seednode_p2pKey.pem"
shutil.copy(p2p_key_path, testnet_config.seednode_config_folder() / "p2pKey.pem")


def patch_nodes_p2p_config(testnet_config: TestnetConfiguration, nodes_config_folders, port_first):
for index, config_folder in enumerate(nodes_config_folders):
config = config_folder / 'p2p.toml'
Expand Down Expand Up @@ -247,27 +255,27 @@ def build_binaries(testnet_config: TestnetConfiguration):
myprocess.run_process(['go', 'build'], cwd=proxy_folder, env=golang_env)

# Now copy the binaries to the testnet folder
wasm_vm_version = _get_wasm_vm_version(testnet_config)
libwasmer_path = path.join(golang.get_gopath(), f"pkg/mod/github.com/!elrond!network/arwen-wasm-vm@{wasm_vm_version}/wasmer/libwasmer_darwin_amd64.dylib")
wasm_vm_package = _get_wasm_vm_package(testnet_config)
libwasmer_osx_path = Path(golang.get_gopath()) / "pkg" / "mod" / wasm_vm_package / "wasmer" / "libwasmer_darwin_amd64.dylib"

shutil.copy(seednode_folder / "seednode", testnet_config.seednode_folder())
if workstation.get_platform() == "osx":
shutil.copy(libwasmer_path, testnet_config.seednode_folder())
shutil.copy(libwasmer_osx_path, testnet_config.seednode_folder())

for destination in testnet_config.all_nodes_folders():
shutil.copy(node_folder / "node", destination)

if workstation.get_platform() == "osx":
shutil.copy(libwasmer_path, destination)
shutil.copy(libwasmer_osx_path, destination)

shutil.copy(proxy_folder / "proxy", testnet_config.proxy_folder())
if workstation.get_platform() == "osx":
shutil.copy(libwasmer_path, testnet_config.proxy_folder())
shutil.copy(libwasmer_osx_path, testnet_config.proxy_folder())


def _get_wasm_vm_version(testnet_config: TestnetConfiguration):
def _get_wasm_vm_package(testnet_config: TestnetConfiguration) -> str:
go_mod = testnet_config.node_source() / "go.mod"
lines = utils.read_lines(go_mod)
line = next(line for line in lines if "github.com/ElrondNetwork/arwen-wasm-vm" in line)
line = [line for line in lines if "github.com/multiversx/mx-chain-vm-v" in line][-1]
parts = line.split()
return parts[1]
return f"{parts[0]}@{parts[1]}"
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ validators = 1
[networking]
host = "127.0.0.1"
port_seednode = 9999
p2p_id_seednode = "16Uiu2HAkw5SNNtSvH1zJiQ6Gc3WoGNSxiyNueRKe6fuAuh57G3Bk"
p2p_id_seednode = "16Uiu2HAkx4QqgXXDdHdUWbLu5kxhd3Uo2hqB2FfCxmxH5Sd7bZFk"
port_proxy = 7950
port_first_observer = 21100
port_first_observer_rest_api = 10000
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import setuptools

VERSION = "5.3.1"
VERSION = "5.3.2"

try:
with open('./multiversx_sdk_cli/_version.py', 'wt') as versionfile:
Expand Down

0 comments on commit 46f9994

Please sign in to comment.