reth_rpc_api/testing.rs
1//! Testing namespace for building a block in a single call.
2//!
3//! This follows the `testing_buildBlockV1` specification. **Highly sensitive:**
4//! testing-only, powerful enough to include arbitrary transactions; must stay
5//! disabled by default and never be exposed on public-facing RPC without an
6//! explicit operator flag.
7
8use alloy_primitives::{Bytes, B256};
9use alloy_rpc_types_engine::{ExecutionPayloadEnvelopeV5, PayloadAttributes};
10use jsonrpsee::proc_macros::rpc;
11
12pub use alloy_rpc_types_engine::{TestingBuildBlockRequestV1, TESTING_BUILD_BLOCK_V1};
13
14/// Capability string for `testing_commitBlockV1`.
15pub const TESTING_COMMIT_BLOCK_V1: &str = "testing_commitBlockV1";
16
17/// Testing RPC interface for building a block in a single call.
18///
19/// # Enabling
20///
21/// This namespace is disabled by default for security reasons. To enable it,
22/// add `testing` to the `--http.api` flag:
23///
24/// ```sh
25/// reth node --http --http.api eth,testing
26/// ```
27///
28/// **Warning:** Never expose this on public-facing RPC endpoints without proper
29/// authentication.
30#[cfg_attr(not(feature = "client"), rpc(server, namespace = "testing"))]
31#[cfg_attr(feature = "client", rpc(server, client, namespace = "testing"))]
32pub trait TestingApi {
33 /// Builds a block using the provided parent, payload attributes, and transactions.
34 ///
35 /// See <https://github.com/marcindsobczak/execution-apis/blob/main/src/testing/testing_buildBlockV1.md>
36 #[method(name = "buildBlockV1")]
37 async fn build_block_v1(
38 &self,
39 request: TestingBuildBlockRequestV1,
40 ) -> jsonrpsee::core::RpcResult<ExecutionPayloadEnvelopeV5>;
41
42 /// Builds a block on top of the current canonical head, inserts it, and makes it canonical.
43 ///
44 /// See <https://github.com/ethereum/execution-apis/pull/801>
45 #[method(name = "commitBlockV1")]
46 async fn commit_block_v1(
47 &self,
48 payload_attributes: PayloadAttributes,
49 transactions: Option<Vec<Bytes>>,
50 extra_data: Option<Bytes>,
51 ) -> jsonrpsee::core::RpcResult<B256>;
52}