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
40 changes: 38 additions & 2 deletions multiversx_sdk_cli/localnet/node_config_toml.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict
from typing import Any, Dict, Optional

from multiversx_sdk_cli.localnet.config_root import ConfigRoot
from multiversx_sdk_cli.localnet.constants import (
Expand All @@ -10,7 +10,16 @@
ConfigDict = Dict[str, Any]


def patch_config(data: ConfigDict, config: ConfigRoot, enable_epochs_config: ConfigDict):
def patch_config(
data: ConfigDict,
config: ConfigRoot,
enable_epochs_config: ConfigDict,
enable_rounds_config: ConfigDict,
):
"""
Note: "enable_rounds_config" must be the original (not yet patched) "enableRounds.toml",
so that we can detect the default (upstream) Supernova activation round.
"""
supernova_activation_epoch = enable_epochs_config["EnableEpochs"].get("SupernovaEnableEpoch", None)

data["GeneralSettings"]["ChainID"] = CHAIN_ID
Expand Down Expand Up @@ -77,6 +86,26 @@ def patch_config(data: ConfigDict, config: ConfigRoot, enable_epochs_config: Con
if enable_epoch == supernova_activation_epoch:
item["StartRound"] = _compute_supernova_activation_round(config, supernova_activation_epoch)

# Adjust the "*ByRound" configs: entries defined (upstream) at the default Supernova activation round
# must be moved to the (localnet-specific) computed Supernova activation round.
# Otherwise, the node fails with "supernova activation configs mismatch".
default_supernova_activation_round = _get_supernova_activation_round(enable_rounds_config)

if supernova_activation_epoch is not None and default_supernova_activation_round is not None:
supernova_activation_round = _compute_supernova_activation_round(config, supernova_activation_epoch)

configs_by_round = [
(data["GeneralSettings"].get("ProcessConfigsByRound", []), "EnableRound"),
(data["GeneralSettings"].get("EpochStartConfigsByRound", []), "EnableRound"),
(data["GeneralSettings"].get("ConsensusConfigsByRound", []), "EnableRound"),
(data.get("Antiflood", {}).get("ConfigsByRound", []), "Round"),
]

for items, round_key in configs_by_round:
for item in items:
if int(item.get(round_key, 0)) == default_supernova_activation_round:
item[round_key] = supernova_activation_round


def patch_api(data: ConfigDict, config: ConfigRoot):
routes = data["APIPackages"]["transaction"]["Routes"]
Expand Down Expand Up @@ -121,6 +150,13 @@ def patch_enable_rounds(data: ConfigDict, config: ConfigRoot, enable_epochs_conf
supernova_entry["Round"] = str(supernova_computed_activation_round)


def _get_supernova_activation_round(enable_rounds_config: ConfigDict) -> Optional[int]:
supernova_entry = enable_rounds_config.get("RoundActivations", {}).get("SupernovaEnableRound")
if not supernova_entry:
return None
return int(supernova_entry["Round"])


def _compute_supernova_activation_round(config: ConfigRoot, supernova_activation_epoch: int) -> int:
# Epochs are zero-indexed.
return (
Expand Down
2 changes: 1 addition & 1 deletion multiversx_sdk_cli/localnet/step_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def patch_node_config(config: ConfigRoot):
enable_rounds_config_data = utils.read_toml_file(enable_rounds_config_file)
genesis_smart_contracts_data = utils.read_json_file(genesis_smart_contracts_file)

node_config_toml.patch_config(node_config_data, config, enable_epochs_config_data)
node_config_toml.patch_config(node_config_data, config, enable_epochs_config_data, enable_rounds_config_data)
node_config_toml.patch_api(api_config_data, config)
node_config_toml.patch_enable_epochs(enable_epochs_config_data, config)
node_config_toml.patch_enable_rounds(enable_rounds_config_data, config, enable_epochs_config_data)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "multiversx-sdk-cli"
version = "12.0.0"
version = "12.0.1"
authors = [
{ name="MultiversX" },
]
Expand Down
Loading