mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 02:40:45 +00:00
Implement https://github.com/ethereum/go-ethereum/issues/32078 Parse and lookup the delegation account if EIP7702 is enabled. --------- Signed-off-by: jsvisa <delweng@gmail.com> Co-authored-by: Delweng <delweng@gmail.com>
This commit is contained in:
parent
256c76d025
commit
510be504ef
3 changed files with 197 additions and 14 deletions
163
eth/tracers/internal/tracetest/testdata/prestate_tracer/7702_delegate.json
vendored
Normal file
163
eth/tracers/internal/tracetest/testdata/prestate_tracer/7702_delegate.json
vendored
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -67,6 +67,10 @@
|
||||||
"0x0000000000000000000000000000000000000000": {
|
"0x0000000000000000000000000000000000000000": {
|
||||||
"balance": "0x272e0528"
|
"balance": "0x272e0528"
|
||||||
},
|
},
|
||||||
|
"0x000000000000000000000000000000000000bbbb": {
|
||||||
|
"balance": "0x0",
|
||||||
|
"code": "0x6042604255"
|
||||||
|
},
|
||||||
"0x703c4b2bd70c169f5717101caee543299fc946c7": {
|
"0x703c4b2bd70c169f5717101caee543299fc946c7": {
|
||||||
"balance": "0xde0b6b3a7640000",
|
"balance": "0xde0b6b3a7640000",
|
||||||
"storage": {
|
"storage": {
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@ type prestateTracer struct {
|
||||||
post stateMap
|
post stateMap
|
||||||
to common.Address
|
to common.Address
|
||||||
config prestateTracerConfig
|
config prestateTracerConfig
|
||||||
|
chainConfig *params.ChainConfig
|
||||||
interrupt atomic.Bool // Atomic flag to signal execution interruption
|
interrupt atomic.Bool // Atomic flag to signal execution interruption
|
||||||
reason error // Textual reason for the interruption
|
reason error // Textual reason for the interruption
|
||||||
created map[common.Address]bool
|
created map[common.Address]bool
|
||||||
|
|
@ -86,6 +87,7 @@ func newPrestateTracer(ctx *tracers.Context, cfg json.RawMessage, chainConfig *p
|
||||||
pre: stateMap{},
|
pre: stateMap{},
|
||||||
post: stateMap{},
|
post: stateMap{},
|
||||||
config: config,
|
config: config,
|
||||||
|
chainConfig: chainConfig,
|
||||||
created: make(map[common.Address]bool),
|
created: make(map[common.Address]bool),
|
||||||
deleted: make(map[common.Address]bool),
|
deleted: make(map[common.Address]bool),
|
||||||
}
|
}
|
||||||
|
|
@ -126,6 +128,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 the delegation target
|
||||||
|
if t.chainConfig.IsPrague(t.env.BlockNumber) {
|
||||||
|
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)
|
||||||
|
|
@ -154,6 +163,13 @@ func (t *prestateTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction
|
||||||
t.created[t.to] = true
|
t.created[t.to] = true
|
||||||
} else {
|
} else {
|
||||||
t.to = *tx.To()
|
t.to = *tx.To()
|
||||||
|
// Lookup the delegation target
|
||||||
|
if t.chainConfig.IsPrague(t.env.BlockNumber) {
|
||||||
|
code := t.env.StateDB.GetCode(t.to)
|
||||||
|
if target, ok := types.ParseDelegation(code); ok {
|
||||||
|
t.lookupAccount(target)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t.lookupAccount(from)
|
t.lookupAccount(from)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue