modifications made in service of block tracer

This commit is contained in:
philip-morlier
2021-11-05 17:26:53 -07:00
parent f18c3be78f
commit 9ac78685b3
7 changed files with 724 additions and 213 deletions
+9
View File
@@ -71,29 +71,38 @@ 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
vmenv := vm.NewEVM(blockContext, vm.TxContext{}, statedb, p.config, cfg)
// Iterate over and process the individual transactions
pluginPreProcessBlock(block)
blockTracer.PreProcessBlock(block)
for i, tx := range block.Transactions() {
msg, err := tx.AsMessage(types.MakeSigner(p.config, header.Number), header.BaseFee)
if err != nil {
pluginBlockProcessingError(tx, block, err)
blockTracer.BlockProcessingError(tx, block, err)
return nil, nil, 0, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err)
}
statedb.Prepare(tx.Hash(), i)
pluginPreProcessTransaction(tx, block, i)
blockTracer.PreProcessTransaction(tx, block, i)
receipt, err := applyTransaction(msg, p.config, p.bc, nil, gp, statedb, blockNumber, blockHash, tx, usedGas, vmenv)
if err != nil {
pluginBlockProcessingError(tx, block, err)
blockTracer.BlockProcessingError(tx, block, err)
return nil, nil, 0, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err)
}
pluginPostProcessTransaction(tx, block, i, receipt)
blockTracer.PostProcessTransaction(tx, block, i, receipt)
receipts = append(receipts, receipt)
allLogs = append(allLogs, receipt.Logs...)
}
// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
p.engine.Finalize(p.bc, header, statedb, block.Transactions(), block.Uncles())
pluginPostProcessBlock(block)
blockTracer.PostProcessBlock(block)
return receipts, allLogs, *usedGas, nil
}