ethereum.forks.bogota.blocks

A Block is a single link in the chain that is Ethereum. Each Block contains a Header and zero or more transactions. Each Header contains associated metadata like the block number, parent block hash, and how much gas was consumed by its transactions.

Together, these blocks form a cryptographically secure journal recording the history of all state transitions that have happened since the genesis of the chain.

Withdrawal

Withdrawals represent a transfer of ETH from the consensus layer (beacon chain) to the execution layer, as validated by the consensus layer. Each withdrawal is listed in the block's list of withdrawals. See block.

35
@final
36
@slotted_freezable
37
@dataclass
class Withdrawal:

index

The unique index of the withdrawal, incremented for each withdrawal processed.

47
    index: U64

validator_index

The index of the validator on the consensus layer that is withdrawing.

53
    validator_index: U64

address

The execution-layer address receiving the withdrawn ETH.

58
    address: Address

amount

The amount of ETH being withdrawn, in Gwei.

63
    amount: U64

Header

Header portion of a block on the chain, containing metadata and cryptographic commitments to the block's contents.

69
@final
70
@slotted_freezable
71
@dataclass
class Header:

parent_hash

Hash (keccak256) of the parent block's header, encoded with RLP.

78
    parent_hash: Hash32

ommers_hash

Hash (keccak256) of the ommers (uncle blocks) in this block, encoded with RLP. However, in post merge forks ommers_hash is always EMPTY_OMMER_HASH.

86
    ommers_hash: Hash32

coinbase

Address of the miner (or validator) who mined this block.

The coinbase address receives the block reward and the priority fees (tips) from included transactions. Base fees (introduced in EIP-1559) are burned and do not go to the coinbase.

97
    coinbase: Address

state_root

Root hash (keccak256) of the state trie after executing all transactions in this block. It represents the state of the Ethereum Virtual Machine (EVM) after all transactions in this block have been processed. It is computed using compute_state_root(), which computes the root of the Merkle-Patricia Trie representing the Ethereum world state after applying the block's state changes.

108
    state_root: Root

transactions_root

Root hash (keccak256) of the transactions trie, which contains all transactions included in this block in their original order. It is computed using the root() function over the Merkle-Patricia trie of transactions as the parameter.

122
    transactions_root: Root

receipt_root

Root hash (keccak256) of the receipts trie, which contains all receipts for transactions in this block. It is computed using the root() function over the Merkle-Patricia trie constructed from the receipts.

134
    receipt_root: Root

bloom

Bloom filter for logs generated by transactions in this block. Constructed from all logs in the block using the logs bloom mechanism.

145
    bloom: Bloom

difficulty

Difficulty of the block (pre-PoS), or a constant in PoS.

153
    difficulty: Uint

number

Block number (height) in the chain.

158
    number: Uint

gas_limit

Maximum gas allowed in this block. Pre EIP-1559, this was the maximum gas that could be consumed by all transactions in the block. Post EIP-1559, this is still the maximum gas limit, but the base fee per gas is adjusted so that effective block gas utilization targets 50% of that limit. The gas_limit is a voted parameter that can be adjusted by a factor of 1/1024 from the previous block's limit by the block proposer, allowing the network to coordinate on capacity increases (e.g. the 60M limit proposed in EIP-7935).

163
    gas_limit: Uint

gas_used

The larger of the execution gas and the state gas used by all transactions in this block (EIP-8037). Unlike the cumulative gas of the receipts, it is not reduced by refunds (EIP-7778).

179
    gas_used: Uint

timestamp

Timestamp of when the block was mined, in seconds since the unix epoch.

189
    timestamp: U256

extra_data

Arbitrary data included by the miner.

194
    extra_data: Bytes

prev_randao

Output of the RANDAO beacon for random validator selection.

199
    prev_randao: Bytes32

nonce

Nonce used in the mining process (pre-PoS), set to zero in PoS.

204
    nonce: Bytes8

base_fee_per_gas

Base fee per gas for transactions in this block, introduced in EIP-1559. This is the minimum fee per gas that must be paid for a transaction to be included in this block.

209
    base_fee_per_gas: Uint

withdrawals_root

Root hash of the withdrawals trie, which contains all withdrawals in this block.

218
    withdrawals_root: Root

blob_gas_used

Total blob gas consumed by the transactions within this block. Introduced in EIP-4844.

224
    blob_gas_used: U64

excess_blob_gas

Running total of blob gas consumed in excess of the target, prior to this block. Blocks with above-target blob gas consumption increase this value, while blocks with below-target blob gas consumption decrease it (to a minimum of zero). Introduced in EIP-4844.

232
    excess_blob_gas: U64

parent_beacon_block_root

Root hash of the corresponding beacon chain block.

242
    parent_beacon_block_root: Root

requests_hash

SHA2-256 hash of all the collected requests in this block. Introduced in EIP-7685. See compute_requests_hash for more details.

247
    requests_hash: Hash32

block_access_list_hash

keccak256 hash of the Block Access List containing all accounts and storage locations accessed during block execution. Introduced in EIP-7928. See hash_block_access_list for more details.

257
    block_access_list_hash: Hash32

slot_number

The slot number of this block as provided by the consensus layer. Introduced in EIP-7843.

269
    slot_number: U64

Block

A complete block on Ethereum, which is composed of a block header, a list of transactions, a list of ommers (deprecated), and a list of validator withdrawals.

The block header includes fields relevant to the Proof-of-Stake consensus, with deprecated Proof-of-Work fields such as difficulty, nonce, and ommersHash set to constants. The coinbase field denotes the address receiving priority fees from the block.

The header also contains commitments to the current state (stateRoot), the transactions (transactionsRoot), the transaction receipts (receiptsRoot), and withdrawalsRoot committing to the validator withdrawals included in this block. It also includes a bloom filter which summarizes log data from the transactions.

Withdrawals represent ETH transfers from validators to their recipients, introduced by the consensus layer. Ommers remain deprecated and empty.

278
@final
279
@slotted_freezable
280
@dataclass
class Block:

header

The block header containing metadata and cryptographic commitments. Refer to headers for more details on the fields included in the header.

305
    header: Header

transactions

A tuple of transactions included in this block. Each transaction can be any of a legacy transaction, an access list transaction, a fee market transaction, a blob transaction, or a set code transaction.

313
    transactions: Tuple[Bytes | LegacyTransaction, ...]

ommers

A tuple of ommers (uncle blocks) included in this block. Always empty in Proof-of-Stake forks.

320
    ommers: Tuple[Header, ...]

withdrawals

A tuple of withdrawals processed in this block.

326
    withdrawals: Tuple[Withdrawal, ...]

Log

Data record produced during the execution of a transaction. Logs are used by smart contracts to emit events (using the EVM log opcodes (LOG0, LOG1, LOG2, LOG3 and LOG4), which can be efficiently searched using the bloom filter in the block header.

332
@final
333
@slotted_freezable
334
@dataclass
class Log:

address

The address of the contract that emitted the log.

349
    address: Address

topics

A tuple of up to four topics associated with the log, used for filtering.

354
    topics: Tuple[Hash32, ...]

data

The data payload of the log, which can contain any arbitrary data.

359
    data: Bytes

Receipt

Result of a transaction execution. Receipts are included in the receipts trie.

365
@final
366
@slotted_freezable
367
@dataclass
class Receipt:

succeeded

Whether the transaction execution was successful.

374
    succeeded: bool

cumulative_gas_used

Total gas used in the block up to and including this transaction. This is the gas used after refunds, paid by the user.

379
    cumulative_gas_used: Uint

bloom

Bloom filter for logs generated by this transaction. This is a 2048-byte bit array that allows for efficient filtering of logs.

385
    bloom: Bloom

logs

A tuple of logs generated by this transaction. Each log contains the address of the contract that emitted it, a tuple of topics, and the data payload.

391
    logs: Tuple[Log, ...]

GasUsed

The gas a Frame used, one amount per gas dimension, mirroring the frame's GasLimits.

399
@final
400
@slotted_freezable
401
@dataclass
class GasUsed:

execution

Execution gas used by the frame, not reduced by refunds. Final once the frame completes.

411
    execution: Uint

state

State gas attributed to the frame after all refills and rollbacks applied so far. A later frame's refill of a charge this frame paid lowers this amount, and an atomic batch unroll zeroes it for the unrolled frames; the value is final only when the transaction ends. The sum over all frames is the transaction's state gas usage.

417
    state: Uint

FrameReceipt

Result of a single frame's execution, included in the frame transaction's receipt.

428
@final
429
@slotted_freezable
430
@dataclass
class FrameReceipt:

status

Outcome of the frame's execution.

437
    status: FrameStatus

gas_used

Gas used by the frame, one amount per gas dimension.

442
    gas_used: GasUsed

logs

A tuple of logs generated by this frame. Emptied when the frame's atomic batch was unrolled.

447
    logs: Tuple[Log, ...]

FrameTransactionReceipt

Result of a frame transaction's execution. Frame transaction receipts are included in the receipts trie.

Unlike Receipt, there is no transaction-level status and no bloom filter: outcomes are reported per frame, and the logs of all frames contribute to the block's log bloom in frame order.

454
@final
455
@slotted_freezable
456
@dataclass
class FrameTransactionReceipt:

cumulative_gas_used

Total gas used in the block up to and including this transaction. This is the gas used after refunds, paid by the payer.

467
    cumulative_gas_used: Uint

payer

The account that paid for the transaction's gas.

473
    payer: Address

frame_receipts

A tuple of per-frame receipts, in frame order.

478
    frame_receipts: Tuple[FrameReceipt, ...]

encode_receipt

Encodes a transaction receipt based on the transaction type.

The encoding follows the same format as transactions encoding, where:

  • AccessListTransaction receipts are prefixed with b"\x01".

  • FeeMarketTransaction receipts are prefixed with b"\x02".

  • BlobTransaction receipts are prefixed with b"\x03".

  • SetCodeTransaction receipts are prefixed with b"\x04".

  • FrameTransaction receipts are prefixed with b"\x06".

  • LegacyTransaction receipts are returned as is.

def encode_receipt(​tx: Transaction, ​​receipt: Receipt | FrameTransactionReceipt​) -> Bytes | Receipt:
487
    <snip>
498
    if isinstance(tx, AccessListTransaction):
499
        return b"\x01" + rlp.encode(receipt)
500
    elif isinstance(tx, FeeMarketTransaction):
501
        return b"\x02" + rlp.encode(receipt)
502
    elif isinstance(tx, BlobTransaction):
503
        return b"\x03" + rlp.encode(receipt)
504
    elif isinstance(tx, SetCodeTransaction):
505
        return b"\x04" + rlp.encode(receipt)
506
    elif isinstance(tx, FrameTransaction):
507
        return b"\x06" + rlp.encode(receipt)
508
    else:
509
        assert isinstance(receipt, Receipt)
510
        return receipt

decode_receipt

Decodes a receipt from its serialized form.

The decoding follows the same format as transactions decoding, where:

  • Receipts prefixed with b"\x01" are decoded as AccessListTransaction receipts.

  • Receipts prefixed with b"\x02" are decoded as FeeMarketTransaction receipts.

  • Receipts prefixed with b"\x03" are decoded as BlobTransaction receipts.

  • Receipts prefixed with b"\x04" are decoded as SetCodeTransaction receipts.

  • Receipts prefixed with b"\x06" are decoded as FrameTransaction receipts.

  • LegacyTransaction receipts are returned as is.

def decode_receipt(​receipt: Bytes | Receipt​) -> Receipt | FrameTransactionReceipt:
516
    <snip>
532
    if isinstance(receipt, Bytes):
533
        if receipt[0] == 6:
534
            return rlp.decode_to(FrameTransactionReceipt, receipt[1:])
535
        assert receipt[0] in (1, 2, 3, 4)
536
        return rlp.decode_to(Receipt, receipt[1:])
537
    else:
538
        return receipt