Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/multiversx/mx-chain-go in…
Browse files Browse the repository at this point in the history
…to rc/v1.7.next1

# Conflicts:
#	common/enablers/enableEpochsHandler_test.go
#	config/tomlConfig_test.go
#	integrationTests/chainSimulator/staking/stake/simpleStake_test.go
#	integrationTests/chainSimulator/staking/stake/stakeAndUnStake_test.go
#	integrationTests/chainSimulator/staking/stakingProvider/delegation_test.go
  • Loading branch information
sstanculeanu committed May 20, 2024
2 parents ad05efd + f7efd0f commit c920001
Show file tree
Hide file tree
Showing 27 changed files with 510 additions and 206 deletions.
4 changes: 4 additions & 0 deletions cmd/node/config/enableEpochs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@
# StakingV4Step3EnableEpoch represents the epoch in which selected nodes from auction will be distributed to waiting list
StakingV4Step3EnableEpoch = 3

# CleanupAuctionOnLowWaitingListEnableEpoch represents the epoch when duplicated data cleanup from auction list is enabled in the condition of a low waiting list
# Should have the same value as StakingV4Step1EnableEpoch if the low waiting list has not happened, otherwise should have a greater value
CleanupAuctionOnLowWaitingListEnableEpoch = 1

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

Expand Down
1 change: 1 addition & 0 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,7 @@ const (
StakingV4Step1Flag core.EnableEpochFlag = "StakingV4Step1Flag"
StakingV4Step2Flag core.EnableEpochFlag = "StakingV4Step2Flag"
StakingV4Step3Flag core.EnableEpochFlag = "StakingV4Step3Flag"
CleanupAuctionOnLowWaitingListFlag core.EnableEpochFlag = "CleanupAuctionOnLowWaitingListFlag"
StakingV4StartedFlag core.EnableEpochFlag = "StakingV4StartedFlag"
AlwaysMergeContextsInEEIFlag core.EnableEpochFlag = "AlwaysMergeContextsInEEIFlag"
DynamicESDTFlag core.EnableEpochFlag = "DynamicEsdtFlag"
Expand Down
9 changes: 8 additions & 1 deletion common/enablers/enableEpochsHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (

"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/check"
logger "github.com/multiversx/mx-chain-logger-go"

"github.com/multiversx/mx-chain-go/common"
"github.com/multiversx/mx-chain-go/config"
"github.com/multiversx/mx-chain-go/process"
logger "github.com/multiversx/mx-chain-logger-go"
)

var log = logger.GetOrCreate("common/enablers")
Expand Down Expand Up @@ -713,6 +714,12 @@ func (handler *enableEpochsHandler) createAllFlagsMap() {
},
activationEpoch: handler.enableEpochsConfig.StakingV4Step3EnableEpoch,
},
common.CleanupAuctionOnLowWaitingListFlag: {
isActiveInEpoch: func(epoch uint32) bool {
return epoch >= handler.enableEpochsConfig.CleanupAuctionOnLowWaitingListEnableEpoch
},
activationEpoch: handler.enableEpochsConfig.CleanupAuctionOnLowWaitingListEnableEpoch,
},
common.StakingV4StartedFlag: {
isActiveInEpoch: func(epoch uint32) bool {
return epoch >= handler.enableEpochsConfig.StakingV4Step1EnableEpoch
Expand Down
15 changes: 9 additions & 6 deletions common/enablers/enableEpochsHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"testing"

"github.com/multiversx/mx-chain-core-go/core/check"
vmcommon "github.com/multiversx/mx-chain-vm-common-go"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/multiversx/mx-chain-go/common"
"github.com/multiversx/mx-chain-go/config"
"github.com/multiversx/mx-chain-go/process"
"github.com/multiversx/mx-chain-go/testscommon/epochNotifier"
vmcommon "github.com/multiversx/mx-chain-vm-common-go"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func createEnableEpochsConfig() config.EnableEpochs {
Expand Down Expand Up @@ -114,9 +115,10 @@ func createEnableEpochsConfig() config.EnableEpochs {
StakingV4Step2EnableEpoch: 98,
StakingV4Step3EnableEpoch: 99,
AlwaysMergeContextsInEEIEnableEpoch: 100,
DynamicESDTEnableEpoch: 101,
EGLDInMultiTransferEnableEpoch: 102,
CryptoOpcodesV2EnableEpoch: 103,
CleanupAuctionOnLowWaitingListEnableEpoch: 101,
DynamicESDTEnableEpoch: 102,
EGLDInMultiTransferEnableEpoch: 103,
CryptoOpcodesV2EnableEpoch: 104,
}
}

Expand Down Expand Up @@ -430,6 +432,7 @@ func TestEnableEpochsHandler_GetActivationEpoch(t *testing.T) {
require.Equal(t, cfg.StakingV4Step1EnableEpoch, handler.GetActivationEpoch(common.StakingV4Step1Flag))
require.Equal(t, cfg.StakingV4Step2EnableEpoch, handler.GetActivationEpoch(common.StakingV4Step2Flag))
require.Equal(t, cfg.StakingV4Step3EnableEpoch, handler.GetActivationEpoch(common.StakingV4Step3Flag))
require.Equal(t, cfg.CleanupAuctionOnLowWaitingListEnableEpoch, handler.GetActivationEpoch(common.CleanupAuctionOnLowWaitingListFlag))
require.Equal(t, cfg.StakingV4Step1EnableEpoch, handler.GetActivationEpoch(common.StakingV4StartedFlag))
require.Equal(t, cfg.AlwaysMergeContextsInEEIEnableEpoch, handler.GetActivationEpoch(common.AlwaysMergeContextsInEEIFlag))
require.Equal(t, cfg.DynamicESDTEnableEpoch, handler.GetActivationEpoch(common.DynamicESDTFlag))
Expand Down
1 change: 1 addition & 0 deletions config/epochConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ type EnableEpochs struct {
StakingV4Step1EnableEpoch uint32
StakingV4Step2EnableEpoch uint32
StakingV4Step3EnableEpoch uint32
CleanupAuctionOnLowWaitingListEnableEpoch uint32
AlwaysMergeContextsInEEIEnableEpoch uint32
DynamicESDTEnableEpoch uint32
EGLDInMultiTransferEnableEpoch uint32
Expand Down
19 changes: 12 additions & 7 deletions config/tomlConfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"strconv"
"testing"

p2pConfig "github.com/multiversx/mx-chain-go/p2p/config"
"github.com/pelletier/go-toml"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

p2pConfig "github.com/multiversx/mx-chain-go/p2p/config"
)

func TestTomlParser(t *testing.T) {
Expand Down Expand Up @@ -859,14 +860,17 @@ func TestEnableEpochConfig(t *testing.T) {
# AlwaysMergeContextsInEEIEnableEpoch represents the epoch in which the EEI will always merge the contexts
AlwaysMergeContextsInEEIEnableEpoch = 94
# CleanupAuctionOnLowWaitingListEnableEpoch represents the epoch when the cleanup auction on low waiting list is enabled
CleanupAuctionOnLowWaitingListEnableEpoch = 95
# DynamicESDTEnableEpoch represents the epoch when dynamic NFT feature is enabled
DynamicESDTEnableEpoch = 95
DynamicESDTEnableEpoch = 96
# EGLDInMultiTransferEnableEpoch represents the epoch when EGLD in MultiTransfer is enabled
EGLDInMultiTransferEnableEpoch = 96
EGLDInMultiTransferEnableEpoch = 97
# CryptoOpcodesV2EnableEpoch represents the epoch when BLSMultiSig, Secp256r1 and other opcodes are enabled
CryptoOpcodesV2EnableEpoch = 97
CryptoOpcodesV2EnableEpoch = 98
# MaxNodesChangeEnableEpoch holds configuration for changing the maximum number of nodes and the enabling epoch
MaxNodesChangeEnableEpoch = [
Expand Down Expand Up @@ -980,9 +984,10 @@ func TestEnableEpochConfig(t *testing.T) {
MigrateDataTrieEnableEpoch: 92,
CurrentRandomnessOnSortingEnableEpoch: 93,
AlwaysMergeContextsInEEIEnableEpoch: 94,
DynamicESDTEnableEpoch: 95,
EGLDInMultiTransferEnableEpoch: 96,
CryptoOpcodesV2EnableEpoch: 97,
CleanupAuctionOnLowWaitingListEnableEpoch: 95,
DynamicESDTEnableEpoch: 96,
EGLDInMultiTransferEnableEpoch: 97,
CryptoOpcodesV2EnableEpoch: 98,
MaxNodesChangeEnableEpoch: []MaxNodesChangeConfig{
{
EpochEnable: 44,
Expand Down
5 changes: 5 additions & 0 deletions epochStart/bootstrap/disabled/disabledNodesCoordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ func (n *nodesCoordinator) GetAllShuffledOutValidatorsPublicKeys(_ uint32) (map[
return nil, nil
}

// GetShuffledOutToAuctionValidatorsPublicKeys -
func (n *nodesCoordinator) GetShuffledOutToAuctionValidatorsPublicKeys(_ uint32) (map[uint32][][]byte, error) {
return nil, nil
}

// GetConsensusValidatorsPublicKeys -
func (n *nodesCoordinator) GetConsensusValidatorsPublicKeys(_ []byte, _ uint64, _ uint32, _ uint32) ([]string, error) {
return nil, nil
Expand Down
26 changes: 13 additions & 13 deletions integrationTests/chainSimulator/staking/stake/simpleStake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import (
"testing"
"time"

"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/data/transaction"
"github.com/stretchr/testify/require"

"github.com/multiversx/mx-chain-go/common"
"github.com/multiversx/mx-chain-go/config"
"github.com/multiversx/mx-chain-go/integrationTests/chainSimulator/staking"
Expand All @@ -15,10 +19,6 @@ import (
"github.com/multiversx/mx-chain-go/node/chainSimulator/configs"
"github.com/multiversx/mx-chain-go/node/chainSimulator/process"
"github.com/multiversx/mx-chain-go/vm"

"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/data/transaction"
"github.com/stretchr/testify/require"
)

// Test scenarios
Expand Down Expand Up @@ -266,30 +266,30 @@ func TestChainSimulator_StakingV4Step2APICalls(t *testing.T) {
err = cs.GenerateBlocks(2)
require.Nil(t, err)

numQualified, numUnQualified := getNumQualifiedAndUnqualified(t, metachainNode)
require.Equal(t, 8, numQualified)
require.Equal(t, 1, numUnQualified)
qualified, unQualified := getQualifiedAndUnqualifiedNodes(t, metachainNode)
require.Equal(t, 8, len(qualified))
require.Equal(t, 1, len(unQualified))
}
}

func getNumQualifiedAndUnqualified(t *testing.T, metachainNode process.NodeHandler) (int, int) {
func getQualifiedAndUnqualifiedNodes(t *testing.T, metachainNode process.NodeHandler) ([]string, []string) {
err := metachainNode.GetProcessComponents().ValidatorsProvider().ForceUpdate()
require.Nil(t, err)
auctionList, err := metachainNode.GetProcessComponents().ValidatorsProvider().GetAuctionList()
require.Nil(t, err)

numQualified := 0
numUnQualified := 0
qualified := make([]string, 0)
unQualified := make([]string, 0)

for _, auctionOwnerData := range auctionList {
for _, auctionNode := range auctionOwnerData.Nodes {
if auctionNode.Qualified {
numQualified++
qualified = append(qualified, auctionNode.BlsKey)
} else {
numUnQualified++
unQualified = append(unQualified, auctionNode.BlsKey)
}
}
}

return numQualified, numUnQualified
return qualified, unQualified
}
Loading

0 comments on commit c920001

Please sign in to comment.