Skip to main content

reth_primitives/
lib.rs

1//! Commonly used types in Reth.
2//!
3//! This crate contains Ethereum primitive types and helper functions.
4//!
5//! ## Feature Flags
6//!
7//! - `arbitrary`: Adds `proptest` and `arbitrary` support for primitive types.
8//! - `test-utils`: Export utilities for testing
9//! - `reth-codec`: Enables db codec support for reth types including zstd compression for certain
10//!   types.
11
12#![doc(
13    html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
14    html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
15    issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
16)]
17#![cfg_attr(not(test), warn(unused_crate_dependencies))]
18#![cfg_attr(docsrs, feature(doc_cfg))]
19#![cfg_attr(not(feature = "std"), no_std)]
20
21// These are used as optional dependencies solely for feature forwarding.
22#[cfg(feature = "alloy-eips")]
23use alloy_eips as _;
24#[cfg(feature = "alloy-genesis")]
25use alloy_genesis as _;
26#[cfg(feature = "alloy-primitives")]
27use alloy_primitives as _;
28#[cfg(feature = "alloy-rlp")]
29use alloy_rlp as _;
30#[cfg(feature = "reth-codecs")]
31use reth_codecs as _;
32
33mod block;
34mod receipt;
35pub use reth_static_file_types as static_file;
36pub mod transaction;
37#[cfg(any(test, feature = "arbitrary"))]
38pub use block::{generate_valid_header, valid_header_strategy};
39pub use block::{Block, BlockBody, SealedBlock};
40#[expect(deprecated)]
41pub use block::{BlockWithSenders, SealedBlockFor, SealedBlockWithSenders};
42
43pub use receipt::{gas_spent_by_transactions, Receipt};
44pub use reth_primitives_traits::{
45    logs_bloom, Account, BlockTy, BodyTy, Bytecode, GotExpected, GotExpectedBoxed, Header,
46    HeaderTy, Log, LogData, NodePrimitives, ReceiptTy, RecoveredBlock, SealedHeader, StorageEntry,
47    TxTy,
48};
49pub use static_file::StaticFileSegment;
50
51pub use alloy_consensus::{
52    transaction::{PooledTransaction, Recovered, TransactionMeta},
53    ReceiptWithBloom,
54};
55
56/// Recovered transaction
57#[deprecated(note = "use `Recovered` instead")]
58pub type RecoveredTx<T> = Recovered<T>;
59
60pub use transaction::{
61    util::secp256k1::{public_key_to_address, recover_signer_unchecked, sign_message},
62    InvalidTransactionError, Transaction, TransactionSigned, TxType,
63};
64#[expect(deprecated)]
65pub use transaction::{PooledTransactionsElementEcRecovered, TransactionSignedEcRecovered};
66
67// Re-exports
68pub use reth_ethereum_forks::*;
69
70#[cfg(feature = "c-kzg")]
71pub use c_kzg as kzg;
72
73/// Bincode-compatible serde implementations for commonly used types in Reth.
74///
75/// `bincode` crate doesn't work with optionally serializable serde fields, but some of the
76/// Reth types require optional serialization for RPC compatibility. This module makes so that
77/// all fields are serialized.
78///
79/// Read more: <https://github.com/bincode-org/bincode/issues/326>
80#[cfg(feature = "serde-bincode-compat")]
81pub mod serde_bincode_compat {
82    pub use reth_primitives_traits::serde_bincode_compat::*;
83}
84
85// Re-export of `EthPrimitives`
86pub use reth_ethereum_primitives::EthPrimitives;