Skip to main content

Module consensus

Module consensus 

Source
Expand description

Consensus types for Era post-merge history files

§Decoding

This crate handles compression/decompression and, for post-merge blocks, extraction of the embedded execution block via CompressedSignedBeaconBlock::decode_execution_block. The decompressed bytes are SSZ-encoded consensus types decoded with alloy_rpc_types_beacon’s fork-specific beacon block types — no external consensus client is required.

§Example

§Decoding the execution block from a CompressedSignedBeaconBlock

use reth_era::era::types::consensus::CompressedSignedBeaconBlock;
use reth_ethereum_primitives::TransactionSigned;

fn decode_block(
    compressed: &CompressedSignedBeaconBlock,
) -> Result<(), Box<dyn std::error::Error>> {
    // Post-merge blocks carry an execution payload; pre-merge slots yield `None`.
    if let Some(block) = compressed.decode_execution_block::<TransactionSigned>()? {
        println!("Execution block number: {}", block.header.number);
    }
    Ok(())
}

Structs§

CompressedBeaconState
Compressed beacon state
CompressedSignedBeaconBlock
Compressed signed beacon block

Constants§

COMPRESSED_BEACON_STATE
CompressedBeaconState record type: [0x02, 0x00]
COMPRESSED_SIGNED_BEACON_BLOCK
CompressedSignedBeaconBlock record type: [0x01, 0x00]