aboutsummaryrefslogtreecommitdiff
path: root/core/state_prefetcher.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/state_prefetcher.go')
-rw-r--r--core/state_prefetcher.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/core/state_prefetcher.go b/core/state_prefetcher.go
index 4997333..08a01e2 100644
--- a/core/state_prefetcher.go
+++ b/core/state_prefetcher.go
@@ -24,7 +24,7 @@ import (
"github.com/ava-labs/coreth/core/types"
"github.com/ava-labs/coreth/core/vm"
"github.com/ava-labs/coreth/params"
- "github.com/ava-labs/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/common"
)
// statePrefetcher is a basic Prefetcher, which blindly executes a block on top
@@ -54,6 +54,7 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c
gaspool = new(GasPool).AddGas(block.GasLimit())
)
// Iterate over and process the individual transactions
+ byzantium := p.config.IsByzantium(block.Number())
for i, tx := range block.Transactions() {
// If block precaching was interrupted, abort
if interrupt != nil && atomic.LoadUint32(interrupt) == 1 {
@@ -64,6 +65,14 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c
if err := precacheTransaction(p.config, p.bc, nil, gaspool, statedb, header, tx, cfg); err != nil {
return // Ugh, something went horribly wrong, bail out
}
+ // If we're pre-byzantium, pre-load trie nodes for the intermediate root
+ if !byzantium {
+ statedb.IntermediateRoot(true)
+ }
+ }
+ // If were post-byzantium, pre-load trie nodes for the final root hash
+ if byzantium {
+ statedb.IntermediateRoot(true)
}
}
@@ -80,6 +89,6 @@ func precacheTransaction(config *params.ChainConfig, bc ChainContext, author *co
context := NewEVMContext(msg, header, bc, author)
vm := vm.NewEVM(context, statedb, config, cfg)
- _, _, _, err = ApplyMessage(vm, msg, gaspool)
+ _, err = ApplyMessage(vm, msg, gaspool)
return err
}