Expand description
Commonly used types and traits in Reth.
This crate contains various primitive traits used across reth’s components.
It provides the Block
trait which is used to represent a block and all its components.
A Block
is composed of a Header
and a BlockBody
. In ethereum (and optimism), a block
body consists of a list of transactions, a list of uncle headers, and a list of withdrawals. For
optimism, uncle headers and withdrawals are always empty lists.
§Feature Flags
arbitrary
: Addsproptest
andarbitrary
support for primitive types.op
: Implements the traits for various op-alloy types.reth-codec
: Enables db codec support for reth types including zstd compression for certain types.serde
: Adds serde support for all types.secp256k1
: Adds secp256k1 support for transaction signing/recovery. (By default the no-std friendlyk256
is used)rayon
: Usesrayon
for parallel transaction sender recovery inBlockBody
by default.serde-bincode-compat
provides helpers for dealing with thebincode
crate.
§Overview
This crate defines various traits and types that form the foundation of the reth stack.
The top-level trait is Block
which represents a block in the blockchain. A Block
is
composed of a Header
and a BlockBody
. A BlockBody
contains the transactions in the
block any additional data that is part of the block. A Header
contains the metadata of the
block.
§Sealing (Hashing)
The block hash is derived from the Header
and is used to uniquely identify the block. This
operation is referred to as sealing in the context of this crate. Sealing is an expensive
operation. This crate provides various wrapper types that cache the hash of the block to avoid
recomputing it: SealedHeader
and SealedBlock
. All sealed types can be downgraded to
their unsealed counterparts.
§Recovery
The raw consensus transactions that make up a block don’t include the sender’s address. This
information is recovered from the transaction signature. This operation is referred to as
recovery in the context of this crate and is an expensive operation. The RecoveredBlock
represents a SealedBlock
with the sender addresses recovered. A SealedBlock
can be
upgraded to a RecoveredBlock
by recovering the sender addresses:
SealedBlock::try_recover
. A RecoveredBlock
can be downgraded to a SealedBlock
by
removing the sender addresses: RecoveredBlock::into_sealed_block
.
§Naming
The types in this crate support multiple recovery functions, e.g.
SealedBlock::try_recover_unchecked
and SealedBlock::try_recover_unchecked
. The _unchecked
suffix indicates that this function recovers the signer without ensuring that the signature has a low s
value, in other words this rule introduced in EIP-2 is ignored.
Hence this function is necessary when dealing with pre EIP-2 transactions on the ethereum
mainnet. Newer transactions must always be recovered with the regular recover
functions, see
also recover_signer
.
§Bincode serde compatibility
The bincode-crate is often used by additional tools when sending data over the network.
bincode
crate doesn’t work well with optionally serializable serde fields, but some of the consensus types require optional serialization for RPC compatibility. Read more: https://github.com/bincode-org/bincode/issues/326
As a workaround this crate introduces the
SerdeBincodeCompat
trait used to a bincode
compatible serde representation.
Re-exports§
pub use constants::gas_units::format_gas;
pub use constants::gas_units::format_gas_throughput;
pub use account::Account;
pub use account::Bytecode;
pub use receipt::FullReceipt;
pub use receipt::Receipt;
pub use transaction::execute::FillTxEnv;
pub use transaction::signed::FullSignedTx;
pub use transaction::signed::SignedTransaction;
pub use transaction::FullTransaction;
pub use transaction::Transaction;
pub use block::body::BlockBody;
pub use block::body::FullBlockBody;
pub use block::header::BlockHeader;
pub use block::header::FullBlockHeader;
pub use block::Block;
pub use block::FullBlock;
pub use block::RecoveredBlock;
pub use block::SealedBlock;
pub use header::HeaderError;
pub use header::SealedHeader;
pub use header::SealedHeaderFor;
pub use size::InMemorySize;
pub use node::BlockTy;
pub use node::BodyTy;
pub use node::FullNodePrimitives;
pub use node::HeaderTy;
pub use node::NodePrimitives;
pub use node::ReceiptTy;
pub use node::TxTy;
Modules§
- account
- Minimal account
- block
- Block abstraction.
- constants
- Common constants. Ethereum protocol-related constants
- crypto
- Crypto utilities.
- header
- Common header types
- node
- Node traits
- proofs
- Helper function for calculating Merkle proofs and hashes.
- receipt
- Receipt abstraction
- serde_
bincode_ compat serde-bincode-compat
- Bincode-compatible serde implementations for common abstracted types in Reth.
- size
- Heuristic size trait
- sync
- Lock synchronization primitives
- test_
utils arbitrary
ortest-utils
- Utilities for testing.
- transaction
- Transaction abstraction
Structs§
- GotExpected
- A pair of values, one of which is expected and one of which is actual.
- GotExpected
Boxed - A pair of values, one of which is expected and one of which is actual.
- Header
- Ethereum Block header
- Log
- A log consists of an address, and some log data.
- LogData
- An Ethereum event log object.
- Receipt
With Bloom - [
Receipt
] with calculated bloom filter. - Recovered
- Signed object with recovered signer.
- Storage
Entry - Account storage entry.
- Transaction
Meta - Additional fields in the context of a block that contains this mined transaction.
- With
Encoded - Generic wrapper with encoded Bytes, such as transaction data.
Traits§
- Alloy
Block Header - Re-exported alias Trait for extracting specific Ethereum block data from a header
- Maybe
Compact reth-codec
- Helper trait that requires database encoding implementation since
reth-codec
feature is enabled. - Maybe
Serde serde
- Helper trait that requires de-/serialize implementation since
serde
feature is enabled. - Maybe
Serde Bincode Compat serde-bincode-compat
- Helper trait that requires serde bincode compatibility implementation.
Functions§
- logs_
bloom - Compute the logs bloom filter for the given logs.