Skip to content

Commit 0b1a39c

Browse files
committed
Tests for initcode size limit with CREATE2 opcode
1 parent c672f7b commit 0b1a39c

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# CREATE2 with max allowed init code size
2+
create2InitCodeSizeLimit:
3+
env:
4+
currentCoinbase: 2adc25665018aa1fe0e6bc666dac8fc2697ff9ba
5+
currentDifficulty: '0x020000'
6+
currentGasLimit: '20000000'
7+
currentBaseFee: '10'
8+
currentNumber: '1'
9+
currentTimestamp: '1000'
10+
previousHash: 5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6
11+
12+
pre:
13+
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
14+
balance: 200000000
15+
code: ''
16+
nonce: 0
17+
storage: {}
18+
b94f5374fce5edbc8e2a8697c15331677e6ebf0b:
19+
balance: 0
20+
code: |
21+
:yul
22+
{
23+
// :yul { codecopy(0x00, 0x00, 0x0a) return(0x00, 0x0a) }
24+
mstore(0, 0x600a80600080396000f300000000000000000000000000000000000000000000)
25+
// get initcode size from calldata
26+
let initcode_size := calldataload(0)
27+
let gas_before := gas()
28+
let create_result := create2(0, 0, initcode_size, 0)
29+
sstore(10, sub(gas_before, gas()))
30+
sstore(0, create_result)
31+
sstore(1, 1)
32+
}
33+
nonce: 0
34+
storage: {}
35+
36+
transaction:
37+
data:
38+
# Valid initcode size = 49152 bytes
39+
- ':label valid :raw 0x000000000000000000000000000000000000000000000000000000000000c000'
40+
# Invalid initcode size = 49153 bytes
41+
- ':label invalid :raw 0x000000000000000000000000000000000000000000000000000000000000c001'
42+
gasLimit:
43+
- 15000000
44+
gasPrice: 10
45+
nonce: 0
46+
secretKey: 45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8
47+
to: 'b94f5374fce5edbc8e2a8697c15331677e6ebf0b'
48+
value:
49+
- 0
50+
51+
expect:
52+
- indexes:
53+
data: ':label valid'
54+
network:
55+
- 'Merge'
56+
result:
57+
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
58+
nonce: 1
59+
b94f5374fce5edbc8e2a8697c15331677e6ebf0b:
60+
storage:
61+
'0': '7b453b2ba212f731bec025f8f441f01547d79bfb'
62+
'1': 1
63+
'10': 52467
64+
7b453b2ba212f731bec025f8f441f01547d79bfb:
65+
balance: 0
66+
code: '0x600a80600080396000f3'
67+
nonce: 1
68+
storage: {}
69+
70+
- indexes:
71+
data: ':label invalid'
72+
network:
73+
- 'Merge'
74+
result:
75+
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
76+
nonce: 1
77+
b94f5374fce5edbc8e2a8697c15331677e6ebf0b:
78+
storage:
79+
'0': '094147686c565aa7ccac18000c3b7b4d099f92d3'
80+
'1': 1
81+
'10': 52482
82+
094147686c565aa7ccac18000c3b7b4d099f92d3:
83+
balance: 0
84+
code: '0x600a80600080396000f3'
85+
nonce: 1
86+
storage: {}
87+
88+
- indexes:
89+
data: ':label valid'
90+
network:
91+
- 'Merge+3860'
92+
result:
93+
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
94+
nonce: 1
95+
b94f5374fce5edbc8e2a8697c15331677e6ebf0b:
96+
storage:
97+
'0': '7b453b2ba212f731bec025f8f441f01547d79bfb'
98+
'1': 1
99+
# Difference with Merge is the charge for initcode 49152 // 32 * 2 = 3072 gas
100+
'10': 55539
101+
7b453b2ba212f731bec025f8f441f01547d79bfb:
102+
balance: 0
103+
code: '0x600a80600080396000f3'
104+
nonce: 1
105+
storage: {}
106+
107+
- indexes:
108+
data: ':label invalid'
109+
network:
110+
- 'Merge+3860'
111+
result:
112+
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
113+
nonce: 1
114+
b94f5374fce5edbc8e2a8697c15331677e6ebf0b:
115+
storage:
116+
'0': 0
117+
'1': 1
118+
'10': 53532
119+
094147686c565aa7ccac18000c3b7b4d099f92d3:
120+
shouldnotexist: 1

0 commit comments

Comments
 (0)