diff --git a/eth/calltracer/calltracer.go b/eth/calltracer/calltracer.go index ca833a0ba1e..8afca5f6412 100644 --- a/eth/calltracer/calltracer.go +++ b/eth/calltracer/calltracer.go @@ -33,13 +33,13 @@ import ( type CallTracer struct { froms map[libcommon.Address]struct{} - tos map[libcommon.Address]bool // address -> isCreated + tos map[libcommon.Address]struct{} } func NewCallTracer() *CallTracer { return &CallTracer{ froms: make(map[libcommon.Address]struct{}), - tos: make(map[libcommon.Address]bool), + tos: make(map[libcommon.Address]struct{}), } } @@ -47,26 +47,16 @@ func (ct *CallTracer) CaptureTxStart(gasLimit uint64) {} func (ct *CallTracer) CaptureTxEnd(restGas uint64) {} // CaptureStart and CaptureEnter also capture SELFDESTRUCT opcode invocations -func (ct *CallTracer) captureStartOrEnter(from, to libcommon.Address, create bool, code []byte) { +func (ct *CallTracer) captureStartOrEnter(from, to libcommon.Address) { ct.froms[from] = struct{}{} - - created, ok := ct.tos[to] - if !ok { - ct.tos[to] = false - } - - if !created && create { - if len(code) > 0 { - ct.tos[to] = true - } - } + ct.froms[to] = struct{}{} } func (ct *CallTracer) CaptureStart(env *vm.EVM, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { - ct.captureStartOrEnter(from, to, create, code) + ct.captureStartOrEnter(from, to) } func (ct *CallTracer) CaptureEnter(typ vm.OpCode, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) { - ct.captureStartOrEnter(from, to, create, code) + ct.captureStartOrEnter(from, to) } func (ct *CallTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error) { } @@ -78,9 +68,9 @@ func (ct *CallTracer) CaptureExit(output []byte, usedGas uint64, err error) { } func (ct *CallTracer) WriteToDb(tx kv.StatelessWriteTx, block *types.Block, vmConfig vm.Config) error { - ct.tos[block.Coinbase()] = false + ct.tos[block.Coinbase()] = struct{}{} for _, uncle := range block.Uncles() { - ct.tos[uncle.Coinbase] = false + ct.tos[uncle.Coinbase] = struct{}{} } list := make(common.Addresses, len(ct.froms)+len(ct.tos)) i := 0