2022-11-03 04:32:15 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
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/types"
|
|
|
|
"github.com/ledgerwatch/erigon/core/vm"
|
|
|
|
)
|
|
|
|
|
|
|
|
type CreateTracer struct {
|
|
|
|
DefaultTracer
|
|
|
|
ctx context.Context
|
|
|
|
target common.Address
|
|
|
|
found bool
|
|
|
|
Creator common.Address
|
|
|
|
Tx types.Transaction
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewCreateTracer(ctx context.Context, target common.Address) *CreateTracer {
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2022-12-18 16:11:31 +00:00
|
|
|
func (t *CreateTracer) captureStartOrEnter(from, to common.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
|
|
|
|
2022-12-19 03:12:08 +00:00
|
|
|
func (t *CreateTracer) 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, create)
|
|
|
|
}
|
|
|
|
|
2022-12-19 03:12:08 +00:00
|
|
|
func (t *CreateTracer) 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, create)
|
|
|
|
}
|