Skip to content

Commit e49d60f

Browse files
committed
fix(tests): Adjust to container size limit
1 parent 9b00eb1 commit e49d60f

File tree

3 files changed

+37
-33
lines changed

3 files changed

+37
-33
lines changed

tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_container_size.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ def test_max_size(
3030
"""
3131
Verify EOF container valid at maximum size, invalid above
3232
"""
33-
minimal_code = bytearray(bytes(VALID_CONTAINER))
3433
# Expand the minimal EOF code by more noop code, reaching the desired target container size.
3534
code = Container(
3635
sections=[
3736
Section.Code(
38-
code=Op.JUMPDEST * (MAX_INITCODE_SIZE - len(minimal_code) + over_limit) + Op.STOP
37+
code=Op.JUMPDEST * (MAX_INITCODE_SIZE - len(VALID_CONTAINER) + over_limit)
38+
+ Op.STOP
3939
)
4040
]
4141
)

tests/prague/eip7692_eof_v1/eip7480_data_section/test_code_validation.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717

1818
pytestmark = pytest.mark.valid_from(EOF_FORK_NAME)
1919

20+
smallest_runtime_subcontainer = Container(
21+
name="Runtime Subcontainer",
22+
sections=[
23+
Section.Code(code=Op.STOP),
24+
],
25+
)
26+
2027
VALID: List[Container] = [
2128
Container(
2229
name="empty_data_section",
@@ -51,11 +58,9 @@
5158
Container(
5259
name="max_data_section",
5360
sections=[
54-
Section.Code(
55-
code=Op.ADDRESS + Op.POP + Op.STOP,
56-
max_stack_height=1,
57-
),
58-
Section.Data(data=("1122334455667788" * 8 * 1024)[2:]),
61+
Section.Code(code=Op.STOP),
62+
# Hits the 49152 bytes limit for the entire container
63+
Section.Data(data=(b"12345678" * 6 * 1024)[len(smallest_runtime_subcontainer) :]),
5964
],
6065
),
6166
Container(
@@ -88,16 +93,6 @@
8893
Section.Data(data="1122334455667788" * 16),
8994
],
9095
),
91-
Container(
92-
name="DATALOADN_max",
93-
sections=[
94-
Section.Code(
95-
code=Op.DATALOADN[0xFFFF - 32] + Op.POP + Op.STOP,
96-
max_stack_height=1,
97-
),
98-
Section.Data(data=("1122334455667788" * 8 * 1024)[2:]),
99-
],
100-
),
10196
]
10297

10398
INVALID: List[Container] = [
@@ -133,6 +128,15 @@
133128
],
134129
validity_error=EOFException.INVALID_DATALOADN_INDEX,
135130
),
131+
Container(
132+
name="data_section_over_container_limit",
133+
sections=[
134+
Section.Code(code=Op.STOP),
135+
# Over the 49152 bytes limit for the entire container
136+
Section.Data(data=(b"12345678" * 6 * 1024)[len(smallest_runtime_subcontainer) - 1 :]),
137+
],
138+
validity_error=EOFException.CONTAINER_SIZE_ABOVE_LIMIT,
139+
),
136140
]
137141

138142

tests/prague/eip7692_eof_v1/eip7620_eof_create/test_eofcreate_failures.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def test_initcode_aborts(
153153
Size of the factory portion of test_eofcreate_deploy_sizes, but as the runtime code is dynamic, we
154154
have to use a pre-calculated size
155155
"""
156-
factory_size = 30
156+
factory_size = 74
157157

158158

159159
@pytest.mark.parametrize(
@@ -206,27 +206,27 @@ def test_eofcreate_deploy_sizes(
206206
],
207207
)
208208

209+
factory_container = Container(
210+
sections=[
211+
Section.Code(
212+
code=Op.SSTORE(slot_create_address, Op.EOFCREATE[0](0, 0, 0, 0))
213+
+ Op.SSTORE(slot_code_worked, value_code_worked)
214+
+ Op.STOP,
215+
max_stack_height=4,
216+
),
217+
Section.Container(container=initcode_subcontainer),
218+
]
219+
)
220+
209221
assert factory_size == (
210-
len(initcode_subcontainer) - len(runtime_container)
222+
len(factory_container) - len(runtime_container)
211223
), "factory_size is wrong, expected factory_size is %d, calculated is %d" % (
212224
factory_size,
213-
len(initcode_subcontainer),
225+
len(factory_container),
214226
)
215227

216228
sender = pre.fund_eoa()
217-
contract_address = pre.deploy_contract(
218-
code=Container(
219-
sections=[
220-
Section.Code(
221-
code=Op.SSTORE(slot_create_address, Op.EOFCREATE[0](0, 0, 0, 0))
222-
+ Op.SSTORE(slot_code_worked, value_code_worked)
223-
+ Op.STOP,
224-
max_stack_height=4,
225-
),
226-
Section.Container(container=initcode_subcontainer),
227-
]
228-
)
229-
)
229+
contract_address = pre.deploy_contract(code=factory_container)
230230
# Storage in 0 should have the address,
231231
# Storage 1 is a canary of 1 to make sure it tried to execute, which also covers cases of
232232
# data+code being greater than initcode_size_max, which is allowed.

0 commit comments

Comments
 (0)