Skip to content

Conversation

@andreibancioiu
Copy link
Contributor

@andreibancioiu andreibancioiu commented Nov 24, 2025

Here, we attempt to make the localnet compatible with the Node pre & post-Supernova. This should not be a breaking change.

In Supernova, EpochStartConfig.RoundsPerEpoch and EpochStartConfig.MinRoundsBetweenEpochs are dropped. In turn, the parameters are moved to ChainParametersByEpoch.

We introduce two new (optional) localnet parameters: rounds_per_epoch_in_supernova and round_duration_milliseconds_in_supernova. They are used to patch Node's config.toml as depicted below:

ChainParametersByEpoch = [
    { EnableEpoch = 0, RoundDuration = <round_duration_milliseconds>, RoundsPerEpoch = <rounds_per_epoch>, ... },
    { EnableEpoch = 1, RoundDuration = <round_duration_milliseconds>, RoundsPerEpoch = <rounds_per_epoch>, ... },
    { EnableEpoch = 2, RoundDuration = <round_duration_milliseconds_in_supernova>, RoundsPerEpoch = <rounds_per_epoch_in_supernova>, ... },
]

In the future, some time after the release of Supernova, we should drop this cumbersome (but necessary at this moment) logic from mxpy.

References:


def patch_enable_epochs(data: ConfigDict, config: ConfigRoot):
enable_epochs = data["EnableEpochs"]
enable_epochs["SCDeployEnableEpoch"] = 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andreibancioiu andreibancioiu self-assigned this Nov 24, 2025

return {
"startTime": config.genesis_time(),
"roundDuration": config.general.round_duration_milliseconds,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

genesis_smart_contracts_json.patch(data, config)
utils.write_json_file(genesis_smart_contracts_file, data)

node_config_data = utils.read_toml_file(node_config_file)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trivial refactoring, so that we can read & pass supernova_activation_epoch to patch_config more easily.

Comment on lines +48 to +49
item["RoundDuration"] = config.general.round_duration_milliseconds_in_supernova
item["RoundsPerEpoch"] = config.general.rounds_per_epoch_in_supernova
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once Supernova is active, we use the new localnet configuration entries: round_duration_milliseconds_in_supernova and rounds_per_epoch_in_supernova.

chain_parameters_by_epoch = data["GeneralSettings"].get("ChainParametersByEpoch", [])

if chain_parameters_by_epoch:
# For convenience, keep a single entry ...
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tricky. Changed to use the whole collection of ChainParametersByEpoch entries.



def patch_config(data: ConfigDict, config: ConfigRoot):
def patch_config(data: ConfigDict, config: ConfigRoot, supernova_activation_epoch: Optional[int] = None):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new argument is used when iterating over ChainParametersByEpoch.

@andreibancioiu andreibancioiu marked this pull request as ready for review November 24, 2025 15:52
popenta
popenta previously approved these changes Nov 25, 2025
mradian1
mradian1 previously approved these changes Nov 25, 2025
@andreibancioiu andreibancioiu dismissed stale reviews from mradian1 and popenta via a57fa49 November 25, 2025 15:13
)


def patch_enable_rounds(data: ConfigDict, config: ConfigRoot, enable_epochs_config: ConfigDict):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# See https://github.com/multiversx/mx-chain-go/blob/master/cmd/node/config/config.toml.
ROUNDS_PER_EPOCH_TO_MIN_ROUNDS_BETWEEN_EPOCHS_RATIO = 4
NUM_ROUNDS_BETWEEN_SUPERNOVA_ACTIVATION_EPOCH_AND_ACTIVATION_ROUND = 20
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enable_epoch = item["StartEpoch"]

if enable_epoch == supernova_activation_epoch:
item["StartRound"] = _compute_supernova_activation_round(config, supernova_activation_epoch)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for the Supernova upgrade to the localnet configuration, ensuring backward compatibility with pre-Supernova nodes. The implementation introduces optional localnet parameters for Supernova-specific epoch and round configurations while maintaining support for the legacy configuration system.

Key changes:

  • Added two new optional parameters (rounds_per_epoch_in_supernova and round_duration_milliseconds_in_supernova) to configure epoch timing in Supernova
  • Modified node configuration patching to conditionally apply Supernova settings based on SupernovaEnableEpoch detection
  • Removed redundant fields from nodesSetup.json that are now handled by ChainParametersByEpoch

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
pyproject.toml Version bump to 11.3.0
multiversx_sdk_cli/localnet/config_general.py Added two new parameters for Supernova epoch/round configuration and updated override logic
multiversx_sdk_cli/localnet/config_default.py Set default values for Supernova parameters (300 rounds per epoch, 2000ms round duration)
multiversx_sdk_cli/localnet/constants.py Added constants for epoch/round ratio calculation and Supernova activation round offset
multiversx_sdk_cli/localnet/node_config_toml.py Implemented conditional logic to apply Supernova configuration, added enable rounds patching, and helper function for activation round calculation
multiversx_sdk_cli/localnet/step_config.py Refactored config patching to batch file reads/writes and added enable_rounds_config handling
multiversx_sdk_cli/localnet/nodes_setup_json.py Removed fields now managed by ChainParametersByEpoch (roundDuration, consensusGroupSize, etc.)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

round_duration_milliseconds=6000,
# For the purpose of the localnet, we'll have 3x for Supernova (by default).
rounds_per_epoch_in_supernova=300,
round_duration_milliseconds_in_supernova=2000,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we have the actual duration of the round (600ms)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question!

I've chosen 2 seconds by default in order to demand less resources from the host machine (development machine).

All good?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me. We should at least document that the localnet starts with a roundtime of 2s and we should show people where to change in case they want to run a 600ms round, replicating mainnet config.

@andreibancioiu andreibancioiu merged commit 4cdaeff into main Dec 2, 2025
12 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants