diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index d13682d0c3..6e0f5eb579 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -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 diff --git a/core/blockchain.go b/core/blockchain.go index 9d123fc9e8..17d066cfe7 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -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 @@ -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 } diff --git a/eth/backend.go b/eth/backend.go index ed1132bcc2..a6f4bc371a 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -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) diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index b9a999e62b..e486f915b0 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -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.