aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-11-13 00:47:34 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-11-15 18:22:13 +0800
commit434dd5bc0067cdf604d84426df9086015721dd36 (patch)
tree279d85e32a36b8804d60c5a4b83b444514850782 /eth
parent9a000601c6c4e4f8134caedba1957ffe28d2b659 (diff)
downloaddexon-434dd5bc0067cdf604d84426df9086015721dd36.tar.gz
dexon-434dd5bc0067cdf604d84426df9086015721dd36.tar.zst
dexon-434dd5bc0067cdf604d84426df9086015721dd36.zip
cmd, core, eth, light, trie: add trie read caching layer
Diffstat (limited to 'eth')
-rw-r--r--eth/api.go6
-rw-r--r--eth/api_tracer.go4
-rw-r--r--eth/backend.go2
-rw-r--r--eth/config.go22
-rw-r--r--eth/gen_config.go28
5 files changed, 41 insertions, 21 deletions
diff --git a/eth/api.go b/eth/api.go
index 3ec3afb81..816b9cd33 100644
--- a/eth/api.go
+++ b/eth/api.go
@@ -444,16 +444,16 @@ func (api *PrivateDebugAPI) getModifiedAccounts(startBlock, endBlock *types.Bloc
if startBlock.Number().Uint64() >= endBlock.Number().Uint64() {
return nil, fmt.Errorf("start block height (%d) must be less than end block height (%d)", startBlock.Number().Uint64(), endBlock.Number().Uint64())
}
+ triedb := api.eth.BlockChain().StateCache().TrieDB()
- oldTrie, err := trie.NewSecure(startBlock.Root(), trie.NewDatabase(api.eth.chainDb), 0)
+ oldTrie, err := trie.NewSecure(startBlock.Root(), triedb, 0)
if err != nil {
return nil, err
}
- newTrie, err := trie.NewSecure(endBlock.Root(), trie.NewDatabase(api.eth.chainDb), 0)
+ newTrie, err := trie.NewSecure(endBlock.Root(), triedb, 0)
if err != nil {
return nil, err
}
-
diff, _ := trie.NewDifferenceIterator(oldTrie.NodeIterator([]byte{}), newTrie.NodeIterator([]byte{}))
iter := trie.NewIterator(diff)
diff --git a/eth/api_tracer.go b/eth/api_tracer.go
index 80552ada8..2ebbcc5fd 100644
--- a/eth/api_tracer.go
+++ b/eth/api_tracer.go
@@ -138,7 +138,7 @@ func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Bl
// Ensure we have a valid starting state before doing any work
origin := start.NumberU64()
- database := state.NewDatabase(api.eth.ChainDb())
+ database := state.NewDatabaseWithCache(api.eth.ChainDb(), 16) // Chain tracing will probably start at genesis
if number := start.NumberU64(); number > 0 {
start = api.eth.blockchain.GetBlock(start.ParentHash(), start.NumberU64()-1)
@@ -492,7 +492,7 @@ func (api *PrivateDebugAPI) computeStateDB(block *types.Block, reexec uint64) (*
}
// Otherwise try to reexec blocks until we find a state or reach our limit
origin := block.NumberU64()
- database := state.NewDatabase(api.eth.ChainDb())
+ database := state.NewDatabaseWithCache(api.eth.ChainDb(), 16)
for i := uint64(0); i < reexec; i++ {
block = api.eth.blockchain.GetBlock(block.ParentHash(), block.NumberU64()-1)
diff --git a/eth/backend.go b/eth/backend.go
index b555b064a..472140842 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -154,7 +154,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
EWASMInterpreter: config.EWASMInterpreter,
EVMInterpreter: config.EVMInterpreter,
}
- cacheConfig = &core.CacheConfig{Disabled: config.NoPruning, TrieNodeLimit: config.TrieCache, TrieTimeLimit: config.TrieTimeout}
+ cacheConfig = &core.CacheConfig{Disabled: config.NoPruning, TrieCleanLimit: config.TrieCleanCache, TrieDirtyLimit: config.TrieDirtyCache, TrieTimeLimit: config.TrieTimeout}
)
eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, eth.chainConfig, eth.engine, vmConfig, eth.shouldPreserve)
if err != nil {
diff --git a/eth/config.go b/eth/config.go
index e32c01a73..601f4735e 100644
--- a/eth/config.go
+++ b/eth/config.go
@@ -43,15 +43,16 @@ var DefaultConfig = Config{
DatasetsInMem: 1,
DatasetsOnDisk: 2,
},
- NetworkId: 1,
- LightPeers: 100,
- DatabaseCache: 768,
- TrieCache: 256,
- TrieTimeout: 60 * time.Minute,
- MinerGasFloor: 8000000,
- MinerGasCeil: 8000000,
- MinerGasPrice: big.NewInt(params.GWei),
- MinerRecommit: 3 * time.Second,
+ NetworkId: 1,
+ LightPeers: 100,
+ DatabaseCache: 512,
+ TrieCleanCache: 256,
+ TrieDirtyCache: 256,
+ TrieTimeout: 60 * time.Minute,
+ MinerGasFloor: 8000000,
+ MinerGasCeil: 8000000,
+ MinerGasPrice: big.NewInt(params.GWei),
+ MinerRecommit: 3 * time.Second,
TxPool: core.DefaultTxPoolConfig,
GPO: gasprice.Config{
@@ -94,7 +95,8 @@ type Config struct {
SkipBcVersionCheck bool `toml:"-"`
DatabaseHandles int `toml:"-"`
DatabaseCache int
- TrieCache int
+ TrieCleanCache int
+ TrieDirtyCache int
TrieTimeout time.Duration
// Mining-related options
diff --git a/eth/gen_config.go b/eth/gen_config.go
index d401a917d..2777aa9e8 100644
--- a/eth/gen_config.go
+++ b/eth/gen_config.go
@@ -28,7 +28,8 @@ func (c Config) MarshalTOML() (interface{}, error) {
SkipBcVersionCheck bool `toml:"-"`
DatabaseHandles int `toml:"-"`
DatabaseCache int
- TrieCache int
+ TrieCleanCache int
+ TrieDirtyCache int
TrieTimeout time.Duration
Etherbase common.Address `toml:",omitempty"`
MinerNotify []string `toml:",omitempty"`
@@ -43,6 +44,8 @@ func (c Config) MarshalTOML() (interface{}, error) {
GPO gasprice.Config
EnablePreimageRecording bool
DocRoot string `toml:"-"`
+ EWASMInterpreter string
+ EVMInterpreter string
}
var enc Config
enc.Genesis = c.Genesis
@@ -54,7 +57,8 @@ func (c Config) MarshalTOML() (interface{}, error) {
enc.SkipBcVersionCheck = c.SkipBcVersionCheck
enc.DatabaseHandles = c.DatabaseHandles
enc.DatabaseCache = c.DatabaseCache
- enc.TrieCache = c.TrieCache
+ enc.TrieCleanCache = c.TrieCleanCache
+ enc.TrieDirtyCache = c.TrieDirtyCache
enc.TrieTimeout = c.TrieTimeout
enc.Etherbase = c.Etherbase
enc.MinerNotify = c.MinerNotify
@@ -69,6 +73,8 @@ func (c Config) MarshalTOML() (interface{}, error) {
enc.GPO = c.GPO
enc.EnablePreimageRecording = c.EnablePreimageRecording
enc.DocRoot = c.DocRoot
+ enc.EWASMInterpreter = c.EWASMInterpreter
+ enc.EVMInterpreter = c.EVMInterpreter
return &enc, nil
}
@@ -84,7 +90,8 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
SkipBcVersionCheck *bool `toml:"-"`
DatabaseHandles *int `toml:"-"`
DatabaseCache *int
- TrieCache *int
+ TrieCleanCache *int
+ TrieDirtyCache *int
TrieTimeout *time.Duration
Etherbase *common.Address `toml:",omitempty"`
MinerNotify []string `toml:",omitempty"`
@@ -99,6 +106,8 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
GPO *gasprice.Config
EnablePreimageRecording *bool
DocRoot *string `toml:"-"`
+ EWASMInterpreter *string
+ EVMInterpreter *string
}
var dec Config
if err := unmarshal(&dec); err != nil {
@@ -131,8 +140,11 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
if dec.DatabaseCache != nil {
c.DatabaseCache = *dec.DatabaseCache
}
- if dec.TrieCache != nil {
- c.TrieCache = *dec.TrieCache
+ if dec.TrieCleanCache != nil {
+ c.TrieCleanCache = *dec.TrieCleanCache
+ }
+ if dec.TrieDirtyCache != nil {
+ c.TrieDirtyCache = *dec.TrieDirtyCache
}
if dec.TrieTimeout != nil {
c.TrieTimeout = *dec.TrieTimeout
@@ -176,5 +188,11 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
if dec.DocRoot != nil {
c.DocRoot = *dec.DocRoot
}
+ if dec.EWASMInterpreter != nil {
+ c.EWASMInterpreter = *dec.EWASMInterpreter
+ }
+ if dec.EVMInterpreter != nil {
+ c.EVMInterpreter = *dec.EVMInterpreter
+ }
return nil
}