Skip to content

Commit e6d34c1

Browse files
authored
eth/tracers: fix prestateTracer for EIP-6780 SELFDESTRUCT (#33050)
fix #33049
1 parent 243407a commit e6d34c1

File tree

2 files changed

+110
-1
lines changed

2 files changed

+110
-1
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
{
2+
"context": {
3+
"difficulty": "0",
4+
"gasLimit": "8000000",
5+
"miner": "0x0000000000000000000000000000000000000000",
6+
"number": "1",
7+
"timestamp": "1000",
8+
"baseFeePerGas": "7"
9+
},
10+
"genesis": {
11+
"alloc": {
12+
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
13+
"balance": "0x10000000000000000",
14+
"nonce": "0",
15+
"code": "0x",
16+
"storage": {}
17+
},
18+
"0x1111111111111111111111111111111111111111": {
19+
"balance": "0x0",
20+
"nonce": "0",
21+
"code": "0x",
22+
"storage": {}
23+
},
24+
"0x2222222222222222222222222222222222222222": {
25+
"balance": "0xde0b6b3a7640000",
26+
"nonce": "1",
27+
"code": "0x6099600155731111111111111111111111111111111111111111ff",
28+
"storage": {
29+
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x000000000000000000000000000000000000000000000000000000000000abcd",
30+
"0x0000000000000000000000000000000000000000000000000000000000000002": "0x0000000000000000000000000000000000000000000000000000000000001234"
31+
}
32+
}
33+
},
34+
"config": {
35+
"chainId": 1,
36+
"homesteadBlock": 0,
37+
"eip150Block": 0,
38+
"eip155Block": 0,
39+
"eip158Block": 0,
40+
"byzantiumBlock": 0,
41+
"constantinopleBlock": 0,
42+
"petersburgBlock": 0,
43+
"istanbulBlock": 0,
44+
"berlinBlock": 0,
45+
"londonBlock": 0,
46+
"mergeNetsplitBlock": 0,
47+
"shanghaiTime": 0,
48+
"cancunTime": 0,
49+
"terminalTotalDifficulty": 0,
50+
"terminalTotalDifficultyPassed": true
51+
},
52+
"difficulty": "0",
53+
"extraData": "0x",
54+
"gasLimit": "8000000",
55+
"hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
56+
"miner": "0x0000000000000000000000000000000000000000",
57+
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
58+
"nonce": "0x0000000000000000",
59+
"number": "0",
60+
"stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
61+
"timestamp": "0"
62+
},
63+
"input": "0xf860800a830186a094222222222222222222222222222222222222222280801ba0c4829400221936e8016721406f84b4710ead5608f15c785a3cedc20a7aebaab2a033e8e6e12cc432098b5ce8a409691f977867249073a3fc7804e8676c4d159475",
64+
"tracerConfig": {
65+
"diffMode": true
66+
},
67+
"result": {
68+
"pre": {
69+
"0x2222222222222222222222222222222222222222": {
70+
"balance": "0xde0b6b3a7640000",
71+
"nonce": 1,
72+
"code": "0x6099600155731111111111111111111111111111111111111111ff",
73+
"codeHash": "0x701bdb1d43777a9304905a100f758955d130e09c8e86d97e3f6becccdc001048",
74+
"storage": {
75+
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x000000000000000000000000000000000000000000000000000000000000abcd"
76+
}
77+
},
78+
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
79+
"balance": "0x10000000000000000"
80+
}
81+
},
82+
"post": {
83+
"0x0000000000000000000000000000000000000000": {
84+
"balance": "0x2aed3"
85+
},
86+
"0x1111111111111111111111111111111111111111": {
87+
"balance": "0xde0b6b3a7640000"
88+
},
89+
"0x2222222222222222222222222222222222222222": {
90+
"balance": "0x0",
91+
"storage": {
92+
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000099"
93+
}
94+
},
95+
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
96+
"balance": "0xfffffffffff70e96",
97+
"nonce": 1
98+
}
99+
}
100+
}
101+
}

eth/tracers/native/prestate.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,15 @@ func (t *prestateTracer) OnOpcode(pc uint64, opcode byte, gas, cost uint64, scop
131131
addr := common.Address(stackData[stackLen-1].Bytes20())
132132
t.lookupAccount(addr)
133133
if op == vm.SELFDESTRUCT {
134-
t.deleted[caller] = true
134+
if t.chainConfig.IsCancun(t.env.BlockNumber, t.env.Time) {
135+
// EIP-6780: only delete if created in same transaction
136+
if t.created[caller] {
137+
t.deleted[caller] = true
138+
}
139+
} else {
140+
// Pre-EIP-6780: always delete
141+
t.deleted[caller] = true
142+
}
135143
}
136144
case stackLen >= 5 && (op == vm.DELEGATECALL || op == vm.CALL || op == vm.STATICCALL || op == vm.CALLCODE):
137145
addr := common.Address(stackData[stackLen-2].Bytes20())

0 commit comments

Comments
 (0)