Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 50 additions & 29 deletions packages/testing/src/execution_testing/forks/forks/forks.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,44 +115,44 @@ def gas_costs(
"""
del block_number, timestamp
return GasCosts(
G_JUMPDEST=1,
G_BASE=2,
G_VERY_LOW=3,
G_LOW=5,
G_MID=8,
G_HIGH=10,
G_WARM_ACCOUNT_ACCESS=100,
G_COLD_ACCOUNT_ACCESS=2_600,
GAS_JUMPDEST=1,
GAS_BASE=2,
GAS_VERY_LOW=3,
GAS_LOW=5,
GAS_MID=8,
GAS_HIGH=10,
GAS_WARM_ACCESS=100,
GAS_COLD_ACCOUNT_ACCESS=2_600,
G_ACCESS_LIST_ADDRESS=2_400,
G_ACCESS_LIST_STORAGE=1_900,
G_WARM_SLOAD=100,
G_COLD_SLOAD=2_100,
G_STORAGE_SET=20_000,
G_STORAGE_RESET=2_900,
R_STORAGE_CLEAR=4_800,
G_SELF_DESTRUCT=5_000,
G_CREATE=32_000,
G_CODE_DEPOSIT_BYTE=200,
GAS_COLD_SLOAD=2_100,
GAS_STORAGE_SET=20_000,
GAS_STORAGE_UPDATE=2_900,
GAS_STORAGE_CLEAR_REFUND=4_800,
GAS_SELF_DESTRUCT=5_000,
GAS_CREATE=32_000,
GAS_CODE_DEPOSIT=200,
G_INITCODE_WORD=2,
G_CALL_VALUE=9_000,
G_CALL_STIPEND=2_300,
G_NEW_ACCOUNT=25_000,
G_EXP=10,
G_EXP_BYTE=50,
G_MEMORY=3,
GAS_CALL_VALUE=9_000,
GAS_CALL_STIPEND=2_300,
GAS_NEW_ACCOUNT=25_000,
GAS_EXPONENTIATION=10,
GAS_EXPONENTIATION_PER_BYTE=50,
GAS_MEMORY=3,
G_TX_DATA_ZERO=4,
G_TX_DATA_NON_ZERO=68,
G_TX_DATA_STANDARD_TOKEN_COST=0,
G_TX_DATA_FLOOR_TOKEN_COST=0,
G_TRANSACTION=21_000,
G_TRANSACTION_CREATE=32_000,
G_LOG=375,
G_LOG_DATA=8,
G_LOG_TOPIC=375,
G_KECCAK_256=30,
G_KECCAK_256_WORD=6,
G_COPY=3,
G_BLOCKHASH=20,
GAS_LOG=375,
GAS_LOG_DATA=8,
GAS_LOG_TOPIC=375,
GAS_KECCAK256=30,
GAS_KECCAK256_WORD=6,
GAS_COPY=3,
GAS_BLOCK_HASH=20,
G_AUTHORIZATION=0,
R_AUTHORIZATION_EXISTING_AUTHORITY=0,
)
Expand All @@ -176,7 +176,7 @@ def fn(*, new_bytes: int, previous_bytes: int = 0) -> int:
previous_words = ceiling_division(previous_bytes, 32)

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

return c(new_words) - c(previous_words)

Expand Down Expand Up @@ -2325,6 +2325,27 @@ def blob_base_cost(
del block_number, timestamp
return 2**13 # EIP-7918 new parameter

@classmethod
def gas_costs(
cls, *, block_number: int = 0, timestamp: int = 0
) -> GasCosts:
"""Return the gas costs for the fork."""
from ethereum.forks.osaka.vm import gas as g
from dataclasses import fields

# Build kwargs by matching GasCosts field names with gas module variables
kwargs = {}
for field in fields(GasCosts):
if hasattr(g, field.name):
kwargs[field.name] = getattr(g, field.name)
# Handle special mappings where names differ
elif field.name == "G_WARM_SLOAD":
kwargs[field.name] = g.GAS_WARM_ACCESS
elif field.name == "G_INITCODE_WORD":
kwargs[field.name] = g.GAS_INIT_CODE_WORD_COST

return GasCosts(**kwargs)
Comment on lines +2328 to +2347
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could import the variable in EEST like this, and create a new function for opcode cost. With this, we have a fork dependent gas table



class BPO1(Osaka, bpo_fork=True):
"""Mainnet BPO1 fork - Blob Parameter Only fork 1."""
Expand Down
56 changes: 28 additions & 28 deletions packages/testing/src/execution_testing/forks/gas_costs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,37 @@
class GasCosts:
"""Class that contains the gas cost constants for any fork."""

G_JUMPDEST: int
G_BASE: int
G_VERY_LOW: int
G_LOW: int
G_MID: int
G_HIGH: int
G_WARM_ACCOUNT_ACCESS: int
G_COLD_ACCOUNT_ACCESS: int
GAS_JUMPDEST: int
GAS_BASE: int
GAS_VERY_LOW: int
GAS_LOW: int
GAS_MID: int
GAS_HIGH: int
GAS_WARM_ACCESS: int
GAS_COLD_ACCOUNT_ACCESS: int
G_ACCESS_LIST_ADDRESS: int
G_ACCESS_LIST_STORAGE: int
G_WARM_SLOAD: int
G_COLD_SLOAD: int
G_STORAGE_SET: int
G_STORAGE_RESET: int
GAS_COLD_SLOAD: int
GAS_STORAGE_SET: int
GAS_STORAGE_UPDATE: int

R_STORAGE_CLEAR: int
GAS_STORAGE_CLEAR_REFUND: int

G_SELF_DESTRUCT: int
G_CREATE: int
GAS_SELF_DESTRUCT: int
GAS_CREATE: int

G_CODE_DEPOSIT_BYTE: int
GAS_CODE_DEPOSIT: int
G_INITCODE_WORD: int

G_CALL_VALUE: int
G_CALL_STIPEND: int
G_NEW_ACCOUNT: int
GAS_CALL_VALUE: int
GAS_CALL_STIPEND: int
GAS_NEW_ACCOUNT: int

G_EXP: int
G_EXP_BYTE: int
GAS_EXPONENTIATION: int
GAS_EXPONENTIATION_PER_BYTE: int

G_MEMORY: int
GAS_MEMORY: int

G_TX_DATA_ZERO: int
G_TX_DATA_NON_ZERO: int
Expand All @@ -47,15 +47,15 @@ class GasCosts:
G_TRANSACTION: int
G_TRANSACTION_CREATE: int

G_LOG: int
G_LOG_DATA: int
G_LOG_TOPIC: int
GAS_LOG: int
GAS_LOG_DATA: int
GAS_LOG_TOPIC: int

G_KECCAK_256: int
G_KECCAK_256_WORD: int
GAS_KECCAK256: int
GAS_KECCAK256_WORD: int

G_COPY: int
G_BLOCKHASH: int
GAS_COPY: int
GAS_BLOCK_HASH: int

G_AUTHORIZATION: int

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,9 @@ def wrapper(
# code will only work once, so if the system contract is re-
# executed in a subsequent block, it will consume less gas.
gas_used_per_storage = (
gas_costs.G_STORAGE_SET
+ gas_costs.G_COLD_SLOAD
+ (gas_costs.G_VERY_LOW * 2)
gas_costs.GAS_STORAGE_SET
+ gas_costs.GAS_COLD_SLOAD
+ (gas_costs.GAS_VERY_LOW * 2)
)
modified_system_contract_code += sum(
Op.SSTORE(i, 1)
Expand All @@ -358,8 +358,8 @@ def wrapper(
# If the gas limit is not divisible by the gas used per
# storage, we need to add some NO-OP (JUMPDEST) to the code
# that each consume 1 gas.
assert gas_costs.G_JUMPDEST == 1, (
f"JUMPDEST gas cost should be 1, but got {gas_costs.G_JUMPDEST}. "
assert gas_costs.GAS_JUMPDEST == 1, (
f"JUMPDEST gas cost should be 1, but got {gas_costs.GAS_JUMPDEST}. "
"Generator `generate_system_contract_error_test` needs to be updated."
)
modified_system_contract_code += sum(
Expand Down
55 changes: 55 additions & 0 deletions src/ethereum/forks/gas_repricing/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""
The Gas Repricing fork ([EIP-7607]) includes networking changes (peerDAS), increases
the gas cost while limiting the input size of the `MODEXP` precompile, limits
the maximum gas per transaction, raises the blob base fee to always be above
the execution cost, limits the RLP-encoded size of blocks, introduces a count
leading zeros (`CLZ`) instruction, and adds a new precompile supporting the
secp256r1 curve.

### Notices

- [EIP-7935: Set default gas limit to XX0M][EIP-7935]

### Changes

- [EIP-7594: PeerDAS - Peer Data Availability Sampling][EIP-7594]
- [EIP-7823: Set upper bounds for MODEXP][EIP-7823]
- [EIP-7825: Transaction Gas Limit Cap][EIP-7825]
- [EIP-7883: ModExp Gas Cost Increase][EIP-7883]
- [EIP-7918: Blob base fee bounded by execution cost][EIP-7918]
- [EIP-7934: RLP Execution Block Size Limit][EIP-7934]
- [EIP-7939: Count leading zeros (CLZ) opcode][EIP-7939]
- [EIP-7951: Precompile for secp256r1 Curve Support][EIP-7951]
- [EIP-7892: Blob Parameter Only Hardforks][EIP-7892]
- [EIP-7642: eth/69 - history expiry and simpler receipts][EIP-7642]
- [EIP-7910: eth_config JSON-RPC Method][EIP-7910]

### Upgrade Schedule

| Network | Timestamp | Date & Time (UTC) | Fork Hash | Beacon Chain Epoch |
|---------|--------------|-------------------------|--------------| ------------------ |
| Holesky | ` ` | - - : : | `0x ` | |
| Sepolia | ` ` | - - : : | `0x ` | |
| Hoodi | ` ` | - - : : | `0x ` | |
| Mainnet | ` ` | - - : : | `0x ` | |

### Releases

[EIP-7607]: https://eips.ethereum.org/EIPS/eip-7607
[EIP-7594]: https://eips.ethereum.org/EIPS/eip-7594
[EIP-7823]: https://eips.ethereum.org/EIPS/eip-7823
[EIP-7825]: https://eips.ethereum.org/EIPS/eip-7825
[EIP-7883]: https://eips.ethereum.org/EIPS/eip-7883
[EIP-7918]: https://eips.ethereum.org/EIPS/eip-7918
[EIP-7934]: https://eips.ethereum.org/EIPS/eip-7934
[EIP-7935]: https://eips.ethereum.org/EIPS/eip-7935
[EIP-7939]: https://eips.ethereum.org/EIPS/eip-7939
[EIP-7951]: https://eips.ethereum.org/EIPS/eip-7951
[EIP-7892]: https://eips.ethereum.org/EIPS/eip-7892
[EIP-7642]: https://eips.ethereum.org/EIPS/eip-7642
[EIP-7910]: https://eips.ethereum.org/EIPS/eip-7910
""" # noqa: E501

from ethereum.fork_criteria import Unscheduled

FORK_CRITERIA = Unscheduled()
Loading
Loading