Skip to content

Commit

Permalink
refactor(tests): EOF - remove max_stack_height from most tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marioevz committed Jun 17, 2024
1 parent c435b58 commit 21a7cf9
Show file tree
Hide file tree
Showing 19 changed files with 19 additions and 212 deletions.
7 changes: 0 additions & 7 deletions tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
sections=[
Section.Code(
code=Op.SSTORE(slot_caller, Op.CALLER()) + Op.STOP,
max_stack_height=2,
)
]
)
Expand Down Expand Up @@ -151,7 +150,6 @@ def test_legacy_calls_eof_mstore(
Section.Code(
code=Op.MSTORE8(0, int.from_bytes(value_returndata_magic, "big"))
+ Op.RETURN(0, len(value_returndata_magic)),
max_stack_height=2,
)
]
)
Expand Down Expand Up @@ -221,7 +219,6 @@ def test_eof_calls_eof_sstore(
code=Op.SSTORE(slot_call_result, opcode(destination_contract_address, *suffix))
+ Op.SSTORE(slot_code_worked, value_code_worked)
+ Op.STOP,
max_stack_height=1 + len(suffix),
)
]
)
Expand Down Expand Up @@ -287,7 +284,6 @@ def test_eof_calls_eof_mstore(
Section.Code(
code=Op.MSTORE8(0, int.from_bytes(value_returndata_magic, "big"))
+ Op.RETURN(0, 32),
max_stack_height=2,
)
]
)
Expand All @@ -301,7 +297,6 @@ def test_eof_calls_eof_mstore(
+ Op.SSTORE(slot_returndata, Op.RETURNDATALOAD(0))
+ Op.SSTORE(slot_code_worked, value_code_worked)
+ Op.STOP,
max_stack_height=1 + len(suffix),
)
]
)
Expand Down Expand Up @@ -364,7 +359,6 @@ def test_eof_calls_legacy_sstore(
code=Op.SSTORE(slot_call_result, opcode(destination_contract_address, *suffix))
+ Op.SSTORE(slot_code_worked, value_code_worked)
+ Op.STOP,
max_stack_height=1 + len(suffix),
)
]
)
Expand Down Expand Up @@ -437,7 +431,6 @@ def test_eof_calls_legacy_mstore(
+ Op.SSTORE(slot_returndata, Op.RETURNDATALOAD(0))
+ Op.SSTORE(slot_code_worked, value_code_worked)
+ Op.STOP,
max_stack_height=1 + len(suffix),
)
]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
sections=[
Section.Code(
code=Op.ADDRESS + Op.POP + Op.STOP,
max_stack_height=1,
),
Section.Data("0xef"),
],
Expand All @@ -43,7 +42,6 @@
sections=[
Section.Code(
code=Op.ADDRESS + Op.POP + Op.STOP,
max_stack_height=1,
),
Section.Data("0x0bad", custom_size=4),
],
Expand All @@ -59,7 +57,6 @@
sections=[
Section.Code(
code=Op.ADDRESS + Op.POP + Op.STOP,
max_stack_height=1,
),
Section.Data("0x0bad60A70BAD", custom_size=4),
],
Expand All @@ -75,7 +72,6 @@
sections=[
Section.Code(
code=Op.ADDRESS + Op.POP + Op.STOP,
max_stack_height=1,
),
Section.Data("0x0bad60A7"),
],
Expand All @@ -91,7 +87,6 @@
sections=[
Section.Code(
code=Op.ADDRESS + Opcode(0xEF) + Op.STOP,
max_stack_height=1,
),
Section.Data("0x0bad60A7"),
],
Expand All @@ -107,7 +102,6 @@
sections=[
Section.Code(
code=Op.ADDRESS + Op.POP + Op.INVALID,
max_stack_height=1,
),
Section.Data("0x0bad60A7"),
],
Expand All @@ -123,7 +117,6 @@
sections=[
Section.Code(
code=Op.ADDRESS + Op.POP + Op.STOP,
max_stack_height=1,
),
Section.Data("0xef"),
],
Expand All @@ -145,7 +138,6 @@
+ Op.RJUMP[3]
+ Op.RJUMP[-6]
+ Op.STOP,
max_stack_height=1,
),
Section.Data("0x0bad60A7"),
],
Expand Down Expand Up @@ -174,7 +166,6 @@
sections=[
Section.Code(
code=Op.PUSH1(1) + Op.RJUMPI[1] + Op.NOOP + Op.STOP,
max_stack_height=1,
),
Section.Data("0x0bad60A7"),
],
Expand All @@ -197,15 +188,12 @@
+ Op.JUMPF[3]
+ Op.CALLF[4]
+ Op.STOP,
max_stack_height=1,
),
Section.Code(
code=Op.PUSH0 + Op.PUSH0 + Op.RETURN,
max_stack_height=2,
),
Section.Code(
code=Op.PUSH0 + Op.PUSH0 + Op.REVERT,
max_stack_height=2,
),
Section.Code(code=Op.INVALID),
Section.Code(
Expand Down Expand Up @@ -233,7 +221,6 @@
+ Op.ADDRESS
+ Op.POP
+ Op.STOP,
max_stack_height=1,
),
Section.Data("0x0bad60A7"),
],
Expand All @@ -255,7 +242,6 @@
+ Op.ADDRESS
+ Op.POP
+ Op.STOP,
max_stack_height=1,
),
Section.Data("0x0bad60A7"),
],
Expand All @@ -272,7 +258,6 @@
sections=[
Section.Code(
code=Op.PUSH1(1) + Op.RJUMPI[1] + Op.ADDRESS + Op.NOOP + Op.STOP,
max_stack_height=1,
),
Section.Data("0x0bad60A7"),
],
Expand Down Expand Up @@ -307,7 +292,6 @@
+ Op.RJUMPI[2]
+ Op.RJUMPI[-6]
+ Op.STOP,
max_stack_height=3,
),
Section.Data("0x0bad60A7"),
],
Expand All @@ -323,7 +307,6 @@
sections=[
Section.Code(
code=Op.PUSH1(3) + Op.JUMP + Op.JUMPDEST + Op.STOP,
max_stack_height=1,
),
Section.Data("0xef"),
],
Expand Down Expand Up @@ -425,7 +408,6 @@ def test_code_section_header_body_mismatch(
sections=[
Section.Code(
code=Op.ADDRESS + Op.POP + Op.STOP,
max_stack_height=1,
),
Section.Code(
code=Op.ADDRESS + Op.POP + Op.STOP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
sections=[
Section.Code(
code=Op.CALLF[1] + Op.SSTORE(0, 1) + Op.STOP,
max_stack_height=2,
)
]
+ [
Expand All @@ -36,7 +35,6 @@
code=(Op.CALLF[i] + Op.SSTORE(i - 1, 1) + Op.RETF),
code_inputs=0,
code_outputs=0,
max_stack_height=2,
)
for i in range(2, MAX_CODE_SECTIONS)
]
Expand All @@ -56,7 +54,6 @@
),
code_inputs=0,
code_outputs=0,
max_stack_height=4,
)
],
)
Expand All @@ -68,7 +65,6 @@
# to their call stack height key
Section.Code(
code=Op.CALLF[i + 1] + Op.SSTORE(i, 1) + Op.STOP,
max_stack_height=2,
)
for i in range(MAX_CODE_SECTIONS - 1)
]
Expand All @@ -90,7 +86,6 @@
),
code_inputs=0,
code_outputs=0,
max_stack_height=7,
)
],
)
Expand All @@ -101,13 +96,11 @@
sections=[
Section.Code(
code=(Op.CALLF[1] + Op.STOP),
max_stack_height=0,
),
Section.Code(
code=(Op.RETF),
code_inputs=0,
code_outputs=0,
max_stack_height=0,
),
],
),
Expand All @@ -116,7 +109,6 @@
sections=[
Section.Code(
code=(Op.PUSH1(1) + Op.CALLF[1] + Op.STOP),
max_stack_height=1,
),
Section.Code(
code=(
Expand Down Expand Up @@ -172,7 +164,6 @@
sections=[
Section.Code(
code=(Op.PUSH1(1) + Op.PUSH0 + Op.MSTORE + Op.CALLF[1] + Op.STOP),
max_stack_height=2,
),
Section.Code(
code=(
Expand Down Expand Up @@ -208,7 +199,6 @@
sections=[
Section.Code(
code=(Op.INVALID),
max_stack_height=0,
),
],
),
Expand All @@ -217,7 +207,6 @@
sections=[
Section.Code(
code=(Op.PUSH1(1) + Op.CALLF[1] + Op.STOP),
max_stack_height=1,
),
Section.Code(
code=(
Expand Down Expand Up @@ -399,7 +388,6 @@ def test_eof_functions_contract_call_within_deep_nested(
sections=[
Section.Code(
code=Op.CALLF[1] + Op.SSTORE(0, 1) + Op.STOP,
max_stack_height=2,
)
]
+ [
Expand All @@ -408,7 +396,6 @@ def test_eof_functions_contract_call_within_deep_nested(
Section.Code(
code=(Op.CALLF[i] + Op.SSTORE(i - 1, 1) + Op.RETF),
code_outputs=0,
max_stack_height=2,
)
for i in range(2, MAX_CODE_SECTIONS)
]
Expand All @@ -423,7 +410,6 @@ def test_eof_functions_contract_call_within_deep_nested(
+ Op.RETF
),
code_outputs=0,
max_stack_height=4,
)
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
Section,
SectionKind,
)
from ethereum_test_tools.eof.v1.constants import NON_RETURNING_SECTION

from .. import EOF_FORK_NAME

Expand Down Expand Up @@ -171,9 +170,6 @@ def make_section_order(kind) -> List[Section]:

section_code = Section.Code(
code=Op.ADDRESS + Op.POP + Op.STOP,
code_inputs=0,
code_outputs=NON_RETURNING_SECTION,
max_stack_height=1,
skip_header_listing=calculate_skip_flag(SectionKind.CODE, CasePosition.HEADER),
skip_body_listing=calculate_skip_flag(SectionKind.CODE, CasePosition.BODY),
)
Expand Down
Loading

0 comments on commit 21a7cf9

Please sign in to comment.