Skip to content

Commit 6e0125a

Browse files
author
Stuart Reed
committed
Updates based on feedback
1 parent ce01131 commit 6e0125a

24 files changed

+17
-1303
lines changed

tests/frontier/identity_precompile/common.py

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from dataclasses import dataclass
44
from typing import Tuple
55

6+
from pydantic import BaseModel
7+
68
from ethereum_test_base_types.composite_types import Storage
79
from ethereum_test_tools import (
810
Bytecode,
@@ -17,25 +19,16 @@ class Constants:
1719
IDENTITY_PRECOMPILE_ADDRESS = 0x04
1820

1921

20-
class CallArgs:
22+
class CallArgs(BaseModel):
2123
"""Defines inputs to CALL for the Identity precompile."""
2224

23-
def __init__(
24-
self,
25-
gas=0x1F4,
26-
value=0x0,
27-
args_offset=0x0,
28-
args_size=0x20,
29-
ret_offset=0x0,
30-
ret_size=0x20,
31-
):
32-
"""Create a new instance with the provided values."""
33-
self.gas = gas
34-
self.value = value
35-
self.args_offset = args_offset
36-
self.args_size = args_size
37-
self.ret_offset = ret_offset
38-
self.ret_size = ret_size
25+
address: int = Constants.IDENTITY_PRECOMPILE_ADDRESS
26+
gas: int = 0x1F4
27+
value: int = 0x0
28+
args_offset: int = 0x0
29+
args_size: int = 0x20
30+
ret_offset: int = 0x0
31+
ret_size: int = 0x20
3932

4033

4134
def generate_identity_call_bytecode(
@@ -76,15 +69,7 @@ def generate_identity_call_bytecode(
7669
code += (
7770
Op.SSTORE(
7871
storage.store_next(call_succeeds),
79-
call_type(
80-
gas=call_args.gas,
81-
address=Constants.IDENTITY_PRECOMPILE_ADDRESS,
82-
value=call_args.value,
83-
args_offset=call_args.args_offset,
84-
args_size=call_args.args_size,
85-
ret_offset=call_args.ret_offset,
86-
ret_size=call_args.ret_size,
87-
),
72+
call_type(**call_args.model_dump()),
8873
)
8974
+ Op.SSTORE(storage.store_next(mstore_value), Op.MLOAD(mstore_offset))
9075
+ Op.STOP

tests/frontier/identity_precompile/test_identity.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
id="identity_1",
3535
),
3636
pytest.param(
37-
CallArgs(gas=0x30D40, value=0x13, args_size=0x0),
37+
CallArgs(gas=0x30D40, value=0x1, args_size=0x0),
3838
None,
3939
False,
40-
id="identity_1_nonzero",
40+
id="identity_1_nonzerovalue",
4141
),
4242
pytest.param(
4343
CallArgs(args_size=0x25),
@@ -61,13 +61,13 @@
6161
CallArgs(gas=0x11),
6262
(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF,),
6363
False,
64-
id="identity_4_gas17",
64+
id="identity_4_insufficient_gas",
6565
),
6666
pytest.param(
6767
CallArgs(gas=0x12),
6868
(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF,),
6969
True,
70-
id="identity_4_gas18",
70+
id="identity_4_exact_gas",
7171
),
7272
],
7373
)

tests/frontier/identity_precompile/test_identity_returndatasize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
@pytest.mark.parametrize(
1919
["args_size", "output_size", "expected_returndatasize"],
2020
[
21-
pytest.param(16, 32, 16, id="output_16"),
22-
pytest.param(32, 16, 32, id="output_32"),
21+
pytest.param(16, 32, 16, id="output_size_greater_than_input"),
22+
pytest.param(32, 16, 32, id="output_size_less_than_input"),
2323
],
2424
)
2525
def test_identity_precompile_returndata(

tests/static/state_tests/stPreCompiledContracts/identity_to_biggerFiller.json

Lines changed: 0 additions & 65 deletions
This file was deleted.

tests/static/state_tests/stPreCompiledContracts/identity_to_smallerFiller.json

Lines changed: 0 additions & 65 deletions
This file was deleted.

tests/static/state_tests/stPreCompiledContracts2/CALLCODEIdentitiy_0Filler.json

Lines changed: 0 additions & 59 deletions
This file was deleted.

tests/static/state_tests/stPreCompiledContracts2/CALLCODEIdentitiy_1Filler.json

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)