reth_rpc_eth_api/helpers/mod.rs
1//! Behaviour needed to serve `eth_` RPC requests, divided into general database reads and
2//! specific database access.
3//!
4//! Traits with `Load` prefix, read atomic data from database, e.g. a block or transaction. Any
5//! database read done in more than one default `Eth` trait implementation, is defined in a `Load`
6//! trait.
7//!
8//! Traits with `Eth` prefix, compose specific data needed to serve RPC requests in the `eth`
9//! namespace. They use `Load` traits as building blocks. [`EthTransactions`] also writes data
10//! (submits transactions). Based on the `eth_` request method semantics, request methods are
11//! divided into: [`EthTransactions`], [`EthBlocks`], [`EthFees`], [`EthState`] and [`EthCall`].
12//! Default implementation of the `Eth` traits, is done w.r.t. L1.
13//!
14//! [`EthApiServer`](crate::EthApiServer), is implemented for any type that implements
15//! all the `Eth` traits, e.g. `reth_rpc::EthApi`.
16
17pub mod block;
18pub mod blocking_task;
19pub mod call;
20pub mod config;
21pub mod estimate;
22pub mod fee;
23pub mod pending_block;
24pub mod receipt;
25pub mod signer;
26pub mod spec;
27pub mod state;
28pub mod trace;
29pub mod transaction;
30
31pub use block::{EthBlocks, LoadBlock};
32pub use blocking_task::SpawnBlocking;
33pub use call::{Call, EthCall};
34pub use fee::{EthFees, LoadFee};
35pub use pending_block::LoadPendingBlock;
36pub use receipt::LoadReceipt;
37pub use signer::{AddDevSigners, EthSigner};
38pub use spec::EthApiSpec;
39pub use state::{EthState, LoadState};
40pub use trace::Trace;
41pub use transaction::{EthTransactions, LoadTransaction};
42
43use crate::FullEthApiTypes;
44
45/// Extension trait that bundles traits needed for tracing transactions.
46pub trait TraceExt: LoadTransaction + LoadBlock + SpawnBlocking + Trace + Call {}
47
48impl<T> TraceExt for T where T: LoadTransaction + LoadBlock + Trace + Call {}
49
50/// Helper trait to unify all `eth` rpc server building block traits, for simplicity.
51///
52/// This trait is automatically implemented for any type that implements all the `Eth` traits.
53pub trait FullEthApi:
54 FullEthApiTypes
55 + EthApiSpec
56 + EthTransactions
57 + EthBlocks
58 + EthState
59 + EthCall
60 + EthFees
61 + Trace
62 + LoadReceipt
63{
64}
65
66impl<T> FullEthApi for T where
67 T: FullEthApiTypes
68 + EthApiSpec
69 + EthTransactions
70 + EthBlocks
71 + EthState
72 + EthCall
73 + EthFees
74 + Trace
75 + LoadReceipt
76{
77}