-
Notifications
You must be signed in to change notification settings - Fork 36
Localnet: add support for Supernova #560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
||
| def patch_enable_epochs(data: ConfigDict, config: ConfigRoot): | ||
| enable_epochs = data["EnableEpochs"] | ||
| enable_epochs["SCDeployEnableEpoch"] = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| return { | ||
| "startTime": config.genesis_time(), | ||
| "roundDuration": config.general.round_duration_milliseconds, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped some time ago.
https://github.com/multiversx/mx-chain-go/blob/master/cmd/node/config/nodesSetup.json
| 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) |
There was a problem hiding this comment.
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.
| item["RoundDuration"] = config.general.round_duration_milliseconds_in_supernova | ||
| item["RoundsPerEpoch"] = config.general.rounds_per_epoch_in_supernova |
There was a problem hiding this comment.
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 ... |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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.
a57fa49
| ) | ||
|
|
||
|
|
||
| def patch_enable_rounds(data: ConfigDict, config: ConfigRoot, enable_epochs_config: ConfigDict): |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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_supernovaandround_duration_milliseconds_in_supernova) to configure epoch timing in Supernova - Modified node configuration patching to conditionally apply Supernova settings based on
SupernovaEnableEpochdetection - Removed redundant fields from
nodesSetup.jsonthat are now handled byChainParametersByEpoch
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, |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Here, we attempt to make the localnet compatible with the Node pre & post-Supernova. This should not be a breaking change.
In Supernova,
EpochStartConfig.RoundsPerEpochandEpochStartConfig.MinRoundsBetweenEpochsare dropped. In turn, the parameters are moved toChainParametersByEpoch.We introduce two new (optional) localnet parameters:
rounds_per_epoch_in_supernovaandround_duration_milliseconds_in_supernova. They are used to patch Node'sconfig.tomlas depicted below:In the future, some time after the release of Supernova, we should drop this cumbersome (but necessary at this moment) logic from mxpy.
References: