Avoid unnecessary RLP encoding

While looking for the source of a memory leak, I decided to optimize
the metatracer to avoid encoding values when there weren't any tracers
configured to received the encoded values.

I also avoided putting the EVM into debug mode when there weren't any
tracers configured.

None of these fixed the memory leak, but they still seem like good
practices. Memory leak fix is in the next commit.
This commit is contained in:
Austin Roberts
2022-01-07 11:34:07 -06:00
parent 13009f4c51
commit 1201e7c4f8
2 changed files with 13 additions and 6 deletions
+5 -3
View File
@@ -71,9 +71,11 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
misc.ApplyDAOHardFork(statedb)
}
blockContext := NewEVMBlockContext(header, p.bc, nil)
blockTracer := pluginGetBlockTracer(header.Hash(), statedb)
cfg.Tracer = blockTracer
cfg.Debug = true
blockTracer, ok := pluginGetBlockTracer(header.Hash(), statedb)
if ok {
cfg.Tracer = blockTracer
cfg.Debug = true
}
vmenv := vm.NewEVM(blockContext, vm.TxContext{}, statedb, p.config, cfg)
// Iterate over and process the individual transactions
pluginPreProcessBlock(block)