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::{
10 ExecutionPayloadEnvelopeV5, PayloadAttributes as EthPayloadAttributes,
11};
12use jsonrpsee::proc_macros::rpc;
13use serde::{Deserialize, Serialize};
14
15/// Capability string for `testing_buildBlockV1`.
16pub const TESTING_BUILD_BLOCK_V1: &str = "testing_buildBlockV1";
17
18/// Request payload for `testing_buildBlockV1`.
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(rename_all = "camelCase")]
21pub struct TestingBuildBlockRequestV1 {
22 /// Parent block hash of the block to build.
23 pub parent_block_hash: B256,
24 /// Payload attributes (Cancun version).
25 pub payload_attributes: EthPayloadAttributes,
26 /// Raw signed transactions to force-include in order.
27 pub transactions: Vec<Bytes>,
28 /// Optional extra data for the block header.
29 #[serde(default, skip_serializing_if = "Option::is_none")]
30 pub extra_data: Option<Bytes>,
31}
32
33/// Testing RPC interface for building a block in a single call.
34#[cfg_attr(not(feature = "client"), rpc(server, namespace = "testing"))]
35#[cfg_attr(feature = "client", rpc(server, client, namespace = "testing"))]
36pub trait TestingApi {
37 /// Builds a block using the provided parent, payload attributes, and transactions.
38 ///
39 /// See <https://github.com/marcindsobczak/execution-apis/blob/main/src/testing/testing_buildBlockV1.md>
40 #[method(name = "buildBlockV1")]
41 async fn build_block_v1(
42 &self,
43 request: TestingBuildBlockRequestV1,
44 ) -> jsonrpsee::core::RpcResult<ExecutionPayloadEnvelopeV5>;
45}