Skip to content

Commit aed705b

Browse files
committed
eth/tracers: add support for setcode tx in prestate tracer
1 parent e98e686 commit aed705b

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"genesis": {
3+
"baseFeePerGas": "7",
4+
"blobGasUsed": "0",
5+
"difficulty": "0",
6+
"excessBlobGas": "36306944",
7+
"extraData": "0xd983010e00846765746888676f312e32312e308664617277696e",
8+
"gasLimit": "15639172",
9+
"hash": "0xc682259fda061bb9ce8ccb491d5b2d436cb73daf04e1025dd116d045ce4ad28c",
10+
"miner": "0x0000000000000000000000000000000000000000",
11+
"mixHash": "0xae1a5ba939a4c9ac38aabeff361169fb55a6fc2c9511457e0be6eff9514faec0",
12+
"nonce": "0x0000000000000000",
13+
"number": "315",
14+
"parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
15+
"stateRoot": "0x577f42ab21ccfd946511c57869ace0bdf7c217c36f02b7cd3459df0ed1cffc1a",
16+
"timestamp": "1709626771",
17+
"withdrawals": [],
18+
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
19+
"alloc": {
20+
"0x0000000000000000000000000000000000000000": {
21+
"balance": "0x272e0528"
22+
},
23+
"0x000000000000000000000000000000000000aaaa": {
24+
"code": "0x6000600060006000600173703c4b2bd70c169f5717101caee543299fc946c75af1",
25+
"balance": "0x0"
26+
},
27+
"0x000000000000000000000000000000000000bbbb": {
28+
"code": "0x6042604255",
29+
"balance": "0x0"
30+
},
31+
"0x703c4b2bd70c169f5717101caee543299fc946c7": {
32+
"balance": "0xde0b6b3a7640000"
33+
},
34+
"0x71562b71999873db5b286df957af199ec94617f7": {
35+
"balance": "0xde0b6b3a7640000"
36+
}
37+
},
38+
"config": {
39+
"chainId": 1337,
40+
"homesteadBlock": 0,
41+
"eip150Block": 0,
42+
"eip155Block": 0,
43+
"eip158Block": 0,
44+
"byzantiumBlock": 0,
45+
"constantinopleBlock": 0,
46+
"petersburgBlock": 0,
47+
"istanbulBlock": 0,
48+
"muirGlacierBlock": 0,
49+
"berlinBlock": 0,
50+
"londonBlock": 0,
51+
"arrowGlacierBlock": 0,
52+
"grayGlacierBlock": 0,
53+
"shanghaiTime": 0,
54+
"cancunTime": 0,
55+
"pragueTime": 0,
56+
"terminalTotalDifficulty": 0
57+
}
58+
},
59+
"context": {
60+
"number": "316",
61+
"difficulty": "0",
62+
"timestamp": "1709626785",
63+
"gasLimit": "15654443",
64+
"miner": "0x0000000000000000000000000000000000000000",
65+
"baseFeePerGas": "7"
66+
},
67+
"input": "04f90126820539800285012a05f2008307a1209471562b71999873db5b286df957af199ec94617f78080c0f8baf85c82053994000000000000000000000000000000000000aaaa0101a07ed17af7d2d2b9ba7d797a202125bf505b9a0f962a67b3b61b56783d8faf7461a001b73b6e586edc706dce6c074eaec28692fa6359fb3446a2442f36777e1c0669f85a8094000000000000000000000000000000000000bbbb8001a05011890f198f0356a887b0779bde5afa1ed04e6acb1e3f37f8f18c7b6f521b98a056c3fa3456b103f3ef4a0acb4b647b9cab9ec4bc68fbcdf1e10b49fb2bcbcf6101a0167b0ecfc343a497095c22ee4270d3cc3b971cc3599fc73bbff727e0d2ed432da01c003c72306807492bf1150e39b2f79da23b49a4e83eb6e9209ae30d3572368f",
68+
"result": {
69+
"0x0000000000000000000000000000000000000000": {
70+
"balance": "0x272e0528"
71+
},
72+
"0x703c4b2bd70c169f5717101caee543299fc946c7": {
73+
"balance": "0xde0b6b3a7640000",
74+
"storage": {
75+
"0x0000000000000000000000000000000000000000000000000000000000000042": "0x0000000000000000000000000000000000000000000000000000000000000000"
76+
}
77+
},
78+
"0x71562b71999873db5b286df957af199ec94617f7": {
79+
"balance": "0xde0b6b3a7640000"
80+
}
81+
}
82+
}

eth/tracers/native/prestate.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,15 @@ func (t *prestateTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction
159159
t.lookupAccount(from)
160160
t.lookupAccount(t.to)
161161
t.lookupAccount(env.Coinbase)
162+
163+
// Add accounts with authorizations to the prestate before they get applied.
164+
for _, auth := range tx.AuthList() {
165+
addr, err := auth.Authority()
166+
if err != nil {
167+
continue
168+
}
169+
t.lookupAccount(addr)
170+
}
162171
}
163172

164173
func (t *prestateTracer) OnTxEnd(receipt *types.Receipt, err error) {

0 commit comments

Comments
 (0)