Skip to content

Commit

Permalink
flags.go: add ConcurrentUpdateThresholdFlag
Browse files Browse the repository at this point in the history
config.go: add ConcurrentUpdateThreshold flag
blockchain: add ConcurrentUpdateThreshold flag to cacheConfig
backend.go: init ConcurrentUpdateThreshold flag of the cacheConfig
flags.go: add ConcurrentUpdateThresholdFlag
  • Loading branch information
Francesco4203 committed May 21, 2024
1 parent 324ccbd commit 70ae86c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
7 changes: 7 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,13 @@ var (
Usage: "List of mock bls public keys which are reflect 1:1 with mock.validators",
Category: flags.MockCategory,
}

ConcurrentUpdateThresholdFlag = &cli.IntFlag{
Name: "concurrencyupdatethreashold",
Usage: "The threshold of concurrent update",
Value: 0, // disable concurrent update by default
Category: flags.EthCategory,
}
)

// MakeDataDir retrieves the currently requested data directory, terminating
Expand Down
4 changes: 4 additions & 0 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ type CacheConfig struct {
TriesInMemory int // The number of tries is kept in memory before pruning

SnapshotWait bool // Wait for snapshot construction on startup. TODO(karalabe): This is a dirty hack for testing, nuke it

// Minimum stateObjects (updating accounts) to apply concurrent updates, 0 to disable
ConcurrentUpdateThreshold int
}

// defaultCacheConfig are the default caching values if none are specified by the
Expand Down Expand Up @@ -1814,6 +1817,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
parent = bc.GetHeader(block.ParentHash(), block.NumberU64()-1)
}
statedb, err := state.New(parent.Root, bc.stateCache, bc.snaps)
statedb.ConcurrentUpdateThreshold = bc.cacheConfig.ConcurrentUpdateThreshold
if err != nil {
return it.index, err
}
Expand Down
21 changes: 11 additions & 10 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,17 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
EnablePreimageRecording: config.EnablePreimageRecording,
}
cacheConfig = &core.CacheConfig{
TrieCleanLimit: config.TrieCleanCache,
TrieCleanJournal: stack.ResolvePath(config.TrieCleanCacheJournal),
TrieCleanRejournal: config.TrieCleanCacheRejournal,
TrieCleanNoPrefetch: config.NoPrefetch,
TrieDirtyLimit: config.TrieDirtyCache,
TrieDirtyDisabled: config.NoPruning,
TrieTimeLimit: config.TrieTimeout,
SnapshotLimit: config.SnapshotCache,
Preimages: config.Preimages,
TriesInMemory: config.TriesInMemory,
TrieCleanLimit: config.TrieCleanCache,
TrieCleanJournal: stack.ResolvePath(config.TrieCleanCacheJournal),
TrieCleanRejournal: config.TrieCleanCacheRejournal,
TrieCleanNoPrefetch: config.NoPrefetch,
TrieDirtyLimit: config.TrieDirtyCache,
TrieDirtyDisabled: config.NoPruning,
TrieTimeLimit: config.TrieTimeout,
SnapshotLimit: config.SnapshotCache,
Preimages: config.Preimages,
TriesInMemory: config.TriesInMemory,
ConcurrentUpdateThreshold: config.ConcurrentUpdateThreshold,
}
)
eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, chainConfig, eth.engine, vmConfig, eth.shouldPreserve, &config.TxLookupLimit)
Expand Down
3 changes: 3 additions & 0 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ type Config struct {

// Send additional chain event
EnableAdditionalChainEvent bool

// Minimum stateObjects (updating accounts) to apply concurrent updates, 0 to disable
ConcurrentUpdateThreshold int
}

// CreateConsensusEngine creates a consensus engine for the given chain configuration.
Expand Down

0 comments on commit 70ae86c

Please sign in to comment.