2022-11-03 04:32:15 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
|
2022-11-30 01:31:39 +00:00
|
|
|
"github.com/holiman/uint256"
|
2022-11-03 04:32:15 +00:00
|
|
|
"github.com/ledgerwatch/erigon/common"
|
|
|
|
"github.com/ledgerwatch/erigon/core/vm"
|
|
|
|
)
|
|
|
|
|
|
|
|
type TouchTracer struct {
|
|
|
|
DefaultTracer
|
|
|
|
searchAddr common.Address
|
|
|
|
Found bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewTouchTracer(searchAddr common.Address) *TouchTracer {
|
|
|
|
return &TouchTracer{
|
|
|
|
searchAddr: searchAddr,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-18 16:11:31 +00:00
|
|
|
func (t *TouchTracer) captureStartOrEnter(from, to common.Address) {
|
2022-11-03 04:32:15 +00:00
|
|
|
if !t.Found && (bytes.Equal(t.searchAddr.Bytes(), from.Bytes()) || bytes.Equal(t.searchAddr.Bytes(), to.Bytes())) {
|
|
|
|
t.Found = true
|
|
|
|
}
|
|
|
|
}
|
2022-12-18 16:11:31 +00:00
|
|
|
|
2022-12-19 03:12:08 +00:00
|
|
|
func (t *TouchTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) {
|
2022-12-18 16:11:31 +00:00
|
|
|
t.captureStartOrEnter(from, to)
|
|
|
|
}
|
|
|
|
|
2022-12-19 03:12:08 +00:00
|
|
|
func (t *TouchTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) {
|
2022-12-18 16:11:31 +00:00
|
|
|
t.captureStartOrEnter(from, to)
|
|
|
|
}
|