Skip to content

Commit 4fb062e

Browse files
committed
refactor: move post-frontier opcodes
1 parent 1b0910f commit 4fb062e

2 files changed

Lines changed: 27 additions & 14 deletions

File tree

packages/testing/src/execution_testing/forks/forks/forks.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,21 +223,14 @@ def gas_costs(
223223
GAS_OPCODE_XOR=3,
224224
GAS_OPCODE_NOT=3,
225225
GAS_OPCODE_BYTE=3,
226-
GAS_OPCODE_SHL=3,
227-
GAS_OPCODE_SHR=3,
228-
GAS_OPCODE_SAR=3,
229-
GAS_OPCODE_CLZ=5,
230-
GAS_OPCODE_BLOBHASH=3,
231226
GAS_OPCODE_JUMP=8,
232227
GAS_OPCODE_JUMPI=10,
233228
GAS_OPCODE_CALLDATALOAD=3,
234229
GAS_OPCODE_CALLDATACOPY=3,
235230
GAS_OPCODE_CODECOPY=3,
236-
GAS_OPCODE_RETURNDATACOPY=3,
237231
GAS_OPCODE_MLOAD=3,
238232
GAS_OPCODE_MSTORE=3,
239233
GAS_OPCODE_MSTORE8=3,
240-
GAS_OPCODE_MCOPY=3,
241234
GAS_OPCODE_PUSH_N=3,
242235
GAS_OPCODE_DUP_N=3,
243236
GAS_OPCODE_SWAP_N=3,
@@ -1778,6 +1771,7 @@ def gas_costs(
17781771
GAS_PRECOMPILE_ECMUL=40_000,
17791772
GAS_PRECOMPILE_ECPAIRING_BASE=100_000,
17801773
GAS_PRECOMPILE_ECPAIRING_PER_POINT=80_000,
1774+
GAS_OPCODE_RETURNDATACOPY=3,
17811775
)
17821776

17831777

@@ -1816,6 +1810,20 @@ def create_opcodes(
18161810
block_number=block_number, timestamp=timestamp
18171811
)
18181812

1813+
@classmethod
1814+
def gas_costs(
1815+
cls, *, block_number: int = 0, timestamp: int = 0
1816+
) -> GasCosts:
1817+
"""At Constantinople, shift opcodes are introduced."""
1818+
return replace(
1819+
super(Constantinople, cls).gas_costs(
1820+
block_number=block_number, timestamp=timestamp
1821+
),
1822+
GAS_OPCODE_SHL=3,
1823+
GAS_OPCODE_SHR=3,
1824+
GAS_OPCODE_SAR=3,
1825+
)
1826+
18191827
@classmethod
18201828
def opcode_gas_map(
18211829
cls, *, block_number: int = 0, timestamp: int = 0
@@ -2700,6 +2708,8 @@ def gas_costs(
27002708
block_number=block_number, timestamp=timestamp
27012709
),
27022710
GAS_PRECOMPILE_POINT_EVALUATION=50_000,
2711+
GAS_OPCODE_BLOBHASH=3,
2712+
GAS_OPCODE_MCOPY=3,
27032713
)
27042714

27052715
@classmethod
@@ -2829,6 +2839,7 @@ def gas_costs(
28292839
GAS_PRECOMPILE_BLS_G2MAP=23_800,
28302840
GAS_PRECOMPILE_BLS_PAIRING_BASE=37_700,
28312841
GAS_PRECOMPILE_BLS_PAIRING_PER_PAIR=32_600,
2842+
GAS_OPCODE_CLZ=5,
28322843
)
28332844

28342845
@classmethod

packages/testing/src/execution_testing/forks/gas_costs.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,23 @@ class GasCosts:
114114
GAS_OPCODE_XOR: int
115115
GAS_OPCODE_NOT: int
116116
GAS_OPCODE_BYTE: int
117-
GAS_OPCODE_SHL: int
118-
GAS_OPCODE_SHR: int
119-
GAS_OPCODE_SAR: int
120-
GAS_OPCODE_CLZ: int
121-
GAS_OPCODE_BLOBHASH: int
122117
GAS_OPCODE_JUMP: int
123118
GAS_OPCODE_JUMPI: int
124119
GAS_OPCODE_CALLDATALOAD: int
125120
GAS_OPCODE_CALLDATACOPY: int
126121
GAS_OPCODE_CODECOPY: int
127-
GAS_OPCODE_RETURNDATACOPY: int
128122
GAS_OPCODE_MLOAD: int
129123
GAS_OPCODE_MSTORE: int
130124
GAS_OPCODE_MSTORE8: int
131-
GAS_OPCODE_MCOPY: int
132125
GAS_OPCODE_PUSH_N: int
133126
GAS_OPCODE_DUP_N: int
134127
GAS_OPCODE_SWAP_N: int
128+
129+
# Defined post-Frontier
130+
GAS_OPCODE_SHL: int = 0
131+
GAS_OPCODE_SHR: int = 0
132+
GAS_OPCODE_SAR: int = 0
133+
GAS_OPCODE_RETURNDATACOPY: int = 0
134+
GAS_OPCODE_BLOBHASH: int = 0
135+
GAS_OPCODE_MCOPY: int = 0
136+
GAS_OPCODE_CLZ: int = 0

0 commit comments

Comments
 (0)