Skip to content

Ethereum Test Forks package

Ethereum test fork definitions.

RefundTypes

Bases: Enum

Enum used to describe all refund types a fork can have.

Source code in packages/testing/src/execution_testing/forks/base_fork.py
259
260
261
262
263
class RefundTypes(Enum):
    """Enum used to describe all refund types a fork can have."""

    STORAGE_CLEAR = auto()
    AUTHORIZATION_EXISTING_AUTHORITY = auto()

SystemCallPhase

Bases: Enum

When a block calls a system contract, if at all.

Source code in packages/testing/src/execution_testing/forks/base_fork.py
266
267
268
269
270
271
class SystemCallPhase(Enum):
    """When a block calls a system contract, if at all."""

    NONE = "none"
    BEFORE_TRANSACTIONS = "before_transactions"
    AFTER_TRANSACTIONS = "after_transactions"

BuilderDepositRequest

Bases: FeeSystemContractRequest

Builder deposit request (EIP-8282).

Serves both a builder's first deposit and stake top-ups. The request pays the shared EIP-1559-style fee on top of the staked amount, so its call value is fee + amount * 1 gwei.

Source code in packages/testing/src/execution_testing/forks/forks/eips/amsterdam/eip_8282.py
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
class BuilderDepositRequest(FeeSystemContractRequest):
    """
    Builder deposit request (EIP-8282).

    Serves both a builder's first deposit and stake top-ups. The request pays
    the shared EIP-1559-style fee on top of the staked `amount`, so its call
    value is `fee + amount * 1 gwei`.
    """

    pubkey: BLSPublicKey
    """The public key of the beacon chain builder."""
    withdrawal_credentials: Hash
    """The withdrawal credentials of the beacon chain builder."""
    amount: HexNumber
    """The amount in gwei of the builder deposit."""
    signature: BLSSignature
    """
    The signature of the deposit using the builder's private key that matches
    the `pubkey`.
    """
    extra_wei: int = 0
    """
    Extra wei added to (or, if negative, subtracted from) the call value, used
    to test the predeploy's `value >= fee + amount * 1 gwei` check.
    """

    type: ClassVar[int] = 3
    system_contract_address: ClassVar[Address] = Address(
        BUILDER_DEPOSIT_CONTRACT_ADDRESS,
        label="BUILDER_DEPOSIT_CONTRACT_ADDRESS",
    )
    max_per_block: ClassVar[int] = 64
    target_per_block: ClassVar[int] = 8
    min_fee: ClassVar[int] = 1
    fee_update_fraction: ClassVar[int] = 17
    excess_fee_processing: ClassVar[Literal["block", "call"]] = "call"
    # The 184-byte deposit input: pubkey, withdrawal credentials, amount and
    # signature.
    slots_per_request: ClassVar[int] = 6
    min_deposit_wei: ClassVar[int] = 10**18
    """Minimum credited stake for a builder deposit, in wei (1 ETH)."""

    def __bytes__(self) -> bytes:
        """Return builder deposit's attributes as bytes."""
        return (
            bytes(self.pubkey)
            + bytes(self.withdrawal_credentials)
            + self.amount.to_bytes(8, "little")
            + bytes(self.signature)
        )

    @property
    def value(self) -> int:
        """Return the fee plus the staked amount in wei, plus `extra_wei`."""
        return self.fee + self.amount * 10**9 + self.extra_wei

    @property
    def calldata(self) -> bytes:
        """
        Return the 184-byte input: `pubkey ++ withdrawal_credentials ++ amount
        (big-endian) ++ signature`.
        """
        return self.calldata_modifier(
            bytes(self.pubkey)
            + bytes(self.withdrawal_credentials)
            + self.amount.to_bytes(8, "big")
            + bytes(self.signature)
        )

    def with_source_address(self, source_address: Address) -> Self:
        """Return a copy; deposit records carry no source address."""
        del source_address
        return self.copy()

    @classmethod
    def from_index(cls, index: int) -> Self:
        """Build a builder deposit request from a sequential index."""
        return cls(
            pubkey=index * 3,
            withdrawal_credentials=(index * 3) + 1,
            amount=cls.min_deposit_wei // 10**9,
            signature=(index * 3) + 2,
        )

pubkey instance-attribute

The public key of the beacon chain builder.

withdrawal_credentials instance-attribute

The withdrawal credentials of the beacon chain builder.

amount instance-attribute

The amount in gwei of the builder deposit.

signature instance-attribute

The signature of the deposit using the builder's private key that matches the pubkey.

extra_wei = 0 class-attribute instance-attribute

Extra wei added to (or, if negative, subtracted from) the call value, used to test the predeploy's value >= fee + amount * 1 gwei check.

min_deposit_wei = 10 ** 18 class-attribute

Minimum credited stake for a builder deposit, in wei (1 ETH).

__bytes__()

Return builder deposit's attributes as bytes.

Source code in packages/testing/src/execution_testing/forks/forks/eips/amsterdam/eip_8282.py
77
78
79
80
81
82
83
84
def __bytes__(self) -> bytes:
    """Return builder deposit's attributes as bytes."""
    return (
        bytes(self.pubkey)
        + bytes(self.withdrawal_credentials)
        + self.amount.to_bytes(8, "little")
        + bytes(self.signature)
    )

value property

Return the fee plus the staked amount in wei, plus extra_wei.

calldata property

Return the 184-byte input: pubkey ++ withdrawal_credentials ++ amount (big-endian) ++ signature.

with_source_address(source_address)

Return a copy; deposit records carry no source address.

Source code in packages/testing/src/execution_testing/forks/forks/eips/amsterdam/eip_8282.py
104
105
106
107
def with_source_address(self, source_address: Address) -> Self:
    """Return a copy; deposit records carry no source address."""
    del source_address
    return self.copy()

from_index(index) classmethod

Build a builder deposit request from a sequential index.

Source code in packages/testing/src/execution_testing/forks/forks/eips/amsterdam/eip_8282.py
109
110
111
112
113
114
115
116
117
@classmethod
def from_index(cls, index: int) -> Self:
    """Build a builder deposit request from a sequential index."""
    return cls(
        pubkey=index * 3,
        withdrawal_credentials=(index * 3) + 1,
        amount=cls.min_deposit_wei // 10**9,
        signature=(index * 3) + 2,
    )

BuilderExitRequest

Bases: FeeSystemContractRequest

Builder exit request (EIP-8282).

Authorized by the caller's address (recorded as source_address); it stakes no value and only pays the shared request fee.

Source code in packages/testing/src/execution_testing/forks/forks/eips/amsterdam/eip_8282.py
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
class BuilderExitRequest(FeeSystemContractRequest):
    """
    Builder exit request (EIP-8282).

    Authorized by the caller's address (recorded as `source_address`); it
    stakes no value and only pays the shared request fee.
    """

    source_address: Address = Address(0)
    """
    The address of the execution layer account that made the builder exit
    request.
    """
    pubkey: BLSPublicKey
    """The public key of the builder to exit."""

    type: ClassVar[int] = 4
    system_contract_address: ClassVar[Address] = Address(
        BUILDER_EXIT_CONTRACT_ADDRESS,
        label="BUILDER_EXIT_CONTRACT_ADDRESS",
    )
    max_per_block: ClassVar[int] = 16
    target_per_block: ClassVar[int] = 2
    min_fee: ClassVar[int] = 1
    fee_update_fraction: ClassVar[int] = 17
    excess_fee_processing: ClassVar[Literal["block", "call"]] = "call"
    # Source address, then the 48-byte builder pubkey.
    slots_per_request: ClassVar[int] = 3

    def __bytes__(self) -> bytes:
        """Return builder exit's attributes as bytes."""
        return bytes(self.source_address) + bytes(self.pubkey)

    @property
    def calldata(self) -> bytes:
        """Return the 48-byte input: the builder `pubkey`."""
        return self.calldata_modifier(bytes(self.pubkey))

    def with_source_address(self, source_address: Address) -> Self:
        """Return a copy with the source address set."""
        return self.copy(source_address=source_address)

    @classmethod
    def from_index(cls, index: int) -> Self:
        """Build a builder exit request from a sequential index."""
        return cls(pubkey=index)

source_address = Address(0) class-attribute instance-attribute

The address of the execution layer account that made the builder exit request.

pubkey instance-attribute

The public key of the builder to exit.

__bytes__()

Return builder exit's attributes as bytes.

Source code in packages/testing/src/execution_testing/forks/forks/eips/amsterdam/eip_8282.py
149
150
151
def __bytes__(self) -> bytes:
    """Return builder exit's attributes as bytes."""
    return bytes(self.source_address) + bytes(self.pubkey)

calldata property

Return the 48-byte input: the builder pubkey.

with_source_address(source_address)

Return a copy with the source address set.

Source code in packages/testing/src/execution_testing/forks/forks/eips/amsterdam/eip_8282.py
158
159
160
def with_source_address(self, source_address: Address) -> Self:
    """Return a copy with the source address set."""
    return self.copy(source_address=source_address)

from_index(index) classmethod

Build a builder exit request from a sequential index.

Source code in packages/testing/src/execution_testing/forks/forks/eips/amsterdam/eip_8282.py
162
163
164
165
@classmethod
def from_index(cls, index: int) -> Self:
    """Build a builder exit request from a sequential index."""
    return cls(pubkey=index)

DepositRequest

Bases: SystemContractRequest

Deposit request (EIP-6110), read from the deposit contract's log.

Source code in packages/testing/src/execution_testing/forks/forks/eips/prague/eip_6110.py
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
class DepositRequest(SystemContractRequest):
    """Deposit request (EIP-6110), read from the deposit contract's log."""

    pubkey: BLSPublicKey
    """The public key of the beacon chain validator."""
    withdrawal_credentials: Hash
    """The withdrawal credentials of the beacon chain validator."""
    amount: HexNumber
    """The amount in gwei of the deposit."""
    signature: BLSSignature
    """
    The signature of the deposit using the validator's private key that matches
    the `pubkey`.
    """
    index: HexNumber
    """The index of the deposit."""

    extra_wei: int = 0
    """
    Extra amount in wei to be sent with the deposit. If this value modulo 10**9
    is not zero, the deposit will be invalid. The value can be negative but if
    the total value is negative, an exception will be raised.
    """

    type: ClassVar[int] = 0
    system_contract_address: ClassVar[Address] = Address(
        DEPOSIT_CONTRACT_ADDRESS,
        label="DEPOSIT_CONTRACT_ADDRESS",
    )

    def __bytes__(self) -> bytes:
        """Return deposit's attributes as bytes."""
        return (
            bytes(self.pubkey)
            + bytes(self.withdrawal_credentials)
            + self.amount.to_bytes(8, "little")
            + bytes(self.signature)
            + self.index.to_bytes(8, "little")
        )

    @property
    def value(self) -> int:
        """
        Return the value of the deposit transaction, equal to the amount in
        gwei plus the extra amount in wei.
        """
        value = (self.amount * 10**9) + self.extra_wei
        if value < 0:
            raise ValueError("Value cannot be negative")
        return value

    @cached_property
    def deposit_data_root(self) -> Hash:
        """Return the deposit data root of the deposit."""
        pubkey_root = _sha256(self.pubkey, b"\x00" * 16)
        signature_root = _sha256(
            _sha256(self.signature[:64]),
            _sha256(self.signature[64:], b"\x00" * 32),
        )
        pubkey_withdrawal_root = _sha256(
            pubkey_root, self.withdrawal_credentials
        )
        amount_bytes = (self.amount).to_bytes(32, byteorder="little")
        amount_signature_root = _sha256(amount_bytes, signature_root)
        return Hash(_sha256(pubkey_withdrawal_root, amount_signature_root))

    @property
    def calldata(self) -> bytes:
        """
        Return the calldata needed to call the beacon chain deposit contract
        and make the deposit.

        deposit(
          bytes calldata pubkey,
          bytes calldata withdrawal_credentials,
          bytes calldata signature,
          bytes32 deposit_data_root
        )
        """
        offset_length = 32
        pubkey_offset = offset_length * 3 + len(self.deposit_data_root)
        withdrawal_offset = pubkey_offset + offset_length + len(self.pubkey)
        signature_offset = (
            withdrawal_offset
            + offset_length
            + len(self.withdrawal_credentials)
        )
        return self.calldata_modifier(
            b"\x22\x89\x51\x18"
            + pubkey_offset.to_bytes(offset_length, byteorder="big")
            + withdrawal_offset.to_bytes(offset_length, byteorder="big")
            + signature_offset.to_bytes(offset_length, byteorder="big")
            + self.deposit_data_root
            + len(self.pubkey).to_bytes(offset_length, byteorder="big")
            + self.pubkey
            + len(self.withdrawal_credentials).to_bytes(
                offset_length, byteorder="big"
            )
            + self.withdrawal_credentials
            + len(self.signature).to_bytes(offset_length, byteorder="big")
            + self.signature
        )

    def log(self, *, include_abi_encoding: bool = True) -> bytes:
        """
        Return the log data for the deposit event.

        event DepositEvent(
          bytes pubkey,
          bytes withdrawal_credentials,
          bytes amount,
          bytes signature,
          bytes index
        );
        """
        data = bytearray(576)
        if include_abi_encoding:
            # Insert ABI encoding
            data[30:32] = b"\x00\xa0"  # Offset: pubkey (160)
            data[62:64] = b"\x01\x00"  # Offset: withdrawal_credentials (256)
            data[94:96] = b"\x01\x40"  # Offset: amount (320)
            data[126:128] = b"\x01\x80"  # Offset: signature (384)
            data[158:160] = b"\x02\x00"  # Offset: index (512)
            data[190:192] = b"\x00\x30"  # Size: pubkey (48)
            data[286:288] = b"\x00\x20"  # Size: withdrawal_credentials (32)
            data[350:352] = b"\x00\x08"  # Size: amount (8)
            data[414:416] = b"\x00\x60"  # Size: signature (96)
            data[542:544] = b"\x00\x08"  # Size: index (8)
        offset = 192
        data[offset : offset + len(self.pubkey)] = self.pubkey  # [192:240]
        offset += 48 + len(self.pubkey)
        data[offset : offset + len(self.withdrawal_credentials)] = (
            self.withdrawal_credentials
        )  # [288:320]
        offset += 32 + len(self.withdrawal_credentials)
        data[offset : offset + 8] = (self.amount).to_bytes(
            8, byteorder="little"
        )  # [352:360]
        offset += 56 + 8
        data[offset : offset + len(self.signature)] = (
            self.signature
        )  # [416:512]
        offset += 32 + len(self.signature)
        data[offset : offset + 8] = (self.index).to_bytes(
            8, byteorder="little"
        )  # [544:552]
        return bytes(data)

    def with_source_address(self, source_address: Address) -> Self:
        """Return a copy."""
        del source_address
        return self.copy()

    @classmethod
    def from_index(cls, index: int) -> Self:
        """Build a request from a sequential index."""
        return cls(
            pubkey=(index * 3),
            withdrawal_credentials=(index * 3) + 1,
            amount=1_000_000_000,
            signature=(index * 3) + 2,
            index=index,
        )

pubkey instance-attribute

The public key of the beacon chain validator.

withdrawal_credentials instance-attribute

The withdrawal credentials of the beacon chain validator.

amount instance-attribute

The amount in gwei of the deposit.

signature instance-attribute

The signature of the deposit using the validator's private key that matches the pubkey.

index instance-attribute

The index of the deposit.

extra_wei = 0 class-attribute instance-attribute

Extra amount in wei to be sent with the deposit. If this value modulo 10**9 is not zero, the deposit will be invalid. The value can be negative but if the total value is negative, an exception will be raised.

__bytes__()

Return deposit's attributes as bytes.

Source code in packages/testing/src/execution_testing/forks/forks/eips/prague/eip_6110.py
123
124
125
126
127
128
129
130
131
def __bytes__(self) -> bytes:
    """Return deposit's attributes as bytes."""
    return (
        bytes(self.pubkey)
        + bytes(self.withdrawal_credentials)
        + self.amount.to_bytes(8, "little")
        + bytes(self.signature)
        + self.index.to_bytes(8, "little")
    )

value property

Return the value of the deposit transaction, equal to the amount in gwei plus the extra amount in wei.

deposit_data_root cached property

Return the deposit data root of the deposit.

calldata property

Return the calldata needed to call the beacon chain deposit contract and make the deposit.

deposit( bytes calldata pubkey, bytes calldata withdrawal_credentials, bytes calldata signature, bytes32 deposit_data_root )

log(*, include_abi_encoding=True)

Return the log data for the deposit event.

event DepositEvent( bytes pubkey, bytes withdrawal_credentials, bytes amount, bytes signature, bytes index );

Source code in packages/testing/src/execution_testing/forks/forks/eips/prague/eip_6110.py
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
def log(self, *, include_abi_encoding: bool = True) -> bytes:
    """
    Return the log data for the deposit event.

    event DepositEvent(
      bytes pubkey,
      bytes withdrawal_credentials,
      bytes amount,
      bytes signature,
      bytes index
    );
    """
    data = bytearray(576)
    if include_abi_encoding:
        # Insert ABI encoding
        data[30:32] = b"\x00\xa0"  # Offset: pubkey (160)
        data[62:64] = b"\x01\x00"  # Offset: withdrawal_credentials (256)
        data[94:96] = b"\x01\x40"  # Offset: amount (320)
        data[126:128] = b"\x01\x80"  # Offset: signature (384)
        data[158:160] = b"\x02\x00"  # Offset: index (512)
        data[190:192] = b"\x00\x30"  # Size: pubkey (48)
        data[286:288] = b"\x00\x20"  # Size: withdrawal_credentials (32)
        data[350:352] = b"\x00\x08"  # Size: amount (8)
        data[414:416] = b"\x00\x60"  # Size: signature (96)
        data[542:544] = b"\x00\x08"  # Size: index (8)
    offset = 192
    data[offset : offset + len(self.pubkey)] = self.pubkey  # [192:240]
    offset += 48 + len(self.pubkey)
    data[offset : offset + len(self.withdrawal_credentials)] = (
        self.withdrawal_credentials
    )  # [288:320]
    offset += 32 + len(self.withdrawal_credentials)
    data[offset : offset + 8] = (self.amount).to_bytes(
        8, byteorder="little"
    )  # [352:360]
    offset += 56 + 8
    data[offset : offset + len(self.signature)] = (
        self.signature
    )  # [416:512]
    offset += 32 + len(self.signature)
    data[offset : offset + 8] = (self.index).to_bytes(
        8, byteorder="little"
    )  # [544:552]
    return bytes(data)

with_source_address(source_address)

Return a copy.

Source code in packages/testing/src/execution_testing/forks/forks/eips/prague/eip_6110.py
241
242
243
244
def with_source_address(self, source_address: Address) -> Self:
    """Return a copy."""
    del source_address
    return self.copy()

from_index(index) classmethod

Build a request from a sequential index.

Source code in packages/testing/src/execution_testing/forks/forks/eips/prague/eip_6110.py
246
247
248
249
250
251
252
253
254
255
@classmethod
def from_index(cls, index: int) -> Self:
    """Build a request from a sequential index."""
    return cls(
        pubkey=(index * 3),
        withdrawal_credentials=(index * 3) + 1,
        amount=1_000_000_000,
        signature=(index * 3) + 2,
        index=index,
    )

create_deposit_log_bytes(pubkey_size=48, pubkey_data=b'', pubkey_offset=160, withdrawal_credentials_size=32, withdrawal_credentials_data=b'', withdrawal_credentials_offset=256, amount_size=8, amount_data=b'', amount_offset=320, signature_size=96, signature_data=b'', signature_offset=384, index_size=8, index_data=b'', index_offset=512)

Create the deposit log bytes.

Source code in packages/testing/src/execution_testing/forks/forks/eips/prague/eip_6110.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
def create_deposit_log_bytes(
    pubkey_size: int = 48,
    pubkey_data: bytes = b"",
    pubkey_offset: int = 160,
    withdrawal_credentials_size: int = 32,
    withdrawal_credentials_data: bytes = b"",
    withdrawal_credentials_offset: int = 256,
    amount_size: int = 8,
    amount_data: bytes = b"",
    amount_offset: int = 320,
    signature_size: int = 96,
    signature_data: bytes = b"",
    signature_offset: int = 384,
    index_size: int = 8,
    index_data: bytes = b"",
    index_offset: int = 512,
) -> bytes:
    """Create the deposit log bytes."""
    result = bytearray(576)
    offset = 0

    def write_uint256(value: int) -> None:
        nonlocal offset
        result[offset : offset + 32] = value.to_bytes(32, byteorder="big")
        offset += 32

    def write_bytes(data: bytes, size: int) -> None:
        nonlocal offset
        padded = data.ljust(size, b"\x00")
        result[offset : offset + size] = padded
        offset += size

    write_uint256(pubkey_offset)
    write_uint256(withdrawal_credentials_offset)
    write_uint256(amount_offset)
    write_uint256(signature_offset)
    write_uint256(index_offset)

    write_uint256(pubkey_size)
    write_bytes(pubkey_data, 64)

    write_uint256(withdrawal_credentials_size)
    write_bytes(withdrawal_credentials_data, 32)

    write_uint256(amount_size)
    write_bytes(amount_data, 32)

    write_uint256(signature_size)
    write_bytes(signature_data, 96)

    write_uint256(index_size)
    write_bytes(index_data, 32)

    return bytes(result)

WithdrawalRequest

Bases: FeeSystemContractRequest

Withdrawal request (EIP-7002).

Source code in packages/testing/src/execution_testing/forks/forks/eips/prague/eip_7002.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
class WithdrawalRequest(FeeSystemContractRequest):
    """Withdrawal request (EIP-7002)."""

    source_address: Address = Address(0)
    """
    The address of the execution layer account that made the withdrawal
    request.
    """
    validator_pubkey: BLSPublicKey
    """
    The current public key of the validator as it currently is in the beacon
    state.
    """
    amount: HexNumber
    """The amount in gwei to be withdrawn on the beacon chain."""

    type: ClassVar[int] = 1
    system_contract_address: ClassVar[Address] = Address(
        WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS,
        label="WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS",
    )
    max_per_block: ClassVar[int] = 16
    target_per_block: ClassVar[int] = 2
    min_fee: ClassVar[int] = 1
    fee_update_fraction: ClassVar[int] = 17
    excess_fee_processing: ClassVar[Literal["block", "call"]] = "block"
    # Source address, then the 48-byte validator pubkey and 8-byte amount.
    slots_per_request: ClassVar[int] = 3

    def __bytes__(self) -> bytes:
        """Return withdrawal's attributes as bytes."""
        return (
            bytes(self.source_address)
            + bytes(self.validator_pubkey)
            + self.amount.to_bytes(8, "little")
        )

    @property
    def calldata(self) -> bytes:
        """Return the 56-byte input: `validator_pubkey ++ amount`."""
        return self.calldata_modifier(
            self.validator_pubkey + self.amount.to_bytes(8, byteorder="big")
        )

    def with_source_address(self, source_address: Address) -> Self:
        """Return a copy with the source address set."""
        return self.copy(source_address=source_address)

    @classmethod
    def from_index(cls, index: int) -> Self:
        """Build a withdrawal request from a sequential index."""
        return cls(validator_pubkey=index, amount=0)

source_address = Address(0) class-attribute instance-attribute

The address of the execution layer account that made the withdrawal request.

validator_pubkey instance-attribute

The current public key of the validator as it currently is in the beacon state.

amount instance-attribute

The amount in gwei to be withdrawn on the beacon chain.

__bytes__()

Return withdrawal's attributes as bytes.

Source code in packages/testing/src/execution_testing/forks/forks/eips/prague/eip_7002.py
55
56
57
58
59
60
61
def __bytes__(self) -> bytes:
    """Return withdrawal's attributes as bytes."""
    return (
        bytes(self.source_address)
        + bytes(self.validator_pubkey)
        + self.amount.to_bytes(8, "little")
    )

calldata property

Return the 56-byte input: validator_pubkey ++ amount.

with_source_address(source_address)

Return a copy with the source address set.

Source code in packages/testing/src/execution_testing/forks/forks/eips/prague/eip_7002.py
70
71
72
def with_source_address(self, source_address: Address) -> Self:
    """Return a copy with the source address set."""
    return self.copy(source_address=source_address)

from_index(index) classmethod

Build a withdrawal request from a sequential index.

Source code in packages/testing/src/execution_testing/forks/forks/eips/prague/eip_7002.py
74
75
76
77
@classmethod
def from_index(cls, index: int) -> Self:
    """Build a withdrawal request from a sequential index."""
    return cls(validator_pubkey=index, amount=0)

ConsolidationRequest

Bases: FeeSystemContractRequest

Consolidation request (EIP-7251).

Source code in packages/testing/src/execution_testing/forks/forks/eips/prague/eip_7251.py
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
class ConsolidationRequest(FeeSystemContractRequest):
    """Consolidation request (EIP-7251)."""

    source_address: Address = Address(0)
    """
    The address of the execution layer account that made the consolidation
    request.
    """
    source_pubkey: BLSPublicKey
    """
    The public key of the source validator as it currently is in the beacon
    state.
    """
    target_pubkey: BLSPublicKey
    """
    The public key of the target validator as it currently is in the beacon
    state.
    """

    type: ClassVar[int] = 2
    system_contract_address: ClassVar[Address] = Address(
        CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS,
        label="CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS",
    )
    max_per_block: ClassVar[int] = 2
    target_per_block: ClassVar[int] = 1
    min_fee: ClassVar[int] = 1
    fee_update_fraction: ClassVar[int] = 17
    excess_fee_processing: ClassVar[Literal["block", "call"]] = "block"
    # Source address, then the 48-byte source and target validator pubkeys.
    slots_per_request: ClassVar[int] = 4

    def __bytes__(self) -> bytes:
        """Return consolidation's attributes as bytes."""
        return (
            bytes(self.source_address)
            + bytes(self.source_pubkey)
            + bytes(self.target_pubkey)
        )

    @property
    def calldata(self) -> bytes:
        """Return the 96-byte input: `source_pubkey ++ target_pubkey`."""
        return self.calldata_modifier(self.source_pubkey + self.target_pubkey)

    def with_source_address(self, source_address: Address) -> Self:
        """Return a copy with the source address set."""
        return self.copy(source_address=source_address)

    @classmethod
    def from_index(cls, index: int) -> Self:
        """Build a consolidation request from a sequential index."""
        return cls(source_pubkey=index * 2, target_pubkey=index * 2 + 1)

source_address = Address(0) class-attribute instance-attribute

The address of the execution layer account that made the consolidation request.

source_pubkey instance-attribute

The public key of the source validator as it currently is in the beacon state.

target_pubkey instance-attribute

The public key of the target validator as it currently is in the beacon state.

__bytes__()

Return consolidation's attributes as bytes.

Source code in packages/testing/src/execution_testing/forks/forks/eips/prague/eip_7251.py
57
58
59
60
61
62
63
def __bytes__(self) -> bytes:
    """Return consolidation's attributes as bytes."""
    return (
        bytes(self.source_address)
        + bytes(self.source_pubkey)
        + bytes(self.target_pubkey)
    )

calldata property

Return the 96-byte input: source_pubkey ++ target_pubkey.

with_source_address(source_address)

Return a copy with the source address set.

Source code in packages/testing/src/execution_testing/forks/forks/eips/prague/eip_7251.py
70
71
72
def with_source_address(self, source_address: Address) -> Self:
    """Return a copy with the source address set."""
    return self.copy(source_address=source_address)

from_index(index) classmethod

Build a consolidation request from a sequential index.

Source code in packages/testing/src/execution_testing/forks/forks/eips/prague/eip_7251.py
74
75
76
77
@classmethod
def from_index(cls, index: int) -> Self:
    """Build a consolidation request from a sequential index."""
    return cls(source_pubkey=index * 2, target_pubkey=index * 2 + 1)

BPO1

Bases: Osaka

Mainnet BPO1 fork - Blob Parameter Only fork 1.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
class BPO1(
    Osaka,
    bpo_fork=True,
    update_blob_constants={
        "BLOB_BASE_FEE_UPDATE_FRACTION": 8346193,
        "TARGET_BLOBS_PER_BLOCK": 10,
        "MAX_BLOBS_PER_BLOCK": 15,
    },
):
    """Mainnet BPO1 fork - Blob Parameter Only fork 1."""

    pass

BPO2

Bases: BPO1

Mainnet BPO2 fork - Blob Parameter Only fork 2.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
class BPO2(
    BPO1,
    bpo_fork=True,
    update_blob_constants={
        "BLOB_BASE_FEE_UPDATE_FRACTION": 11684671,
        "TARGET_BLOBS_PER_BLOCK": 14,
        "MAX_BLOBS_PER_BLOCK": 21,
    },
):
    """Mainnet BPO2 fork - Blob Parameter Only fork 2."""

    pass

BPO3

Bases: BPO2

Pseudo BPO3 fork - Blob Parameter Only fork 3. For testing purposes only.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
class BPO3(
    BPO2,
    bpo_fork=True,
    deployed=False,
    update_blob_constants={
        "BLOB_BASE_FEE_UPDATE_FRACTION": 20609697,
        "TARGET_BLOBS_PER_BLOCK": 21,
        "MAX_BLOBS_PER_BLOCK": 32,
    },
):
    """
    Pseudo BPO3 fork - Blob Parameter Only fork 3.
    For testing purposes only.
    """

    pass

BPO4

Bases: BPO3

Pseudo BPO4 fork - Blob Parameter Only fork 4. For testing purposes only. Testing a decrease in values from BPO3.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
class BPO4(
    BPO3,
    bpo_fork=True,
    update_blob_constants={
        "BLOB_BASE_FEE_UPDATE_FRACTION": 13739630,
        "TARGET_BLOBS_PER_BLOCK": 14,
        "MAX_BLOBS_PER_BLOCK": 21,
    },
):
    """
    Pseudo BPO4 fork - Blob Parameter Only fork 4.
    For testing purposes only. Testing a decrease in values from BPO3.
    """

    pass

BPO5

Bases: BPO4

Pseudo BPO5 fork - Blob Parameter Only fork 5. For testing purposes only. Required to parse Fusaka devnet genesis files.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
class BPO5(
    BPO4,
    bpo_fork=True,
):
    """
    Pseudo BPO5 fork - Blob Parameter Only fork 5.
    For testing purposes only. Required to parse Fusaka devnet genesis files.
    """

    pass

Amsterdam

Bases: AmsterdamEIPs, BPO2

Amsterdam fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
class Amsterdam(
    AmsterdamEIPs,
    BPO2,
    deployed=False,
):
    """Amsterdam fork."""

    # TODO: We may need to adjust which BPO Amsterdam inherits from as the
    #  related Amsterdam specs change over time, and before Amsterdam is
    #  live on mainnet.

    @classmethod
    def engine_payload_attribute_target_gas_limit(cls) -> bool:
        """
        Starting from Amsterdam, payload attributes now include the target gas
        limit.
        """
        return True

engine_payload_attribute_target_gas_limit() classmethod

Starting from Amsterdam, payload attributes now include the target gas limit.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1651
1652
1653
1654
1655
1656
1657
@classmethod
def engine_payload_attribute_target_gas_limit(cls) -> bool:
    """
    Starting from Amsterdam, payload attributes now include the target gas
    limit.
    """
    return True

ArrowGlacier

Bases: London

Arrow Glacier fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1478
1479
1480
1481
1482
1483
1484
class ArrowGlacier(
    London,
    ignore=True,
):
    """Arrow Glacier fork."""

    pass

Berlin

Bases: EIP2930, EIP2929, Istanbul

Berlin fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1456
1457
1458
1459
1460
1461
1462
1463
class Berlin(
    eips.EIP2930,
    eips.EIP2929,
    Istanbul,
):
    """Berlin fork."""

    pass

Byzantium

Bases: EIP649, EIP214, EIP211, EIP140, EIP198, EIP196, EIP197, SpuriousDragon

Byzantium fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
class Byzantium(
    eips.EIP649,
    eips.EIP214,
    eips.EIP211,
    eips.EIP140,
    eips.EIP198,
    eips.EIP196,
    eips.EIP197,
    SpuriousDragon,
):
    """Byzantium fork."""

    pass

Cancun

Bases: EIP5656, EIP1153, EIP4788, EIP4844, EIP7516, EIP6780, Shanghai

Cancun fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
class Cancun(
    eips.EIP5656,
    eips.EIP1153,
    eips.EIP4788,
    eips.EIP4844,
    eips.EIP7516,
    eips.EIP6780,
    Shanghai,
):
    """Cancun fork."""

    pass

Constantinople

Bases: EIP1234, EIP1052, EIP1014, EIP145, Byzantium

Constantinople fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
class Constantinople(
    eips.EIP1234,
    eips.EIP1052,
    eips.EIP1014,
    eips.EIP145,
    Byzantium,
):
    """Constantinople fork."""

    pass

ConstantinopleFix

Bases: Constantinople

Constantinople Fix fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1423
1424
1425
1426
1427
1428
1429
class ConstantinopleFix(
    Constantinople,
    ruleset_name="PETERSBURG",
):
    """Constantinople Fix fork."""

    pass

Frontier

Bases: BaseFork

Frontier fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
class Frontier(BaseFork):
    """Frontier fork."""

    @classmethod
    def transition_tool_name(cls) -> str:
        """
        Return fork name as it's meant to be passed to the transition tool for
        execution.
        """
        if cls._transition_tool_name is not None:
            return cls._transition_tool_name
        return cls.name()

    @classmethod
    def header_base_fee_required(cls) -> bool:
        """At genesis, header must not contain base fee."""
        return False

    @classmethod
    def header_prev_randao_required(cls) -> bool:
        """At genesis, header must not contain Prev Randao value."""
        return False

    @classmethod
    def header_zero_difficulty_required(cls) -> bool:
        """At genesis, header must not have difficulty zero."""
        return False

    @classmethod
    def header_withdrawals_required(cls) -> bool:
        """At genesis, header must not contain withdrawals."""
        return False

    @classmethod
    def header_excess_blob_gas_required(cls) -> bool:
        """At genesis, header must not contain excess blob gas."""
        return False

    @classmethod
    def header_blob_gas_used_required(cls) -> bool:
        """At genesis, header must not contain blob gas used."""
        return False

    @classmethod
    def gas_costs(cls) -> GasCosts:
        """
        Return dataclass with the defined gas costs constants for genesis.
        """
        return GasCosts(
            # Tiers
            BASE=BASE,
            VERY_LOW=VERY_LOW,
            LOW=LOW,
            MID=MID,
            HIGH=HIGH,
            # Access
            WARM_ACCESS=100,
            COLD_ACCOUNT_ACCESS=2_600,
            WARM_SLOAD=100,
            COLD_STORAGE_ACCESS=2_100,
            OPCODE_BALANCE=20,
            OPCODE_EXTERNAL_BASE=20,
            OPCODE_CALL_BASE=40,
            OPCODE_SLOAD=50,
            # Storage
            STORAGE_SET=20_000,
            COLD_STORAGE_WRITE=5_000,
            STORAGE_RESET=2_900,
            # Call
            CALL_VALUE=9_000,
            CALL_STIPEND=2_300,
            NEW_ACCOUNT=25_000,
            # Contract Creation
            CODE_DEPOSIT_PER_BYTE=200,
            # Authorization
            AUTH_PER_EMPTY_ACCOUNT=0,
            # Utility
            MEMORY_PER_WORD=3,
            # Transactions
            TX_BASE=21_000,
            TX_ACCESS_LIST_ADDRESS=2_400,
            TX_ACCESS_LIST_STORAGE_KEY=1_900,
            TX_DATA_PER_ZERO=4,
            TX_DATA_PER_NON_ZERO=68,
            TX_CREATE=32_000,
            # Refunds
            REFUND_STORAGE_CLEAR=15_000,
            REFUND_SELF_DESTRUCT=24_000,
            REFUND_AUTH_PER_EXISTING_ACCOUNT=0,
            # Precompiles
            PRECOMPILE_ECRECOVER=3_000,
            PRECOMPILE_SHA256_BASE=60,
            PRECOMPILE_SHA256_PER_WORD=12,
            PRECOMPILE_RIPEMD160_BASE=600,
            PRECOMPILE_RIPEMD160_PER_WORD=120,
            PRECOMPILE_IDENTITY_BASE=15,
            PRECOMPILE_IDENTITY_PER_WORD=3,
            # Static Opcodes
            OPCODE_ADD=VERY_LOW,
            OPCODE_SUB=VERY_LOW,
            OPCODE_MUL=LOW,
            OPCODE_DIV=LOW,
            OPCODE_SDIV=LOW,
            OPCODE_MOD=LOW,
            OPCODE_SMOD=LOW,
            OPCODE_ADDMOD=MID,
            OPCODE_MULMOD=MID,
            OPCODE_SIGNEXTEND=LOW,
            OPCODE_LT=VERY_LOW,
            OPCODE_GT=VERY_LOW,
            OPCODE_SLT=VERY_LOW,
            OPCODE_SGT=VERY_LOW,
            OPCODE_EQ=VERY_LOW,
            OPCODE_ISZERO=VERY_LOW,
            OPCODE_AND=VERY_LOW,
            OPCODE_OR=VERY_LOW,
            OPCODE_XOR=VERY_LOW,
            OPCODE_NOT=VERY_LOW,
            OPCODE_BYTE=VERY_LOW,
            OPCODE_JUMP=MID,
            OPCODE_JUMPI=HIGH,
            OPCODE_JUMPDEST=1,
            OPCODE_CALLDATALOAD=VERY_LOW,
            OPCODE_BLOCKHASH=20,
            OPCODE_COINBASE=BASE,
            OPCODE_PUSH=VERY_LOW,
            OPCODE_DUP=VERY_LOW,
            OPCODE_SWAP=VERY_LOW,
            # Dynamic Opcode Components
            OPCODE_CALLDATACOPY_BASE=VERY_LOW,
            OPCODE_CODECOPY_BASE=VERY_LOW,
            OPCODE_MLOAD_BASE=VERY_LOW,
            OPCODE_MSTORE_BASE=VERY_LOW,
            OPCODE_MSTORE8_BASE=VERY_LOW,
            OPCODE_SELFDESTRUCT_BASE=0,
            OPCODE_COPY_PER_WORD=3,
            OPCODE_CREATE_BASE=32_000,
            OPCODE_EXP_BASE=10,
            OPCODE_EXP_PER_BYTE=10,
            OPCODE_LOG_BASE=375,
            OPCODE_LOG_DATA_PER_BYTE=8,
            OPCODE_LOG_TOPIC=375,
            OPCODE_KECCAK256_BASE=30,
            OPCODE_KECCAK256_PER_WORD=6,
            # Zero-initialized: introduced in later forks, set via
            # replace() in the fork that activates them.
            CODE_INIT_PER_WORD=0,
            TX_DATA_TOKEN_STANDARD=0,
            TX_DATA_TOKEN_FLOOR=0,
            PRECOMPILE_ECADD=0,
            PRECOMPILE_ECMUL=0,
            PRECOMPILE_ECPAIRING_BASE=0,
            PRECOMPILE_ECPAIRING_PER_POINT=0,
            PRECOMPILE_BLAKE2F_BASE=0,
            PRECOMPILE_BLAKE2F_PER_ROUND=0,
            PRECOMPILE_POINT_EVALUATION=0,
            PRECOMPILE_BLS_G1ADD=0,
            PRECOMPILE_BLS_G1MUL=0,
            PRECOMPILE_BLS_G1MAP=0,
            PRECOMPILE_BLS_G2ADD=0,
            PRECOMPILE_BLS_G2MUL=0,
            PRECOMPILE_BLS_G2MAP=0,
            PRECOMPILE_BLS_PAIRING_BASE=0,
            PRECOMPILE_BLS_PAIRING_PER_PAIR=0,
            PRECOMPILE_P256VERIFY=0,
            BLOCK_ACCESS_LIST_ITEM=0,
        )

    @classmethod
    def _with_memory_expansion(
        cls,
        base_gas: int | Callable[[OpcodeBase], int],
        memory_expansion_gas_calculator: MemoryExpansionGasCalculator,
    ) -> Callable[[OpcodeBase], int]:
        """
        Wrap a gas cost calculator to include memory expansion cost.

        Args:
            base_gas: Either a constant gas cost (int) or a callable that
                      calculates it
            memory_expansion_gas_calculator: Calculator for memory expansion
                                             cost

        Returns:
            A callable that calculates base_gas + memory_expansion_cost

        """

        def wrapper(opcode: OpcodeBase) -> int:
            # Calculate base gas cost
            if callable(base_gas):
                base_cost = base_gas(opcode)
            else:
                base_cost = base_gas

            # Add memory expansion cost if metadata is present
            new_memory_size = opcode.metadata["new_memory_size"]
            old_memory_size = opcode.metadata["old_memory_size"]
            expansion_cost = memory_expansion_gas_calculator(
                new_bytes=new_memory_size, previous_bytes=old_memory_size
            )

            return base_cost + expansion_cost

        return wrapper

    @classmethod
    def _with_account_access(
        cls,
        base_gas: int | Callable[[OpcodeBase], int],
        gas_costs: "GasCosts",
    ) -> Callable[[OpcodeBase], int]:
        """
        Wrap a gas cost calculator to include account access cost.

        Args:
            base_gas: Either a constant gas cost (int) or a callable that
                      calculates it
            gas_costs: The gas costs dataclass for accessing warm/cold costs

        Returns:
            A callable that calculates base_gas + account_access_cost

        """

        def wrapper(opcode: OpcodeBase) -> int:
            # Calculate base gas cost
            if callable(base_gas):
                base_cost = base_gas(opcode)
            else:
                base_cost = base_gas

            # Add account access cost based on warmth
            if opcode.metadata["address_warm"]:
                access_cost = gas_costs.WARM_ACCESS
            else:
                access_cost = gas_costs.COLD_ACCOUNT_ACCESS

            return base_cost + access_cost

        return wrapper

    @classmethod
    def _with_data_copy(
        cls,
        base_gas: int | Callable[[OpcodeBase], int],
        gas_costs: "GasCosts",
    ) -> Callable[[OpcodeBase], int]:
        """
        Wrap a gas cost calculator to include data copy cost.

        Args:
            base_gas: Either a constant gas cost (int) or a callable that
                      calculates it
            gas_costs: The gas costs dataclass for accessing
                       OPCODE_COPY_PER_WORD

        Returns:
            A callable that calculates base_gas + copy_cost

        """

        def wrapper(opcode: OpcodeBase) -> int:
            # Calculate base gas cost
            if callable(base_gas):
                base_cost = base_gas(opcode)
            else:
                base_cost = base_gas

            # Add copy cost based on data size
            data_size = opcode.metadata["data_size"]
            word_count = (data_size + 31) // 32
            copy_cost = gas_costs.OPCODE_COPY_PER_WORD * word_count

            return base_cost + copy_cost

        return wrapper

    @classmethod
    def minimum_block_gas_limit(cls) -> int:
        """
        Return the minimum gas limit for the block to be considered valid.
        """
        minimum_block_gas_limit = 5_000
        bal_minimum_block_gas_limit = 0
        if cls.header_bal_hash_required():
            # The block gas limit is influenced by the minimum amount of
            # block level access elements the system contracts contain.
            bal_minimum_block_gas_limit = (
                cls.empty_block_bal_item_count()
                * cls.gas_costs().BLOCK_ACCESS_LIST_ITEM
            )
        return max(minimum_block_gas_limit, bal_minimum_block_gas_limit)

    @classmethod
    def opcode_gas_map(
        cls,
    ) -> Dict[OpcodeBase, int | Callable[[OpcodeBase], int]]:
        """
        Return a mapping of opcodes to their gas costs.
        """
        gas_costs = cls.gas_costs()
        memory_expansion_calculator = cls.memory_expansion_gas_calculator()

        return {
            Opcodes.STOP: 0,
            Opcodes.ADD: gas_costs.OPCODE_ADD,
            Opcodes.MUL: gas_costs.OPCODE_MUL,
            Opcodes.SUB: gas_costs.OPCODE_SUB,
            Opcodes.DIV: gas_costs.OPCODE_DIV,
            Opcodes.SDIV: gas_costs.OPCODE_SDIV,
            Opcodes.MOD: gas_costs.OPCODE_MOD,
            Opcodes.SMOD: gas_costs.OPCODE_SMOD,
            Opcodes.ADDMOD: gas_costs.OPCODE_ADDMOD,
            Opcodes.MULMOD: gas_costs.OPCODE_MULMOD,
            Opcodes.EXP: lambda op: (
                gas_costs.OPCODE_EXP_BASE
                + gas_costs.OPCODE_EXP_PER_BYTE
                * ((op.metadata["exponent"].bit_length() + 7) // 8)
            ),
            Opcodes.SIGNEXTEND: gas_costs.OPCODE_SIGNEXTEND,
            Opcodes.LT: gas_costs.OPCODE_LT,
            Opcodes.GT: gas_costs.OPCODE_GT,
            Opcodes.SLT: gas_costs.OPCODE_SLT,
            Opcodes.SGT: gas_costs.OPCODE_SGT,
            Opcodes.EQ: gas_costs.OPCODE_EQ,
            Opcodes.ISZERO: gas_costs.OPCODE_ISZERO,
            Opcodes.AND: gas_costs.OPCODE_AND,
            Opcodes.OR: gas_costs.OPCODE_OR,
            Opcodes.XOR: gas_costs.OPCODE_XOR,
            Opcodes.NOT: gas_costs.OPCODE_NOT,
            Opcodes.BYTE: gas_costs.OPCODE_BYTE,
            Opcodes.SHA3: cls._with_memory_expansion(
                lambda op: (
                    gas_costs.OPCODE_KECCAK256_BASE
                    + gas_costs.OPCODE_KECCAK256_PER_WORD
                    * ((op.metadata["data_size"] + 31) // 32)
                ),
                memory_expansion_calculator,
            ),
            Opcodes.ADDRESS: gas_costs.BASE,
            Opcodes.BALANCE: gas_costs.OPCODE_BALANCE,
            Opcodes.ORIGIN: gas_costs.BASE,
            Opcodes.CALLER: gas_costs.BASE,
            Opcodes.CALLVALUE: gas_costs.BASE,
            Opcodes.CALLDATALOAD: gas_costs.OPCODE_CALLDATALOAD,
            Opcodes.CALLDATASIZE: gas_costs.BASE,
            Opcodes.CALLDATACOPY: cls._with_memory_expansion(
                cls._with_data_copy(
                    gas_costs.OPCODE_CALLDATACOPY_BASE, gas_costs
                ),
                memory_expansion_calculator,
            ),
            Opcodes.CODESIZE: gas_costs.BASE,
            Opcodes.CODECOPY: cls._with_memory_expansion(
                cls._with_data_copy(gas_costs.OPCODE_CODECOPY_BASE, gas_costs),
                memory_expansion_calculator,
            ),
            Opcodes.GASPRICE: gas_costs.BASE,
            Opcodes.EXTCODESIZE: gas_costs.OPCODE_EXTERNAL_BASE,
            Opcodes.EXTCODECOPY: cls._with_memory_expansion(
                cls._with_data_copy(
                    gas_costs.OPCODE_EXTERNAL_BASE,
                    gas_costs,
                ),
                memory_expansion_calculator,
            ),
            Opcodes.BLOCKHASH: gas_costs.OPCODE_BLOCKHASH,
            Opcodes.COINBASE: gas_costs.OPCODE_COINBASE,
            Opcodes.TIMESTAMP: gas_costs.BASE,
            Opcodes.NUMBER: gas_costs.BASE,
            Opcodes.PREVRANDAO: gas_costs.BASE,
            Opcodes.GASLIMIT: gas_costs.BASE,
            Opcodes.POP: gas_costs.BASE,
            Opcodes.MLOAD: cls._with_memory_expansion(
                gas_costs.OPCODE_MLOAD_BASE,
                memory_expansion_calculator,
            ),
            Opcodes.MSTORE: cls._with_memory_expansion(
                gas_costs.OPCODE_MSTORE_BASE,
                memory_expansion_calculator,
            ),
            Opcodes.MSTORE8: cls._with_memory_expansion(
                gas_costs.OPCODE_MSTORE8_BASE,
                memory_expansion_calculator,
            ),
            Opcodes.SLOAD: gas_costs.OPCODE_SLOAD,
            Opcodes.SSTORE: lambda op: cls._calculate_sstore_gas(
                op, gas_costs
            ),
            Opcodes.JUMP: gas_costs.OPCODE_JUMP,
            Opcodes.JUMPI: gas_costs.OPCODE_JUMPI,
            Opcodes.PC: gas_costs.BASE,
            Opcodes.MSIZE: gas_costs.BASE,
            Opcodes.GAS: gas_costs.BASE,
            Opcodes.JUMPDEST: gas_costs.OPCODE_JUMPDEST,
            **{
                getattr(Opcodes, f"PUSH{i}"): gas_costs.OPCODE_PUSH
                for i in range(1, 33)
            },
            **{
                getattr(Opcodes, f"DUP{i}"): gas_costs.OPCODE_DUP
                for i in range(1, 17)
            },
            **{
                getattr(Opcodes, f"SWAP{i}"): gas_costs.OPCODE_SWAP
                for i in range(1, 17)
            },
            Opcodes.LOG0: cls._with_memory_expansion(
                lambda op: (
                    gas_costs.OPCODE_LOG_BASE
                    + gas_costs.OPCODE_LOG_DATA_PER_BYTE
                    * op.metadata["data_size"]
                ),
                memory_expansion_calculator,
            ),
            Opcodes.LOG1: cls._with_memory_expansion(
                lambda op: (
                    gas_costs.OPCODE_LOG_BASE
                    + gas_costs.OPCODE_LOG_DATA_PER_BYTE
                    * op.metadata["data_size"]
                    + gas_costs.OPCODE_LOG_TOPIC
                ),
                memory_expansion_calculator,
            ),
            Opcodes.LOG2: cls._with_memory_expansion(
                lambda op: (
                    gas_costs.OPCODE_LOG_BASE
                    + gas_costs.OPCODE_LOG_DATA_PER_BYTE
                    * op.metadata["data_size"]
                    + gas_costs.OPCODE_LOG_TOPIC * 2
                ),
                memory_expansion_calculator,
            ),
            Opcodes.LOG3: cls._with_memory_expansion(
                lambda op: (
                    gas_costs.OPCODE_LOG_BASE
                    + gas_costs.OPCODE_LOG_DATA_PER_BYTE
                    * op.metadata["data_size"]
                    + gas_costs.OPCODE_LOG_TOPIC * 3
                ),
                memory_expansion_calculator,
            ),
            Opcodes.LOG4: cls._with_memory_expansion(
                lambda op: (
                    gas_costs.OPCODE_LOG_BASE
                    + gas_costs.OPCODE_LOG_DATA_PER_BYTE
                    * op.metadata["data_size"]
                    + gas_costs.OPCODE_LOG_TOPIC * 4
                ),
                memory_expansion_calculator,
            ),
            Opcodes.CREATE: cls._with_memory_expansion(
                lambda op: cls._calculate_create_gas(op, gas_costs),
                memory_expansion_calculator,
            ),
            Opcodes.CALL: cls._with_memory_expansion(
                lambda op: cls._calculate_call_gas(op, gas_costs),
                memory_expansion_calculator,
            ),
            Opcodes.CALLCODE: cls._with_memory_expansion(
                lambda op: cls._calculate_call_gas(op, gas_costs),
                memory_expansion_calculator,
            ),
            Opcodes.RETURN: cls._with_memory_expansion(
                lambda op: cls._calculate_return_gas(op, gas_costs),
                memory_expansion_calculator,
            ),
            Opcodes.INVALID: 0,
            Opcodes.SELFDESTRUCT: lambda op: cls._calculate_selfdestruct_gas(
                op, gas_costs
            ),
        }

    @classmethod
    def opcode_gas_calculator(cls) -> OpcodeGasCalculator:
        """
        Return callable that calculates the gas cost of a single opcode.
        """
        opcode_gas_map = cls.opcode_gas_map()

        def fn(opcode: OpcodeBase) -> int:
            if opcode not in opcode_gas_map:
                raise ValueError(
                    f"No gas cost defined for opcode: {opcode._name_}"
                )
            gas_cost_or_calculator = opcode_gas_map[opcode]

            if callable(gas_cost_or_calculator):
                return gas_cost_or_calculator(opcode)

            return gas_cost_or_calculator

        return fn

    @classmethod
    def opcode_state_map(
        cls,
    ) -> Dict[OpcodeBase, int | Callable[[OpcodeBase], int]]:
        """
        Return a mapping of opcodes to their state gas costs.
        """
        return {}

    @classmethod
    def opcode_state_calculator(cls) -> OpcodeGasCalculator:
        """
        Return callable that calculates the state gas of a single opcode.
        """

        def fn(opcode: OpcodeBase) -> int:
            del opcode
            return 0

        return fn

    @classmethod
    def opcode_refund_map(
        cls,
    ) -> Dict[OpcodeBase, int | Callable[[OpcodeBase], int]]:
        """
        Return a mapping of opcodes to their gas refunds.
        """
        gas_costs = cls.gas_costs()

        return {
            Opcodes.SSTORE: lambda op: cls._calculate_sstore_refund(
                op, gas_costs
            ),
            Opcodes.SELFDESTRUCT: lambda op: (
                gas_costs.REFUND_SELF_DESTRUCT
                if op.metadata["self_destructed_account"]
                else 0
            ),
        }

    @classmethod
    def opcode_refund_calculator(cls) -> OpcodeGasCalculator:
        """
        Return callable that calculates the gas refund of a single opcode.
        """
        opcode_refund_map = cls.opcode_refund_map()

        def fn(opcode: OpcodeBase) -> int:
            if opcode not in opcode_refund_map:
                return 0
            refund_or_calculator = opcode_refund_map[opcode]

            if callable(refund_or_calculator):
                return refund_or_calculator(opcode)

            return refund_or_calculator

        return fn

    @classmethod
    def opcode_state_refund_map(
        cls,
    ) -> Dict[OpcodeBase, int | Callable[[OpcodeBase], int]]:
        """
        Return a mapping of opcodes to their state refunds.
        """
        return {}

    @classmethod
    def opcode_state_refund_calculator(cls) -> OpcodeGasCalculator:
        """
        Return callable that calculates the state refund of a single opcode.
        """

        def fn(opcode: OpcodeBase) -> int:
            del opcode
            return 0

        return fn

    @classmethod
    def _calculate_sstore_refund(
        cls, opcode: OpcodeBase, gas_costs: GasCosts
    ) -> int:
        """Calculate SSTORE gas refund based on metadata."""
        metadata = opcode.metadata

        current_value = metadata["current_value"]
        if current_value is None:
            current_value = metadata["original_value"]
        new_value = metadata["new_value"]

        # Every clearing write is refunded, no net metering before
        # EIP-2200.
        if current_value != 0 and new_value == 0:
            return gas_costs.REFUND_STORAGE_CLEAR

        return 0

    @classmethod
    def _calculate_sstore_gas(
        cls, opcode: OpcodeBase, gas_costs: GasCosts
    ) -> int:
        """Calculate SSTORE gas cost based on metadata."""
        metadata = opcode.metadata

        current_value = metadata["current_value"]
        if current_value is None:
            current_value = metadata["original_value"]
        new_value = metadata["new_value"]

        # The charge depends on the current value only, no net metering
        # before EIP-2200.
        if current_value == 0 and new_value != 0:
            return gas_costs.STORAGE_SET

        return gas_costs.COLD_STORAGE_WRITE

    @classmethod
    def _call_access_cost(cls, opcode: OpcodeBase, gas_costs: GasCosts) -> int:
        """
        Return the CALL family account access cost.

        Flat before EIP-2929 introduces warm and cold pricing.
        """
        del opcode
        return gas_costs.OPCODE_CALL_BASE

    @classmethod
    def _selfdestruct_access_cost(
        cls, opcode: OpcodeBase, gas_costs: GasCosts
    ) -> int:
        """
        Return the SELFDESTRUCT beneficiary access cost.

        Zero before EIP-2929 introduces warm and cold pricing.
        """
        del opcode, gas_costs
        return 0

    @classmethod
    def _calculate_call_gas(
        cls, opcode: OpcodeBase, gas_costs: GasCosts
    ) -> int:
        """
        Calculate CALL/DELEGATECALL/STATICCALL gas cost based on metadata.
        """
        metadata = opcode.metadata

        base_cost = cls._call_access_cost(opcode, gas_costs)

        if metadata["inner_call_cost"]:
            base_cost += metadata["inner_call_cost"]

        # Value transfer and new account charges apply from Frontier.
        # They are independent until EIP-161 couples the new account
        # charge to a value transfer.
        if "value_transfer" in metadata and metadata["value_transfer"]:
            base_cost += gas_costs.CALL_VALUE
        if "account_new" in metadata and metadata["account_new"]:
            base_cost += gas_costs.NEW_ACCOUNT

        return base_cost

    @classmethod
    def _calculate_create_gas(
        cls, opcode: OpcodeBase, gas_costs: GasCosts
    ) -> int:
        """CREATE gas is constant at Frontier."""
        del opcode
        return gas_costs.OPCODE_CREATE_BASE

    @classmethod
    def _calculate_create2_gas(
        cls, opcode: OpcodeBase, gas_costs: GasCosts
    ) -> int:
        """
        Calculate CREATE2 gas cost including initcode cost.
        """
        raise NotImplementedError(
            f"CREATE2 opcode is not supported in {cls.name()}"
        )

    @classmethod
    def _calculate_return_gas(
        cls, opcode: OpcodeBase, gas_costs: GasCosts
    ) -> int:
        """Calculate RETURN gas cost based on metadata."""
        metadata = opcode.metadata

        # Code deposit cost when returning from initcode
        code_deposit_size = metadata["code_deposit_size"]
        return gas_costs.CODE_DEPOSIT_PER_BYTE * code_deposit_size

    @classmethod
    def _calculate_selfdestruct_gas(
        cls, opcode: OpcodeBase, gas_costs: GasCosts
    ) -> int:
        """Calculate SELFDESTRUCT gas cost based on metadata."""
        base_cost = gas_costs.OPCODE_SELFDESTRUCT_BASE

        base_cost += cls._selfdestruct_access_cost(opcode, gas_costs)

        return base_cost

    @classmethod
    def memory_expansion_gas_calculator(cls) -> MemoryExpansionGasCalculator:
        """
        Return callable that calculates the gas cost of memory expansion for
        the fork.
        """
        gas_costs = cls.gas_costs()

        def fn(*, new_bytes: int, previous_bytes: int = 0) -> int:
            if new_bytes <= previous_bytes:
                return 0
            new_words = ceiling_division(new_bytes, 32)
            previous_words = ceiling_division(previous_bytes, 32)

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

            return c(new_words) - c(previous_words)

        return fn

    @classmethod
    def calldata_gas_calculator(cls) -> CalldataGasCalculator:
        """
        Return callable that calculates the transaction gas cost for its
        calldata depending on its contents.
        """
        gas_costs = cls.gas_costs()

        def fn(*, data: BytesConvertible, floor: bool = False) -> int:
            del floor

            raw = Bytes(data)
            num_zeros = raw.count(0)
            num_non_zeros = len(raw) - num_zeros
            return (
                num_zeros * gas_costs.TX_DATA_PER_ZERO
                + num_non_zeros * gas_costs.TX_DATA_PER_NON_ZERO
            )

        return fn

    @classmethod
    def base_fee_per_gas_calculator(cls) -> BaseFeePerGasCalculator:
        """
        Return a callable that calculates the base fee per gas at a given fork.
        """
        raise NotImplementedError(
            f"Base fee per gas calculator is not supported in {cls.name()}"
        )

    @classmethod
    def base_fee_change_calculator(cls) -> BaseFeeChangeCalculator:
        """
        Return a callable that calculates the gas that needs to be used to
        change the base fee.
        """
        raise NotImplementedError(
            f"Base fee change calculator is not supported in {cls.name()}"
        )

    @classmethod
    def cost_per_state_byte(cls) -> int:
        """
        Return the cost per state byte, 0 before state gas applies.
        """
        return 0

    @classmethod
    def base_fee_max_change_denominator(cls) -> int:
        """Return the base fee max change denominator at a given fork."""
        raise NotImplementedError(
            f"Base fee max change denominator is not supported in {cls.name()}"
        )

    @classmethod
    def base_fee_elasticity_multiplier(cls) -> int:
        """Return the base fee elasticity multiplier at a given fork."""
        raise NotImplementedError(
            f"Base fee elasticity multiplier is not supported in {cls.name()}"
        )

    @classmethod
    def transaction_data_floor_cost_calculator(
        cls,
    ) -> TransactionDataFloorCostCalculator:
        """At frontier, the transaction data floor cost is a constant zero."""

        def fn(
            *,
            data: BytesConvertible,
            access_list: List[AccessList] | None = None,
            contract_creation: bool = False,
            sends_value: bool = False,
            recipient_type: RecipientType = RecipientType.CONTRACT,
        ) -> int:
            del data, access_list
            del contract_creation, sends_value, recipient_type
            return 0

        return fn

    @classmethod
    def transaction_intrinsic_cost_calculator(
        cls,
    ) -> TransactionIntrinsicCostCalculator:
        """
        Return callable that calculates the intrinsic gas cost of a transaction
        for the fork.
        """
        gas_costs = cls.gas_costs()
        calldata_gas_calculator = cls.calldata_gas_calculator()

        def fn(
            *,
            calldata: BytesConvertible = b"",
            contract_creation: bool = False,
            access_list: List[AccessList] | None = None,
            authorization_list_or_count: Sized | int | None = None,
            return_cost_deducted_prior_execution: bool = False,
            sends_value: bool = False,
            recipient_type: RecipientType = RecipientType.CONTRACT,
        ) -> int:
            del return_cost_deducted_prior_execution
            del sends_value, recipient_type
            del contract_creation

            assert access_list is None, (
                f"Access list is not supported in {cls.name()}"
            )
            assert authorization_list_or_count is None, (
                f"Authorizations are not supported in {cls.name()}"
            )

            intrinsic_cost: int = gas_costs.TX_BASE

            return intrinsic_cost + calldata_gas_calculator(data=calldata)

        return fn

    @classmethod
    def blob_gas_price_calculator(cls) -> BlobGasPriceCalculator:
        """
        Return a callable that calculates the blob gas price at a given fork.
        """
        raise NotImplementedError(
            f"Blob gas price calculator is not supported in {cls.name()}"
        )

    @classmethod
    def excess_blob_gas_calculator(cls) -> ExcessBlobGasCalculator:
        """
        Return a callable that calculates the excess blob gas for a block at a
        given fork.
        """
        raise NotImplementedError(
            f"Excess blob gas calculator is not supported in {cls.name()}"
        )

    @classmethod
    def supports_blobs(cls) -> bool:
        """Blobs are not supported at Frontier."""
        return False

    @classmethod
    def blob_reserve_price_active(cls) -> bool:
        """
        Return whether the fork uses a reserve price mechanism for blobs or
        not.
        """
        raise NotImplementedError(
            f"Blob reserve price is not supported in {cls.name()}"
        )

    @classmethod
    def full_blob_tx_wrapper_version(cls) -> int | None:
        """Return the version of the full blob transaction wrapper."""
        raise NotImplementedError(
            "Full blob transaction wrapper version is not supported in "
            f"{cls.name()}"
        )

    @classmethod
    def blob_schedule(cls) -> BlobSchedule | None:
        """At genesis, no blob schedule is used."""
        return None

    @classmethod
    def header_requests_required(cls) -> bool:
        """At genesis, header must not contain beacon chain requests."""
        return False

    @classmethod
    def header_bal_hash_required(cls) -> bool:
        """At genesis, header must not contain block access list hash."""
        return False

    @classmethod
    def empty_block_bal_item_count(cls) -> int:
        """Pre-Amsterdam forks have no block access list."""
        return 0

    @classmethod
    def header_beacon_root_required(cls) -> bool:
        """At genesis, header must not contain parent beacon block root."""
        return False

    @classmethod
    def header_slot_number_required(cls) -> bool:
        """At genesis, header must not contain slot number (EIP-7843)."""
        return False

    @classmethod
    def engine_new_payload_blob_hashes(cls) -> bool:
        """At genesis, payloads do not have blob hashes."""
        return False

    @classmethod
    def engine_new_payload_beacon_root(cls) -> bool:
        """At genesis, payloads do not have a parent beacon block root."""
        return False

    @classmethod
    def engine_new_payload_requests(cls) -> bool:
        """At genesis, payloads do not have requests."""
        return False

    @classmethod
    def engine_execution_payload_block_access_list(cls) -> bool:
        """At genesis, payloads do not have block access list."""
        return False

    @classmethod
    def engine_new_payload_target_blobs_per_block(cls) -> bool:
        """At genesis, payloads do not have target blobs per block."""
        return False

    @classmethod
    def engine_payload_attribute_target_blobs_per_block(cls) -> bool:
        """
        At genesis, payload attributes do not include the target blobs per
        block.
        """
        return False

    @classmethod
    def engine_payload_attribute_max_blobs_per_block(cls) -> bool:
        """
        At genesis, payload attributes do not include the max blobs per block.
        """
        return False

    @classmethod
    def engine_payload_attribute_slot_number(cls) -> bool:
        """
        At genesis, payload attributes do not include the slot number.
        """
        return False

    @classmethod
    def engine_payload_attribute_target_gas_limit(cls) -> bool:
        """
        At genesis, payload attributes do not include the target gas limit.
        """
        return False

    @classmethod
    def get_reward(cls) -> int:
        """
        At Genesis the expected reward amount in wei is
        5_000_000_000_000_000_000.
        """
        return 5_000_000_000_000_000_000

    @classmethod
    def supports_protected_txs(cls) -> bool:
        """At Genesis, fork has no support for EIP-155 protected txs."""
        return False

    @classmethod
    def tx_types(cls) -> List[int]:
        """At Genesis, only legacy transactions are allowed."""
        return [0]

    @classmethod
    def contract_creating_tx_types(cls) -> List[int]:
        """At Genesis, only legacy transactions are allowed."""
        return [0]

    @classmethod
    def transaction_gas_limit_cap(cls) -> int | None:
        """At Genesis, no transaction gas limit cap is imposed."""
        return None

    @classmethod
    def state_gas_reservoir_enabled(cls) -> bool:
        """
        At Genesis, state gas reservoir is not enabled.
        """
        return False

    @classmethod
    def code_deposit_state_gas(cls, *, code_size: int) -> int:
        """Return the state gas for code deposit of the given size."""
        del code_size
        return 0

    @classmethod
    def create_state_gas(cls, *, code_size: int = 0) -> int:
        """Return total state gas for CREATE (new account + code deposit)."""
        del code_size
        return 0

    @classmethod
    def block_rlp_size_limit(cls) -> int | None:
        """At Genesis, no RLP block size limit is imposed."""
        return None

    @classmethod
    def precompiles(cls) -> List[Address]:
        """
        At Genesis, EC-recover, SHA256, RIPEMD160, and Identity precompiles
        are introduced.
        """
        return [
            Address(1, label="ECREC"),
            Address(2, label="SHA256"),
            Address(3, label="RIPEMD160"),
            Address(4, label="ID"),
        ]

    @classmethod
    def system_contracts(cls) -> List[Address]:
        """At Genesis, no system contracts are present."""
        return []

    @classmethod
    def system_contract_request_types(
        cls,
    ) -> List[Type[SystemContractRequest]]:
        """At Genesis, no system contract triggers execution requests."""
        return []

    @classmethod
    def system_contract_call_phases(cls) -> Mapping[Address, SystemCallPhase]:
        """At Genesis, no system contract is called."""
        return {}

    @classmethod
    def deterministic_factory_predeploy_address(cls) -> Address | None:
        """At Genesis, no deterministic factory predeploy is present."""
        return None

    @classmethod
    def max_code_size(cls) -> int:
        """
        At genesis, there is no upper bound for code size (bounded by block gas
        limit).

        However, the default is set to the limit of EIP-170 (Spurious Dragon)
        """
        return 0x6000

    @classmethod
    def max_stack_height(cls) -> int:
        """At genesis, the maximum stack height is 1024."""
        return 1024

    @classmethod
    def max_initcode_size(cls) -> int:
        """
        At genesis, there is no upper bound for initcode size.

        However, the default is set to the limit of EIP-3860 (Shanghai).
        """
        return 0xC000

    @classmethod
    def call_opcodes(cls) -> List[Opcodes]:
        """Return list of call opcodes supported by the fork."""
        return [Opcodes.CALL, Opcodes.CALLCODE]

    @classmethod
    def valid_opcodes(cls) -> List[Opcodes]:
        """Return list of Opcodes that are valid to work on this fork."""
        return [
            Opcodes.STOP,
            Opcodes.ADD,
            Opcodes.MUL,
            Opcodes.SUB,
            Opcodes.DIV,
            Opcodes.SDIV,
            Opcodes.MOD,
            Opcodes.SMOD,
            Opcodes.ADDMOD,
            Opcodes.MULMOD,
            Opcodes.EXP,
            Opcodes.SIGNEXTEND,
            Opcodes.LT,
            Opcodes.GT,
            Opcodes.SLT,
            Opcodes.SGT,
            Opcodes.EQ,
            Opcodes.ISZERO,
            Opcodes.AND,
            Opcodes.OR,
            Opcodes.XOR,
            Opcodes.NOT,
            Opcodes.BYTE,
            Opcodes.SHA3,
            Opcodes.ADDRESS,
            Opcodes.BALANCE,
            Opcodes.ORIGIN,
            Opcodes.CALLER,
            Opcodes.CALLVALUE,
            Opcodes.CALLDATALOAD,
            Opcodes.CALLDATASIZE,
            Opcodes.CALLDATACOPY,
            Opcodes.CODESIZE,
            Opcodes.CODECOPY,
            Opcodes.GASPRICE,
            Opcodes.EXTCODESIZE,
            Opcodes.EXTCODECOPY,
            Opcodes.BLOCKHASH,
            Opcodes.COINBASE,
            Opcodes.TIMESTAMP,
            Opcodes.NUMBER,
            Opcodes.PREVRANDAO,
            Opcodes.GASLIMIT,
            Opcodes.POP,
            Opcodes.MLOAD,
            Opcodes.MSTORE,
            Opcodes.MSTORE8,
            Opcodes.SLOAD,
            Opcodes.SSTORE,
            Opcodes.PC,
            Opcodes.MSIZE,
            Opcodes.GAS,
            Opcodes.JUMP,
            Opcodes.JUMPI,
            Opcodes.JUMPDEST,
            Opcodes.PUSH1,
            Opcodes.PUSH2,
            Opcodes.PUSH3,
            Opcodes.PUSH4,
            Opcodes.PUSH5,
            Opcodes.PUSH6,
            Opcodes.PUSH7,
            Opcodes.PUSH8,
            Opcodes.PUSH9,
            Opcodes.PUSH10,
            Opcodes.PUSH11,
            Opcodes.PUSH12,
            Opcodes.PUSH13,
            Opcodes.PUSH14,
            Opcodes.PUSH15,
            Opcodes.PUSH16,
            Opcodes.PUSH17,
            Opcodes.PUSH18,
            Opcodes.PUSH19,
            Opcodes.PUSH20,
            Opcodes.PUSH21,
            Opcodes.PUSH22,
            Opcodes.PUSH23,
            Opcodes.PUSH24,
            Opcodes.PUSH25,
            Opcodes.PUSH26,
            Opcodes.PUSH27,
            Opcodes.PUSH28,
            Opcodes.PUSH29,
            Opcodes.PUSH30,
            Opcodes.PUSH31,
            Opcodes.PUSH32,
            Opcodes.DUP1,
            Opcodes.DUP2,
            Opcodes.DUP3,
            Opcodes.DUP4,
            Opcodes.DUP5,
            Opcodes.DUP6,
            Opcodes.DUP7,
            Opcodes.DUP8,
            Opcodes.DUP9,
            Opcodes.DUP10,
            Opcodes.DUP11,
            Opcodes.DUP12,
            Opcodes.DUP13,
            Opcodes.DUP14,
            Opcodes.DUP15,
            Opcodes.DUP16,
            Opcodes.SWAP1,
            Opcodes.SWAP2,
            Opcodes.SWAP3,
            Opcodes.SWAP4,
            Opcodes.SWAP5,
            Opcodes.SWAP6,
            Opcodes.SWAP7,
            Opcodes.SWAP8,
            Opcodes.SWAP9,
            Opcodes.SWAP10,
            Opcodes.SWAP11,
            Opcodes.SWAP12,
            Opcodes.SWAP13,
            Opcodes.SWAP14,
            Opcodes.SWAP15,
            Opcodes.SWAP16,
            Opcodes.LOG0,
            Opcodes.LOG1,
            Opcodes.LOG2,
            Opcodes.LOG3,
            Opcodes.LOG4,
            Opcodes.CREATE,
            Opcodes.CALL,
            Opcodes.CALLCODE,
            Opcodes.RETURN,
            Opcodes.SELFDESTRUCT,
        ]

    @classmethod
    def create_opcodes(cls) -> List[Opcodes]:
        """At Genesis, only `CREATE` opcode is supported."""
        return [Opcodes.CREATE]

    @classmethod
    def max_refund_quotient(cls) -> int:
        """Return the max refund quotient at Genesis."""
        return 2

    @classmethod
    def max_request_type(cls) -> int:
        """At genesis, no request type is supported, signaled by -1."""
        return -1

    @classmethod
    def refund_types(cls) -> List[RefundTypes]:
        """
        At genesis, storage clearing refund is introduced.
        """
        return [RefundTypes.STORAGE_CLEAR]

    @classmethod
    def pre_allocation(cls) -> Mapping:
        """
        Return whether the fork expects pre-allocation of accounts.

        Frontier does not require pre-allocated accounts
        """
        return {}

    @classmethod
    def pre_allocation_blockchain(cls) -> Mapping:
        """
        Return whether the fork expects pre-allocation of accounts.

        Frontier does not require pre-allocated accounts
        """
        return {}

    @classmethod
    def build_default_block_header(
        cls, *, block_number: int = 0, timestamp: int = 0
    ) -> FixtureHeader:
        """
        Build a default block header for this fork with the given attributes.

        This method automatically detects which header fields are required by
        the fork and assigns appropriate default values. It introspects the
        FixtureHeader model to find fields with HeaderForkRequirement
        annotations and automatically includes them if the fork requires them.

        Args:
            block_number: The block number
            timestamp: The block timestamp

        Returns:
            FixtureHeader instance with default values applied based on fork
            requirements.

        Raises:
            TypeError: If the overrides don't have the correct type.

        """
        from execution_testing.fixtures.blockchain import FixtureHeader

        defaults = {
            "number": ZeroPaddedHexNumber(block_number),
            "timestamp": ZeroPaddedHexNumber(timestamp),
            "fork": cls,
        }

        # Iterate through FixtureHeader fields to populate defaults
        for field_name, field_info in FixtureHeader.model_fields.items():
            if field_name in defaults:
                continue

            # Get default value, checking fork requirements and model defaults
            default_value = FixtureHeader.get_default_from_annotation(
                fork=cls,
                field_name=field_name,
                field_hint=field_info.annotation,
            )
            if default_value is not None:
                defaults[field_name] = default_value

        return FixtureHeader(**defaults)

transition_tool_name() classmethod

Return fork name as it's meant to be passed to the transition tool for execution.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
49
50
51
52
53
54
55
56
57
@classmethod
def transition_tool_name(cls) -> str:
    """
    Return fork name as it's meant to be passed to the transition tool for
    execution.
    """
    if cls._transition_tool_name is not None:
        return cls._transition_tool_name
    return cls.name()

header_base_fee_required() classmethod

At genesis, header must not contain base fee.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
59
60
61
62
@classmethod
def header_base_fee_required(cls) -> bool:
    """At genesis, header must not contain base fee."""
    return False

header_prev_randao_required() classmethod

At genesis, header must not contain Prev Randao value.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
64
65
66
67
@classmethod
def header_prev_randao_required(cls) -> bool:
    """At genesis, header must not contain Prev Randao value."""
    return False

header_zero_difficulty_required() classmethod

At genesis, header must not have difficulty zero.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
69
70
71
72
@classmethod
def header_zero_difficulty_required(cls) -> bool:
    """At genesis, header must not have difficulty zero."""
    return False

header_withdrawals_required() classmethod

At genesis, header must not contain withdrawals.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
74
75
76
77
@classmethod
def header_withdrawals_required(cls) -> bool:
    """At genesis, header must not contain withdrawals."""
    return False

header_excess_blob_gas_required() classmethod

At genesis, header must not contain excess blob gas.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
79
80
81
82
@classmethod
def header_excess_blob_gas_required(cls) -> bool:
    """At genesis, header must not contain excess blob gas."""
    return False

header_blob_gas_used_required() classmethod

At genesis, header must not contain blob gas used.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
84
85
86
87
@classmethod
def header_blob_gas_used_required(cls) -> bool:
    """At genesis, header must not contain blob gas used."""
    return False

gas_costs() classmethod

Return dataclass with the defined gas costs constants for genesis.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
@classmethod
def gas_costs(cls) -> GasCosts:
    """
    Return dataclass with the defined gas costs constants for genesis.
    """
    return GasCosts(
        # Tiers
        BASE=BASE,
        VERY_LOW=VERY_LOW,
        LOW=LOW,
        MID=MID,
        HIGH=HIGH,
        # Access
        WARM_ACCESS=100,
        COLD_ACCOUNT_ACCESS=2_600,
        WARM_SLOAD=100,
        COLD_STORAGE_ACCESS=2_100,
        OPCODE_BALANCE=20,
        OPCODE_EXTERNAL_BASE=20,
        OPCODE_CALL_BASE=40,
        OPCODE_SLOAD=50,
        # Storage
        STORAGE_SET=20_000,
        COLD_STORAGE_WRITE=5_000,
        STORAGE_RESET=2_900,
        # Call
        CALL_VALUE=9_000,
        CALL_STIPEND=2_300,
        NEW_ACCOUNT=25_000,
        # Contract Creation
        CODE_DEPOSIT_PER_BYTE=200,
        # Authorization
        AUTH_PER_EMPTY_ACCOUNT=0,
        # Utility
        MEMORY_PER_WORD=3,
        # Transactions
        TX_BASE=21_000,
        TX_ACCESS_LIST_ADDRESS=2_400,
        TX_ACCESS_LIST_STORAGE_KEY=1_900,
        TX_DATA_PER_ZERO=4,
        TX_DATA_PER_NON_ZERO=68,
        TX_CREATE=32_000,
        # Refunds
        REFUND_STORAGE_CLEAR=15_000,
        REFUND_SELF_DESTRUCT=24_000,
        REFUND_AUTH_PER_EXISTING_ACCOUNT=0,
        # Precompiles
        PRECOMPILE_ECRECOVER=3_000,
        PRECOMPILE_SHA256_BASE=60,
        PRECOMPILE_SHA256_PER_WORD=12,
        PRECOMPILE_RIPEMD160_BASE=600,
        PRECOMPILE_RIPEMD160_PER_WORD=120,
        PRECOMPILE_IDENTITY_BASE=15,
        PRECOMPILE_IDENTITY_PER_WORD=3,
        # Static Opcodes
        OPCODE_ADD=VERY_LOW,
        OPCODE_SUB=VERY_LOW,
        OPCODE_MUL=LOW,
        OPCODE_DIV=LOW,
        OPCODE_SDIV=LOW,
        OPCODE_MOD=LOW,
        OPCODE_SMOD=LOW,
        OPCODE_ADDMOD=MID,
        OPCODE_MULMOD=MID,
        OPCODE_SIGNEXTEND=LOW,
        OPCODE_LT=VERY_LOW,
        OPCODE_GT=VERY_LOW,
        OPCODE_SLT=VERY_LOW,
        OPCODE_SGT=VERY_LOW,
        OPCODE_EQ=VERY_LOW,
        OPCODE_ISZERO=VERY_LOW,
        OPCODE_AND=VERY_LOW,
        OPCODE_OR=VERY_LOW,
        OPCODE_XOR=VERY_LOW,
        OPCODE_NOT=VERY_LOW,
        OPCODE_BYTE=VERY_LOW,
        OPCODE_JUMP=MID,
        OPCODE_JUMPI=HIGH,
        OPCODE_JUMPDEST=1,
        OPCODE_CALLDATALOAD=VERY_LOW,
        OPCODE_BLOCKHASH=20,
        OPCODE_COINBASE=BASE,
        OPCODE_PUSH=VERY_LOW,
        OPCODE_DUP=VERY_LOW,
        OPCODE_SWAP=VERY_LOW,
        # Dynamic Opcode Components
        OPCODE_CALLDATACOPY_BASE=VERY_LOW,
        OPCODE_CODECOPY_BASE=VERY_LOW,
        OPCODE_MLOAD_BASE=VERY_LOW,
        OPCODE_MSTORE_BASE=VERY_LOW,
        OPCODE_MSTORE8_BASE=VERY_LOW,
        OPCODE_SELFDESTRUCT_BASE=0,
        OPCODE_COPY_PER_WORD=3,
        OPCODE_CREATE_BASE=32_000,
        OPCODE_EXP_BASE=10,
        OPCODE_EXP_PER_BYTE=10,
        OPCODE_LOG_BASE=375,
        OPCODE_LOG_DATA_PER_BYTE=8,
        OPCODE_LOG_TOPIC=375,
        OPCODE_KECCAK256_BASE=30,
        OPCODE_KECCAK256_PER_WORD=6,
        # Zero-initialized: introduced in later forks, set via
        # replace() in the fork that activates them.
        CODE_INIT_PER_WORD=0,
        TX_DATA_TOKEN_STANDARD=0,
        TX_DATA_TOKEN_FLOOR=0,
        PRECOMPILE_ECADD=0,
        PRECOMPILE_ECMUL=0,
        PRECOMPILE_ECPAIRING_BASE=0,
        PRECOMPILE_ECPAIRING_PER_POINT=0,
        PRECOMPILE_BLAKE2F_BASE=0,
        PRECOMPILE_BLAKE2F_PER_ROUND=0,
        PRECOMPILE_POINT_EVALUATION=0,
        PRECOMPILE_BLS_G1ADD=0,
        PRECOMPILE_BLS_G1MUL=0,
        PRECOMPILE_BLS_G1MAP=0,
        PRECOMPILE_BLS_G2ADD=0,
        PRECOMPILE_BLS_G2MUL=0,
        PRECOMPILE_BLS_G2MAP=0,
        PRECOMPILE_BLS_PAIRING_BASE=0,
        PRECOMPILE_BLS_PAIRING_PER_PAIR=0,
        PRECOMPILE_P256VERIFY=0,
        BLOCK_ACCESS_LIST_ITEM=0,
    )

minimum_block_gas_limit() classmethod

Return the minimum gas limit for the block to be considered valid.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
@classmethod
def minimum_block_gas_limit(cls) -> int:
    """
    Return the minimum gas limit for the block to be considered valid.
    """
    minimum_block_gas_limit = 5_000
    bal_minimum_block_gas_limit = 0
    if cls.header_bal_hash_required():
        # The block gas limit is influenced by the minimum amount of
        # block level access elements the system contracts contain.
        bal_minimum_block_gas_limit = (
            cls.empty_block_bal_item_count()
            * cls.gas_costs().BLOCK_ACCESS_LIST_ITEM
        )
    return max(minimum_block_gas_limit, bal_minimum_block_gas_limit)

opcode_gas_map() classmethod

Return a mapping of opcodes to their gas costs.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
@classmethod
def opcode_gas_map(
    cls,
) -> Dict[OpcodeBase, int | Callable[[OpcodeBase], int]]:
    """
    Return a mapping of opcodes to their gas costs.
    """
    gas_costs = cls.gas_costs()
    memory_expansion_calculator = cls.memory_expansion_gas_calculator()

    return {
        Opcodes.STOP: 0,
        Opcodes.ADD: gas_costs.OPCODE_ADD,
        Opcodes.MUL: gas_costs.OPCODE_MUL,
        Opcodes.SUB: gas_costs.OPCODE_SUB,
        Opcodes.DIV: gas_costs.OPCODE_DIV,
        Opcodes.SDIV: gas_costs.OPCODE_SDIV,
        Opcodes.MOD: gas_costs.OPCODE_MOD,
        Opcodes.SMOD: gas_costs.OPCODE_SMOD,
        Opcodes.ADDMOD: gas_costs.OPCODE_ADDMOD,
        Opcodes.MULMOD: gas_costs.OPCODE_MULMOD,
        Opcodes.EXP: lambda op: (
            gas_costs.OPCODE_EXP_BASE
            + gas_costs.OPCODE_EXP_PER_BYTE
            * ((op.metadata["exponent"].bit_length() + 7) // 8)
        ),
        Opcodes.SIGNEXTEND: gas_costs.OPCODE_SIGNEXTEND,
        Opcodes.LT: gas_costs.OPCODE_LT,
        Opcodes.GT: gas_costs.OPCODE_GT,
        Opcodes.SLT: gas_costs.OPCODE_SLT,
        Opcodes.SGT: gas_costs.OPCODE_SGT,
        Opcodes.EQ: gas_costs.OPCODE_EQ,
        Opcodes.ISZERO: gas_costs.OPCODE_ISZERO,
        Opcodes.AND: gas_costs.OPCODE_AND,
        Opcodes.OR: gas_costs.OPCODE_OR,
        Opcodes.XOR: gas_costs.OPCODE_XOR,
        Opcodes.NOT: gas_costs.OPCODE_NOT,
        Opcodes.BYTE: gas_costs.OPCODE_BYTE,
        Opcodes.SHA3: cls._with_memory_expansion(
            lambda op: (
                gas_costs.OPCODE_KECCAK256_BASE
                + gas_costs.OPCODE_KECCAK256_PER_WORD
                * ((op.metadata["data_size"] + 31) // 32)
            ),
            memory_expansion_calculator,
        ),
        Opcodes.ADDRESS: gas_costs.BASE,
        Opcodes.BALANCE: gas_costs.OPCODE_BALANCE,
        Opcodes.ORIGIN: gas_costs.BASE,
        Opcodes.CALLER: gas_costs.BASE,
        Opcodes.CALLVALUE: gas_costs.BASE,
        Opcodes.CALLDATALOAD: gas_costs.OPCODE_CALLDATALOAD,
        Opcodes.CALLDATASIZE: gas_costs.BASE,
        Opcodes.CALLDATACOPY: cls._with_memory_expansion(
            cls._with_data_copy(
                gas_costs.OPCODE_CALLDATACOPY_BASE, gas_costs
            ),
            memory_expansion_calculator,
        ),
        Opcodes.CODESIZE: gas_costs.BASE,
        Opcodes.CODECOPY: cls._with_memory_expansion(
            cls._with_data_copy(gas_costs.OPCODE_CODECOPY_BASE, gas_costs),
            memory_expansion_calculator,
        ),
        Opcodes.GASPRICE: gas_costs.BASE,
        Opcodes.EXTCODESIZE: gas_costs.OPCODE_EXTERNAL_BASE,
        Opcodes.EXTCODECOPY: cls._with_memory_expansion(
            cls._with_data_copy(
                gas_costs.OPCODE_EXTERNAL_BASE,
                gas_costs,
            ),
            memory_expansion_calculator,
        ),
        Opcodes.BLOCKHASH: gas_costs.OPCODE_BLOCKHASH,
        Opcodes.COINBASE: gas_costs.OPCODE_COINBASE,
        Opcodes.TIMESTAMP: gas_costs.BASE,
        Opcodes.NUMBER: gas_costs.BASE,
        Opcodes.PREVRANDAO: gas_costs.BASE,
        Opcodes.GASLIMIT: gas_costs.BASE,
        Opcodes.POP: gas_costs.BASE,
        Opcodes.MLOAD: cls._with_memory_expansion(
            gas_costs.OPCODE_MLOAD_BASE,
            memory_expansion_calculator,
        ),
        Opcodes.MSTORE: cls._with_memory_expansion(
            gas_costs.OPCODE_MSTORE_BASE,
            memory_expansion_calculator,
        ),
        Opcodes.MSTORE8: cls._with_memory_expansion(
            gas_costs.OPCODE_MSTORE8_BASE,
            memory_expansion_calculator,
        ),
        Opcodes.SLOAD: gas_costs.OPCODE_SLOAD,
        Opcodes.SSTORE: lambda op: cls._calculate_sstore_gas(
            op, gas_costs
        ),
        Opcodes.JUMP: gas_costs.OPCODE_JUMP,
        Opcodes.JUMPI: gas_costs.OPCODE_JUMPI,
        Opcodes.PC: gas_costs.BASE,
        Opcodes.MSIZE: gas_costs.BASE,
        Opcodes.GAS: gas_costs.BASE,
        Opcodes.JUMPDEST: gas_costs.OPCODE_JUMPDEST,
        **{
            getattr(Opcodes, f"PUSH{i}"): gas_costs.OPCODE_PUSH
            for i in range(1, 33)
        },
        **{
            getattr(Opcodes, f"DUP{i}"): gas_costs.OPCODE_DUP
            for i in range(1, 17)
        },
        **{
            getattr(Opcodes, f"SWAP{i}"): gas_costs.OPCODE_SWAP
            for i in range(1, 17)
        },
        Opcodes.LOG0: cls._with_memory_expansion(
            lambda op: (
                gas_costs.OPCODE_LOG_BASE
                + gas_costs.OPCODE_LOG_DATA_PER_BYTE
                * op.metadata["data_size"]
            ),
            memory_expansion_calculator,
        ),
        Opcodes.LOG1: cls._with_memory_expansion(
            lambda op: (
                gas_costs.OPCODE_LOG_BASE
                + gas_costs.OPCODE_LOG_DATA_PER_BYTE
                * op.metadata["data_size"]
                + gas_costs.OPCODE_LOG_TOPIC
            ),
            memory_expansion_calculator,
        ),
        Opcodes.LOG2: cls._with_memory_expansion(
            lambda op: (
                gas_costs.OPCODE_LOG_BASE
                + gas_costs.OPCODE_LOG_DATA_PER_BYTE
                * op.metadata["data_size"]
                + gas_costs.OPCODE_LOG_TOPIC * 2
            ),
            memory_expansion_calculator,
        ),
        Opcodes.LOG3: cls._with_memory_expansion(
            lambda op: (
                gas_costs.OPCODE_LOG_BASE
                + gas_costs.OPCODE_LOG_DATA_PER_BYTE
                * op.metadata["data_size"]
                + gas_costs.OPCODE_LOG_TOPIC * 3
            ),
            memory_expansion_calculator,
        ),
        Opcodes.LOG4: cls._with_memory_expansion(
            lambda op: (
                gas_costs.OPCODE_LOG_BASE
                + gas_costs.OPCODE_LOG_DATA_PER_BYTE
                * op.metadata["data_size"]
                + gas_costs.OPCODE_LOG_TOPIC * 4
            ),
            memory_expansion_calculator,
        ),
        Opcodes.CREATE: cls._with_memory_expansion(
            lambda op: cls._calculate_create_gas(op, gas_costs),
            memory_expansion_calculator,
        ),
        Opcodes.CALL: cls._with_memory_expansion(
            lambda op: cls._calculate_call_gas(op, gas_costs),
            memory_expansion_calculator,
        ),
        Opcodes.CALLCODE: cls._with_memory_expansion(
            lambda op: cls._calculate_call_gas(op, gas_costs),
            memory_expansion_calculator,
        ),
        Opcodes.RETURN: cls._with_memory_expansion(
            lambda op: cls._calculate_return_gas(op, gas_costs),
            memory_expansion_calculator,
        ),
        Opcodes.INVALID: 0,
        Opcodes.SELFDESTRUCT: lambda op: cls._calculate_selfdestruct_gas(
            op, gas_costs
        ),
    }

opcode_gas_calculator() classmethod

Return callable that calculates the gas cost of a single opcode.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
@classmethod
def opcode_gas_calculator(cls) -> OpcodeGasCalculator:
    """
    Return callable that calculates the gas cost of a single opcode.
    """
    opcode_gas_map = cls.opcode_gas_map()

    def fn(opcode: OpcodeBase) -> int:
        if opcode not in opcode_gas_map:
            raise ValueError(
                f"No gas cost defined for opcode: {opcode._name_}"
            )
        gas_cost_or_calculator = opcode_gas_map[opcode]

        if callable(gas_cost_or_calculator):
            return gas_cost_or_calculator(opcode)

        return gas_cost_or_calculator

    return fn

opcode_state_map() classmethod

Return a mapping of opcodes to their state gas costs.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
541
542
543
544
545
546
547
548
@classmethod
def opcode_state_map(
    cls,
) -> Dict[OpcodeBase, int | Callable[[OpcodeBase], int]]:
    """
    Return a mapping of opcodes to their state gas costs.
    """
    return {}

opcode_state_calculator() classmethod

Return callable that calculates the state gas of a single opcode.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
550
551
552
553
554
555
556
557
558
559
560
@classmethod
def opcode_state_calculator(cls) -> OpcodeGasCalculator:
    """
    Return callable that calculates the state gas of a single opcode.
    """

    def fn(opcode: OpcodeBase) -> int:
        del opcode
        return 0

    return fn

opcode_refund_map() classmethod

Return a mapping of opcodes to their gas refunds.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
@classmethod
def opcode_refund_map(
    cls,
) -> Dict[OpcodeBase, int | Callable[[OpcodeBase], int]]:
    """
    Return a mapping of opcodes to their gas refunds.
    """
    gas_costs = cls.gas_costs()

    return {
        Opcodes.SSTORE: lambda op: cls._calculate_sstore_refund(
            op, gas_costs
        ),
        Opcodes.SELFDESTRUCT: lambda op: (
            gas_costs.REFUND_SELF_DESTRUCT
            if op.metadata["self_destructed_account"]
            else 0
        ),
    }

opcode_refund_calculator() classmethod

Return callable that calculates the gas refund of a single opcode.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
@classmethod
def opcode_refund_calculator(cls) -> OpcodeGasCalculator:
    """
    Return callable that calculates the gas refund of a single opcode.
    """
    opcode_refund_map = cls.opcode_refund_map()

    def fn(opcode: OpcodeBase) -> int:
        if opcode not in opcode_refund_map:
            return 0
        refund_or_calculator = opcode_refund_map[opcode]

        if callable(refund_or_calculator):
            return refund_or_calculator(opcode)

        return refund_or_calculator

    return fn

opcode_state_refund_map() classmethod

Return a mapping of opcodes to their state refunds.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
601
602
603
604
605
606
607
608
@classmethod
def opcode_state_refund_map(
    cls,
) -> Dict[OpcodeBase, int | Callable[[OpcodeBase], int]]:
    """
    Return a mapping of opcodes to their state refunds.
    """
    return {}

opcode_state_refund_calculator() classmethod

Return callable that calculates the state refund of a single opcode.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
610
611
612
613
614
615
616
617
618
619
620
@classmethod
def opcode_state_refund_calculator(cls) -> OpcodeGasCalculator:
    """
    Return callable that calculates the state refund of a single opcode.
    """

    def fn(opcode: OpcodeBase) -> int:
        del opcode
        return 0

    return fn

memory_expansion_gas_calculator() classmethod

Return callable that calculates the gas cost of memory expansion for the fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
@classmethod
def memory_expansion_gas_calculator(cls) -> MemoryExpansionGasCalculator:
    """
    Return callable that calculates the gas cost of memory expansion for
    the fork.
    """
    gas_costs = cls.gas_costs()

    def fn(*, new_bytes: int, previous_bytes: int = 0) -> int:
        if new_bytes <= previous_bytes:
            return 0
        new_words = ceiling_division(new_bytes, 32)
        previous_words = ceiling_division(previous_bytes, 32)

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

        return c(new_words) - c(previous_words)

    return fn

calldata_gas_calculator() classmethod

Return callable that calculates the transaction gas cost for its calldata depending on its contents.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
@classmethod
def calldata_gas_calculator(cls) -> CalldataGasCalculator:
    """
    Return callable that calculates the transaction gas cost for its
    calldata depending on its contents.
    """
    gas_costs = cls.gas_costs()

    def fn(*, data: BytesConvertible, floor: bool = False) -> int:
        del floor

        raw = Bytes(data)
        num_zeros = raw.count(0)
        num_non_zeros = len(raw) - num_zeros
        return (
            num_zeros * gas_costs.TX_DATA_PER_ZERO
            + num_non_zeros * gas_costs.TX_DATA_PER_NON_ZERO
        )

    return fn

base_fee_per_gas_calculator() classmethod

Return a callable that calculates the base fee per gas at a given fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
789
790
791
792
793
794
795
796
@classmethod
def base_fee_per_gas_calculator(cls) -> BaseFeePerGasCalculator:
    """
    Return a callable that calculates the base fee per gas at a given fork.
    """
    raise NotImplementedError(
        f"Base fee per gas calculator is not supported in {cls.name()}"
    )

base_fee_change_calculator() classmethod

Return a callable that calculates the gas that needs to be used to change the base fee.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
798
799
800
801
802
803
804
805
806
@classmethod
def base_fee_change_calculator(cls) -> BaseFeeChangeCalculator:
    """
    Return a callable that calculates the gas that needs to be used to
    change the base fee.
    """
    raise NotImplementedError(
        f"Base fee change calculator is not supported in {cls.name()}"
    )

cost_per_state_byte() classmethod

Return the cost per state byte, 0 before state gas applies.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
808
809
810
811
812
813
@classmethod
def cost_per_state_byte(cls) -> int:
    """
    Return the cost per state byte, 0 before state gas applies.
    """
    return 0

base_fee_max_change_denominator() classmethod

Return the base fee max change denominator at a given fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
815
816
817
818
819
820
@classmethod
def base_fee_max_change_denominator(cls) -> int:
    """Return the base fee max change denominator at a given fork."""
    raise NotImplementedError(
        f"Base fee max change denominator is not supported in {cls.name()}"
    )

base_fee_elasticity_multiplier() classmethod

Return the base fee elasticity multiplier at a given fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
822
823
824
825
826
827
@classmethod
def base_fee_elasticity_multiplier(cls) -> int:
    """Return the base fee elasticity multiplier at a given fork."""
    raise NotImplementedError(
        f"Base fee elasticity multiplier is not supported in {cls.name()}"
    )

transaction_data_floor_cost_calculator() classmethod

At frontier, the transaction data floor cost is a constant zero.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
@classmethod
def transaction_data_floor_cost_calculator(
    cls,
) -> TransactionDataFloorCostCalculator:
    """At frontier, the transaction data floor cost is a constant zero."""

    def fn(
        *,
        data: BytesConvertible,
        access_list: List[AccessList] | None = None,
        contract_creation: bool = False,
        sends_value: bool = False,
        recipient_type: RecipientType = RecipientType.CONTRACT,
    ) -> int:
        del data, access_list
        del contract_creation, sends_value, recipient_type
        return 0

    return fn

transaction_intrinsic_cost_calculator() classmethod

Return callable that calculates the intrinsic gas cost of a transaction for the fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
@classmethod
def transaction_intrinsic_cost_calculator(
    cls,
) -> TransactionIntrinsicCostCalculator:
    """
    Return callable that calculates the intrinsic gas cost of a transaction
    for the fork.
    """
    gas_costs = cls.gas_costs()
    calldata_gas_calculator = cls.calldata_gas_calculator()

    def fn(
        *,
        calldata: BytesConvertible = b"",
        contract_creation: bool = False,
        access_list: List[AccessList] | None = None,
        authorization_list_or_count: Sized | int | None = None,
        return_cost_deducted_prior_execution: bool = False,
        sends_value: bool = False,
        recipient_type: RecipientType = RecipientType.CONTRACT,
    ) -> int:
        del return_cost_deducted_prior_execution
        del sends_value, recipient_type
        del contract_creation

        assert access_list is None, (
            f"Access list is not supported in {cls.name()}"
        )
        assert authorization_list_or_count is None, (
            f"Authorizations are not supported in {cls.name()}"
        )

        intrinsic_cost: int = gas_costs.TX_BASE

        return intrinsic_cost + calldata_gas_calculator(data=calldata)

    return fn

blob_gas_price_calculator() classmethod

Return a callable that calculates the blob gas price at a given fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
887
888
889
890
891
892
893
894
@classmethod
def blob_gas_price_calculator(cls) -> BlobGasPriceCalculator:
    """
    Return a callable that calculates the blob gas price at a given fork.
    """
    raise NotImplementedError(
        f"Blob gas price calculator is not supported in {cls.name()}"
    )

excess_blob_gas_calculator() classmethod

Return a callable that calculates the excess blob gas for a block at a given fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
896
897
898
899
900
901
902
903
904
@classmethod
def excess_blob_gas_calculator(cls) -> ExcessBlobGasCalculator:
    """
    Return a callable that calculates the excess blob gas for a block at a
    given fork.
    """
    raise NotImplementedError(
        f"Excess blob gas calculator is not supported in {cls.name()}"
    )

supports_blobs() classmethod

Blobs are not supported at Frontier.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
906
907
908
909
@classmethod
def supports_blobs(cls) -> bool:
    """Blobs are not supported at Frontier."""
    return False

blob_reserve_price_active() classmethod

Return whether the fork uses a reserve price mechanism for blobs or not.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
911
912
913
914
915
916
917
918
919
@classmethod
def blob_reserve_price_active(cls) -> bool:
    """
    Return whether the fork uses a reserve price mechanism for blobs or
    not.
    """
    raise NotImplementedError(
        f"Blob reserve price is not supported in {cls.name()}"
    )

full_blob_tx_wrapper_version() classmethod

Return the version of the full blob transaction wrapper.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
921
922
923
924
925
926
927
@classmethod
def full_blob_tx_wrapper_version(cls) -> int | None:
    """Return the version of the full blob transaction wrapper."""
    raise NotImplementedError(
        "Full blob transaction wrapper version is not supported in "
        f"{cls.name()}"
    )

blob_schedule() classmethod

At genesis, no blob schedule is used.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
929
930
931
932
@classmethod
def blob_schedule(cls) -> BlobSchedule | None:
    """At genesis, no blob schedule is used."""
    return None

header_requests_required() classmethod

At genesis, header must not contain beacon chain requests.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
934
935
936
937
@classmethod
def header_requests_required(cls) -> bool:
    """At genesis, header must not contain beacon chain requests."""
    return False

header_bal_hash_required() classmethod

At genesis, header must not contain block access list hash.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
939
940
941
942
@classmethod
def header_bal_hash_required(cls) -> bool:
    """At genesis, header must not contain block access list hash."""
    return False

empty_block_bal_item_count() classmethod

Pre-Amsterdam forks have no block access list.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
944
945
946
947
@classmethod
def empty_block_bal_item_count(cls) -> int:
    """Pre-Amsterdam forks have no block access list."""
    return 0

header_beacon_root_required() classmethod

At genesis, header must not contain parent beacon block root.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
949
950
951
952
@classmethod
def header_beacon_root_required(cls) -> bool:
    """At genesis, header must not contain parent beacon block root."""
    return False

header_slot_number_required() classmethod

At genesis, header must not contain slot number (EIP-7843).

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
954
955
956
957
@classmethod
def header_slot_number_required(cls) -> bool:
    """At genesis, header must not contain slot number (EIP-7843)."""
    return False

engine_new_payload_blob_hashes() classmethod

At genesis, payloads do not have blob hashes.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
959
960
961
962
@classmethod
def engine_new_payload_blob_hashes(cls) -> bool:
    """At genesis, payloads do not have blob hashes."""
    return False

engine_new_payload_beacon_root() classmethod

At genesis, payloads do not have a parent beacon block root.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
964
965
966
967
@classmethod
def engine_new_payload_beacon_root(cls) -> bool:
    """At genesis, payloads do not have a parent beacon block root."""
    return False

engine_new_payload_requests() classmethod

At genesis, payloads do not have requests.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
969
970
971
972
@classmethod
def engine_new_payload_requests(cls) -> bool:
    """At genesis, payloads do not have requests."""
    return False

engine_execution_payload_block_access_list() classmethod

At genesis, payloads do not have block access list.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
974
975
976
977
@classmethod
def engine_execution_payload_block_access_list(cls) -> bool:
    """At genesis, payloads do not have block access list."""
    return False

engine_new_payload_target_blobs_per_block() classmethod

At genesis, payloads do not have target blobs per block.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
979
980
981
982
@classmethod
def engine_new_payload_target_blobs_per_block(cls) -> bool:
    """At genesis, payloads do not have target blobs per block."""
    return False

engine_payload_attribute_target_blobs_per_block() classmethod

At genesis, payload attributes do not include the target blobs per block.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
984
985
986
987
988
989
990
@classmethod
def engine_payload_attribute_target_blobs_per_block(cls) -> bool:
    """
    At genesis, payload attributes do not include the target blobs per
    block.
    """
    return False

engine_payload_attribute_max_blobs_per_block() classmethod

At genesis, payload attributes do not include the max blobs per block.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
992
993
994
995
996
997
@classmethod
def engine_payload_attribute_max_blobs_per_block(cls) -> bool:
    """
    At genesis, payload attributes do not include the max blobs per block.
    """
    return False

engine_payload_attribute_slot_number() classmethod

At genesis, payload attributes do not include the slot number.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
 999
1000
1001
1002
1003
1004
@classmethod
def engine_payload_attribute_slot_number(cls) -> bool:
    """
    At genesis, payload attributes do not include the slot number.
    """
    return False

engine_payload_attribute_target_gas_limit() classmethod

At genesis, payload attributes do not include the target gas limit.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1006
1007
1008
1009
1010
1011
@classmethod
def engine_payload_attribute_target_gas_limit(cls) -> bool:
    """
    At genesis, payload attributes do not include the target gas limit.
    """
    return False

get_reward() classmethod

At Genesis the expected reward amount in wei is 5_000_000_000_000_000_000.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1013
1014
1015
1016
1017
1018
1019
@classmethod
def get_reward(cls) -> int:
    """
    At Genesis the expected reward amount in wei is
    5_000_000_000_000_000_000.
    """
    return 5_000_000_000_000_000_000

supports_protected_txs() classmethod

At Genesis, fork has no support for EIP-155 protected txs.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1021
1022
1023
1024
@classmethod
def supports_protected_txs(cls) -> bool:
    """At Genesis, fork has no support for EIP-155 protected txs."""
    return False

tx_types() classmethod

At Genesis, only legacy transactions are allowed.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1026
1027
1028
1029
@classmethod
def tx_types(cls) -> List[int]:
    """At Genesis, only legacy transactions are allowed."""
    return [0]

contract_creating_tx_types() classmethod

At Genesis, only legacy transactions are allowed.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1031
1032
1033
1034
@classmethod
def contract_creating_tx_types(cls) -> List[int]:
    """At Genesis, only legacy transactions are allowed."""
    return [0]

transaction_gas_limit_cap() classmethod

At Genesis, no transaction gas limit cap is imposed.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1036
1037
1038
1039
@classmethod
def transaction_gas_limit_cap(cls) -> int | None:
    """At Genesis, no transaction gas limit cap is imposed."""
    return None

state_gas_reservoir_enabled() classmethod

At Genesis, state gas reservoir is not enabled.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1041
1042
1043
1044
1045
1046
@classmethod
def state_gas_reservoir_enabled(cls) -> bool:
    """
    At Genesis, state gas reservoir is not enabled.
    """
    return False

code_deposit_state_gas(*, code_size) classmethod

Return the state gas for code deposit of the given size.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1048
1049
1050
1051
1052
@classmethod
def code_deposit_state_gas(cls, *, code_size: int) -> int:
    """Return the state gas for code deposit of the given size."""
    del code_size
    return 0

create_state_gas(*, code_size=0) classmethod

Return total state gas for CREATE (new account + code deposit).

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1054
1055
1056
1057
1058
@classmethod
def create_state_gas(cls, *, code_size: int = 0) -> int:
    """Return total state gas for CREATE (new account + code deposit)."""
    del code_size
    return 0

block_rlp_size_limit() classmethod

At Genesis, no RLP block size limit is imposed.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1060
1061
1062
1063
@classmethod
def block_rlp_size_limit(cls) -> int | None:
    """At Genesis, no RLP block size limit is imposed."""
    return None

precompiles() classmethod

At Genesis, EC-recover, SHA256, RIPEMD160, and Identity precompiles are introduced.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
@classmethod
def precompiles(cls) -> List[Address]:
    """
    At Genesis, EC-recover, SHA256, RIPEMD160, and Identity precompiles
    are introduced.
    """
    return [
        Address(1, label="ECREC"),
        Address(2, label="SHA256"),
        Address(3, label="RIPEMD160"),
        Address(4, label="ID"),
    ]

system_contracts() classmethod

At Genesis, no system contracts are present.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1078
1079
1080
1081
@classmethod
def system_contracts(cls) -> List[Address]:
    """At Genesis, no system contracts are present."""
    return []

system_contract_request_types() classmethod

At Genesis, no system contract triggers execution requests.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1083
1084
1085
1086
1087
1088
@classmethod
def system_contract_request_types(
    cls,
) -> List[Type[SystemContractRequest]]:
    """At Genesis, no system contract triggers execution requests."""
    return []

system_contract_call_phases() classmethod

At Genesis, no system contract is called.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1090
1091
1092
1093
@classmethod
def system_contract_call_phases(cls) -> Mapping[Address, SystemCallPhase]:
    """At Genesis, no system contract is called."""
    return {}

deterministic_factory_predeploy_address() classmethod

At Genesis, no deterministic factory predeploy is present.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1095
1096
1097
1098
@classmethod
def deterministic_factory_predeploy_address(cls) -> Address | None:
    """At Genesis, no deterministic factory predeploy is present."""
    return None

max_code_size() classmethod

At genesis, there is no upper bound for code size (bounded by block gas limit).

However, the default is set to the limit of EIP-170 (Spurious Dragon)

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1100
1101
1102
1103
1104
1105
1106
1107
1108
@classmethod
def max_code_size(cls) -> int:
    """
    At genesis, there is no upper bound for code size (bounded by block gas
    limit).

    However, the default is set to the limit of EIP-170 (Spurious Dragon)
    """
    return 0x6000

max_stack_height() classmethod

At genesis, the maximum stack height is 1024.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1110
1111
1112
1113
@classmethod
def max_stack_height(cls) -> int:
    """At genesis, the maximum stack height is 1024."""
    return 1024

max_initcode_size() classmethod

At genesis, there is no upper bound for initcode size.

However, the default is set to the limit of EIP-3860 (Shanghai).

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1115
1116
1117
1118
1119
1120
1121
1122
@classmethod
def max_initcode_size(cls) -> int:
    """
    At genesis, there is no upper bound for initcode size.

    However, the default is set to the limit of EIP-3860 (Shanghai).
    """
    return 0xC000

call_opcodes() classmethod

Return list of call opcodes supported by the fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1124
1125
1126
1127
@classmethod
def call_opcodes(cls) -> List[Opcodes]:
    """Return list of call opcodes supported by the fork."""
    return [Opcodes.CALL, Opcodes.CALLCODE]

valid_opcodes() classmethod

Return list of Opcodes that are valid to work on this fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
@classmethod
def valid_opcodes(cls) -> List[Opcodes]:
    """Return list of Opcodes that are valid to work on this fork."""
    return [
        Opcodes.STOP,
        Opcodes.ADD,
        Opcodes.MUL,
        Opcodes.SUB,
        Opcodes.DIV,
        Opcodes.SDIV,
        Opcodes.MOD,
        Opcodes.SMOD,
        Opcodes.ADDMOD,
        Opcodes.MULMOD,
        Opcodes.EXP,
        Opcodes.SIGNEXTEND,
        Opcodes.LT,
        Opcodes.GT,
        Opcodes.SLT,
        Opcodes.SGT,
        Opcodes.EQ,
        Opcodes.ISZERO,
        Opcodes.AND,
        Opcodes.OR,
        Opcodes.XOR,
        Opcodes.NOT,
        Opcodes.BYTE,
        Opcodes.SHA3,
        Opcodes.ADDRESS,
        Opcodes.BALANCE,
        Opcodes.ORIGIN,
        Opcodes.CALLER,
        Opcodes.CALLVALUE,
        Opcodes.CALLDATALOAD,
        Opcodes.CALLDATASIZE,
        Opcodes.CALLDATACOPY,
        Opcodes.CODESIZE,
        Opcodes.CODECOPY,
        Opcodes.GASPRICE,
        Opcodes.EXTCODESIZE,
        Opcodes.EXTCODECOPY,
        Opcodes.BLOCKHASH,
        Opcodes.COINBASE,
        Opcodes.TIMESTAMP,
        Opcodes.NUMBER,
        Opcodes.PREVRANDAO,
        Opcodes.GASLIMIT,
        Opcodes.POP,
        Opcodes.MLOAD,
        Opcodes.MSTORE,
        Opcodes.MSTORE8,
        Opcodes.SLOAD,
        Opcodes.SSTORE,
        Opcodes.PC,
        Opcodes.MSIZE,
        Opcodes.GAS,
        Opcodes.JUMP,
        Opcodes.JUMPI,
        Opcodes.JUMPDEST,
        Opcodes.PUSH1,
        Opcodes.PUSH2,
        Opcodes.PUSH3,
        Opcodes.PUSH4,
        Opcodes.PUSH5,
        Opcodes.PUSH6,
        Opcodes.PUSH7,
        Opcodes.PUSH8,
        Opcodes.PUSH9,
        Opcodes.PUSH10,
        Opcodes.PUSH11,
        Opcodes.PUSH12,
        Opcodes.PUSH13,
        Opcodes.PUSH14,
        Opcodes.PUSH15,
        Opcodes.PUSH16,
        Opcodes.PUSH17,
        Opcodes.PUSH18,
        Opcodes.PUSH19,
        Opcodes.PUSH20,
        Opcodes.PUSH21,
        Opcodes.PUSH22,
        Opcodes.PUSH23,
        Opcodes.PUSH24,
        Opcodes.PUSH25,
        Opcodes.PUSH26,
        Opcodes.PUSH27,
        Opcodes.PUSH28,
        Opcodes.PUSH29,
        Opcodes.PUSH30,
        Opcodes.PUSH31,
        Opcodes.PUSH32,
        Opcodes.DUP1,
        Opcodes.DUP2,
        Opcodes.DUP3,
        Opcodes.DUP4,
        Opcodes.DUP5,
        Opcodes.DUP6,
        Opcodes.DUP7,
        Opcodes.DUP8,
        Opcodes.DUP9,
        Opcodes.DUP10,
        Opcodes.DUP11,
        Opcodes.DUP12,
        Opcodes.DUP13,
        Opcodes.DUP14,
        Opcodes.DUP15,
        Opcodes.DUP16,
        Opcodes.SWAP1,
        Opcodes.SWAP2,
        Opcodes.SWAP3,
        Opcodes.SWAP4,
        Opcodes.SWAP5,
        Opcodes.SWAP6,
        Opcodes.SWAP7,
        Opcodes.SWAP8,
        Opcodes.SWAP9,
        Opcodes.SWAP10,
        Opcodes.SWAP11,
        Opcodes.SWAP12,
        Opcodes.SWAP13,
        Opcodes.SWAP14,
        Opcodes.SWAP15,
        Opcodes.SWAP16,
        Opcodes.LOG0,
        Opcodes.LOG1,
        Opcodes.LOG2,
        Opcodes.LOG3,
        Opcodes.LOG4,
        Opcodes.CREATE,
        Opcodes.CALL,
        Opcodes.CALLCODE,
        Opcodes.RETURN,
        Opcodes.SELFDESTRUCT,
    ]

create_opcodes() classmethod

At Genesis, only CREATE opcode is supported.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1264
1265
1266
1267
@classmethod
def create_opcodes(cls) -> List[Opcodes]:
    """At Genesis, only `CREATE` opcode is supported."""
    return [Opcodes.CREATE]

max_refund_quotient() classmethod

Return the max refund quotient at Genesis.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1269
1270
1271
1272
@classmethod
def max_refund_quotient(cls) -> int:
    """Return the max refund quotient at Genesis."""
    return 2

max_request_type() classmethod

At genesis, no request type is supported, signaled by -1.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1274
1275
1276
1277
@classmethod
def max_request_type(cls) -> int:
    """At genesis, no request type is supported, signaled by -1."""
    return -1

refund_types() classmethod

At genesis, storage clearing refund is introduced.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1279
1280
1281
1282
1283
1284
@classmethod
def refund_types(cls) -> List[RefundTypes]:
    """
    At genesis, storage clearing refund is introduced.
    """
    return [RefundTypes.STORAGE_CLEAR]

pre_allocation() classmethod

Return whether the fork expects pre-allocation of accounts.

Frontier does not require pre-allocated accounts

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1286
1287
1288
1289
1290
1291
1292
1293
@classmethod
def pre_allocation(cls) -> Mapping:
    """
    Return whether the fork expects pre-allocation of accounts.

    Frontier does not require pre-allocated accounts
    """
    return {}

pre_allocation_blockchain() classmethod

Return whether the fork expects pre-allocation of accounts.

Frontier does not require pre-allocated accounts

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1295
1296
1297
1298
1299
1300
1301
1302
@classmethod
def pre_allocation_blockchain(cls) -> Mapping:
    """
    Return whether the fork expects pre-allocation of accounts.

    Frontier does not require pre-allocated accounts
    """
    return {}

build_default_block_header(*, block_number=0, timestamp=0) classmethod

Build a default block header for this fork with the given attributes.

This method automatically detects which header fields are required by the fork and assigns appropriate default values. It introspects the FixtureHeader model to find fields with HeaderForkRequirement annotations and automatically includes them if the fork requires them.

Parameters:

Name Type Description Default
block_number int

The block number

0
timestamp int

The block timestamp

0

Returns:

Type Description
FixtureHeader

FixtureHeader instance with default values applied based on fork

FixtureHeader

requirements.

Raises:

Type Description
TypeError

If the overrides don't have the correct type.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
@classmethod
def build_default_block_header(
    cls, *, block_number: int = 0, timestamp: int = 0
) -> FixtureHeader:
    """
    Build a default block header for this fork with the given attributes.

    This method automatically detects which header fields are required by
    the fork and assigns appropriate default values. It introspects the
    FixtureHeader model to find fields with HeaderForkRequirement
    annotations and automatically includes them if the fork requires them.

    Args:
        block_number: The block number
        timestamp: The block timestamp

    Returns:
        FixtureHeader instance with default values applied based on fork
        requirements.

    Raises:
        TypeError: If the overrides don't have the correct type.

    """
    from execution_testing.fixtures.blockchain import FixtureHeader

    defaults = {
        "number": ZeroPaddedHexNumber(block_number),
        "timestamp": ZeroPaddedHexNumber(timestamp),
        "fork": cls,
    }

    # Iterate through FixtureHeader fields to populate defaults
    for field_name, field_info in FixtureHeader.model_fields.items():
        if field_name in defaults:
            continue

        # Get default value, checking fork requirements and model defaults
        default_value = FixtureHeader.get_default_from_annotation(
            fork=cls,
            field_name=field_name,
            field_hint=field_info.annotation,
        )
        if default_value is not None:
            defaults[field_name] = default_value

    return FixtureHeader(**defaults)

GrayGlacier

Bases: ArrowGlacier

Gray Glacier fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1487
1488
1489
1490
1491
1492
1493
class GrayGlacier(
    ArrowGlacier,
    ignore=True,
):
    """Gray Glacier fork."""

    pass

Homestead

Bases: EIP7, EIP2, Frontier

Homestead fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1353
1354
1355
1356
1357
1358
1359
1360
class Homestead(
    eips.EIP7,
    eips.EIP2,
    Frontier,
):
    """Homestead fork."""

    pass

Istanbul

Bases: EIP2200, EIP2028, EIP1884, EIP1344, EIP1108, EIP152, ConstantinopleFix

Istanbul fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
class Istanbul(
    eips.EIP2200,
    eips.EIP2028,
    eips.EIP1884,
    eips.EIP1344,
    eips.EIP1108,
    eips.EIP152,
    ConstantinopleFix,
):
    """Istanbul fork."""

    pass

London

Bases: EIP3529, EIP3198, EIP1559, Berlin

London fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1466
1467
1468
1469
1470
1471
1472
1473
1474
class London(
    eips.EIP3529,
    eips.EIP3198,
    eips.EIP1559,
    Berlin,
):
    """London fork."""

    pass

MuirGlacier

Bases: Istanbul

Muir Glacier fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1447
1448
1449
1450
1451
1452
1453
class MuirGlacier(
    Istanbul,
    ignore=True,
):
    """Muir Glacier fork."""

    pass

Osaka

Bases: EIP7939, EIP7934, EIP7825, EIP7918, EIP7594, EIP7951, EIP7883, Prague

Osaka fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
class Osaka(
    eips.EIP7939,
    eips.EIP7934,
    eips.EIP7825,
    eips.EIP7918,
    eips.EIP7594,
    eips.EIP7951,
    eips.EIP7883,
    Prague,
):
    """Osaka fork."""

    pass

Paris

Bases: EIP3675, London

Paris (Merge) fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1496
1497
1498
1499
1500
1501
1502
1503
1504
class Paris(
    eips.EIP3675,
    London,
    transition_tool_name="Merge",
    ruleset_name="MERGE",
):
    """Paris (Merge) fork."""

    pass

Prague

Bases: EIP7691, EIP7685, EIP2935, EIP7251, EIP7002, EIP6110, EIP7623, EIP7702, EIP2537, Cancun

Prague fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
class Prague(
    eips.EIP7691,
    eips.EIP7685,
    eips.EIP2935,
    eips.EIP7251,
    eips.EIP7002,
    eips.EIP6110,
    eips.EIP7623,
    eips.EIP7702,
    eips.EIP2537,
    Cancun,
):
    """Prague fork."""

    pass

Shanghai

Bases: EIP3855, EIP3860, EIP4895, Paris

Shanghai fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
class Shanghai(
    eips.EIP3855,
    eips.EIP3860,
    eips.EIP4895,
    Paris,
    fork_by_timestamp=True,
):
    """Shanghai fork."""

    pass

SpuriousDragon

Bases: EIP170, EIP161, EIP160, EIP155, TangerineWhistle

SpuriousDragon fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
class SpuriousDragon(
    eips.EIP170,
    eips.EIP161,
    eips.EIP160,
    eips.EIP155,
    TangerineWhistle,
    ruleset_name="SPURIOUS",
):
    """SpuriousDragon fork."""

    pass

TangerineWhistle

Bases: EIP150, DAOFork

TangerineWhistle fork (EIP-150).

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1373
1374
1375
1376
1377
1378
1379
1380
class TangerineWhistle(
    eips.EIP150,
    DAOFork,
    ruleset_name="TANGERINE",
):
    """TangerineWhistle fork (EIP-150)."""

    pass

BerlinToLondonAt5

Bases: TransitionBaseClass

Berlin to London transition at Block 5.

Source code in packages/testing/src/execution_testing/forks/forks/transition.py
21
22
23
24
25
@transition_fork(to_fork=London, from_fork=Berlin, at_block=5)
class BerlinToLondonAt5(TransitionBaseClass):
    """Berlin to London transition at Block 5."""

    pass

BPO1ToBPO2AtTime15k

Bases: TransitionBaseClass

BPO1 to BPO2 transition at Timestamp 15k.

Source code in packages/testing/src/execution_testing/forks/forks/transition.py
63
64
65
66
67
@transition_fork(to_fork=BPO2, from_fork=BPO1, at_timestamp=15_000)
class BPO1ToBPO2AtTime15k(TransitionBaseClass):
    """BPO1 to BPO2 transition at Timestamp 15k."""

    pass

BPO2ToAmsterdamAtTime15k

Bases: TransitionBaseClass

BPO2 to Amsterdam transition at Timestamp 15k.

Source code in packages/testing/src/execution_testing/forks/forks/transition.py
70
71
72
73
74
75
76
77
78
@transition_fork(to_fork=Amsterdam, from_fork=BPO2, at_timestamp=15_000)
class BPO2ToAmsterdamAtTime15k(TransitionBaseClass):
    """BPO2 to Amsterdam transition at Timestamp 15k."""

    # TODO: We may need to adjust which BPO Amsterdam inherits from as the
    #  related Amsterdam specs change over time, and before Amsterdam is
    #  live on mainnet.

    pass

BPO2ToBPO3AtTime15k

Bases: TransitionBaseClass

BPO2 to BPO3 transition at Timestamp 15k.

Source code in packages/testing/src/execution_testing/forks/forks/transition.py
81
82
83
84
85
@transition_fork(to_fork=BPO3, from_fork=BPO2, at_timestamp=15_000)
class BPO2ToBPO3AtTime15k(TransitionBaseClass):
    """BPO2 to BPO3 transition at Timestamp 15k."""

    pass

BPO3ToBPO4AtTime15k

Bases: TransitionBaseClass

BPO3 to BPO4 transition at Timestamp 15k.

Source code in packages/testing/src/execution_testing/forks/forks/transition.py
88
89
90
91
92
@transition_fork(to_fork=BPO4, from_fork=BPO3, at_timestamp=15_000)
class BPO3ToBPO4AtTime15k(TransitionBaseClass):
    """BPO3 to BPO4 transition at Timestamp 15k."""

    pass

CancunToPragueAtTime15k

Bases: TransitionBaseClass

Cancun to Prague transition at Timestamp 15k.

Source code in packages/testing/src/execution_testing/forks/forks/transition.py
42
43
44
45
46
@transition_fork(to_fork=Prague, from_fork=Cancun, at_timestamp=15_000)
class CancunToPragueAtTime15k(TransitionBaseClass):
    """Cancun to Prague transition at Timestamp 15k."""

    pass

OsakaToBPO1AtTime15k

Bases: TransitionBaseClass

Osaka to BPO1 transition at Timestamp 15k.

Source code in packages/testing/src/execution_testing/forks/forks/transition.py
56
57
58
59
60
@transition_fork(to_fork=BPO1, from_fork=Osaka, at_timestamp=15_000)
class OsakaToBPO1AtTime15k(TransitionBaseClass):
    """Osaka to BPO1 transition at Timestamp 15k."""

    pass

ParisToShanghaiAtTime15k

Bases: TransitionBaseClass

Paris to Shanghai transition at Timestamp 15k.

Source code in packages/testing/src/execution_testing/forks/forks/transition.py
28
29
30
31
32
@transition_fork(to_fork=Shanghai, from_fork=Paris, at_timestamp=15_000)
class ParisToShanghaiAtTime15k(TransitionBaseClass):
    """Paris to Shanghai transition at Timestamp 15k."""

    pass

PragueToOsakaAtTime15k

Bases: TransitionBaseClass

Prague to Osaka transition at Timestamp 15k.

Source code in packages/testing/src/execution_testing/forks/forks/transition.py
49
50
51
52
53
@transition_fork(to_fork=Osaka, from_fork=Prague, at_timestamp=15_000)
class PragueToOsakaAtTime15k(TransitionBaseClass):
    """Prague to Osaka transition at Timestamp 15k."""

    pass

ShanghaiToCancunAtTime15k

Bases: TransitionBaseClass

Shanghai to Cancun transition at Timestamp 15k.

Source code in packages/testing/src/execution_testing/forks/forks/transition.py
35
36
37
38
39
@transition_fork(to_fork=Cancun, from_fork=Shanghai, at_timestamp=15_000)
class ShanghaiToCancunAtTime15k(TransitionBaseClass):
    """Shanghai to Cancun transition at Timestamp 15k."""

    pass

GasCosts dataclass

Class that contains the gas cost constants for any fork.

Source code in packages/testing/src/execution_testing/forks/gas_costs.py
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
@dataclass(kw_only=True, frozen=True)
class GasCosts:
    """Class that contains the gas cost constants for any fork."""

    # Tiers
    BASE: int
    VERY_LOW: int
    LOW: int
    MID: int
    HIGH: int

    # Access
    WARM_ACCESS: int
    COLD_ACCOUNT_ACCESS: int
    WARM_SLOAD: int
    COLD_STORAGE_ACCESS: int
    # Flat access costs used before EIP-2929 introduces warm and cold
    # pricing. Field names follow the EELS gas constants.
    OPCODE_BALANCE: int
    OPCODE_EXTERNAL_BASE: int
    OPCODE_CALL_BASE: int
    OPCODE_SLOAD: int
    # Introduced by EIP-1052, zero before Constantinople.
    OPCODE_EXTCODEHASH: int = 0

    # Storage
    STORAGE_SET: int
    COLD_STORAGE_WRITE: int
    STORAGE_RESET: int

    # Call
    CALL_VALUE: int
    CALL_STIPEND: int
    NEW_ACCOUNT: int
    ACCOUNT_WRITE: int = 0
    CREATE_ACCESS: int = 0
    TX_VALUE_COST: int = 0

    # Contract Creation
    CODE_DEPOSIT_PER_BYTE: int
    CODE_INIT_PER_WORD: int

    # Authorization
    AUTH_PER_EMPTY_ACCOUNT: int
    # State gas for writing a net-new EIP-7702 delegation indicator;
    # 0 before the state-creation repricing introduces it.
    AUTH_BASE: int = 0
    # State-independent execution gas charged per EIP-7702 authorization
    # tuple; 0 before the state-access repricing introduces it.
    EXECUTION_PER_AUTH_BASE_COST: int = 0

    # Utility
    MEMORY_PER_WORD: int

    # Transactions
    TX_BASE: int
    TX_CREATE: int
    TX_DATA_PER_ZERO: int
    TX_DATA_PER_NON_ZERO: int
    TX_DATA_TOKEN_STANDARD: int
    TX_DATA_TOKEN_FLOOR: int
    TX_ACCESS_LIST_ADDRESS: int
    TX_ACCESS_LIST_STORAGE_KEY: int

    # Refunds
    REFUND_STORAGE_CLEAR: int
    REFUND_SELF_DESTRUCT: int
    REFUND_AUTH_PER_EXISTING_ACCOUNT: int

    # Precompiles
    PRECOMPILE_ECRECOVER: int
    PRECOMPILE_SHA256_BASE: int
    PRECOMPILE_SHA256_PER_WORD: int
    PRECOMPILE_RIPEMD160_BASE: int
    PRECOMPILE_RIPEMD160_PER_WORD: int
    PRECOMPILE_IDENTITY_BASE: int
    PRECOMPILE_IDENTITY_PER_WORD: int
    PRECOMPILE_ECADD: int
    PRECOMPILE_ECMUL: int
    PRECOMPILE_ECPAIRING_BASE: int
    PRECOMPILE_ECPAIRING_PER_POINT: int
    PRECOMPILE_BLAKE2F_BASE: int
    PRECOMPILE_BLAKE2F_PER_ROUND: int
    PRECOMPILE_POINT_EVALUATION: int
    PRECOMPILE_BLS_G1ADD: int
    PRECOMPILE_BLS_G1MUL: int
    PRECOMPILE_BLS_G1MAP: int
    PRECOMPILE_BLS_G2ADD: int
    PRECOMPILE_BLS_G2MUL: int
    PRECOMPILE_BLS_G2MAP: int
    PRECOMPILE_BLS_PAIRING_BASE: int
    PRECOMPILE_BLS_PAIRING_PER_PAIR: int
    PRECOMPILE_P256VERIFY: int

    # Block Access Lists
    BLOCK_ACCESS_LIST_ITEM: int

    # Opcodes
    OPCODE_ADD: int
    OPCODE_SUB: int
    OPCODE_MUL: int
    OPCODE_DIV: int
    OPCODE_SDIV: int
    OPCODE_MOD: int
    OPCODE_SMOD: int
    OPCODE_ADDMOD: int
    OPCODE_MULMOD: int
    OPCODE_SIGNEXTEND: int
    OPCODE_LT: int
    OPCODE_GT: int
    OPCODE_SLT: int
    OPCODE_SGT: int
    OPCODE_EQ: int
    OPCODE_ISZERO: int
    OPCODE_AND: int
    OPCODE_OR: int
    OPCODE_XOR: int
    OPCODE_NOT: int
    OPCODE_BYTE: int
    OPCODE_JUMP: int
    OPCODE_JUMPI: int
    OPCODE_JUMPDEST: int
    OPCODE_CALLDATALOAD: int
    OPCODE_BLOCKHASH: int
    OPCODE_COINBASE: int
    OPCODE_PUSH: int
    OPCODE_DUP: int
    OPCODE_SWAP: int

    # Dynamic Opcode Components
    OPCODE_CALLDATACOPY_BASE: int
    OPCODE_CODECOPY_BASE: int
    OPCODE_MLOAD_BASE: int
    OPCODE_MSTORE_BASE: int
    OPCODE_MSTORE8_BASE: int
    OPCODE_SELFDESTRUCT_BASE: int
    OPCODE_COPY_PER_WORD: int
    OPCODE_CREATE_BASE: int
    OPCODE_EXP_BASE: int
    OPCODE_EXP_PER_BYTE: int
    OPCODE_LOG_BASE: int
    OPCODE_LOG_DATA_PER_BYTE: int
    OPCODE_LOG_TOPIC: int
    OPCODE_KECCAK256_BASE: int
    OPCODE_KECCAK256_PER_WORD: int

    # Defined post-Frontier
    OPCODE_SHL: int = 0
    OPCODE_SHR: int = 0
    OPCODE_SAR: int = 0
    OPCODE_RETURNDATACOPY_BASE: int = 0
    OPCODE_BLOBHASH: int = 0
    OPCODE_MCOPY_BASE: int = 0
    OPCODE_CLZ: int = 0
    OPCODE_TLOAD: int = 0
    OPCODE_TSTORE: int = 0

ForkRangeDescriptor

Bases: BaseModel

Fork descriptor parsed from string normally contained in ethereum/tests fillers.

Source code in packages/testing/src/execution_testing/forks/helpers.py
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
class ForkRangeDescriptor(BaseModel):
    """
    Fork descriptor parsed from string normally contained in ethereum/tests
    fillers.
    """

    greater_equal: Type[BaseFork] | None = None
    less_than: Type[BaseFork] | None = None
    model_config = ConfigDict(frozen=True)

    def fork_in_range(self, fork: Type[BaseFork]) -> bool:
        """Return whether the given fork is within range."""
        if self.greater_equal is not None and fork < self.greater_equal:
            return False
        if self.less_than is not None and fork >= self.less_than:
            return False
        return True

    @model_validator(mode="wrap")
    @classmethod
    def validate_fork_range_descriptor(
        cls, v: Any, handler: ValidatorFunctionWrapHandler
    ) -> "ForkRangeDescriptor":
        """
        Validate the fork range descriptor from a string.

        Examples:
          - ">=Osaka" validates to {greater_equal=Osaka, less_than=None}

          - ">=Prague<Osaka" validates to {greater_equal=Prague,
                                           less_than=Osaka}

        """
        if isinstance(v, str):
            # Decompose the string into its parts
            descriptor_string = re.sub(r"\s+", "", v.strip())
            v = {}
            if m := re.search(r">=(\w+)", descriptor_string):
                fork: Type[BaseFork] | None = get_fork_by_name(m.group(1))
                if fork is None:
                    raise Exception(f"Unable to parse fork name: {m.group(1)}")
                v["greater_equal"] = fork
                descriptor_string = re.sub(r">=(\w+)", "", descriptor_string)
            if m := re.search(r"<(\w+)", descriptor_string):
                fork = get_fork_by_name(m.group(1))
                if fork is None:
                    raise Exception(f"Unable to parse fork name: {m.group(1)}")
                v["less_than"] = fork
                descriptor_string = re.sub(r"<(\w+)", "", descriptor_string)
            if descriptor_string:
                raise Exception(
                    "Unable to completely parse fork range descriptor. "
                    + f'Remaining string: "{descriptor_string}"'
                )
        return handler(v)

fork_in_range(fork)

Return whether the given fork is within range.

Source code in packages/testing/src/execution_testing/forks/helpers.py
424
425
426
427
428
429
430
def fork_in_range(self, fork: Type[BaseFork]) -> bool:
    """Return whether the given fork is within range."""
    if self.greater_equal is not None and fork < self.greater_equal:
        return False
    if self.less_than is not None and fork >= self.less_than:
        return False
    return True

validate_fork_range_descriptor(v, handler) classmethod

Validate the fork range descriptor from a string.

Examples:

  • ">=Osaka" validates to {greater_equal=Osaka, less_than=None}

  • ">=Prague

Source code in packages/testing/src/execution_testing/forks/helpers.py
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
@model_validator(mode="wrap")
@classmethod
def validate_fork_range_descriptor(
    cls, v: Any, handler: ValidatorFunctionWrapHandler
) -> "ForkRangeDescriptor":
    """
    Validate the fork range descriptor from a string.

    Examples:
      - ">=Osaka" validates to {greater_equal=Osaka, less_than=None}

      - ">=Prague<Osaka" validates to {greater_equal=Prague,
                                       less_than=Osaka}

    """
    if isinstance(v, str):
        # Decompose the string into its parts
        descriptor_string = re.sub(r"\s+", "", v.strip())
        v = {}
        if m := re.search(r">=(\w+)", descriptor_string):
            fork: Type[BaseFork] | None = get_fork_by_name(m.group(1))
            if fork is None:
                raise Exception(f"Unable to parse fork name: {m.group(1)}")
            v["greater_equal"] = fork
            descriptor_string = re.sub(r">=(\w+)", "", descriptor_string)
        if m := re.search(r"<(\w+)", descriptor_string):
            fork = get_fork_by_name(m.group(1))
            if fork is None:
                raise Exception(f"Unable to parse fork name: {m.group(1)}")
            v["less_than"] = fork
            descriptor_string = re.sub(r"<(\w+)", "", descriptor_string)
        if descriptor_string:
            raise Exception(
                "Unable to completely parse fork range descriptor. "
                + f'Remaining string: "{descriptor_string}"'
            )
    return handler(v)

InvalidForkError

Bases: Exception

Invalid fork error raised when the fork specified is not found or incompatible.

Source code in packages/testing/src/execution_testing/forks/helpers.py
33
34
35
36
37
38
39
40
41
class InvalidForkError(Exception):
    """
    Invalid fork error raised when the fork specified is not found or
    incompatible.
    """

    def __init__(self, message: str) -> None:
        """Initialize the InvalidForkError exception."""
        super().__init__(message)

__init__(message)

Initialize the InvalidForkError exception.

Source code in packages/testing/src/execution_testing/forks/helpers.py
39
40
41
def __init__(self, message: str) -> None:
    """Initialize the InvalidForkError exception."""
    super().__init__(message)

forks_from(fork, deployed_only=True)

Return specified fork and all forks after it.

Source code in packages/testing/src/execution_testing/forks/helpers.py
341
342
343
344
345
346
347
348
349
def forks_from(
    fork: Type[BaseFork], deployed_only: bool = True
) -> List[Type[BaseFork]]:
    """Return specified fork and all forks after it."""
    if deployed_only:
        latest_fork = get_deployed_forks()[-1]
    else:
        latest_fork = get_forks()[-1]
    return forks_from_until(fork, latest_fork)

forks_from_until(fork_from, fork_until)

Return specified fork and all forks after it until and including the second specified fork.

Source code in packages/testing/src/execution_testing/forks/helpers.py
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
def forks_from_until(
    fork_from: Type[BaseFork], fork_until: Type[BaseFork]
) -> List[Type[BaseFork]]:
    """
    Return specified fork and all forks after it until and including the second
    specified fork.
    """
    prev_fork: Type[BaseFork] | None = fork_until

    forks: List[Type[BaseFork]] = []

    while prev_fork is not None and prev_fork != fork_from:
        forks.insert(0, prev_fork)

        prev_fork = prev_fork.parent()

    if prev_fork == BaseFork:
        return []

    forks.insert(0, fork_from)

    return forks

get_closest_fork(fork)

Return None if BaseFork is passed, otherwise return the fork itself.

Source code in packages/testing/src/execution_testing/forks/helpers.py
110
111
112
113
114
def get_closest_fork(fork: Type[BaseFork]) -> Optional[Type[BaseFork]]:
    """Return None if BaseFork is passed, otherwise return the fork itself."""
    if fork is BaseFork:
        return None
    return fork

get_deployed_forks()

Return all fork classes that have been deployed to mainnet.

Chronologically ordered by deployment. BPO (Blob Parameter Only) forks are excluded as they are handled separately.

Source code in packages/testing/src/execution_testing/forks/helpers.py
87
88
89
90
91
92
93
94
95
96
97
98
def get_deployed_forks() -> List[Type[BaseFork]]:
    """
    Return all fork classes that have been deployed to mainnet.

    Chronologically ordered by deployment. BPO (Blob Parameter Only) forks
    are excluded as they are handled separately.
    """
    return [
        fork
        for fork in get_forks()
        if fork.is_deployed() and not fork.ignore() and not fork.bpo_fork()
    ]

get_development_forks()

Return all fork classes not yet deployed and under development.

The list is ordered by their planned deployment date.

Source code in packages/testing/src/execution_testing/forks/helpers.py
101
102
103
104
105
106
107
def get_development_forks() -> List[Type[BaseFork]]:
    """
    Return all fork classes not yet deployed and under development.

    The list is ordered by their planned deployment date.
    """
    return [fork for fork in get_forks() if not fork.is_deployed()]

get_fork_by_name(fork_name)

Get a fork by name.

Source code in packages/testing/src/execution_testing/forks/helpers.py
385
386
387
388
389
390
def get_fork_by_name(fork_name: str) -> Type[BaseFork] | None:
    """Get a fork by name."""
    for fork in get_forks():
        if fork.name() == fork_name:
            return fork
    return None

get_forks()

Return all fork classes implemented by execution_testing.forks.

Ordered chronologically by deployment.

Source code in packages/testing/src/execution_testing/forks/helpers.py
78
79
80
81
82
83
84
def get_forks() -> List[Type[BaseFork]]:
    """
    Return all fork classes implemented by `execution_testing.forks`.

    Ordered chronologically by deployment.
    """
    return all_forks[:]

get_forks_with_no_descendants(forks)

Get forks with no descendants in the inheritance hierarchy.

Source code in packages/testing/src/execution_testing/forks/helpers.py
171
172
173
174
175
176
177
178
179
180
181
182
183
184
def get_forks_with_no_descendants(
    forks: Set[Type[BaseFork]],
) -> Set[Type[BaseFork]]:
    """Get forks with no descendants in the inheritance hierarchy."""
    resulting_forks: Set[Type[BaseFork]] = set()
    for fork in forks:
        descendants = False
        for next_fork in forks - {fork}:
            if next_fork > fork:
                descendants = True
                break
        if not descendants:
            resulting_forks = resulting_forks | {fork}
    return resulting_forks

get_forks_with_no_parents(forks)

Get forks with no parents in the inheritance hierarchy.

Source code in packages/testing/src/execution_testing/forks/helpers.py
155
156
157
158
159
160
161
162
163
164
165
166
167
168
def get_forks_with_no_parents(
    forks: Set[Type[BaseFork]] | FrozenSet[Type[BaseFork]],
) -> Set[Type[BaseFork]]:
    """Get forks with no parents in the inheritance hierarchy."""
    resulting_forks: Set[Type[BaseFork]] = set()
    for fork in forks:
        parents = False
        for next_fork in forks - {fork}:
            if next_fork < fork:
                parents = True
                break
        if not parents:
            resulting_forks = resulting_forks | {fork}
    return resulting_forks

get_from_until_fork_set(forks, forks_from, forks_until)

Get fork range from forks_from to forks_until.

Source code in packages/testing/src/execution_testing/forks/helpers.py
140
141
142
143
144
145
146
147
148
149
150
151
152
def get_from_until_fork_set(
    forks: Set[Type[BaseFork]] | FrozenSet[Type[BaseFork]],
    forks_from: Set[Type[BaseFork]],
    forks_until: Set[Type[BaseFork]],
) -> Set[Type[BaseFork]]:
    """Get fork range from forks_from to forks_until."""
    resulting_set = set()
    for fork_from in forks_from:
        for fork_until in forks_until:
            for fork in forks:
                if fork <= fork_until and fork >= fork_from:
                    resulting_set.add(fork)
    return resulting_set

get_last_descendants(forks, forks_from)

Get last descendant of a class in the inheritance hierarchy.

Source code in packages/testing/src/execution_testing/forks/helpers.py
187
188
189
190
191
192
193
194
195
196
197
def get_last_descendants(
    forks: Set[Type[BaseFork]], forks_from: Set[Type[BaseFork]]
) -> Set[Type[BaseFork]]:
    """Get last descendant of a class in the inheritance hierarchy."""
    resulting_forks: Set[Type[BaseFork]] = set()
    forks = get_forks_with_no_descendants(forks)
    for fork_from in forks_from:
        for fork in forks:
            if fork >= fork_from:
                resulting_forks = resulting_forks | {fork}
    return resulting_forks

get_relative_fork_markers(fork_identifier, strict_mode=True)

Return a list of marker names for a given fork.

For a base fork (e.g. Shanghai), return [ Shanghai ]. For a transition fork (e.g. ShanghaiToCancunAtTime15k which transitions to Cancun), return [ ShanghaiToCancunAtTime15k, Cancun ].

If strict_mode is set to True, raise an InvalidForkError if the fork is not found, otherwise, simply return the provided (str) fork_identifier (this is required to run consume with forks that are unknown to EEST).

Source code in packages/testing/src/execution_testing/forks/helpers.py
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
def get_relative_fork_markers(
    fork_identifier: Type[BaseFork] | str, strict_mode: bool = True
) -> list[str]:
    """
    Return a list of marker names for a given fork.

    For a base fork (e.g. `Shanghai`), return [ `Shanghai` ]. For a transition
    fork (e.g. `ShanghaiToCancunAtTime15k` which transitions to `Cancun`),
    return [ `ShanghaiToCancunAtTime15k`, `Cancun` ].

    If `strict_mode` is set to `True`, raise an `InvalidForkError` if the fork
    is not found, otherwise, simply return the provided (str) `fork_identifier`
    (this is required to run `consume` with forks that are unknown to EEST).
    """
    all_forks = set(get_forks()) | set(get_transition_forks())
    if isinstance(fork_identifier, str):
        fork_class = None
        for candidate in all_forks:
            if candidate.name() == fork_identifier:
                fork_class = candidate
                break
        if strict_mode and fork_class is None:
            raise InvalidForkError(f"Unknown fork: {fork_identifier}")
        return [fork_identifier]
    else:
        fork_class = fork_identifier

    if issubclass(fork_class, TransitionBaseClass):
        return [fork_class.name(), fork_class.transitions_to().name()]
    else:
        return [fork_class.name()]

get_selected_fork_set(*, single_fork, forks_from, forks_until, transition_forks=True, bpo_siblings=True)

Process sets derived from --fork, --until and --from to return an unified fork set.

Source code in packages/testing/src/execution_testing/forks/helpers.py
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
def get_selected_fork_set(
    *,
    single_fork: Set[Type[BaseFork]],
    forks_from: Set[Type[BaseFork]],
    forks_until: Set[Type[BaseFork]],
    transition_forks: bool = True,
    bpo_siblings: bool = True,
) -> Set[Type[BaseFork | TransitionBaseClass]]:
    """
    Process sets derived from `--fork`, `--until` and `--from` to return an
    unified fork set.
    """
    selected_fork_set: Set[Type[BaseFork]] = set()
    if single_fork:
        selected_fork_set |= single_fork
    else:
        if not forks_from:
            forks_from = get_forks_with_no_parents(ALL_FORKS)
        if not forks_until:
            forks_until = get_last_descendants(
                set(get_deployed_forks()), forks_from
            )
        selected_fork_set |= get_from_until_fork_set(
            ALL_FORKS, forks_from, forks_until
        )
        # Transition fork comparison operators resolve to
        # transitions_to(), so an --until transition fork boundary
        # incorrectly includes its target in the normal fork set.
        for fork_until in forks_until:
            if issubclass(fork_until, TransitionBaseClass):
                selected_fork_set.discard(fork_until.transitions_to())
        if bpo_siblings:
            selected_fork_set |= get_bpo_sibling_forks(
                ALL_FORKS, forks_from, forks_until
            )
    selected_fork_set_with_transitions: Set[
        Type[BaseFork | TransitionBaseClass]
    ] = set() | selected_fork_set
    if transition_forks:
        for normal_fork in list(selected_fork_set):
            transition_fork_set = transition_fork_to(normal_fork)
            selected_fork_set_with_transitions |= transition_fork_set
        # Explicitly add transition fork boundaries whose target fork
        # was removed above (transition_fork_to won't find them).
        if not single_fork:
            for fork in forks_from | forks_until:
                if issubclass(fork, TransitionBaseClass):
                    selected_fork_set_with_transitions.add(fork)
    return selected_fork_set_with_transitions

get_transition_fork_predecessor(transition_fork)

Return the fork from which the transition fork transitions.

Source code in packages/testing/src/execution_testing/forks/helpers.py
122
123
124
125
126
127
128
def get_transition_fork_predecessor(
    transition_fork: Type[BaseFork | TransitionBaseClass],
) -> Type[BaseFork]:
    """Return the fork from which the transition fork transitions."""
    if not issubclass(transition_fork, TransitionBaseClass):
        raise InvalidForkError(f"{transition_fork} is not a transition fork.")
    return transition_fork.transitions_from()

get_transition_fork_successor(transition_fork)

Return the fork to which the transition fork transitions.

Source code in packages/testing/src/execution_testing/forks/helpers.py
131
132
133
134
135
136
137
def get_transition_fork_successor(
    transition_fork: Type[BaseFork],
) -> Type[BaseFork]:
    """Return the fork to which the transition fork transitions."""
    if not issubclass(transition_fork, TransitionBaseClass):
        raise InvalidForkError(f"{transition_fork} is not a transition fork.")
    return transition_fork.transitions_to()

get_transition_forks()

Return all the transition forks.

Source code in packages/testing/src/execution_testing/forks/helpers.py
117
118
119
def get_transition_forks() -> Set[Type[TransitionBaseClass]]:
    """Return all the transition forks."""
    return set(ALL_TRANSITION_FORKS)

ssz_schema_fork_key(schema, fork)

Return the newest schema fork at or before fork.

Schema keys are the fork classes themselves. Transition forks compare as their destination fork.

Source code in packages/testing/src/execution_testing/forks/helpers.py
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
def ssz_schema_fork_key(
    schema: SSZForkSchema, fork: Type[BaseFork]
) -> Type[BaseFork]:
    """
    Return the newest schema fork at or before ``fork``.

    Schema keys are the fork classes themselves. Transition forks
    compare as their destination fork.
    """
    for key in reversed(schema.forks()):
        if not (isinstance(key, type) and issubclass(key, BaseFork)):
            raise ValueError(
                f"SSZ schema fork key {key!r} is not a fork class"
            )
        if fork >= key:
            return key
    raise ValueError(
        f"{fork.name()} predates the SSZ schema base fork {schema.base_fork!r}"
    )

transition_fork_from_to(fork_from, fork_to)

Return transition fork that transitions to and from the specified forks.

Source code in packages/testing/src/execution_testing/forks/helpers.py
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
def transition_fork_from_to(
    fork_from: Type[BaseFork], fork_to: Type[BaseFork]
) -> Type[TransitionBaseClass] | None:
    """
    Return transition fork that transitions to and from the specified forks.
    """
    for transition_fork in get_transition_forks():
        if not issubclass(transition_fork, TransitionBaseClass):
            continue
        if (
            transition_fork.transitions_to() == fork_to
            and transition_fork.transitions_from() == fork_from
        ):
            return transition_fork

    return None

transition_fork_to(fork_to)

Return transition fork that transitions to the specified fork.

Source code in packages/testing/src/execution_testing/forks/helpers.py
301
302
303
304
305
306
307
308
309
310
311
312
313
314
def transition_fork_to(
    fork_to: Type[BaseFork | TransitionBaseClass],
) -> Set[Type[TransitionBaseClass]]:
    """Return transition fork that transitions to the specified fork."""
    selected_forks: Set[Type[TransitionBaseClass]] = set()
    if issubclass(fork_to, TransitionBaseClass):
        return selected_forks
    for transition_fork in get_transition_forks():
        if not issubclass(transition_fork, TransitionBaseClass):
            continue
        if transition_fork.transitions_to() == fork_to:
            selected_forks.add(transition_fork)

    return selected_forks

FeeSystemContractRequest

Bases: SystemContractRequest

A SystemContractRequest whose system contract queues the requests for the post-execution system call to dequeue, charging a fee that grows with the per-block excess request count via fake_exponential.

Subclasses set the contract address, the per-block caps, the fee parameters and the record width, and implement from_index to build a request from a sequential index. The queue storage layout follows the EIP-7002 predeploy: excess, count, queue head and queue tail each take a slot, and queued records occupy slots_per_request consecutive slots from queue_offset onward.

Source code in packages/testing/src/execution_testing/forks/requests.py
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
class FeeSystemContractRequest(SystemContractRequest):
    """
    A `SystemContractRequest` whose system contract queues the requests for
    the post-execution system call to dequeue, charging a fee that grows
    with the per-block excess request count via `fake_exponential`.

    Subclasses set the contract address, the per-block caps, the fee
    parameters and the record width, and implement `from_index` to build a
    request from a sequential index. The queue storage layout follows the
    EIP-7002 predeploy: excess, count, queue head and queue tail each take a
    slot, and queued records occupy `slots_per_request` consecutive slots
    from `queue_offset` onward.
    """

    fee: int = 0
    """Fee (in wei) paid to the system contract to enqueue the request."""

    max_per_block: ClassVar[int]
    """Maximum number of requests dequeued into a single block."""
    target_per_block: ClassVar[int]
    """Target requests per block; excess above this raises the fee."""
    min_fee: ClassVar[int]
    """Minimum fee, charged when there is no excess."""
    fee_update_fraction: ClassVar[int]
    """Controls how quickly the fee grows with the excess request count."""
    excess_fee_processing: ClassVar[Literal["block", "call"]]
    """When the excess fee is recalculated."""
    slots_per_request: ClassVar[int]
    """Storage slots each queued record occupies."""

    excess_slot: ClassVar[int] = 0
    count_slot: ClassVar[int] = 1
    queue_head_slot: ClassVar[int] = 2
    queue_tail_slot: ClassVar[int] = 3
    queue_offset: ClassVar[int] = 4

    @property
    def value(self) -> int:
        """The value of the triggering call is the fee."""
        return self.fee

    @classmethod
    def get_fee(cls, excess: int) -> int:
        """Return the fee charged for the given excess request count."""
        return fake_exponential(cls.min_fee, excess, cls.fee_update_fraction)

    @classmethod
    def get_excess(cls, previous_excess: int, count: int) -> int:
        """Return the new excess after a block processing `count` requests."""
        return max(0, previous_excess + count - cls.target_per_block)

    @classmethod
    def get_enqueue_fees(cls, count: int) -> List[int]:
        """
        Return the fee each of `count` requests enqueued in one block must pay
        when no excess is stored.

        With "call" processing, requests already queued this block beyond the
        target raise the fee for the next one; with "block" processing the fee
        changes only at the block's system call.
        """
        if cls.excess_fee_processing == "call":
            return [
                cls.get_fee(max(i - cls.target_per_block, 0))
                for i in range(count)
            ]
        elif cls.excess_fee_processing == "block":
            return [cls.get_fee(0)] * count
        raise ValueError(
            f"unhandled fee processing {cls.excess_fee_processing}"
        )

    @classmethod
    def get_n_fee_increments(cls, n: int) -> List[int]:
        """Get the first N excess request counts that increase the fee."""
        excess_request_counts: List[int] = []
        last_fee = 1
        i = 0
        while len(excess_request_counts) < n:
            fee = cls.get_fee(i)
            if fee > last_fee:
                excess_request_counts.append(i)
                last_fee = fee
            i += 1
        return excess_request_counts

    @classmethod
    def empty_block_bal_item_count(cls) -> int:
        """
        Return the block access list items an idle queue adds to a block:
        the contract address plus the excess, count, head and tail slots its
        system call reads.
        """
        return 1 + len(
            {
                cls.excess_slot,
                cls.count_slot,
                cls.queue_head_slot,
                cls.queue_tail_slot,
            }
        )

    @classmethod
    def record_slots(cls, start_index: int, count: int) -> List[int]:
        """Return the slots of `count` queued records from `start_index` on."""
        first = cls.queue_offset + start_index * cls.slots_per_request
        return list(range(first, first + count * cls.slots_per_request))

fee = 0 class-attribute instance-attribute

Fee (in wei) paid to the system contract to enqueue the request.

max_per_block class-attribute

Maximum number of requests dequeued into a single block.

target_per_block class-attribute

Target requests per block; excess above this raises the fee.

min_fee class-attribute

Minimum fee, charged when there is no excess.

fee_update_fraction class-attribute

Controls how quickly the fee grows with the excess request count.

excess_fee_processing class-attribute

When the excess fee is recalculated.

slots_per_request class-attribute

Storage slots each queued record occupies.

value property

The value of the triggering call is the fee.

get_fee(excess) classmethod

Return the fee charged for the given excess request count.

Source code in packages/testing/src/execution_testing/forks/requests.py
123
124
125
126
@classmethod
def get_fee(cls, excess: int) -> int:
    """Return the fee charged for the given excess request count."""
    return fake_exponential(cls.min_fee, excess, cls.fee_update_fraction)

get_excess(previous_excess, count) classmethod

Return the new excess after a block processing count requests.

Source code in packages/testing/src/execution_testing/forks/requests.py
128
129
130
131
@classmethod
def get_excess(cls, previous_excess: int, count: int) -> int:
    """Return the new excess after a block processing `count` requests."""
    return max(0, previous_excess + count - cls.target_per_block)

get_enqueue_fees(count) classmethod

Return the fee each of count requests enqueued in one block must pay when no excess is stored.

With "call" processing, requests already queued this block beyond the target raise the fee for the next one; with "block" processing the fee changes only at the block's system call.

Source code in packages/testing/src/execution_testing/forks/requests.py
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
@classmethod
def get_enqueue_fees(cls, count: int) -> List[int]:
    """
    Return the fee each of `count` requests enqueued in one block must pay
    when no excess is stored.

    With "call" processing, requests already queued this block beyond the
    target raise the fee for the next one; with "block" processing the fee
    changes only at the block's system call.
    """
    if cls.excess_fee_processing == "call":
        return [
            cls.get_fee(max(i - cls.target_per_block, 0))
            for i in range(count)
        ]
    elif cls.excess_fee_processing == "block":
        return [cls.get_fee(0)] * count
    raise ValueError(
        f"unhandled fee processing {cls.excess_fee_processing}"
    )

get_n_fee_increments(n) classmethod

Get the first N excess request counts that increase the fee.

Source code in packages/testing/src/execution_testing/forks/requests.py
154
155
156
157
158
159
160
161
162
163
164
165
166
@classmethod
def get_n_fee_increments(cls, n: int) -> List[int]:
    """Get the first N excess request counts that increase the fee."""
    excess_request_counts: List[int] = []
    last_fee = 1
    i = 0
    while len(excess_request_counts) < n:
        fee = cls.get_fee(i)
        if fee > last_fee:
            excess_request_counts.append(i)
            last_fee = fee
        i += 1
    return excess_request_counts

empty_block_bal_item_count() classmethod

Return the block access list items an idle queue adds to a block: the contract address plus the excess, count, head and tail slots its system call reads.

Source code in packages/testing/src/execution_testing/forks/requests.py
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
@classmethod
def empty_block_bal_item_count(cls) -> int:
    """
    Return the block access list items an idle queue adds to a block:
    the contract address plus the excess, count, head and tail slots its
    system call reads.
    """
    return 1 + len(
        {
            cls.excess_slot,
            cls.count_slot,
            cls.queue_head_slot,
            cls.queue_tail_slot,
        }
    )

record_slots(start_index, count) classmethod

Return the slots of count queued records from start_index on.

Source code in packages/testing/src/execution_testing/forks/requests.py
184
185
186
187
188
@classmethod
def record_slots(cls, start_index: int, count: int) -> List[int]:
    """Return the slots of `count` queued records from `start_index` on."""
    first = cls.queue_offset + start_index * cls.slots_per_request
    return list(range(first, first + count * cls.slots_per_request))

RequestBase

Base class for requests.

Source code in packages/testing/src/execution_testing/forks/requests.py
21
22
23
24
25
26
27
28
29
class RequestBase:
    """Base class for requests."""

    type: ClassVar[int]

    @abstractmethod
    def __bytes__(self) -> bytes:
        """Return request's attributes as bytes."""
        ...

__bytes__() abstractmethod

Return request's attributes as bytes.

Source code in packages/testing/src/execution_testing/forks/requests.py
26
27
28
29
@abstractmethod
def __bytes__(self) -> bytes:
    """Return request's attributes as bytes."""
    ...

Requests

Requests for the transition tool.

Source code in packages/testing/src/execution_testing/forks/requests.py
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
class Requests:
    """Requests for the transition tool."""

    requests_list: List[Bytes]

    def __init__(
        self,
        *requests: RequestBase,
        requests_lists: List[List[RequestBase] | Bytes] | None = None,
    ) -> None:
        """Initialize requests object."""
        if requests_lists is not None:
            assert len(requests) == 0, (
                "requests must be empty if list is provided"
            )
            self.requests_list = []
            for requests_list in requests_lists:
                self.requests_list.append(
                    requests_list_to_bytes(requests_list)
                )
            return
        else:
            lists: Dict[int, List[RequestBase]] = defaultdict(list)
            for r in requests:
                lists[r.type].append(r)

            self.requests_list = [
                Bytes(
                    bytes([request_type])
                    + requests_list_to_bytes(lists[request_type])
                )
                for request_type in sorted(lists.keys())
            ]

    def __bytes__(self) -> bytes:
        """Return requests hash."""
        s: bytes = b"".join(r.sha256() for r in self.requests_list)
        return Bytes(s).sha256()

__init__(*requests, requests_lists=None)

Initialize requests object.

Source code in packages/testing/src/execution_testing/forks/requests.py
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
def __init__(
    self,
    *requests: RequestBase,
    requests_lists: List[List[RequestBase] | Bytes] | None = None,
) -> None:
    """Initialize requests object."""
    if requests_lists is not None:
        assert len(requests) == 0, (
            "requests must be empty if list is provided"
        )
        self.requests_list = []
        for requests_list in requests_lists:
            self.requests_list.append(
                requests_list_to_bytes(requests_list)
            )
        return
    else:
        lists: Dict[int, List[RequestBase]] = defaultdict(list)
        for r in requests:
            lists[r.type].append(r)

        self.requests_list = [
            Bytes(
                bytes([request_type])
                + requests_list_to_bytes(lists[request_type])
            )
            for request_type in sorted(lists.keys())
        ]

__bytes__()

Return requests hash.

Source code in packages/testing/src/execution_testing/forks/requests.py
234
235
236
237
def __bytes__(self) -> bytes:
    """Return requests hash."""
    s: bytes = b"".join(r.sha256() for r in self.requests_list)
    return Bytes(s).sha256()

SystemContractRequest

Bases: RequestBase, CamelModel

Test descriptor for a request triggered by calling a system contract.

Holds the fields and interface shared by all request types; the concrete serialized fields (and the RequestBase.__bytes__ / type) are provided by each subclass.

Source code in packages/testing/src/execution_testing/forks/requests.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
class SystemContractRequest(RequestBase, CamelModel):
    """
    Test descriptor for a request triggered by calling a system contract.

    Holds the fields and interface shared by all request types; the concrete
    serialized fields (and the `RequestBase.__bytes__` / `type`) are provided
    by each subclass.
    """

    valid: bool = True
    """Whether the request is expected to be valid and therefore included."""
    calldata_modifier: Callable[[bytes], bytes] = lambda x: x
    """Calldata modifier function applied when building the calldata."""

    system_contract_address: ClassVar[Address]
    """Address of the system contract that processes the request."""

    @property
    @abstractmethod
    def value(self) -> int:
        """Value (in wei) of the call that triggers the request."""
        ...

    @property
    @abstractmethod
    def calldata(self) -> bytes:
        """Calldata of the call that triggers the request."""
        ...

    @abstractmethod
    def with_source_address(self, source_address: Address) -> Self:
        """Return a copy of the request with its source address set."""
        ...

    def set_source_address(self, source_address: Address) -> None:
        """
        Record `source_address` on the request in place, for request types
        that carry one (e.g. withdrawals, consolidations). A no-op for request
        types whose serialized form omits the source (e.g. deposits).
        """
        if "source_address" in type(self).model_fields:
            self.source_address = source_address

    @classmethod
    @abstractmethod
    def from_index(cls, index: int) -> Self:
        """Build a request from a sequential index."""
        ...

valid = True class-attribute instance-attribute

Whether the request is expected to be valid and therefore included.

calldata_modifier = lambda x: x class-attribute instance-attribute

Calldata modifier function applied when building the calldata.

system_contract_address class-attribute

Address of the system contract that processes the request.

value abstractmethod property

Value (in wei) of the call that triggers the request.

calldata abstractmethod property

Calldata of the call that triggers the request.

with_source_address(source_address) abstractmethod

Return a copy of the request with its source address set.

Source code in packages/testing/src/execution_testing/forks/requests.py
61
62
63
64
@abstractmethod
def with_source_address(self, source_address: Address) -> Self:
    """Return a copy of the request with its source address set."""
    ...

set_source_address(source_address)

Record source_address on the request in place, for request types that carry one (e.g. withdrawals, consolidations). A no-op for request types whose serialized form omits the source (e.g. deposits).

Source code in packages/testing/src/execution_testing/forks/requests.py
66
67
68
69
70
71
72
73
def set_source_address(self, source_address: Address) -> None:
    """
    Record `source_address` on the request in place, for request types
    that carry one (e.g. withdrawals, consolidations). A no-op for request
    types whose serialized form omits the source (e.g. deposits).
    """
    if "source_address" in type(self).model_fields:
        self.source_address = source_address

from_index(index) abstractmethod classmethod

Build a request from a sequential index.

Source code in packages/testing/src/execution_testing/forks/requests.py
75
76
77
78
79
@classmethod
@abstractmethod
def from_index(cls, index: int) -> Self:
    """Build a request from a sequential index."""
    ...

requests_list_to_bytes(requests_list)

Convert list of requests to bytes.

Source code in packages/testing/src/execution_testing/forks/requests.py
191
192
193
194
195
196
197
def requests_list_to_bytes(
    requests_list: List[RequestBase] | Bytes | SupportsBytes,
) -> Bytes:
    """Convert list of requests to bytes."""
    if not isinstance(requests_list, list):
        return Bytes(requests_list)
    return Bytes(b"".join([bytes(r) for r in requests_list]))