Skip to content

Commit

Permalink
Merge pull request #2228 from CortexFoundation/dev
Browse files Browse the repository at this point in the history
remove precacheTransaction
  • Loading branch information
ucwong authored Dec 18, 2024
2 parents 7fee353 + 6bc9faa commit f0c67a8
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions core/state_prefetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c
return // Also invalid block, bail out
}
statedb.SetTxContext(tx.Hash(), i)
if err := precacheTransaction(msg, p.config, gaspool, quotaPool, statedb, header, cvm); err != nil {

// We attempt to apply a transaction. The goal is not to execute
// the transaction successfully, rather to warm up touched data slots.
if _, err := ApplyMessage(cvm, msg, gaspool, quotaPool); err != nil {
return // Ugh, something went horribly wrong, bail out
}
// If we're pre-byzantium, pre-load trie nodes for the intermediate root
Expand All @@ -85,13 +88,3 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c
statedb.IntermediateRoot(true)
}
}

// precacheTransaction attempts to apply a transaction to the given state database
// and uses the input parameters for its environment. The goal is not to execute
// the transaction successfully, rather to warm up touched data slots.
func precacheTransaction(msg *Message, config *params.ChainConfig, gaspool *GasPool, quotaPool *QuotaPool, statedb *state.StateDB, header *types.Header, cvm *vm.CVM) error {
cvm.Reset(NewCVMTxContext(msg), statedb)

_, err := ApplyMessage(cvm, msg, gaspool, quotaPool)
return err
}

0 comments on commit f0c67a8

Please sign in to comment.