Skip to content

Commit 39eb2f6

Browse files
pdobaczfelix314159
authored andcommitted
fix(tests): EOF - Rename RETURNCONTRACT to RETURNCODE (ethereum#1284)
1 parent 3bb9f6c commit 39eb2f6

File tree

22 files changed

+169
-175
lines changed

22 files changed

+169
-175
lines changed

src/ethereum_test_specs/eof.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def generate_eof_contract_create_transaction(self) -> Transaction:
415415
)
416416
initcode = Container(
417417
sections=[
418-
Section.Code(Op.RETURNCONTRACT[0](0, 0)),
418+
Section.Code(Op.RETURNCODE[0](0, 0)),
419419
Section.Container(self.container),
420420
]
421421
)

src/ethereum_test_types/eof/v1/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ def Init( # noqa: N802
454454
return cls(
455455
sections=[
456456
Section.Code(
457-
code=initcode_prefix + Op.RETURNCONTRACT[0](0, 0),
457+
code=initcode_prefix + Op.RETURNCODE[0](0, 0),
458458
),
459459
Section.Container(
460460
container=deploy_container,
@@ -502,7 +502,7 @@ def init_container(self) -> Container:
502502
return Container(
503503
sections=[
504504
Section.Code(
505-
code=Op.RETURNCONTRACT[0](0, 0),
505+
code=Op.RETURNCODE[0](0, 0),
506506
max_stack_height=2,
507507
),
508508
Section.Container(

src/ethereum_test_types/tests/test_eof_v1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@
790790
# Code segment 0 code
791791
6000 # 1 PUSH1 0
792792
6000 # 2 PUSH1 0
793-
ee00 # 3 RETURNCONTRACT[0]
793+
ee00 # 3 RETURNCODE[0]
794794
# Subcontainer 0
795795
ef0001 # Magic followed by version
796796
010004 # Types section
@@ -823,7 +823,7 @@
823823
55 # 3 SSTORE
824824
6000 # 4 PUSH1 0
825825
6000 # 5 PUSH1 0
826-
ee00 # 6 RETURNCONTRACT[0]
826+
ee00 # 6 RETURNCODE[0]
827827
# Subcontainer 0
828828
ef0001 # Magic followed by version
829829
010004 # Types section

src/ethereum_test_vm/opcode.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5117,7 +5117,7 @@ class Opcodes(Opcode, Enum):
51175117
51185118
"""
51195119

5120-
RETURNCONTRACT = Opcode(
5120+
RETURNCODE = Opcode(
51215121
0xEE,
51225122
popped_stack_items=2,
51235123
data_portion_length=1,
@@ -5127,7 +5127,7 @@ class Opcodes(Opcode, Enum):
51275127
"""
51285128
!!! Note: This opcode is under development
51295129
5130-
RETURNCONTRACT()
5130+
RETURNCODE()
51315131
----
51325132
51335133
Description

tests/osaka/eip7692_eof_v1/eip3540_eof_v1/opcodes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
Op.DATACOPY,
3232
# EIP-7620 EOF Create and Return Contract operation
3333
Op.EOFCREATE,
34-
Op.RETURNCONTRACT,
34+
Op.RETURNCODE,
3535
# Non-deprecated Legacy Opcodes
3636
Op.STOP,
3737
Op.ADD,
@@ -216,7 +216,7 @@
216216
Op.DATACOPY,
217217
# EIP-7620 EOF Create and Return Contract operation
218218
Op.EOFCREATE,
219-
Op.RETURNCONTRACT,
219+
Op.RETURNCODE,
220220
]
221221
"""
222222
List of valid EOF V1 opcodes that are disabled in legacy bytecode.

tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_all_opcodes_in_container.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
# Halting the execution opcodes can be placed without STOP instruction at the end
4747
halting_opcodes = {
4848
Op.STOP,
49-
Op.RETURNCONTRACT,
49+
Op.RETURNCODE,
5050
Op.RETURN,
5151
Op.REVERT,
5252
Op.INVALID,
@@ -88,7 +88,7 @@ def test_all_opcodes_in_container(
8888
sections = [Section.Code(code=bytecode)]
8989

9090
match opcode:
91-
case Op.EOFCREATE | Op.RETURNCONTRACT:
91+
case Op.EOFCREATE | Op.RETURNCODE:
9292
sections.append(
9393
Section.Container(
9494
container=Container(
@@ -107,7 +107,7 @@ def test_all_opcodes_in_container(
107107
)
108108
sections.append(Section.Data("1122334455667788" * 4))
109109

110-
if opcode == Op.RETURNCONTRACT:
110+
if opcode == Op.RETURNCODE:
111111
eof_code = Container(sections=sections, kind=ContainerKind.INITCODE)
112112
else:
113113
eof_code = Container(sections=sections)
@@ -136,24 +136,24 @@ def test_invalid_opcodes_after_stop(
136136
"""Test that an invalid opcode placed after STOP (terminating instruction) invalidates EOF."""
137137
terminating_code = Bytecode(terminating_opcode)
138138
match terminating_opcode: # Enhance the code for complex opcodes.
139-
case Op.RETURNCONTRACT:
140-
terminating_code = Op.RETURNCONTRACT[0]
139+
case Op.RETURNCODE:
140+
terminating_code = Op.RETURNCODE[0]
141141
case Op.RETURN | Op.REVERT:
142142
terminating_code = Op.PUSH0 + Op.PUSH0 + terminating_opcode
143143
case Op.RJUMP:
144144
terminating_code = Op.RJUMP[-3]
145145

146146
eof_code = Container(
147147
kind=ContainerKind.INITCODE
148-
if terminating_opcode == Op.RETURNCONTRACT
148+
if terminating_opcode == Op.RETURNCODE
149149
else ContainerKind.RUNTIME,
150150
sections=[
151151
Section.Code(code=terminating_code + opcode),
152152
Section.Data("00" * 32),
153153
]
154154
+ (
155155
[Section.Container(container=Container.Code(Op.INVALID))]
156-
if terminating_opcode == Op.RETURNCONTRACT
156+
if terminating_opcode == Op.RETURNCODE
157157
else []
158158
),
159159
)
@@ -194,7 +194,7 @@ def test_all_invalid_terminating_opcodes(
194194
Section.Container(
195195
container=Container(
196196
sections=[
197-
Section.Code(code=Op.RETURNCONTRACT[0](0, 0)),
197+
Section.Code(code=Op.RETURNCODE[0](0, 0)),
198198
Section.Container(Container.Code(code=Op.STOP)),
199199
]
200200
)
@@ -233,13 +233,13 @@ def test_all_unreachable_terminating_opcodes_after_stop(
233233
Section.Code(code=Op.STOP + Op.JUMPF[1]),
234234
Section.Code(code=Op.STOP),
235235
]
236-
case Op.RETURNCONTRACT:
236+
case Op.RETURNCODE:
237237
sections = [
238238
Section.Code(code=Op.EOFCREATE[0](0, 0, 0, 0) + Op.STOP),
239239
Section.Container(
240240
container=Container(
241241
sections=[
242-
Section.Code(code=Op.STOP + Op.RETURNCONTRACT[0](0, 0)),
242+
Section.Code(code=Op.STOP + Op.RETURNCODE[0](0, 0)),
243243
Section.Container(Container.Code(code=Op.STOP)),
244244
]
245245
)
@@ -257,7 +257,7 @@ def test_all_unreachable_terminating_opcodes_after_stop(
257257
sections=sections,
258258
),
259259
expect_exception=EOFException.UNREACHABLE_INSTRUCTIONS
260-
if opcode != Op.RETURNCONTRACT
260+
if opcode != Op.RETURNCODE
261261
else EOFException.INCOMPATIBLE_CONTAINER_KIND,
262262
)
263263

@@ -282,13 +282,13 @@ def test_all_unreachable_terminating_opcodes_before_stop(
282282
Section.Code(code=Op.JUMPF[1] + Op.STOP),
283283
Section.Code(code=Op.STOP),
284284
]
285-
case Op.RETURNCONTRACT:
285+
case Op.RETURNCODE:
286286
sections = [
287287
Section.Code(code=Op.EOFCREATE[0](0, 0, 0, 0) + Op.STOP),
288288
Section.Container(
289289
container=Container(
290290
sections=[
291-
Section.Code(code=Op.RETURNCONTRACT[0](0, 0) + Op.STOP),
291+
Section.Code(code=Op.RETURNCODE[0](0, 0) + Op.STOP),
292292
Section.Container(Container.Code(code=Op.STOP)),
293293
]
294294
)
@@ -306,7 +306,7 @@ def test_all_unreachable_terminating_opcodes_before_stop(
306306
sections=sections,
307307
),
308308
expect_exception=EOFException.UNREACHABLE_INSTRUCTIONS
309-
if opcode != Op.RETURNCONTRACT
309+
if opcode != Op.RETURNCODE
310310
else EOFException.INCOMPATIBLE_CONTAINER_KIND,
311311
)
312312

@@ -336,13 +336,13 @@ def test_all_opcodes_stack_underflow(
336336
Section.Container(
337337
container=Container(
338338
sections=[
339-
Section.Code(code=Op.RETURNCONTRACT[0](0, 0)),
339+
Section.Code(code=Op.RETURNCODE[0](0, 0)),
340340
Section.Container(Container.Code(code=Op.STOP)),
341341
]
342342
)
343343
),
344344
]
345-
elif opcode == Op.RETURNCONTRACT:
345+
elif opcode == Op.RETURNCODE:
346346
sections = [
347347
Section.Code(code=Op.EOFCREATE[0](0, 0, 0, 0) + Op.STOP),
348348
Section.Container(

tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ def test_valid_containers(
926926
Section.Container(
927927
Container(
928928
sections=[
929-
Section.Code(code=Op.RETURNCONTRACT[0](0, 0)),
929+
Section.Code(code=Op.RETURNCODE[0](0, 0)),
930930
Section.Container(container=Container.Code(code=Op.STOP)),
931931
],
932932
)
@@ -1237,7 +1237,7 @@ def test_single_code_section(
12371237
plus_container: bool,
12381238
):
12391239
"""Verify EOF container single code section."""
1240-
sections = [Section.Code(Op.RETURNCONTRACT[0](0, 0) if plus_container else Op.STOP)]
1240+
sections = [Section.Code(Op.RETURNCODE[0](0, 0) if plus_container else Op.STOP)]
12411241
if plus_container:
12421242
sections.append(
12431243
Section.Container(
@@ -1271,7 +1271,7 @@ def test_max_code_sections(
12711271
if plus_container:
12721272
sections = [
12731273
Section.Code(
1274-
Op.JUMPF[i + 1] if i < (MAX_CODE_SECTIONS - 1) else Op.RETURNCONTRACT[0](0, 0)
1274+
Op.JUMPF[i + 1] if i < (MAX_CODE_SECTIONS - 1) else Op.RETURNCODE[0](0, 0)
12751275
)
12761276
for i in range(MAX_CODE_SECTIONS)
12771277
]

tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_opcodes_in_legacy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
pytest.param(Op.DATASIZE, id="DATASIZE"),
4949
pytest.param(Op.DATACOPY(0, 0, 32), id="DATACOPY"),
5050
pytest.param(Op.EOFCREATE[0](0, 0, 0, 0), id="EOFCREATE"),
51-
pytest.param(Op.RETURNCONTRACT[0], id="RETURNCONTRACT"),
51+
pytest.param(Op.RETURNCODE[0], id="RETURNCODE"),
5252
]
5353

5454

tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_section_size.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def test_section_size(
139139
Section.Container(
140140
container=Container(
141141
sections=[
142-
Section.Code(Op.RETURNCONTRACT[0](0, 0)),
142+
Section.Code(Op.RETURNCODE[0](0, 0)),
143143
Section.Container(container=Container(sections=[Section.Code(Op.STOP)])),
144144
]
145145
),
@@ -151,7 +151,7 @@ def test_section_size(
151151
Section.Container(
152152
container=Container(
153153
sections=[
154-
Section.Code(Op.RETURNCONTRACT[0](0, 0)),
154+
Section.Code(Op.RETURNCODE[0](0, 0)),
155155
Section.Container(container=Container(sections=[Section.Code(Op.STOP)])),
156156
]
157157
),

tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjump.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ def test_rjump_into_eofcreate(
975975
container=Container(
976976
sections=[
977977
Section.Code(
978-
code=Op.RETURNCONTRACT[0](0, 0),
978+
code=Op.RETURNCODE[0](0, 0),
979979
),
980980
Section.Container(
981981
container=Container.Code(code=Op.STOP),
@@ -989,10 +989,10 @@ def test_rjump_into_eofcreate(
989989
)
990990

991991

992-
def test_rjump_into_returncontract(
992+
def test_rjump_into_returncode(
993993
eof_test: EOFTestFiller,
994994
):
995-
"""EOF code containing RJUMP with target RETURNCONTRACT immediate."""
995+
"""EOF code containing RJUMP with target RETURNCODE immediate."""
996996
eof_test(
997997
container=Container(
998998
sections=[
@@ -1003,7 +1003,7 @@ def test_rjump_into_returncontract(
10031003
container=Container(
10041004
sections=[
10051005
Section.Code(
1006-
code=Op.PUSH0 * 2 + Op.RJUMP[1] + Op.RETURNCONTRACT[0],
1006+
code=Op.PUSH0 * 2 + Op.RJUMP[1] + Op.RETURNCODE[0],
10071007
),
10081008
Section.Container(
10091009
container=Container.Code(code=Op.STOP),

0 commit comments

Comments
 (0)