mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
eth/tracers: lookup EIP7702 delegation code
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
b62c0c67fa
commit
041b52b00a
1 changed files with 23 additions and 14 deletions
|
|
@ -61,15 +61,16 @@ type accountMarshaling struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type prestateTracer struct {
|
type prestateTracer struct {
|
||||||
env *tracing.VMContext
|
env *tracing.VMContext
|
||||||
pre stateMap
|
pre stateMap
|
||||||
post stateMap
|
post stateMap
|
||||||
to common.Address
|
to common.Address
|
||||||
config prestateTracerConfig
|
config prestateTracerConfig
|
||||||
interrupt atomic.Bool // Atomic flag to signal execution interruption
|
chainConfig *params.ChainConfig
|
||||||
reason error // Textual reason for the interruption
|
interrupt atomic.Bool // Atomic flag to signal execution interruption
|
||||||
created map[common.Address]bool
|
reason error // Textual reason for the interruption
|
||||||
deleted map[common.Address]bool
|
created map[common.Address]bool
|
||||||
|
deleted map[common.Address]bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type prestateTracerConfig struct {
|
type prestateTracerConfig struct {
|
||||||
|
|
@ -90,11 +91,12 @@ func newPrestateTracer(ctx *tracers.Context, cfg json.RawMessage, chainConfig *p
|
||||||
return nil, errors.New("cannot use diffMode with includeEmpty")
|
return nil, errors.New("cannot use diffMode with includeEmpty")
|
||||||
}
|
}
|
||||||
t := &prestateTracer{
|
t := &prestateTracer{
|
||||||
pre: stateMap{},
|
pre: stateMap{},
|
||||||
post: stateMap{},
|
post: stateMap{},
|
||||||
config: config,
|
config: config,
|
||||||
created: make(map[common.Address]bool),
|
chainConfig: chainConfig,
|
||||||
deleted: make(map[common.Address]bool),
|
created: make(map[common.Address]bool),
|
||||||
|
deleted: make(map[common.Address]bool),
|
||||||
}
|
}
|
||||||
return &tracers.Tracer{
|
return &tracers.Tracer{
|
||||||
Hooks: &tracing.Hooks{
|
Hooks: &tracing.Hooks{
|
||||||
|
|
@ -133,6 +135,13 @@ func (t *prestateTracer) OnOpcode(pc uint64, opcode byte, gas, cost uint64, scop
|
||||||
case stackLen >= 5 && (op == vm.DELEGATECALL || op == vm.CALL || op == vm.STATICCALL || op == vm.CALLCODE):
|
case stackLen >= 5 && (op == vm.DELEGATECALL || op == vm.CALL || op == vm.STATICCALL || op == vm.CALLCODE):
|
||||||
addr := common.Address(stackData[stackLen-2].Bytes20())
|
addr := common.Address(stackData[stackLen-2].Bytes20())
|
||||||
t.lookupAccount(addr)
|
t.lookupAccount(addr)
|
||||||
|
// Lookup a delegation target
|
||||||
|
if t.chainConfig.IsPrague(t.env.BlockNumber, t.env.Time) {
|
||||||
|
code := t.env.StateDB.GetCode(addr)
|
||||||
|
if target, ok := types.ParseDelegation(code); ok {
|
||||||
|
t.lookupAccount(target)
|
||||||
|
}
|
||||||
|
}
|
||||||
case op == vm.CREATE:
|
case op == vm.CREATE:
|
||||||
nonce := t.env.StateDB.GetNonce(caller)
|
nonce := t.env.StateDB.GetNonce(caller)
|
||||||
addr := crypto.CreateAddress(caller, nonce)
|
addr := crypto.CreateAddress(caller, nonce)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue