diff --git a/cmd/node/config/enableEpochs.toml b/cmd/node/config/enableEpochs.toml index 539aaa4fcdc..e5b6efe99f3 100644 --- a/cmd/node/config/enableEpochs.toml +++ b/cmd/node/config/enableEpochs.toml @@ -257,6 +257,9 @@ # AutoBalanceDataTriesEnableEpoch represents the epoch when the data tries are automatically balanced by inserting at the hashed key instead of the normal key AutoBalanceDataTriesEnableEpoch = 1 + # MigrateDataTrieEnableEpoch represents the epoch when the data tries migration is enabled + MigrateDataTrieEnableEpoch = 999999 + # KeepExecOrderOnCreatedSCRsEnableEpoch represents the epoch when the execution order of created SCRs is ensured KeepExecOrderOnCreatedSCRsEnableEpoch = 1 diff --git a/common/enablers/enableEpochsHandler.go b/common/enablers/enableEpochsHandler.go index 41e4d45e033..8e52fe54adb 100644 --- a/common/enablers/enableEpochsHandler.go +++ b/common/enablers/enableEpochsHandler.go @@ -133,6 +133,7 @@ func (handler *enableEpochsHandler) EpochConfirmed(epoch uint32, _ uint64) { handler.setFlagValue(epoch >= handler.enableEpochsConfig.NFTStopCreateEnableEpoch, handler.nftStopCreateFlag, "nftStopCreateFlag", epoch, handler.enableEpochsConfig.NFTStopCreateEnableEpoch) handler.setFlagValue(epoch >= handler.enableEpochsConfig.ChangeOwnerAddressCrossShardThroughSCEnableEpoch, handler.changeOwnerAddressCrossShardThroughSCFlag, "changeOwnerAddressCrossShardThroughSCFlag", epoch, handler.enableEpochsConfig.ChangeOwnerAddressCrossShardThroughSCEnableEpoch) handler.setFlagValue(epoch >= handler.enableEpochsConfig.FixGasRemainingForSaveKeyValueBuiltinFunctionEnableEpoch, handler.fixGasRemainingForSaveKeyValueFlag, "fixGasRemainingForSaveKeyValueFlag", epoch, handler.enableEpochsConfig.FixGasRemainingForSaveKeyValueBuiltinFunctionEnableEpoch) + handler.setFlagValue(epoch >= handler.enableEpochsConfig.MigrateDataTrieEnableEpoch, handler.migrateDataTrieFlag, "migrateDataTrieFlag", epoch, handler.enableEpochsConfig.MigrateDataTrieEnableEpoch) } func (handler *enableEpochsHandler) setFlagValue(value bool, flag *atomic.Flag, flagName string, epoch uint32, flagEpoch uint32) { diff --git a/common/enablers/enableEpochsHandler_test.go b/common/enablers/enableEpochsHandler_test.go index 7f412524538..ced326d41ba 100644 --- a/common/enablers/enableEpochsHandler_test.go +++ b/common/enablers/enableEpochsHandler_test.go @@ -106,6 +106,7 @@ func createEnableEpochsConfig() config.EnableEpochs { ScToScLogEventEnableEpoch: 88, NFTStopCreateEnableEpoch: 89, FixGasRemainingForSaveKeyValueBuiltinFunctionEnableEpoch: 90, + MigrateDataTrieEnableEpoch: 91, } } @@ -251,6 +252,7 @@ func TestNewEnableEpochsHandler_EpochConfirmed(t *testing.T) { assert.True(t, handler.FixDelegationChangeOwnerOnAccountEnabled()) assert.True(t, handler.NFTStopCreateEnabled()) assert.True(t, handler.FixGasRemainingForSaveKeyValueBuiltinFunctionEnabled()) + assert.True(t, handler.IsMigrateDataTrieEnabled()) }) t.Run("flags with == condition should not be set, the ones with >= should be set", func(t *testing.T) { t.Parallel() @@ -372,6 +374,7 @@ func TestNewEnableEpochsHandler_EpochConfirmed(t *testing.T) { assert.True(t, handler.FixDelegationChangeOwnerOnAccountEnabled()) assert.True(t, handler.NFTStopCreateEnabled()) assert.True(t, handler.FixGasRemainingForSaveKeyValueBuiltinFunctionEnabled()) + assert.True(t, handler.IsMigrateDataTrieEnabled()) }) t.Run("flags with < should be set", func(t *testing.T) { t.Parallel() @@ -488,6 +491,19 @@ func TestNewEnableEpochsHandler_EpochConfirmed(t *testing.T) { assert.False(t, handler.FixDelegationChangeOwnerOnAccountEnabled()) assert.False(t, handler.NFTStopCreateEnabled()) assert.False(t, handler.FixGasRemainingForSaveKeyValueBuiltinFunctionEnabled()) + assert.False(t, handler.IsMigrateDataTrieEnabled()) + }) + t.Run("test for migrate data tries", func(t *testing.T) { + t.Parallel() + + epoch := uint32(90) + cfg := createEnableEpochsConfig() + handler, _ := NewEnableEpochsHandler(cfg, &epochNotifier.EpochNotifierStub{}) + + handler.EpochConfirmed(epoch, 0) + + assert.True(t, handler.IsAutoBalanceDataTriesEnabled()) + assert.False(t, handler.IsMigrateDataTrieEnabled()) }) } diff --git a/common/enablers/epochFlags.go b/common/enablers/epochFlags.go index 84abad52647..05269dee2f2 100644 --- a/common/enablers/epochFlags.go +++ b/common/enablers/epochFlags.go @@ -100,6 +100,7 @@ type epochFlagsHolder struct { changeUsernameFlag *atomic.Flag consistentTokensValuesCheckFlag *atomic.Flag autoBalanceDataTriesFlag *atomic.Flag + migrateDataTrieFlag *atomic.Flag fixDelegationChangeOwnerOnAccountFlag *atomic.Flag dynamicGasCostForDataTrieStorageLoadFlag *atomic.Flag nftStopCreateFlag *atomic.Flag @@ -209,6 +210,7 @@ func newEpochFlagsHolder() *epochFlagsHolder { nftStopCreateFlag: &atomic.Flag{}, changeOwnerAddressCrossShardThroughSCFlag: &atomic.Flag{}, fixGasRemainingForSaveKeyValueFlag: &atomic.Flag{}, + migrateDataTrieFlag: &atomic.Flag{}, } } @@ -740,6 +742,11 @@ func (holder *epochFlagsHolder) IsAutoBalanceDataTriesEnabled() bool { return holder.autoBalanceDataTriesFlag.IsSet() } +// IsMigrateDataTrieEnabled returns true if the migrateDataTrieFlag is enabled +func (holder *epochFlagsHolder) IsMigrateDataTrieEnabled() bool { + return holder.migrateDataTrieFlag.IsSet() +} + // FixDelegationChangeOwnerOnAccountEnabled returns true if the fix for the delegation change owner on account is enabled func (holder *epochFlagsHolder) FixDelegationChangeOwnerOnAccountEnabled() bool { return holder.fixDelegationChangeOwnerOnAccountFlag.IsSet() diff --git a/common/interface.go b/common/interface.go index 9bc3e8c5090..55dbecddc10 100644 --- a/common/interface.go +++ b/common/interface.go @@ -394,6 +394,7 @@ type EnableEpochsHandler interface { IsChangeUsernameEnabled() bool IsConsistentTokensValuesLengthCheckEnabled() bool IsAutoBalanceDataTriesEnabled() bool + IsMigrateDataTrieEnabled() bool IsDynamicGasCostForDataTrieStorageLoadEnabled() bool FixDelegationChangeOwnerOnAccountEnabled() bool NFTStopCreateEnabled() bool diff --git a/config/epochConfig.go b/config/epochConfig.go index c591b17c97b..b23c5a33825 100644 --- a/config/epochConfig.go +++ b/config/epochConfig.go @@ -102,6 +102,7 @@ type EnableEpochs struct { MultiClaimOnDelegationEnableEpoch uint32 ChangeUsernameEnableEpoch uint32 AutoBalanceDataTriesEnableEpoch uint32 + MigrateDataTrieEnableEpoch uint32 ConsistentTokensValuesLengthCheckEnableEpoch uint32 FixDelegationChangeOwnerOnAccountEnableEpoch uint32 DynamicGasCostForDataTrieStorageLoadEnableEpoch uint32 diff --git a/config/tomlConfig_test.go b/config/tomlConfig_test.go index 6e1af87c39b..5b8fa879f6e 100644 --- a/config/tomlConfig_test.go +++ b/config/tomlConfig_test.go @@ -842,6 +842,9 @@ func TestEnableEpochConfig(t *testing.T) { # FixGasRemainingForSaveKeyValueBuiltinFunctionEnableEpoch represents the epoch when the fix for the remaining gas in the SaveKeyValue builtin function is enabled FixGasRemainingForSaveKeyValueBuiltinFunctionEnableEpoch = 91 + + # MigrateDataTrieEnableEpoch represents the epoch when the data tries migration is enabled + MigrateDataTrieEnableEpoch = 92 # MaxNodesChangeEnableEpoch holds configuration for changing the maximum number of nodes and the enabling epoch MaxNodesChangeEnableEpoch = [ @@ -954,6 +957,7 @@ func TestEnableEpochConfig(t *testing.T) { NFTStopCreateEnableEpoch: 89, ChangeOwnerAddressCrossShardThroughSCEnableEpoch: 90, FixGasRemainingForSaveKeyValueBuiltinFunctionEnableEpoch: 91, + MigrateDataTrieEnableEpoch: 92, MaxNodesChangeEnableEpoch: []MaxNodesChangeConfig{ { EpochEnable: 44, diff --git a/go.mod b/go.mod index 2d667980760..45d438fc803 100644 --- a/go.mod +++ b/go.mod @@ -20,8 +20,8 @@ require ( github.com/multiversx/mx-chain-logger-go v1.0.13 github.com/multiversx/mx-chain-scenario-go v1.2.1 github.com/multiversx/mx-chain-storage-go v1.0.14 - github.com/multiversx/mx-chain-vm-common-go v1.5.9 - github.com/multiversx/mx-chain-vm-go v1.5.23 + github.com/multiversx/mx-chain-vm-common-go v1.5.10-0.20240116165528-e13d057575c2 + github.com/multiversx/mx-chain-vm-go v1.5.24-0.20240116171344-b97ba9e3078e github.com/multiversx/mx-chain-vm-v1_2-go v1.2.64 github.com/multiversx/mx-chain-vm-v1_3-go v1.3.65 github.com/multiversx/mx-chain-vm-v1_4-go v1.4.92 diff --git a/go.sum b/go.sum index 11ce63d1c90..7c47eb5a4b1 100644 --- a/go.sum +++ b/go.sum @@ -398,10 +398,10 @@ github.com/multiversx/mx-chain-scenario-go v1.2.1 h1:9eC6VcOEAKRRKZ7EbSWPLzCdNIM github.com/multiversx/mx-chain-scenario-go v1.2.1/go.mod h1:EuZY7DpNFHVNSxJR8dKE1z2I8gBYfEFFPSwNUOXptqE= github.com/multiversx/mx-chain-storage-go v1.0.14 h1:h0acoqPS3FKJ4S3cKBEriTU0OabSQnpxai5WKhi1YCs= github.com/multiversx/mx-chain-storage-go v1.0.14/go.mod h1:sJ2q49tgjxNpMpsHysjABqCAB0FLBmDblbjBkQ8XfmA= -github.com/multiversx/mx-chain-vm-common-go v1.5.9 h1:PnGimbMScV5WXFjumzAmcAcnWrw5e9PQABuIcKKUgZw= -github.com/multiversx/mx-chain-vm-common-go v1.5.9/go.mod h1:sqkKMCnwkWl8DURdb9q7pctK8IANghdHY1KJLE0ox2c= -github.com/multiversx/mx-chain-vm-go v1.5.23 h1:FNkEstebRtQWQNlyQbR2yGSpgGTpiwCMnl4MYVYEy2Q= -github.com/multiversx/mx-chain-vm-go v1.5.23/go.mod h1:T03t+in5jqeTuFZKDt2wH/Sl9MSRczvWhmG+tQEIfec= +github.com/multiversx/mx-chain-vm-common-go v1.5.10-0.20240116165528-e13d057575c2 h1:Gzq8OEYp8JTqj7Mfs9/kUQuS5ANS9W3hQ8r5r6cBmYk= +github.com/multiversx/mx-chain-vm-common-go v1.5.10-0.20240116165528-e13d057575c2/go.mod h1:sqkKMCnwkWl8DURdb9q7pctK8IANghdHY1KJLE0ox2c= +github.com/multiversx/mx-chain-vm-go v1.5.24-0.20240116171344-b97ba9e3078e h1:Nl4JmMDPIMnT4L4C394b6z6jt1R5WhLa1tcednFXE5k= +github.com/multiversx/mx-chain-vm-go v1.5.24-0.20240116171344-b97ba9e3078e/go.mod h1:T03t+in5jqeTuFZKDt2wH/Sl9MSRczvWhmG+tQEIfec= github.com/multiversx/mx-chain-vm-v1_2-go v1.2.64 h1:3BEpSxEQibMMi4LXBjpo2y5vUa1LS7olDC2eDkmUfFQ= github.com/multiversx/mx-chain-vm-v1_2-go v1.2.64/go.mod h1:MUO2E4aEIu3siDkvjraO/WaBh/FxVeQyPWfsrZE+MTU= github.com/multiversx/mx-chain-vm-v1_3-go v1.3.65 h1:H0Duuoz6lR6KapqLqMspWTojaVtQRiLA5lIm6XV9H04= diff --git a/testscommon/enableEpochsHandlerMock/enableEpochsHandlerStub.go b/testscommon/enableEpochsHandlerMock/enableEpochsHandlerStub.go index 43d4139a500..755bdaa10e1 100644 --- a/testscommon/enableEpochsHandlerMock/enableEpochsHandlerStub.go +++ b/testscommon/enableEpochsHandlerMock/enableEpochsHandlerStub.go @@ -129,6 +129,7 @@ type EnableEpochsHandlerStub struct { IsChangeUsernameEnabledField bool IsConsistentTokensValuesLengthCheckEnabledField bool IsAutoBalanceDataTriesEnabledField bool + IsMigrateDataTrieEnabledField bool FixDelegationChangeOwnerOnAccountEnabledField bool IsDynamicGasCostForDataTrieStorageLoadEnabledField bool IsNFTStopCreateEnabledField bool @@ -1119,6 +1120,14 @@ func (stub *EnableEpochsHandlerStub) IsAutoBalanceDataTriesEnabled() bool { return stub.IsAutoBalanceDataTriesEnabledField } +// IsMigrateDataTrieEnabled - +func (stub *EnableEpochsHandlerStub) IsMigrateDataTrieEnabled() bool { + stub.RLock() + defer stub.RUnlock() + + return stub.IsMigrateDataTrieEnabledField +} + // FixDelegationChangeOwnerOnAccountEnabled - func (stub *EnableEpochsHandlerStub) FixDelegationChangeOwnerOnAccountEnabled() bool { stub.RLock()