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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/ethereum/forks/amsterdam/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@
from .blocks import Block, Header, Log, Receipt, Withdrawal, encode_receipt
from .bloom import logs_bloom
from .exceptions import WrongChainIdError
from .fork_types import Authorization, BlockAccessIndex
from .fork_types import (
Authorization,
BlockAccessIndex,
ExecutionGas,
StateGas,
)
from .requests import (
BUILDER_DEPOSIT_REQUEST_TYPE,
BUILDER_EXIT_REQUEST_TYPE,
Expand Down Expand Up @@ -106,7 +111,7 @@
BEACON_ROOTS_ADDRESS = hex_to_address(
"0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02"
)
SYSTEM_TRANSACTION_GAS = Uint(30000000)
SYSTEM_TRANSACTION_GAS = ExecutionGas(Uint(30000000))
SYSTEM_MAX_SSTORES_PER_CALL = Uint(16)
"""
Upper bound on the number of new storage slots a single system call is
Expand Down Expand Up @@ -757,7 +762,7 @@ def process_unchecked_system_transaction(
gas_limit=SYSTEM_TRANSACTION_GAS,
effective_gas_price=block_env.base_fee_per_gas,
execution_gas_grant=SYSTEM_TRANSACTION_GAS,
state_gas_reservoir=(
state_gas_reservoir=StateGas(
StateGasCosts.STORAGE_SET * SYSTEM_MAX_SSTORES_PER_CALL
),
calldata_floor=Uint(0),
Expand Down
19 changes: 12 additions & 7 deletions src/ethereum/forks/amsterdam/vm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@

from ..block_access_lists import BlockAccessList, BlockAccessListBuilder
from ..blocks import Log, Receipt, Withdrawal
from ..fork_types import Authorization, VersionedHash
from ..fork_types import (
Authorization,
ExecutionGas,
StateGas,
VersionedHash,
)
from ..state_tracker import BlockState, TransactionState
from ..transactions import LegacyTransaction
from .gas import GasMeter
Expand Down Expand Up @@ -69,10 +74,10 @@ class BlockOutput:

Contains the following:

block_gas_used : `ethereum.base_types.Uint`
block_gas_used : `ExecutionGas`
Execution gas used for executing all transactions. EIP-8037
names this counter `block_execution_gas_used`.
block_state_gas_used : `ethereum.base_types.Uint`
block_state_gas_used : `StateGas`
State gas used for executing all transactions.
cumulative_gas_used : `ethereum.base_types.Uint`
Cumulative gas paid by users (post-refund, post-floor).
Expand All @@ -95,8 +100,8 @@ class BlockOutput:
The block access list for the block.
"""

block_gas_used: Uint = Uint(0)
block_state_gas_used: Uint = Uint(0)
block_gas_used: ExecutionGas = ExecutionGas(Uint(0))
block_state_gas_used: StateGas = StateGas(Uint(0))
cumulative_gas_used: Uint = Uint(0)
transactions_trie: Trie[Bytes, Optional[Bytes | LegacyTransaction]] = (
field(default_factory=lambda: Trie(secured=False, default=None))
Expand Down Expand Up @@ -129,8 +134,8 @@ class TransactionEnvironment:
value: U256
gas_limit: Uint
effective_gas_price: Uint
execution_gas_grant: Uint
state_gas_reservoir: Uint
execution_gas_grant: ExecutionGas
state_gas_reservoir: StateGas
calldata_floor: Uint
access_list_addresses: Set[Address]
access_list_storage_keys: Set[Tuple[Address, Bytes32]]
Expand Down
10 changes: 5 additions & 5 deletions src/ethereum/forks/amsterdam/vm/eoa_delegation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
from typing import Optional, Set, Tuple

from ethereum_rlp import rlp
from ethereum_types.numeric import U64, U256, Uint
from ethereum_types.numeric import U64, U256

from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
from ethereum.crypto.hash import keccak256
from ethereum.exceptions import InvalidSignatureError
from ethereum.state import Address

from ..fork_types import Authorization
from ..fork_types import Authorization, ExecutionGas
from ..state_tracker import (
TransactionState,
account_exists,
Expand Down Expand Up @@ -154,7 +154,7 @@ def recover_authority(authorization: Authorization) -> Address:

def calculate_delegation_cost(
evm: Evm, address: Address
) -> Tuple[bool, Address, Uint]:
) -> Tuple[bool, Address, ExecutionGas]:
"""
Get the delegation address and the cost of access from the address.

Expand All @@ -167,7 +167,7 @@ def calculate_delegation_cost(

Returns
-------
delegation : `Tuple[bool, Address, Uint]`
delegation : `Tuple[bool, Address, ExecutionGas]`
The delegation address and access gas cost.

"""
Expand All @@ -176,7 +176,7 @@ def calculate_delegation_cost(
code = get_code(tx_state, get_account(tx_state, address).code_hash)

if not is_valid_delegation(code):
return False, address, Uint(0)
return False, address, GasCosts.ZERO

delegated_address = Address(code[EOA_DELEGATION_MARKER_LENGTH:])

Expand Down
Loading
Loading