2022-11-03 04:32:15 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
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/types"
|
|
|
|
"github.com/ledgerwatch/erigon/core/vm"
|
|
|
|
)
|
|
|
|
|
|
|
|
type CreateTracer struct {
|
|
|
|
DefaultTracer
|
|
|
|
ctx context.Context
|
2023-01-13 18:12:18 +00:00
|
|
|
target libcommon.Address
|
2022-11-03 04:32:15 +00:00
|
|
|
found bool
|
2023-01-13 18:12:18 +00:00
|
|
|
Creator libcommon.Address
|
2022-11-03 04:32:15 +00:00
|
|
|
Tx types.Transaction
|
|
|
|
}
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
func NewCreateTracer(ctx context.Context, target libcommon.Address) *CreateTracer {
|
2022-11-03 04:32:15 +00:00
|
|
|
return &CreateTracer{
|
|
|
|
ctx: ctx,
|
|
|
|
target: target,
|
|
|
|
found: false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *CreateTracer) SetTransaction(tx types.Transaction) {
|
|
|
|
t.Tx = tx
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *CreateTracer) Found() bool {
|
|
|
|
return t.found
|
|
|
|
}
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
func (t *CreateTracer) captureStartOrEnter(from, to libcommon.Address, create bool) {
|
2022-11-03 04:32:15 +00:00
|
|
|
if t.found {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if !create {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if to != t.target {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
t.found = true
|
|
|
|
t.Creator = from
|
|
|
|
}
|
2022-12-18 16:11:31 +00:00
|
|
|
|
2023-01-16 22:28:50 +00:00
|
|
|
func (t *CreateTracer) 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, create)
|
|
|
|
}
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
func (t *CreateTracer) 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, create)
|
|
|
|
}
|