Skip to content

Commit

Permalink
Merge pull request #5672 from multiversx/remove-state-checkpoint-oper…
Browse files Browse the repository at this point in the history
…ation

remove the state checkpoint operation
  • Loading branch information
BeniaminDrasovean authored Nov 2, 2023
2 parents a93d158 + c37ba20 commit 8a01c07
Show file tree
Hide file tree
Showing 76 changed files with 177 additions and 2,363 deletions.
29 changes: 0 additions & 29 deletions cmd/node/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -342,32 +342,6 @@
ShardIDProviderType = "BinarySplit"
NumShards = 4

[AccountsTrieCheckpointsStorage]
[AccountsTrieCheckpointsStorage.Cache]
Name = "AccountsTrieCheckpointsStorage"
Capacity = 100000
Type = "SizeLRU"
SizeInBytes = 52428800 #50MB
[AccountsTrieCheckpointsStorage.DB]
FilePath = "AccountsTrieCheckpoints"
Type = "LvlDBSerial"
BatchDelaySeconds = 2
MaxBatchSize = 45000
MaxOpenFiles = 10

[PeerAccountsTrieCheckpointsStorage]
[PeerAccountsTrieCheckpointsStorage.Cache]
Name = "PeerAccountsTrieCheckpointsStorage"
Capacity = 10000
Type = "SizeLRU"
SizeInBytes = 52428800 #50MB
[PeerAccountsTrieCheckpointsStorage.DB]
FilePath = "PeerAccountsTrieCheckpoints"
Type = "LvlDBSerial"
BatchDelaySeconds = 2
MaxBatchSize = 1000
MaxOpenFiles = 10

[EvictionWaitingList]
#total max size ~ 2 * [(RoothashesSize * 32) + (HashesSize * 32)]
RootHashesSize = 10000
Expand All @@ -383,7 +357,6 @@
PruningBufferLen = 100000
SnapshotsBufferLen = 1000000
SnapshotsGoroutineNum = 200
CheckpointHashesHolderMaxSize = 52428800 #50MB

[HeadersPoolConfig]
MaxHeadersPerShard = 1000
Expand Down Expand Up @@ -677,8 +650,6 @@
Version = 0 # Setting 0 means 'use default value'

[StateTriesConfig]
CheckpointRoundsModulus = 100
CheckpointsEnabled = false
SnapshotsEnabled = true
AccountsStatePruningEnabled = false
PeerStatePruningEnabled = true
Expand Down
4 changes: 0 additions & 4 deletions cmd/node/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,6 @@ func processConfigImportDBMode(log logger.Logger, configs *config.Configs) error

// We need to increment "NumActivePersisters" in order to make the storage resolvers work (since they open 2 epochs in advance)
generalConfigs.StoragePruning.NumActivePersisters++
generalConfigs.StateTriesConfig.CheckpointsEnabled = false
generalConfigs.StateTriesConfig.CheckpointRoundsModulus = 100000000
p2pConfigs.Node.ThresholdMinConnectedPeers = 0
p2pConfigs.KadDhtPeerDiscovery.Enabled = false
fullArchiveP2PConfigs.Node.ThresholdMinConnectedPeers = 0
Expand All @@ -723,8 +721,6 @@ func processConfigImportDBMode(log logger.Logger, configs *config.Configs) error

log.Warn("the node is in import mode! Will auto-set some config values, including storage config values",
"GeneralSettings.StartInEpochEnabled", generalConfigs.GeneralSettings.StartInEpochEnabled,
"StateTriesConfig.CheckpointsEnabled", generalConfigs.StateTriesConfig.CheckpointsEnabled,
"StateTriesConfig.CheckpointRoundsModulus", generalConfigs.StateTriesConfig.CheckpointRoundsModulus,
"StoragePruning.NumEpochsToKeep", generalConfigs.StoragePruning.NumEpochsToKeep,
"StoragePruning.NumActivePersisters", generalConfigs.StoragePruning.NumActivePersisters,
"p2p.ThresholdMinConnectedPeers", p2pConfigs.Node.ThresholdMinConnectedPeers,
Expand Down
2 changes: 0 additions & 2 deletions common/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,11 @@ type StorageManager interface {
PutInEpoch(key []byte, val []byte, epoch uint32) error
PutInEpochWithoutCache(key []byte, val []byte, epoch uint32) error
TakeSnapshot(address string, rootHash []byte, mainTrieRootHash []byte, iteratorChannels *TrieIteratorChannels, missingNodesChan chan []byte, stats SnapshotStatisticsHandler, epoch uint32)
SetCheckpoint(rootHash []byte, mainTrieRootHash []byte, iteratorChannels *TrieIteratorChannels, missingNodesChan chan []byte, stats SnapshotStatisticsHandler)
GetLatestStorageEpoch() (uint32, error)
IsPruningEnabled() bool
IsPruningBlocked() bool
EnterPruningBufferingMode()
ExitPruningBufferingMode()
AddDirtyCheckpointHashes([]byte, ModifiedHashes) bool
RemoveFromAllActiveEpochs(hash []byte) error
SetEpochForPutOperation(uint32)
ShouldTakeSnapshot() bool
Expand Down
23 changes: 9 additions & 14 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,12 @@ type Config struct {
BootstrapStorage StorageConfig
MetaBlockStorage StorageConfig

AccountsTrieStorage StorageConfig
PeerAccountsTrieStorage StorageConfig
AccountsTrieCheckpointsStorage StorageConfig
PeerAccountsTrieCheckpointsStorage StorageConfig
EvictionWaitingList EvictionWaitingListConfig
StateTriesConfig StateTriesConfig
TrieStorageManagerConfig TrieStorageManagerConfig
BadBlocksCache CacheConfig
AccountsTrieStorage StorageConfig
PeerAccountsTrieStorage StorageConfig
EvictionWaitingList EvictionWaitingListConfig
StateTriesConfig StateTriesConfig
TrieStorageManagerConfig TrieStorageManagerConfig
BadBlocksCache CacheConfig

TxBlockBodyDataPool CacheConfig
PeerBlockBodyDataPool CacheConfig
Expand Down Expand Up @@ -293,8 +291,6 @@ type FacadeConfig struct {

// StateTriesConfig will hold information about state tries
type StateTriesConfig struct {
CheckpointRoundsModulus uint
CheckpointsEnabled bool
SnapshotsEnabled bool
AccountsStatePruningEnabled bool
PeerStatePruningEnabled bool
Expand All @@ -304,10 +300,9 @@ type StateTriesConfig struct {

// TrieStorageManagerConfig will hold config information about trie storage manager
type TrieStorageManagerConfig struct {
PruningBufferLen uint32
SnapshotsBufferLen uint32
SnapshotsGoroutineNum uint32
CheckpointHashesHolderMaxSize uint64
PruningBufferLen uint32
SnapshotsBufferLen uint32
SnapshotsGoroutineNum uint32
}

// EndpointsThrottlersConfig holds a pair of an endpoint and its maximum number of simultaneous go routines
Expand Down
4 changes: 0 additions & 4 deletions config/tomlConfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ func TestTomlParser(t *testing.T) {
},
},
StateTriesConfig: StateTriesConfig{
CheckpointRoundsModulus: 37,
CheckpointsEnabled: true,
SnapshotsEnabled: true,
AccountsStatePruningEnabled: true,
PeerStatePruningEnabled: true,
Expand Down Expand Up @@ -232,8 +230,6 @@ func TestTomlParser(t *testing.T) {
DoProfileOnShuffleOut = true
[StateTriesConfig]
CheckpointRoundsModulus = 37
CheckpointsEnabled = true
SnapshotsEnabled = true
AccountsStatePruningEnabled = true
PeerStatePruningEnabled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ func (brcf *baseRequestersContainerFactory) createMiniBlocksRequester(responseTo

func (brcf *baseRequestersContainerFactory) newImportDBTrieStorage(
mainStorer storage.Storer,
checkpointsStorer storage.Storer,
storageIdentifier dataRetriever.UnitType,
handler common.EnableEpochsHandler,
) (common.StorageManager, dataRetriever.TrieDataGetter, error) {
Expand All @@ -263,9 +262,7 @@ func (brcf *baseRequestersContainerFactory) newImportDBTrieStorage(

args := trieFactory.TrieCreateArgs{
MainStorer: mainStorer,
CheckpointsStorer: checkpointsStorer,
PruningEnabled: brcf.generalConfig.StateTriesConfig.AccountsStatePruningEnabled,
CheckpointsEnabled: brcf.generalConfig.StateTriesConfig.CheckpointsEnabled,
MaxTrieLevelInMem: brcf.generalConfig.StateTriesConfig.MaxStateTrieLevelInMemory,
SnapshotsEnabled: brcf.snapshotsEnabled,
IdleProvider: disabled.NewProcessStatusHandler(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,9 @@ func (mrcf *metaRequestersContainerFactory) generateTrieNodesRequesters() error
return err
}

userAccountsCheckpointStorer, err := mrcf.store.GetStorer(dataRetriever.UserAccountsCheckpointsUnit)
if err != nil {
return err
}

identifierTrieNodes := factory.AccountTrieNodesTopic + core.CommunicationIdentifierBetweenShards(core.MetachainShardId, core.MetachainShardId)
storageManager, userAccountsDataTrie, err := mrcf.newImportDBTrieStorage(
userAccountsStorer,
userAccountsCheckpointStorer,
dataRetriever.UserAccountsUnit,
mrcf.enableEpochsHandler,
)
Expand Down Expand Up @@ -224,15 +218,9 @@ func (mrcf *metaRequestersContainerFactory) generateTrieNodesRequesters() error
return err
}

peerAccountsCheckpointStorer, err := mrcf.store.GetStorer(dataRetriever.PeerAccountsCheckpointsUnit)
if err != nil {
return err
}

identifierTrieNodes = factory.ValidatorTrieNodesTopic + core.CommunicationIdentifierBetweenShards(core.MetachainShardId, core.MetachainShardId)
storageManager, peerAccountsDataTrie, err := mrcf.newImportDBTrieStorage(
peerAccountsStorer,
peerAccountsCheckpointStorer,
dataRetriever.PeerAccountsUnit,
mrcf.enableEpochsHandler,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ func getArgumentsMeta() storagerequesterscontainer.FactoryArgs {
SnapshotsGoroutineNum: 2,
},
StateTriesConfig: config.StateTriesConfig{
CheckpointRoundsModulus: 100,
AccountsStatePruningEnabled: false,
PeerStatePruningEnabled: false,
MaxStateTrieLevelInMemory: 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,9 @@ func (srcf *shardRequestersContainerFactory) generateTrieNodesRequesters() error
return err
}

userAccountsCheckpointStorer, err := srcf.store.GetStorer(dataRetriever.UserAccountsCheckpointsUnit)
if err != nil {
return err
}

identifierTrieNodes := factory.AccountTrieNodesTopic + shardC.CommunicationIdentifier(core.MetachainShardId)
storageManager, userAccountsDataTrie, err := srcf.newImportDBTrieStorage(
userAccountsStorer,
userAccountsCheckpointStorer,
dataRetriever.UserAccountsUnit,
srcf.enableEpochsHandler,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ func getArgumentsShard() storagerequesterscontainer.FactoryArgs {
SnapshotsGoroutineNum: 2,
},
StateTriesConfig: config.StateTriesConfig{
CheckpointRoundsModulus: 100,
AccountsStatePruningEnabled: false,
PeerStatePruningEnabled: false,
MaxStateTrieLevelInMemory: 5,
Expand Down
12 changes: 2 additions & 10 deletions dataRetriever/unitType.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,10 @@ const (
RoundHdrHashDataUnit UnitType = 19
// UserAccountsUnit is the user accounts storage unit identifier
UserAccountsUnit UnitType = 20
// UserAccountsCheckpointsUnit is the user accounts checkpoints storage unit identifier
UserAccountsCheckpointsUnit UnitType = 21
// PeerAccountsUnit is the peer accounts storage unit identifier
PeerAccountsUnit UnitType = 22
// PeerAccountsCheckpointsUnit is the peer accounts checkpoints storage unit identifier
PeerAccountsCheckpointsUnit UnitType = 23
PeerAccountsUnit UnitType = 21
// ScheduledSCRsUnit is the scheduled SCRs storage unit identifier
ScheduledSCRsUnit UnitType = 24
ScheduledSCRsUnit UnitType = 22

// ShardHdrNonceHashDataUnit is the header nonce-hash pair data unit identifier
//TODO: Add only unit types lower than 100
Expand Down Expand Up @@ -110,12 +106,8 @@ func (ut UnitType) String() string {
return "RoundHdrHashDataUnit"
case UserAccountsUnit:
return "UserAccountsUnit"
case UserAccountsCheckpointsUnit:
return "UserAccountsCheckpointsUnit"
case PeerAccountsUnit:
return "PeerAccountsUnit"
case PeerAccountsCheckpointsUnit:
return "PeerAccountsCheckpointsUnit"
case ScheduledSCRsUnit:
return "ScheduledSCRsUnit"
}
Expand Down
4 changes: 0 additions & 4 deletions dataRetriever/unitType_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,8 @@ func TestUnitType_String(t *testing.T) {
require.Equal(t, "RoundHdrHashDataUnit", ut.String())
ut = UserAccountsUnit
require.Equal(t, "UserAccountsUnit", ut.String())
ut = UserAccountsCheckpointsUnit
require.Equal(t, "UserAccountsCheckpointsUnit", ut.String())
ut = PeerAccountsUnit
require.Equal(t, "PeerAccountsUnit", ut.String())
ut = PeerAccountsCheckpointsUnit
require.Equal(t, "PeerAccountsCheckpointsUnit", ut.String())
ut = ScheduledSCRsUnit
require.Equal(t, "ScheduledSCRsUnit", ut.String())

Expand Down
4 changes: 0 additions & 4 deletions epochStart/bootstrap/disabled/disabledAccountsAdapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ func (a *accountsAdapter) CancelPrune(_ []byte, _ state.TriePruningIdentifier) {
func (a *accountsAdapter) SnapshotState(_ []byte, _ uint32) {
}

// SetStateCheckpoint -
func (a *accountsAdapter) SetStateCheckpoint(_ []byte) {
}

// IsPruningEnabled -
func (a *accountsAdapter) IsPruningEnabled() bool {
return false
Expand Down
41 changes: 19 additions & 22 deletions epochStart/bootstrap/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,27 +109,25 @@ func createMockEpochStartBootstrapArgs(
},
FullArchiveMessenger: &p2pmocks.MessengerStub{},
GeneralConfig: config.Config{
MiniBlocksStorage: generalCfg.MiniBlocksStorage,
PeerBlockBodyStorage: generalCfg.PeerBlockBodyStorage,
BlockHeaderStorage: generalCfg.BlockHeaderStorage,
TxStorage: generalCfg.TxStorage,
UnsignedTransactionStorage: generalCfg.UnsignedTransactionStorage,
RewardTxStorage: generalCfg.RewardTxStorage,
ShardHdrNonceHashStorage: generalCfg.ShardHdrNonceHashStorage,
MetaHdrNonceHashStorage: generalCfg.MetaHdrNonceHashStorage,
StatusMetricsStorage: generalCfg.StatusMetricsStorage,
ReceiptsStorage: generalCfg.ReceiptsStorage,
SmartContractsStorage: generalCfg.SmartContractsStorage,
SmartContractsStorageForSCQuery: generalCfg.SmartContractsStorageForSCQuery,
TrieEpochRootHashStorage: generalCfg.TrieEpochRootHashStorage,
BootstrapStorage: generalCfg.BootstrapStorage,
MetaBlockStorage: generalCfg.MetaBlockStorage,
AccountsTrieStorage: generalCfg.AccountsTrieStorage,
PeerAccountsTrieStorage: generalCfg.PeerAccountsTrieStorage,
AccountsTrieCheckpointsStorage: generalCfg.AccountsTrieCheckpointsStorage,
PeerAccountsTrieCheckpointsStorage: generalCfg.PeerAccountsTrieCheckpointsStorage,
HeartbeatV2: generalCfg.HeartbeatV2,
Hardfork: generalCfg.Hardfork,
MiniBlocksStorage: generalCfg.MiniBlocksStorage,
PeerBlockBodyStorage: generalCfg.PeerBlockBodyStorage,
BlockHeaderStorage: generalCfg.BlockHeaderStorage,
TxStorage: generalCfg.TxStorage,
UnsignedTransactionStorage: generalCfg.UnsignedTransactionStorage,
RewardTxStorage: generalCfg.RewardTxStorage,
ShardHdrNonceHashStorage: generalCfg.ShardHdrNonceHashStorage,
MetaHdrNonceHashStorage: generalCfg.MetaHdrNonceHashStorage,
StatusMetricsStorage: generalCfg.StatusMetricsStorage,
ReceiptsStorage: generalCfg.ReceiptsStorage,
SmartContractsStorage: generalCfg.SmartContractsStorage,
SmartContractsStorageForSCQuery: generalCfg.SmartContractsStorageForSCQuery,
TrieEpochRootHashStorage: generalCfg.TrieEpochRootHashStorage,
BootstrapStorage: generalCfg.BootstrapStorage,
MetaBlockStorage: generalCfg.MetaBlockStorage,
AccountsTrieStorage: generalCfg.AccountsTrieStorage,
PeerAccountsTrieStorage: generalCfg.PeerAccountsTrieStorage,
HeartbeatV2: generalCfg.HeartbeatV2,
Hardfork: generalCfg.Hardfork,
EvictionWaitingList: config.EvictionWaitingListConfig{
HashesSize: 100,
RootHashesSize: 100,
Expand All @@ -142,7 +140,6 @@ func createMockEpochStartBootstrapArgs(
},
},
StateTriesConfig: config.StateTriesConfig{
CheckpointRoundsModulus: 5,
AccountsStatePruningEnabled: true,
PeerStatePruningEnabled: true,
MaxStateTrieLevelInMemory: 5,
Expand Down
1 change: 0 additions & 1 deletion epochStart/metachain/systemSCs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,6 @@ func createFullArgumentsForSystemSCProcessing(enableEpochsConfig config.EnableEp
storageManagerArgs.Marshalizer = marshalizer
storageManagerArgs.Hasher = hasher
storageManagerArgs.MainStorer = trieStorer
storageManagerArgs.CheckpointsStorer = trieStorer

trieFactoryManager, _ := trie.CreateTrieStorageManager(storageManagerArgs, storageMock.GetStorageManagerOptions())
argsAccCreator := factory.ArgsAccountCreator{
Expand Down
Loading

0 comments on commit 8a01c07

Please sign in to comment.