From 2c3f947b7a0657a8358fc1e885e60ac4b9cfac4b Mon Sep 17 00:00:00 2001 From: Delweng Date: Thu, 5 Sep 2024 09:49:02 +0800 Subject: [PATCH] feat(eth/calltracer): the captured to address's value is not used (#11722) As the value for each to address is not used, keep the same logic for `froms` and `tos`, --------- Signed-off-by: jsvisa --- eth/calltracer/calltracer.go | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) 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