Skip to content

Commit 769a849

Browse files
temp
1 parent 17344fd commit 769a849

File tree

53 files changed

+1149
-498
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1149
-498
lines changed

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

Lines changed: 50 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -115,44 +115,44 @@ def gas_costs(
115115
"""
116116
del block_number, timestamp
117117
return GasCosts(
118-
G_JUMPDEST=1,
119-
G_BASE=2,
120-
G_VERY_LOW=3,
121-
G_LOW=5,
122-
G_MID=8,
123-
G_HIGH=10,
124-
G_WARM_ACCOUNT_ACCESS=100,
125-
G_COLD_ACCOUNT_ACCESS=2_600,
118+
GAS_JUMPDEST=1,
119+
GAS_BASE=2,
120+
GAS_VERY_LOW=3,
121+
GAS_LOW=5,
122+
GAS_MID=8,
123+
GAS_HIGH=10,
124+
GAS_WARM_ACCESS=100,
125+
GAS_COLD_ACCOUNT_ACCESS=2_600,
126126
G_ACCESS_LIST_ADDRESS=2_400,
127127
G_ACCESS_LIST_STORAGE=1_900,
128128
G_WARM_SLOAD=100,
129-
G_COLD_SLOAD=2_100,
130-
G_STORAGE_SET=20_000,
131-
G_STORAGE_RESET=2_900,
132-
R_STORAGE_CLEAR=4_800,
133-
G_SELF_DESTRUCT=5_000,
134-
G_CREATE=32_000,
135-
G_CODE_DEPOSIT_BYTE=200,
129+
GAS_COLD_SLOAD=2_100,
130+
GAS_STORAGE_SET=20_000,
131+
GAS_STORAGE_UPDATE=2_900,
132+
GAS_STORAGE_CLEAR_REFUND=4_800,
133+
GAS_SELF_DESTRUCT=5_000,
134+
GAS_CREATE=32_000,
135+
GAS_CODE_DEPOSIT=200,
136136
G_INITCODE_WORD=2,
137-
G_CALL_VALUE=9_000,
138-
G_CALL_STIPEND=2_300,
139-
G_NEW_ACCOUNT=25_000,
140-
G_EXP=10,
141-
G_EXP_BYTE=50,
142-
G_MEMORY=3,
137+
GAS_CALL_VALUE=9_000,
138+
GAS_CALL_STIPEND=2_300,
139+
GAS_NEW_ACCOUNT=25_000,
140+
GAS_EXPONENTIATION=10,
141+
GAS_EXPONENTIATION_PER_BYTE=50,
142+
GAS_MEMORY=3,
143143
G_TX_DATA_ZERO=4,
144144
G_TX_DATA_NON_ZERO=68,
145145
G_TX_DATA_STANDARD_TOKEN_COST=0,
146146
G_TX_DATA_FLOOR_TOKEN_COST=0,
147147
G_TRANSACTION=21_000,
148148
G_TRANSACTION_CREATE=32_000,
149-
G_LOG=375,
150-
G_LOG_DATA=8,
151-
G_LOG_TOPIC=375,
152-
G_KECCAK_256=30,
153-
G_KECCAK_256_WORD=6,
154-
G_COPY=3,
155-
G_BLOCKHASH=20,
149+
GAS_LOG=375,
150+
GAS_LOG_DATA=8,
151+
GAS_LOG_TOPIC=375,
152+
GAS_KECCAK256=30,
153+
GAS_KECCAK256_WORD=6,
154+
GAS_COPY=3,
155+
GAS_BLOCK_HASH=20,
156156
G_AUTHORIZATION=0,
157157
R_AUTHORIZATION_EXISTING_AUTHORITY=0,
158158
)
@@ -176,7 +176,7 @@ def fn(*, new_bytes: int, previous_bytes: int = 0) -> int:
176176
previous_words = ceiling_division(previous_bytes, 32)
177177

178178
def c(w: int) -> int:
179-
return (gas_costs.G_MEMORY * w) + ((w * w) // 512)
179+
return (gas_costs.GAS_MEMORY * w) + ((w * w) // 512)
180180

181181
return c(new_words) - c(previous_words)
182182

@@ -2325,6 +2325,27 @@ def blob_base_cost(
23252325
del block_number, timestamp
23262326
return 2**13 # EIP-7918 new parameter
23272327

2328+
@classmethod
2329+
def gas_costs(
2330+
cls, *, block_number: int = 0, timestamp: int = 0
2331+
) -> GasCosts:
2332+
"""Return the gas costs for the fork."""
2333+
from ethereum.forks.osaka.vm import gas as g
2334+
from dataclasses import fields
2335+
2336+
# Build kwargs by matching GasCosts field names with gas module variables
2337+
kwargs = {}
2338+
for field in fields(GasCosts):
2339+
if hasattr(g, field.name):
2340+
kwargs[field.name] = getattr(g, field.name)
2341+
# Handle special mappings where names differ
2342+
elif field.name == "G_WARM_SLOAD":
2343+
kwargs[field.name] = g.GAS_WARM_ACCESS
2344+
elif field.name == "G_INITCODE_WORD":
2345+
kwargs[field.name] = g.GAS_INIT_CODE_WORD_COST
2346+
2347+
return GasCosts(**kwargs)
2348+
23282349

23292350
class BPO1(Osaka, bpo_fork=True):
23302351
"""Mainnet BPO1 fork - Blob Parameter Only fork 1."""

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

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,37 @@
77
class GasCosts:
88
"""Class that contains the gas cost constants for any fork."""
99

10-
G_JUMPDEST: int
11-
G_BASE: int
12-
G_VERY_LOW: int
13-
G_LOW: int
14-
G_MID: int
15-
G_HIGH: int
16-
G_WARM_ACCOUNT_ACCESS: int
17-
G_COLD_ACCOUNT_ACCESS: int
10+
GAS_JUMPDEST: int
11+
GAS_BASE: int
12+
GAS_VERY_LOW: int
13+
GAS_LOW: int
14+
GAS_MID: int
15+
GAS_HIGH: int
16+
GAS_WARM_ACCESS: int
17+
GAS_COLD_ACCOUNT_ACCESS: int
1818
G_ACCESS_LIST_ADDRESS: int
1919
G_ACCESS_LIST_STORAGE: int
2020
G_WARM_SLOAD: int
21-
G_COLD_SLOAD: int
22-
G_STORAGE_SET: int
23-
G_STORAGE_RESET: int
21+
GAS_COLD_SLOAD: int
22+
GAS_STORAGE_SET: int
23+
GAS_STORAGE_UPDATE: int
2424

25-
R_STORAGE_CLEAR: int
25+
GAS_STORAGE_CLEAR_REFUND: int
2626

27-
G_SELF_DESTRUCT: int
28-
G_CREATE: int
27+
GAS_SELF_DESTRUCT: int
28+
GAS_CREATE: int
2929

30-
G_CODE_DEPOSIT_BYTE: int
30+
GAS_CODE_DEPOSIT: int
3131
G_INITCODE_WORD: int
3232

33-
G_CALL_VALUE: int
34-
G_CALL_STIPEND: int
35-
G_NEW_ACCOUNT: int
33+
GAS_CALL_VALUE: int
34+
GAS_CALL_STIPEND: int
35+
GAS_NEW_ACCOUNT: int
3636

37-
G_EXP: int
38-
G_EXP_BYTE: int
37+
GAS_EXPONENTIATION: int
38+
GAS_EXPONENTIATION_PER_BYTE: int
3939

40-
G_MEMORY: int
40+
GAS_MEMORY: int
4141

4242
G_TX_DATA_ZERO: int
4343
G_TX_DATA_NON_ZERO: int
@@ -47,15 +47,15 @@ class GasCosts:
4747
G_TRANSACTION: int
4848
G_TRANSACTION_CREATE: int
4949

50-
G_LOG: int
51-
G_LOG_DATA: int
52-
G_LOG_TOPIC: int
50+
GAS_LOG: int
51+
GAS_LOG_DATA: int
52+
GAS_LOG_TOPIC: int
5353

54-
G_KECCAK_256: int
55-
G_KECCAK_256_WORD: int
54+
GAS_KECCAK256: int
55+
GAS_KECCAK256_WORD: int
5656

57-
G_COPY: int
58-
G_BLOCKHASH: int
57+
GAS_COPY: int
58+
GAS_BLOCK_HASH: int
5959

6060
G_AUTHORIZATION: int
6161

packages/testing/src/execution_testing/tools/utility/generators.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,9 @@ def wrapper(
347347
# code will only work once, so if the system contract is re-
348348
# executed in a subsequent block, it will consume less gas.
349349
gas_used_per_storage = (
350-
gas_costs.G_STORAGE_SET
351-
+ gas_costs.G_COLD_SLOAD
352-
+ (gas_costs.G_VERY_LOW * 2)
350+
gas_costs.GAS_STORAGE_SET
351+
+ gas_costs.GAS_COLD_SLOAD
352+
+ (gas_costs.GAS_VERY_LOW * 2)
353353
)
354354
modified_system_contract_code += sum(
355355
Op.SSTORE(i, 1)
@@ -358,8 +358,8 @@ def wrapper(
358358
# If the gas limit is not divisible by the gas used per
359359
# storage, we need to add some NO-OP (JUMPDEST) to the code
360360
# that each consume 1 gas.
361-
assert gas_costs.G_JUMPDEST == 1, (
362-
f"JUMPDEST gas cost should be 1, but got {gas_costs.G_JUMPDEST}. "
361+
assert gas_costs.GAS_JUMPDEST == 1, (
362+
f"JUMPDEST gas cost should be 1, but got {gas_costs.GAS_JUMPDEST}. "
363363
"Generator `generate_system_contract_error_test` needs to be updated."
364364
)
365365
modified_system_contract_code += sum(

src/ethereum/forks/gas_repricing/utils/gas_cost.yaml

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,63 +8,63 @@
88
# Variable names follow the test framework convention (G_ prefix)
99
static_costs:
1010
# Basic operation costs
11-
G_JUMPDEST: 1
12-
G_BASE: 2
13-
G_VERY_LOW: 3
14-
G_LOW: 5
15-
G_MID: 8
16-
G_HIGH: 10
11+
GAS_JUMPDEST: 1
12+
GAS_BASE: 2
13+
GAS_VERY_LOW: 3
14+
GAS_LOW: 5
15+
GAS_MID: 8
16+
GAS_HIGH: 10
1717

1818
# Storage costs
19-
G_STORAGE_SET: 20000
20-
G_STORAGE_RESET: 5000
21-
R_STORAGE_CLEAR: 4800
19+
GAS_STORAGE_SET: 20000
20+
GAS_STORAGE_UPDATE: 5000
21+
GAS_STORAGE_CLEAR_REFUND: 4800
2222

2323
# Access costs (EIP-2929)
24-
G_COLD_SLOAD: 2100
25-
G_COLD_ACCOUNT_ACCESS: 2600
26-
G_WARM_ACCOUNT_ACCESS: 100
24+
GAS_COLD_SLOAD: 2100
25+
GAS_COLD_ACCOUNT_ACCESS: 2600
26+
GAS_WARM_ACCESS: 100
2727
G_WARM_SLOAD: 100
2828
G_ACCESS_LIST_ADDRESS: 2400
2929
G_ACCESS_LIST_STORAGE: 1900
3030

3131
# Exponentiation costs
32-
G_EXP: 10
33-
G_EXP_BYTE: 50
32+
GAS_EXPONENTIATION: 10
33+
GAS_EXPONENTIATION_PER_BYTE: 50
3434

3535
# Memory costs
36-
G_MEMORY: 3
36+
GAS_MEMORY: 3
3737

3838
# Keccak256 costs
39-
G_KECCAK_256: 30
40-
G_KECCAK_256_WORD: 6
39+
GAS_KECCAK256: 30
40+
GAS_KECCAK256_WORD: 6
4141

4242
# Copy operation costs
43-
G_COPY: 3
43+
GAS_COPY: 3
4444

4545
# Block operation costs
46-
G_BLOCKHASH: 20
46+
GAS_BLOCK_HASH: 20
4747

4848
# Log costs
49-
G_LOG: 375
50-
G_LOG_DATA: 8
51-
G_LOG_TOPIC: 375
49+
GAS_LOG: 375
50+
GAS_LOG_DATA: 8
51+
GAS_LOG_TOPIC: 375
5252

5353
# Create costs
54-
G_CREATE: 32000
55-
G_CODE_DEPOSIT_BYTE: 200
54+
GAS_CREATE: 32000
55+
GAS_CODE_DEPOSIT: 200
5656

5757
# Transaction costs
5858
G_TRANSACTION: 21000
5959
G_TRANSACTION_CREATE: 32000
6060

6161
# Account creation and value transfer costs
62-
G_NEW_ACCOUNT: 25000
63-
G_CALL_VALUE: 9000
64-
G_CALL_STIPEND: 2300
62+
GAS_NEW_ACCOUNT: 25000
63+
GAS_CALL_VALUE: 9000
64+
GAS_CALL_STIPEND: 2300
6565

6666
# Self-destruct costs
67-
G_SELF_DESTRUCT: 5000
67+
GAS_SELF_DESTRUCT: 5000
6868

6969
# Transaction data costs
7070
G_TX_DATA_ZERO: 4
@@ -124,14 +124,14 @@ opcode_costs:
124124
SHL: BASE_OPCODE_COST
125125
SHR: BASE_OPCODE_COST
126126
SAR: BASE_OPCODE_COST
127-
CLZ: G_VERY_LOW
127+
CLZ: GAS_VERY_LOW
128128

129129
# Keccak operation
130-
KECCAK: G_KECCAK_256 # 0x20 - plus G_KECCAK_256_WORD per word
130+
KECCAK: GAS_KECCAK256 # 0x20 - plus GAS_KECCAK256_WORD per word
131131

132132
# Environmental operations
133133
ADDRESS: BASE_OPCODE_COST
134-
BALANCE: G_COLD_ACCOUNT_ACCESS
134+
BALANCE: GAS_COLD_ACCOUNT_ACCESS
135135
ORIGIN: BASE_OPCODE_COST
136136
CALLER: BASE_OPCODE_COST
137137
CALLVALUE: BASE_OPCODE_COST
@@ -141,24 +141,24 @@ opcode_costs:
141141
CODESIZE: BASE_OPCODE_COST
142142
CODECOPY: BASE_OPCODE_COST
143143
GASPRICE: BASE_OPCODE_COST
144-
EXTCODESIZE: G_COLD_ACCOUNT_ACCESS
145-
EXTCODECOPY: G_COLD_ACCOUNT_ACCESS
144+
EXTCODESIZE: GAS_COLD_ACCOUNT_ACCESS
145+
EXTCODECOPY: GAS_COLD_ACCOUNT_ACCESS
146146
RETURNDATASIZE: BASE_OPCODE_COST
147147
RETURNDATACOPY: BASE_OPCODE_COST
148-
EXTCODEHASH: G_WARM_ACCOUNT_ACCESS
148+
EXTCODEHASH: GAS_WARM_ACCESS
149149

150150
# Block operations
151-
BLOCKHASH: G_BLOCKHASH
151+
BLOCKHASH: GAS_BLOCK_HASH
152152
COINBASE: BASE_OPCODE_COST
153153
TIMESTAMP: BASE_OPCODE_COST
154154
NUMBER: BASE_OPCODE_COST
155-
PREVRANDAO: G_BASE
155+
PREVRANDAO: GAS_BASE
156156
GASLIMIT: BASE_OPCODE_COST
157157
CHAINID: BASE_OPCODE_COST
158158
SELFBALANCE: BASE_OPCODE_COST
159-
BASEFEE: G_BASE
160-
BLOBHASH: G_BASE
161-
BLOBBASEFEE: G_BASE
159+
BASEFEE: GAS_BASE
160+
BLOBHASH: GAS_BASE
161+
BLOBBASEFEE: GAS_BASE
162162

163163
# Memory operations
164164
MLOAD: BASE_OPCODE_COST
@@ -171,8 +171,8 @@ opcode_costs:
171171
POP: BASE_OPCODE_COST
172172

173173
# Storage operations
174-
SLOAD: G_COLD_SLOAD
175-
SSTORE: G_STORAGE_SET
174+
SLOAD: GAS_COLD_SLOAD
175+
SSTORE: GAS_STORAGE_SET
176176
TLOAD: WARM_STORAGE_READ_COST
177177
TSTORE: WARM_STORAGE_READ_COST
178178

@@ -194,15 +194,15 @@ opcode_costs:
194194
SWAP: BASE_OPCODE_COST
195195

196196
# Log operations
197-
LOG0: G_LOG
197+
LOG0: GAS_LOG
198198

199199
# System operations
200-
CREATE: G_CREATE
201-
CALL: G_COLD_ACCOUNT_ACCESS
202-
CALLCODE: G_COLD_ACCOUNT_ACCESS
203-
RETURN: G_BASE
204-
DELEGATECALL: G_COLD_ACCOUNT_ACCESS
205-
CREATE2: G_CREATE
206-
STATICCALL: G_COLD_ACCOUNT_ACCESS
207-
REVERT: G_BASE
208-
SELFDESTRUCT: G_SELF_DESTRUCT
200+
CREATE: GAS_CREATE
201+
CALL: GAS_COLD_ACCOUNT_ACCESS
202+
CALLCODE: GAS_COLD_ACCOUNT_ACCESS
203+
RETURN: GAS_BASE
204+
DELEGATECALL: GAS_COLD_ACCOUNT_ACCESS
205+
CREATE2: GAS_CREATE
206+
STATICCALL: GAS_COLD_ACCOUNT_ACCESS
207+
REVERT: GAS_BASE
208+
SELFDESTRUCT: GAS_SELF_DESTRUCT

0 commit comments

Comments
 (0)