|
1 | 1 | from typing import Any, Dict, Optional |
2 | 2 |
|
3 | 3 | 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 | +) |
5 | 8 | from multiversx_sdk_cli.localnet.nodes_setup_json import CHAIN_ID |
6 | 9 |
|
7 | 10 | ConfigDict = Dict[str, Any] |
8 | 11 |
|
9 | 12 |
|
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 | + |
11 | 16 | data["GeneralSettings"]["ChainID"] = CHAIN_ID |
12 | 17 |
|
13 | 18 | # "--operation-mode=historical-balances" is not available for nodes, |
@@ -94,3 +99,19 @@ def patch_enable_epochs(data: ConfigDict, config: ConfigRoot): |
94 | 99 | last_entry["MaxNumNodes"] = ( |
95 | 100 | penultimate_entry["MaxNumNodes"] - (config.shards.num_shards + 1) * penultimate_entry["NodesToShufflePerShard"] |
96 | 101 | ) |
| 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) |
0 commit comments