Skip to content

Commit

Permalink
Merge pull request #6040 from multiversx/stake-unstake-unbond-nodes-s…
Browse files Browse the repository at this point in the history
…cenario

Added stake-unstake-unbond scenario + EEI fix
  • Loading branch information
iulianpascalau authored Mar 15, 2024
2 parents 515aa50 + dc0da21 commit 9361efa
Show file tree
Hide file tree
Showing 8 changed files with 382 additions and 11 deletions.
15 changes: 9 additions & 6 deletions cmd/node/config/enableEpochs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,6 @@
# CurrentRandomnessOnSortingEnableEpoch represents the epoch when the current randomness on sorting is enabled
CurrentRandomnessOnSortingEnableEpoch = 4

# BLSMultiSignerEnableEpoch represents the activation epoch for different types of BLS multi-signers
BLSMultiSignerEnableEpoch = [
{ EnableEpoch = 0, Type = "no-KOSK" },
{ EnableEpoch = 1, Type = "KOSK" }
]

# StakeLimitsEnableEpoch represents the epoch when stake limits on validators are enabled
StakeLimitsEnableEpoch = 5

Expand All @@ -307,6 +301,15 @@
# StakingV4Step3EnableEpoch represents the epoch in which selected nodes from auction will be distributed to waiting list
StakingV4Step3EnableEpoch = 6

# AlwaysMergeContextsInEEIEnableEpoch represents the epoch in which the EEI will always merge the contexts
AlwaysMergeContextsInEEIEnableEpoch = 4

# BLSMultiSignerEnableEpoch represents the activation epoch for different types of BLS multi-signers
BLSMultiSignerEnableEpoch = [
{ EnableEpoch = 0, Type = "no-KOSK" },
{ EnableEpoch = 1, Type = "KOSK" }
]

# MaxNodesChangeEnableEpoch holds configuration for changing the maximum number of nodes and the enabling epoch
MaxNodesChangeEnableEpoch = [
{ EpochEnable = 0, MaxNumNodes = 48, NodesToShufflePerShard = 4 }, # 4 shuffled out keys / shard will not be reached normally
Expand Down
1 change: 1 addition & 0 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -1010,5 +1010,6 @@ const (
StakingV4Step3Flag core.EnableEpochFlag = "StakingV4Step3Flag"
StakingQueueFlag core.EnableEpochFlag = "StakingQueueFlag"
StakingV4StartedFlag core.EnableEpochFlag = "StakingV4StartedFlag"
AlwaysMergeContextsInEEIFlag core.EnableEpochFlag = "AlwaysMergeContextsInEEIFlag"
// all new flags must be added to createAllFlagsMap method, as part of enableEpochsHandler allFlagsDefined
)
6 changes: 6 additions & 0 deletions common/enablers/enableEpochsHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,12 @@ func (handler *enableEpochsHandler) createAllFlagsMap() {
},
activationEpoch: handler.enableEpochsConfig.StakingV4Step1EnableEpoch,
},
common.AlwaysMergeContextsInEEIFlag: {
isActiveInEpoch: func(epoch uint32) bool {
return epoch >= handler.enableEpochsConfig.AlwaysMergeContextsInEEIEnableEpoch
},
activationEpoch: handler.enableEpochsConfig.AlwaysMergeContextsInEEIEnableEpoch,
},
}
}

Expand Down
3 changes: 3 additions & 0 deletions common/enablers/enableEpochsHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func createEnableEpochsConfig() config.EnableEpochs {
StakingV4Step1EnableEpoch: 96,
StakingV4Step2EnableEpoch: 97,
StakingV4Step3EnableEpoch: 98,
AlwaysMergeContextsInEEIEnableEpoch: 99,
}
}

Expand Down Expand Up @@ -319,6 +320,7 @@ func TestEnableEpochsHandler_IsFlagEnabled(t *testing.T) {
require.True(t, handler.IsFlagEnabled(common.StakingV4Step3Flag))
require.False(t, handler.IsFlagEnabled(common.StakingQueueFlag))
require.True(t, handler.IsFlagEnabled(common.StakingV4StartedFlag))
require.True(t, handler.IsFlagEnabled(common.AlwaysMergeContextsInEEIFlag))
}

func TestEnableEpochsHandler_GetActivationEpoch(t *testing.T) {
Expand Down Expand Up @@ -434,6 +436,7 @@ func TestEnableEpochsHandler_GetActivationEpoch(t *testing.T) {
require.Equal(t, cfg.StakingV4Step3EnableEpoch, handler.GetActivationEpoch(common.StakingV4Step3Flag))
require.Equal(t, cfg.StakingV4Step1EnableEpoch, handler.GetActivationEpoch(common.StakingQueueFlag))
require.Equal(t, cfg.StakingV4Step1EnableEpoch, handler.GetActivationEpoch(common.StakingV4StartedFlag))
require.Equal(t, cfg.AlwaysMergeContextsInEEIEnableEpoch, handler.GetActivationEpoch(common.AlwaysMergeContextsInEEIFlag))
}

func TestEnableEpochsHandler_IsInterfaceNil(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion config/epochConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@ type EnableEpochs struct {
ChangeOwnerAddressCrossShardThroughSCEnableEpoch uint32
FixGasRemainingForSaveKeyValueBuiltinFunctionEnableEpoch uint32
CurrentRandomnessOnSortingEnableEpoch uint32
BLSMultiSignerEnableEpoch []MultiSignerConfig
StakeLimitsEnableEpoch uint32
StakingV4Step1EnableEpoch uint32
StakingV4Step2EnableEpoch uint32
StakingV4Step3EnableEpoch uint32
AlwaysMergeContextsInEEIEnableEpoch uint32
BLSMultiSignerEnableEpoch []MultiSignerConfig
}

// GasScheduleByEpochs represents a gas schedule toml entry that will be applied from the provided epoch
Expand Down
4 changes: 4 additions & 0 deletions config/tomlConfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,9 @@ func TestEnableEpochConfig(t *testing.T) {
# CurrentRandomnessOnSortingEnableEpoch represents the epoch when the current randomness on sorting is enabled
CurrentRandomnessOnSortingEnableEpoch = 93
# AlwaysMergeContextsInEEIEnableEpoch represents the epoch in which the EEI will always merge the contexts
AlwaysMergeContextsInEEIEnableEpoch = 94
# MaxNodesChangeEnableEpoch holds configuration for changing the maximum number of nodes and the enabling epoch
MaxNodesChangeEnableEpoch = [
{ EpochEnable = 44, MaxNumNodes = 2169, NodesToShufflePerShard = 80 },
Expand Down Expand Up @@ -951,6 +954,7 @@ func TestEnableEpochConfig(t *testing.T) {
FixGasRemainingForSaveKeyValueBuiltinFunctionEnableEpoch: 91,
MigrateDataTrieEnableEpoch: 92,
CurrentRandomnessOnSortingEnableEpoch: 93,
AlwaysMergeContextsInEEIEnableEpoch: 94,
MaxNodesChangeEnableEpoch: []MaxNodesChangeConfig{
{
EpochEnable: 44,
Expand Down
Loading

0 comments on commit 9361efa

Please sign in to comment.