Skip to content

Commit

Permalink
Merge 7029a48 into d6034af
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan-rosianu committed May 16, 2023
2 parents d6034af + 7029a48 commit b5c34c8
Show file tree
Hide file tree
Showing 38 changed files with 1,170 additions and 87 deletions.
8 changes: 8 additions & 0 deletions cmd/node/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,12 @@ var (
Usage: "String flag for specifying the desired `operation mode`(s) of the node, resulting in altering some configuration values accordingly. Possible values are: snapshotless-observer, full-archive, db-lookup-extension, historical-balances or `\"\"` (empty). Multiple values can be separated via ,",
Value: "",
}

// repopulateTokensSupplies defines a flag that, if set, will repopulate the tokens supplies database by iterating over the trie
repopulateTokensSupplies = cli.BoolFlag{
Name: "repopulate-tokens-supplies",
Usage: "Boolean flag for repopulating the tokens supplies database. It will delete the current data, iterate over the entire trie and add he new obtained supplies",
}
)

func getFlags() []cli.Flag {
Expand Down Expand Up @@ -443,6 +449,7 @@ func getFlags() []cli.Flag {
dbDirectory,
logsDirectory,
operationMode,
repopulateTokensSupplies,
}
}

Expand Down Expand Up @@ -472,6 +479,7 @@ func getFlagsConfig(ctx *cli.Context, log logger.Logger) *config.ContextFlagsCon
flagsConfig.NoKeyProvided = ctx.GlobalBool(noKey.Name)
flagsConfig.SnapshotsEnabled = ctx.GlobalBool(snapshotsEnabled.Name)
flagsConfig.OperationMode = ctx.GlobalString(operationMode.Name)
flagsConfig.RepopulateTokensSupplies = ctx.GlobalBool(repopulateTokensSupplies.Name)

return flagsConfig
}
Expand Down
1 change: 1 addition & 0 deletions config/contextFlagsConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type ContextFlagsConfig struct {
NoKeyProvided bool
SnapshotsEnabled bool
OperationMode string
RepopulateTokensSupplies bool
}

// ImportDbConfig will hold the import-db parameters
Expand Down
5 changes: 2 additions & 3 deletions consensus/message.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions consensus/mock/bootstrapperStub.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type BootstrapperStub struct {
CreateAndCommitEmptyBlockCalled func(uint32) (data.BodyHandler, data.HeaderHandler, error)
AddSyncStateListenerCalled func(func(bool))
GetNodeStateCalled func() common.NodeState
StartSyncingBlocksCalled func()
StartSyncingBlocksCalled func() error
}

// CreateAndCommitEmptyBlock -
Expand Down Expand Up @@ -40,8 +40,12 @@ func (boot *BootstrapperStub) GetNodeState() common.NodeState {
}

// StartSyncingBlocks -
func (boot *BootstrapperStub) StartSyncingBlocks() {
boot.StartSyncingBlocksCalled()
func (boot *BootstrapperStub) StartSyncingBlocks() error {
if boot.StartSyncingBlocksCalled != nil {
return boot.StartSyncingBlocksCalled()
}

return nil
}

// Close -
Expand Down
1 change: 1 addition & 0 deletions dblookupext/esdtSupply/proto/supplyESDT.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ message SupplyESDT {
bytes Supply = 1 [(gogoproto.jsontag) = "value", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"];
bytes Burned = 2 [(gogoproto.jsontag) = "burned", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"];
bytes Minted = 3 [(gogoproto.jsontag) = "minted", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"];
bool RecomputedSupply = 4 [(gogoproto.jsontag) = "recomputedSupply"];
}
96 changes: 72 additions & 24 deletions dblookupext/esdtSupply/supplyESDT.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions epochStart/bootstrap/metaStorageHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func NewMetaStorageHandler(
CreateTrieEpochRootHashStorer: false,
NodeProcessingMode: nodeProcessingMode,
SnapshotsEnabled: snapshotsEnabled,
RepopulateTokensSupplies: false, // tokens supplies cannot be repopulated at this time
ManagedPeersHolder: managedPeersHolder,
},
)
Expand Down
1 change: 1 addition & 0 deletions epochStart/bootstrap/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,7 @@ func (e *epochStartBootstrap) createStorageService(
CreateTrieEpochRootHashStorer: createTrieEpochRootHashStorer,
NodeProcessingMode: e.nodeProcessingMode,
SnapshotsEnabled: e.flagsConfig.SnapshotsEnabled,
RepopulateTokensSupplies: e.flagsConfig.RepopulateTokensSupplies,
ManagedPeersHolder: e.cryptoComponentsHolder.ManagedPeersHolder(),
})
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions epochStart/bootstrap/shardStorageHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func NewShardStorageHandler(
CreateTrieEpochRootHashStorer: false,
NodeProcessingMode: nodeProcessingMode,
SnapshotsEnabled: snapshotsEnabled,
RepopulateTokensSupplies: false, // tokens supplies cannot be repopulated at this time
ManagedPeersHolder: managedPeersHolder,
},
)
Expand Down
10 changes: 9 additions & 1 deletion factory/consensus/consensusComponents.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const defaultSpan = 300 * time.Second
// ConsensusComponentsFactoryArgs holds the arguments needed to create a consensus components factory
type ConsensusComponentsFactoryArgs struct {
Config config.Config
FlagsConfig config.ContextFlagsConfig
BootstrapRoundIndex uint64
CoreComponents factory.CoreComponentsHolder
NetworkComponents factory.NetworkComponentsHolder
Expand All @@ -55,6 +56,7 @@ type ConsensusComponentsFactoryArgs struct {

type consensusComponentsFactory struct {
config config.Config
flagsConfig config.ContextFlagsConfig
bootstrapRoundIndex uint64
coreComponents factory.CoreComponentsHolder
networkComponents factory.NetworkComponentsHolder
Expand Down Expand Up @@ -88,6 +90,7 @@ func NewConsensusComponentsFactory(args ConsensusComponentsFactoryArgs) (*consen

return &consensusComponentsFactory{
config: args.Config,
flagsConfig: args.FlagsConfig,
bootstrapRoundIndex: args.BootstrapRoundIndex,
coreComponents: args.CoreComponents,
networkComponents: args.NetworkComponents,
Expand Down Expand Up @@ -133,7 +136,10 @@ func (ccf *consensusComponentsFactory) Create() (*consensusComponents, error) {
return nil, err
}

cc.bootstrapper.StartSyncingBlocks()
err = cc.bootstrapper.StartSyncingBlocks()
if err != nil {
return nil, err

Check warning on line 141 in factory/consensus/consensusComponents.go

View check run for this annotation

Codecov / codecov/patch

factory/consensus/consensusComponents.go#L141

Added line #L141 was not covered by tests
}

epoch := ccf.getEpoch()
consensusState, err := ccf.createConsensusState(epoch, cc.consensusGroupSize)
Expand Down Expand Up @@ -471,6 +477,7 @@ func (ccf *consensusComponentsFactory) createShardBootstrapper() (process.Bootst
HistoryRepo: ccf.processComponents.HistoryRepository(),
ScheduledTxsExecutionHandler: ccf.processComponents.ScheduledTxsExecutionHandler(),
ProcessWaitTime: time.Duration(ccf.config.GeneralSettings.SyncProcessTimeInMillis) * time.Millisecond,
RepopulateTokensSupplies: ccf.flagsConfig.RepopulateTokensSupplies,
}

argsShardBootstrapper := sync.ArgShardBootstrapper{
Expand Down Expand Up @@ -600,6 +607,7 @@ func (ccf *consensusComponentsFactory) createMetaChainBootstrapper() (process.Bo
HistoryRepo: ccf.processComponents.HistoryRepository(),
ScheduledTxsExecutionHandler: ccf.processComponents.ScheduledTxsExecutionHandler(),
ProcessWaitTime: time.Duration(ccf.config.GeneralSettings.SyncProcessTimeInMillis) * time.Millisecond,
RepopulateTokensSupplies: ccf.flagsConfig.RepopulateTokensSupplies,
}

argsMetaBootstrapper := sync.ArgMetaBootstrapper{
Expand Down
9 changes: 5 additions & 4 deletions factory/data/dataComponents.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ type DataComponentsFactoryArgs struct {
Core factory.CoreComponentsHolder
StatusCore factory.StatusCoreComponentsHolder
Crypto factory.CryptoComponentsHolder
FlagsConfigs config.ContextFlagsConfig
CurrentEpoch uint32
CreateTrieEpochRootHashStorer bool
NodeProcessingMode common.NodeProcessingMode
SnapshotsEnabled bool
}

type dataComponentsFactory struct {
Expand All @@ -40,10 +40,10 @@ type dataComponentsFactory struct {
core factory.CoreComponentsHolder
statusCore factory.StatusCoreComponentsHolder
crypto factory.CryptoComponentsHolder
flagsConfig config.ContextFlagsConfig
currentEpoch uint32
createTrieEpochRootHashStorer bool
nodeProcessingMode common.NodeProcessingMode
snapshotsEnabled bool
}

// dataComponents struct holds the data components
Expand Down Expand Up @@ -79,8 +79,8 @@ func NewDataComponentsFactory(args DataComponentsFactoryArgs) (*dataComponentsFa
statusCore: args.StatusCore,
currentEpoch: args.CurrentEpoch,
createTrieEpochRootHashStorer: args.CreateTrieEpochRootHashStorer,
flagsConfig: args.FlagsConfigs,
nodeProcessingMode: args.NodeProcessingMode,
snapshotsEnabled: args.SnapshotsEnabled,
crypto: args.Crypto,
}, nil
}
Expand Down Expand Up @@ -171,7 +171,8 @@ func (dcf *dataComponentsFactory) createDataStoreFromConfig() (dataRetriever.Sto
StorageType: storageFactory.ProcessStorageService,
CreateTrieEpochRootHashStorer: dcf.createTrieEpochRootHashStorer,
NodeProcessingMode: dcf.nodeProcessingMode,
SnapshotsEnabled: dcf.snapshotsEnabled,
SnapshotsEnabled: dcf.flagsConfig.SnapshotsEnabled,
RepopulateTokensSupplies: dcf.flagsConfig.RepopulateTokensSupplies,
ManagedPeersHolder: dcf.crypto.ManagedPeersHolder(),
})
if err != nil {
Expand Down

0 comments on commit b5c34c8

Please sign in to comment.