Skip to content

Commit

Permalink
Merge pull request #5428 from multiversx/put-back-snapshotless-config
Browse files Browse the repository at this point in the history
Put back snapshot-less config in config.toml
  • Loading branch information
iulianpascalau authored Jul 13, 2023
2 parents 21b5a03 + 5dc741b commit aae130a
Show file tree
Hide file tree
Showing 27 changed files with 67 additions and 113 deletions.
1 change: 1 addition & 0 deletions cmd/node/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@
[StateTriesConfig]
CheckpointRoundsModulus = 100
CheckpointsEnabled = false
SnapshotsEnabled = true
AccountsStatePruningEnabled = false
PeerStatePruningEnabled = true
MaxStateTrieLevelInMemory = 5
Expand Down
16 changes: 9 additions & 7 deletions cmd/node/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,6 @@ func getFlagsConfig(ctx *cli.Context, log logger.Logger) *config.ContextFlagsCon
flagsConfig.DisableConsensusWatchdog = ctx.GlobalBool(disableConsensusWatchdog.Name)
flagsConfig.SerializeSnapshots = ctx.GlobalBool(serializeSnapshots.Name)
flagsConfig.NoKeyProvided = ctx.GlobalBool(noKey.Name)
flagsConfig.SnapshotsEnabled = ctx.GlobalBool(snapshotsEnabled.Name)
flagsConfig.OperationMode = ctx.GlobalString(operationMode.Name)
flagsConfig.RepopulateTokensSupplies = ctx.GlobalBool(repopulateTokensSupplies.Name)

Expand Down Expand Up @@ -516,6 +515,9 @@ func applyFlags(ctx *cli.Context, cfgs *config.Configs, flagsConfig *config.Cont
log.Info("setting a new value for the memoryUsageToCreateProfiles option",
"new value", cfgs.GeneralConfig.Health.MemoryUsageToCreateProfiles)
}
if ctx.IsSet(snapshotsEnabled.Name) {
cfgs.GeneralConfig.StateTriesConfig.SnapshotsEnabled = ctx.GlobalBool(snapshotsEnabled.Name)
}

importDbDirectoryValue := ctx.GlobalString(importDbDirectory.Name)
importDBConfigs := &config.ImportDbConfig{
Expand Down Expand Up @@ -615,9 +617,9 @@ func applyCompatibleConfigs(log logger.Logger, configs *config.Configs) error {
processDbLookupExtensionMode(log, configs)
}

isInLiteObserverMode := operationmodes.SliceContainsElement(operationModes, operationmodes.OperationModeSnapshotlessObserver)
if isInLiteObserverMode {
processLiteObserverMode(log, configs)
isInSnapshotLessObserverMode := operationmodes.SliceContainsElement(operationModes, operationmodes.OperationModeSnapshotlessObserver)
if isInSnapshotLessObserverMode {
processSnapshotLessObserverMode(log, configs)
}

return nil
Expand Down Expand Up @@ -655,14 +657,14 @@ func processDbLookupExtensionMode(log logger.Logger, configs *config.Configs) {
)
}

func processLiteObserverMode(log logger.Logger, configs *config.Configs) {
func processSnapshotLessObserverMode(log logger.Logger, configs *config.Configs) {
configs.GeneralConfig.StoragePruning.ObserverCleanOldEpochsData = true
configs.FlagsConfig.SnapshotsEnabled = false
configs.GeneralConfig.StateTriesConfig.SnapshotsEnabled = false
configs.GeneralConfig.StateTriesConfig.AccountsStatePruningEnabled = true

log.Warn("the node is in snapshotless observer mode! Will auto-set some config values",
"StoragePruning.ObserverCleanOldEpochsData", configs.GeneralConfig.StoragePruning.ObserverCleanOldEpochsData,
"FlagsConfig.SnapshotsEnabled", configs.FlagsConfig.SnapshotsEnabled,
"StateTriesConfig.SnapshotsEnabled", configs.GeneralConfig.StateTriesConfig.SnapshotsEnabled,
"StateTriesConfig.AccountsStatePruningEnabled", configs.GeneralConfig.StateTriesConfig.AccountsStatePruningEnabled,
)
}
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ type FacadeConfig struct {
type StateTriesConfig struct {
CheckpointRoundsModulus uint
CheckpointsEnabled bool
SnapshotsEnabled bool
AccountsStatePruningEnabled bool
PeerStatePruningEnabled bool
MaxStateTrieLevelInMemory uint
Expand Down
1 change: 0 additions & 1 deletion config/contextFlagsConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type ContextFlagsConfig struct {
DisableConsensusWatchdog bool
SerializeSnapshots bool
NoKeyProvided bool
SnapshotsEnabled bool
OperationMode string
RepopulateTokensSupplies bool
}
Expand Down
18 changes: 18 additions & 0 deletions config/tomlConfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,15 @@ func TestTomlParser(t *testing.T) {
DoProfileOnShuffleOut: true,
},
},
StateTriesConfig: StateTriesConfig{
CheckpointRoundsModulus: 37,
CheckpointsEnabled: true,
SnapshotsEnabled: true,
AccountsStatePruningEnabled: true,
PeerStatePruningEnabled: true,
MaxStateTrieLevelInMemory: 38,
MaxPeerTrieLevelInMemory: 39,
},
}
testString := `
[MiniBlocksStorage]
Expand Down Expand Up @@ -218,6 +227,15 @@ func TestTomlParser(t *testing.T) {
CallGCWhenShuffleOut = true
ExtraPrintsOnShuffleOut = true
DoProfileOnShuffleOut = true
[StateTriesConfig]
CheckpointRoundsModulus = 37
CheckpointsEnabled = true
SnapshotsEnabled = true
AccountsStatePruningEnabled = true
PeerStatePruningEnabled = true
MaxStateTrieLevelInMemory = 38
MaxPeerTrieLevelInMemory = 39
`
cfg := Config{}

Expand Down
1 change: 0 additions & 1 deletion dataRetriever/factory/storageRequestersContainer/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ type FactoryArgs struct {
DataPacker dataRetriever.DataPacker
ManualEpochStartNotifier dataRetriever.ManualEpochStartNotifier
ChanGracefullyClose chan endProcess.ArgEndProcess
SnapshotsEnabled bool
EnableEpochsHandler common.EnableEpochsHandler
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewMetaRequestersContainerFactory(
shardIDForTries: args.ShardIDForTries,
chainID: args.ChainID,
workingDir: args.WorkingDirectory,
snapshotsEnabled: args.SnapshotsEnabled,
snapshotsEnabled: args.GeneralConfig.StateTriesConfig.SnapshotsEnabled,
enableEpochsHandler: args.EnableEpochsHandler,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ func getArgumentsMeta() storagerequesterscontainer.FactoryArgs {
DataPacker: &mock.DataPackerStub{},
ManualEpochStartNotifier: &mock.ManualEpochStartNotifierStub{},
ChanGracefullyClose: make(chan endProcess.ArgEndProcess),
SnapshotsEnabled: true,
EnableEpochsHandler: &enableEpochsHandlerMock.EnableEpochsHandlerStub{},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewShardRequestersContainerFactory(
shardIDForTries: args.ShardIDForTries,
chainID: args.ChainID,
workingDir: args.WorkingDirectory,
snapshotsEnabled: args.SnapshotsEnabled,
snapshotsEnabled: args.GeneralConfig.StateTriesConfig.SnapshotsEnabled,
enableEpochsHandler: args.EnableEpochsHandler,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ func getArgumentsShard() storagerequesterscontainer.FactoryArgs {
DataPacker: &mock.DataPackerStub{},
ManualEpochStartNotifier: &mock.ManualEpochStartNotifierStub{},
ChanGracefullyClose: make(chan endProcess.ArgEndProcess),
SnapshotsEnabled: true,
EnableEpochsHandler: &enableEpochsHandlerMock.EnableEpochsHandlerStub{},
}
}
1 change: 0 additions & 1 deletion epochStart/bootstrap/fromLocalStorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ func (e *epochStartBootstrap) prepareEpochFromStorage() (Parameters, error) {
e.closeTrieComponents()
e.storageService = disabled.NewChainStorer()
triesContainer, trieStorageManagers, err := factory.CreateTriesComponentsForShardId(
e.flagsConfig.SnapshotsEnabled,
e.generalConfig,
e.coreComponentsHolder,
e.storageService,
Expand Down
2 changes: 0 additions & 2 deletions epochStart/bootstrap/metaStorageHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func NewMetaStorageHandler(
uint64Converter typeConverters.Uint64ByteSliceConverter,
nodeTypeProvider NodeTypeProviderHandler,
nodeProcessingMode common.NodeProcessingMode,
snapshotsEnabled bool,
managedPeersHolder common.ManagedPeersHolder,
) (*metaStorageHandler, error) {
epochStartNotifier := &disabled.EpochStartNotifier{}
Expand All @@ -53,7 +52,6 @@ func NewMetaStorageHandler(
StorageType: factory.BootstrapStorageService,
CreateTrieEpochRootHashStorer: false,
NodeProcessingMode: nodeProcessingMode,
SnapshotsEnabled: snapshotsEnabled,
RepopulateTokensSupplies: false, // tokens supplies cannot be repopulated at this time
ManagedPeersHolder: managedPeersHolder,
},
Expand Down
7 changes: 0 additions & 7 deletions epochStart/bootstrap/metaStorageHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func TestNewMetaStorageHandler_InvalidConfigErr(t *testing.T) {
uit64Cvt,
nodeTypeProvider,
common.Normal,
false,
managedPeersHolder,
)
assert.True(t, check.IfNil(mtStrHandler))
Expand Down Expand Up @@ -78,7 +77,6 @@ func TestNewMetaStorageHandler_CreateForMetaErr(t *testing.T) {
uit64Cvt,
nodeTypeProvider,
common.Normal,
false,
managedPeersHolder,
)
assert.False(t, check.IfNil(mtStrHandler))
Expand Down Expand Up @@ -111,7 +109,6 @@ func TestMetaStorageHandler_saveLastHeader(t *testing.T) {
uit64Cvt,
nodeTypeProvider,
common.Normal,
false,
managedPeersHolder,
)

Expand Down Expand Up @@ -153,7 +150,6 @@ func TestMetaStorageHandler_saveLastCrossNotarizedHeaders(t *testing.T) {
uit64Cvt,
nodeTypeProvider,
common.Normal,
false,
managedPeersHolder,
)

Expand Down Expand Up @@ -201,7 +197,6 @@ func TestMetaStorageHandler_saveTriggerRegistry(t *testing.T) {
uit64Cvt,
nodeTypeProvider,
common.Normal,
false,
managedPeersHolder,
)

Expand Down Expand Up @@ -240,7 +235,6 @@ func TestMetaStorageHandler_saveDataToStorage(t *testing.T) {
uit64Cvt,
nodeTypeProvider,
common.Normal,
false,
managedPeersHolder,
)

Expand Down Expand Up @@ -296,7 +290,6 @@ func testMetaWithMissingStorer(missingUnit dataRetriever.UnitType, atCallNumber
uit64Cvt,
nodeTypeProvider,
common.Normal,
false,
managedPeersHolder,
)
counter := 0
Expand Down
6 changes: 0 additions & 6 deletions epochStart/bootstrap/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,6 @@ func (e *epochStartBootstrap) prepareComponentsToSyncFromNetwork() error {
e.closeTrieComponents()
e.storageService = disabled.NewChainStorer()
triesContainer, trieStorageManagers, err := factory.CreateTriesComponentsForShardId(
e.flagsConfig.SnapshotsEnabled,
e.generalConfig,
e.coreComponentsHolder,
e.storageService,
Expand Down Expand Up @@ -767,7 +766,6 @@ func (e *epochStartBootstrap) requestAndProcessForMeta(peerMiniBlocks []*block.M
e.coreComponentsHolder.Uint64ByteSliceConverter(),
e.coreComponentsHolder.NodeTypeProvider(),
e.nodeProcessingMode,
e.flagsConfig.SnapshotsEnabled,
e.cryptoComponentsHolder.ManagedPeersHolder(),
)
if err != nil {
Expand All @@ -778,7 +776,6 @@ func (e *epochStartBootstrap) requestAndProcessForMeta(peerMiniBlocks []*block.M

e.closeTrieComponents()
triesContainer, trieStorageManagers, err := factory.CreateTriesComponentsForShardId(
e.flagsConfig.SnapshotsEnabled,
e.generalConfig,
e.coreComponentsHolder,
storageHandlerComponent.storageService,
Expand Down Expand Up @@ -937,7 +934,6 @@ func (e *epochStartBootstrap) requestAndProcessForShard(peerMiniBlocks []*block.
e.coreComponentsHolder.Uint64ByteSliceConverter(),
e.coreComponentsHolder.NodeTypeProvider(),
e.nodeProcessingMode,
e.flagsConfig.SnapshotsEnabled,
e.cryptoComponentsHolder.ManagedPeersHolder(),
)
if err != nil {
Expand All @@ -948,7 +944,6 @@ func (e *epochStartBootstrap) requestAndProcessForShard(peerMiniBlocks []*block.

e.closeTrieComponents()
triesContainer, trieStorageManagers, err := factory.CreateTriesComponentsForShardId(
e.flagsConfig.SnapshotsEnabled,
e.generalConfig,
e.coreComponentsHolder,
storageHandlerComponent.storageService,
Expand Down Expand Up @@ -1122,7 +1117,6 @@ func (e *epochStartBootstrap) createStorageService(
StorageType: storageFactory.BootstrapStorageService,
CreateTrieEpochRootHashStorer: createTrieEpochRootHashStorer,
NodeProcessingMode: e.nodeProcessingMode,
SnapshotsEnabled: e.flagsConfig.SnapshotsEnabled,
RepopulateTokensSupplies: e.flagsConfig.RepopulateTokensSupplies,
ManagedPeersHolder: e.cryptoComponentsHolder.ManagedPeersHolder(),
})
Expand Down
3 changes: 0 additions & 3 deletions epochStart/bootstrap/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,6 @@ func TestSyncValidatorAccountsState_NilRequestHandlerErr(t *testing.T) {
},
}
triesContainer, trieStorageManagers, err := factory.CreateTriesComponentsForShardId(
false,
args.GeneralConfig,
coreComp,
disabled.NewChainStorer(),
Expand All @@ -1025,7 +1024,6 @@ func TestCreateTriesForNewShardID(t *testing.T) {
args.GeneralConfig = testscommon.GetGeneralConfig()

triesContainer, trieStorageManagers, err := factory.CreateTriesComponentsForShardId(
false,
args.GeneralConfig,
coreComp,
disabled.NewChainStorer(),
Expand All @@ -1052,7 +1050,6 @@ func TestSyncUserAccountsState(t *testing.T) {
}

triesContainer, trieStorageManagers, err := factory.CreateTriesComponentsForShardId(
false,
args.GeneralConfig,
coreComp,
disabled.NewChainStorer(),
Expand Down
2 changes: 0 additions & 2 deletions epochStart/bootstrap/shardStorageHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func NewShardStorageHandler(
uint64Converter typeConverters.Uint64ByteSliceConverter,
nodeTypeProvider core.NodeTypeProviderHandler,
nodeProcessingMode common.NodeProcessingMode,
snapshotsEnabled bool,
managedPeersHolder common.ManagedPeersHolder,
) (*shardStorageHandler, error) {
epochStartNotifier := &disabled.EpochStartNotifier{}
Expand All @@ -57,7 +56,6 @@ func NewShardStorageHandler(
StorageType: factory.BootstrapStorageService,
CreateTrieEpochRootHashStorer: false,
NodeProcessingMode: nodeProcessingMode,
SnapshotsEnabled: snapshotsEnabled,
RepopulateTokensSupplies: false, // tokens supplies cannot be repopulated at this time
ManagedPeersHolder: managedPeersHolder,
},
Expand Down
Loading

0 comments on commit aae130a

Please sign in to comment.