Skip to content

Commit

Permalink
feat(eth/calltracer): the captured to address's value is not used (#1…
Browse files Browse the repository at this point in the history
…1722)

As the value for each to address is not used, keep the same logic for
`froms` and `tos`,

---------

Signed-off-by: jsvisa <[email protected]>
  • Loading branch information
jsvisa authored Sep 5, 2024
1 parent 7a7fbec commit 2c3f947
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions eth/calltracer/calltracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,40 +33,30 @@ 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{}),
}
}

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) {
}
Expand All @@ -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
Expand Down

0 comments on commit 2c3f947

Please sign in to comment.