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 d6099536d69..010d55e22d5 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 074a5b37e0f..135f5d22821 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 + github.com/multiversx/mx-chain-vm-go v1.5.24 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 @@ -47,7 +47,7 @@ require ( github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect github.com/containerd/cgroups v1.1.0 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/denisbrodbeck/machineid v1.0.1 // indirect @@ -150,8 +150,7 @@ require ( github.com/quic-go/quic-go v0.33.0 // indirect github.com/quic-go/webtransport-go v0.5.3 // indirect github.com/raulk/go-watchdog v1.3.0 // indirect - github.com/russross/blackfriday/v2 v2.0.1 // indirect - github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/smartystreets/assertions v1.13.1 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect diff --git a/go.sum b/go.sum index 557ea8c7b0a..7940ab735e0 100644 --- a/go.sum +++ b/go.sum @@ -72,8 +72,9 @@ github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+ github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -398,10 +399,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 h1:VoqVt9yX1nQUa0ZujMpdT3J3pKSnQcB6WCQLvIW4sqw= +github.com/multiversx/mx-chain-vm-common-go v1.5.10/go.mod h1:sqkKMCnwkWl8DURdb9q7pctK8IANghdHY1KJLE0ox2c= +github.com/multiversx/mx-chain-vm-go v1.5.24 h1:6RhMvf84Ys8DksDovms+su7w6j9TWz3Rtm/PpgV12Yw= +github.com/multiversx/mx-chain-vm-go v1.5.24/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= @@ -486,8 +487,9 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= @@ -512,7 +514,6 @@ github.com/shurcooL/notifications v0.0.0-20181007000457-627ab5aea122/go.mod h1:b github.com/shurcooL/octicon v0.0.0-20181028054416-fa4f57f9efb2/go.mod h1:eWdoE5JD4R5UVWDucdOPg1g2fqQRq78IQa9zlOV1vpQ= github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1lToEk4d2s07G3XGfz2QrgHXg4RJBvjrOozvoWfk= github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4= github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw= diff --git a/sharding/mock/enableEpochsHandlerMock.go b/sharding/mock/enableEpochsHandlerMock.go index e67f7f486ba..93df39fcd2b 100644 --- a/sharding/mock/enableEpochsHandlerMock.go +++ b/sharding/mock/enableEpochsHandlerMock.go @@ -618,6 +618,11 @@ func (mock *EnableEpochsHandlerMock) IsAutoBalanceDataTriesEnabled() bool { return false } +// IsMigrateDataTrieEnabled - +func (mock *EnableEpochsHandlerMock) IsMigrateDataTrieEnabled() bool { + return false +} + // FixDelegationChangeOwnerOnAccountEnabled - func (mock *EnableEpochsHandlerMock) FixDelegationChangeOwnerOnAccountEnabled() bool { return false 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()