Skip to content

Commit a57fa49

Browse files
Patch "enable rounds", as well.
1 parent b765d63 commit a57fa49

3 files changed

Lines changed: 29 additions & 5 deletions

File tree

multiversx_sdk_cli/localnet/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99

1010
# See https://github.com/multiversx/mx-chain-go/blob/master/cmd/node/config/config.toml.
1111
ROUNDS_PER_EPOCH_TO_MIN_ROUNDS_BETWEEN_EPOCHS_RATIO = 4
12+
NUM_ROUNDS_BETWEEN_SUPERNOVA_ACTIVATION_EPOCH_AND_ACTIVATION_ROUND = 20

multiversx_sdk_cli/localnet/node_config_toml.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
from typing import Any, Dict, Optional
22

33
from multiversx_sdk_cli.localnet.config_root import ConfigRoot
4-
from multiversx_sdk_cli.localnet.constants import ROUNDS_PER_EPOCH_TO_MIN_ROUNDS_BETWEEN_EPOCHS_RATIO
4+
from multiversx_sdk_cli.localnet.constants import (
5+
NUM_ROUNDS_BETWEEN_SUPERNOVA_ACTIVATION_EPOCH_AND_ACTIVATION_ROUND,
6+
ROUNDS_PER_EPOCH_TO_MIN_ROUNDS_BETWEEN_EPOCHS_RATIO,
7+
)
58
from multiversx_sdk_cli.localnet.nodes_setup_json import CHAIN_ID
69

710
ConfigDict = Dict[str, Any]
811

912

10-
def patch_config(data: ConfigDict, config: ConfigRoot, supernova_activation_epoch: Optional[int] = None):
13+
def patch_config(data: ConfigDict, config: ConfigRoot, enable_epochs_config: ConfigDict):
14+
supernova_activation_epoch = enable_epochs_config["EnableEpochs"].get("SupernovaEnableEpoch", None)
15+
1116
data["GeneralSettings"]["ChainID"] = CHAIN_ID
1217

1318
# "--operation-mode=historical-balances" is not available for nodes,
@@ -94,3 +99,19 @@ def patch_enable_epochs(data: ConfigDict, config: ConfigRoot):
9499
last_entry["MaxNumNodes"] = (
95100
penultimate_entry["MaxNumNodes"] - (config.shards.num_shards + 1) * penultimate_entry["NodesToShufflePerShard"]
96101
)
102+
103+
104+
def patch_enable_rounds(data: ConfigDict, config: ConfigRoot, enable_epochs_config: ConfigDict):
105+
supernova_activation_epoch = enable_epochs_config["EnableEpochs"].get("SupernovaEnableEpoch", None)
106+
107+
activations = data["RoundActivations"]
108+
supernova_entry = activations.get("SupernovaEnableRound")
109+
110+
if supernova_entry:
111+
# Epochs are zero-indexed.
112+
supernova_computed_activation_round = (
113+
config.general.rounds_per_epoch * supernova_activation_epoch
114+
+ NUM_ROUNDS_BETWEEN_SUPERNOVA_ACTIVATION_EPOCH_AND_ACTIVATION_ROUND
115+
)
116+
117+
supernova_entry["Round"] = str(supernova_computed_activation_round)

multiversx_sdk_cli/localnet/step_config.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,23 +103,25 @@ def patch_node_config(config: ConfigRoot):
103103
node_config_file = node_config / "config.toml"
104104
api_config_file = node_config / "api.toml"
105105
enable_epochs_config_file = node_config / "enableEpochs.toml"
106+
enable_rounds_config_file = node_config / "enableRounds.toml"
106107
genesis_smart_contracts_file = node_config / "genesisSmartContracts.json"
107108

108109
node_config_data = utils.read_toml_file(node_config_file)
109110
api_config_data = utils.read_toml_file(api_config_file)
110111
enable_epochs_config_data = utils.read_toml_file(enable_epochs_config_file)
112+
enable_rounds_config_data = utils.read_toml_file(enable_rounds_config_file)
111113
genesis_smart_contracts_data = utils.read_json_file(genesis_smart_contracts_file)
112114

113-
supernova_activation_epoch = enable_epochs_config_data["EnableEpochs"].get("SupernovaEnableEpoch", None)
114-
115-
node_config_toml.patch_config(node_config_data, config, supernova_activation_epoch)
115+
node_config_toml.patch_config(node_config_data, config, enable_epochs_config_data)
116116
node_config_toml.patch_api(api_config_data, config)
117117
node_config_toml.patch_enable_epochs(enable_epochs_config_data, config)
118+
node_config_toml.patch_enable_rounds(enable_rounds_config_data, config, enable_epochs_config_data)
118119
genesis_smart_contracts_json.patch(genesis_smart_contracts_data, config)
119120

120121
utils.write_toml_file(node_config_file, node_config_data)
121122
utils.write_toml_file(api_config_file, api_config_data)
122123
utils.write_toml_file(enable_epochs_config_file, enable_epochs_config_data)
124+
utils.write_toml_file(enable_rounds_config_file, enable_rounds_config_data)
123125
utils.write_json_file(genesis_smart_contracts_file, genesis_smart_contracts_data)
124126

125127

0 commit comments

Comments
 (0)