2022-11-03 04:32:15 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
|
2022-11-30 01:31:39 +00:00
|
|
|
"github.com/holiman/uint256"
|
2023-01-13 18:12:18 +00:00
|
|
|
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
|
|
|
|
2022-11-03 04:32:15 +00:00
|
|
|
"github.com/ledgerwatch/erigon/core/vm"
|
|
|
|
)
|
|
|
|
|
|
|
|
type TouchTracer struct {
|
|
|
|
DefaultTracer
|
2023-01-13 18:12:18 +00:00
|
|
|
searchAddr libcommon.Address
|
2022-11-03 04:32:15 +00:00
|
|
|
Found bool
|
|
|
|
}
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
func NewTouchTracer(searchAddr libcommon.Address) *TouchTracer {
|
2022-11-03 04:32:15 +00:00
|
|
|
return &TouchTracer{
|
|
|
|
searchAddr: searchAddr,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
func (t *TouchTracer) captureStartOrEnter(from, to libcommon.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
|
|
|
|
2023-01-16 22:28:50 +00:00
|
|
|
func (t *TouchTracer) CaptureStart(env vm.VMInterface, from libcommon.Address, to libcommon.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)
|
|
|
|
}
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
func (t *TouchTracer) CaptureEnter(typ vm.OpCode, from libcommon.Address, to libcommon.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)
|
|
|
|
}
|