mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(rpc): Start to implement flashbots_validateBuilderSubmissionV3 (#12061)
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -8598,6 +8598,7 @@ dependencies = [
|
|||||||
"alloy-rlp",
|
"alloy-rlp",
|
||||||
"alloy-rpc-types",
|
"alloy-rpc-types",
|
||||||
"alloy-rpc-types-admin",
|
"alloy-rpc-types-admin",
|
||||||
|
"alloy-rpc-types-beacon",
|
||||||
"alloy-rpc-types-debug",
|
"alloy-rpc-types-debug",
|
||||||
"alloy-rpc-types-eth",
|
"alloy-rpc-types-eth",
|
||||||
"alloy-rpc-types-mev",
|
"alloy-rpc-types-mev",
|
||||||
|
|||||||
4
book/cli/reth/node.md
vendored
4
book/cli/reth/node.md
vendored
@ -245,7 +245,7 @@ RPC:
|
|||||||
--http.api <HTTP_API>
|
--http.api <HTTP_API>
|
||||||
Rpc Modules to be configured for the HTTP server
|
Rpc Modules to be configured for the HTTP server
|
||||||
|
|
||||||
[possible values: admin, debug, eth, net, trace, txpool, web3, rpc, reth, ots]
|
[possible values: admin, debug, eth, net, trace, txpool, web3, rpc, reth, ots, flashbots]
|
||||||
|
|
||||||
--http.corsdomain <HTTP_CORSDOMAIN>
|
--http.corsdomain <HTTP_CORSDOMAIN>
|
||||||
Http Corsdomain to allow request from
|
Http Corsdomain to allow request from
|
||||||
@ -269,7 +269,7 @@ RPC:
|
|||||||
--ws.api <WS_API>
|
--ws.api <WS_API>
|
||||||
Rpc Modules to be configured for the WS server
|
Rpc Modules to be configured for the WS server
|
||||||
|
|
||||||
[possible values: admin, debug, eth, net, trace, txpool, web3, rpc, reth, ots]
|
[possible values: admin, debug, eth, net, trace, txpool, web3, rpc, reth, ots, flashbots]
|
||||||
|
|
||||||
--ipcdisable
|
--ipcdisable
|
||||||
Disable the IPC-RPC server
|
Disable the IPC-RPC server
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
//! API for block submission validation.
|
//! API for block submission validation.
|
||||||
|
|
||||||
use alloy_rpc_types_beacon::relay::{
|
use alloy_rpc_types_beacon::relay::{
|
||||||
BuilderBlockValidationRequest, BuilderBlockValidationRequestV2,
|
BuilderBlockValidationRequest, BuilderBlockValidationRequestV2, BuilderBlockValidationRequestV3,
|
||||||
};
|
};
|
||||||
use jsonrpsee::proc_macros::rpc;
|
use jsonrpsee::proc_macros::rpc;
|
||||||
|
|
||||||
@ -22,4 +22,11 @@ pub trait BlockSubmissionValidationApi {
|
|||||||
&self,
|
&self,
|
||||||
request: BuilderBlockValidationRequestV2,
|
request: BuilderBlockValidationRequestV2,
|
||||||
) -> jsonrpsee::core::RpcResult<()>;
|
) -> jsonrpsee::core::RpcResult<()>;
|
||||||
|
|
||||||
|
/// A Request to validate a block submission.
|
||||||
|
#[method(name = "validateBuilderSubmissionV3")]
|
||||||
|
async fn validate_builder_submission_v3(
|
||||||
|
&self,
|
||||||
|
request: BuilderBlockValidationRequestV3,
|
||||||
|
) -> jsonrpsee::core::RpcResult<()>;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -180,7 +180,7 @@ use reth_provider::{
|
|||||||
};
|
};
|
||||||
use reth_rpc::{
|
use reth_rpc::{
|
||||||
AdminApi, DebugApi, EngineEthApi, EthBundle, NetApi, OtterscanApi, RPCApi, RethApi, TraceApi,
|
AdminApi, DebugApi, EngineEthApi, EthBundle, NetApi, OtterscanApi, RPCApi, RethApi, TraceApi,
|
||||||
TxPoolApi, Web3Api,
|
TxPoolApi, ValidationApi, Web3Api,
|
||||||
};
|
};
|
||||||
use reth_rpc_api::servers::*;
|
use reth_rpc_api::servers::*;
|
||||||
use reth_rpc_eth_api::{
|
use reth_rpc_eth_api::{
|
||||||
@ -1067,6 +1067,11 @@ where
|
|||||||
pub fn reth_api(&self) -> RethApi<Provider> {
|
pub fn reth_api(&self) -> RethApi<Provider> {
|
||||||
RethApi::new(self.provider.clone(), Box::new(self.executor.clone()))
|
RethApi::new(self.provider.clone(), Box::new(self.executor.clone()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Instantiates `ValidationApi`
|
||||||
|
pub fn validation_api(&self) -> ValidationApi<Provider> {
|
||||||
|
ValidationApi::new(self.provider.clone())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Provider, Pool, Network, Tasks, Events, EthApi, BlockExecutor>
|
impl<Provider, Pool, Network, Tasks, Events, EthApi, BlockExecutor>
|
||||||
@ -1223,6 +1228,9 @@ where
|
|||||||
.into_rpc()
|
.into_rpc()
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
RethRpcModule::Flashbots => {
|
||||||
|
ValidationApi::new(self.provider.clone()).into_rpc().into()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.clone()
|
.clone()
|
||||||
})
|
})
|
||||||
|
|||||||
@ -258,6 +258,8 @@ pub enum RethRpcModule {
|
|||||||
Reth,
|
Reth,
|
||||||
/// `ots_` module
|
/// `ots_` module
|
||||||
Ots,
|
Ots,
|
||||||
|
/// `flashbots_` module
|
||||||
|
Flashbots,
|
||||||
}
|
}
|
||||||
|
|
||||||
// === impl RethRpcModule ===
|
// === impl RethRpcModule ===
|
||||||
@ -306,6 +308,7 @@ impl FromStr for RethRpcModule {
|
|||||||
"rpc" => Self::Rpc,
|
"rpc" => Self::Rpc,
|
||||||
"reth" => Self::Reth,
|
"reth" => Self::Reth,
|
||||||
"ots" => Self::Ots,
|
"ots" => Self::Ots,
|
||||||
|
"flashbots" => Self::Flashbots,
|
||||||
_ => return Err(ParseError::VariantNotFound),
|
_ => return Err(ParseError::VariantNotFound),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,6 +45,7 @@ alloy-network.workspace = true
|
|||||||
alloy-primitives.workspace = true
|
alloy-primitives.workspace = true
|
||||||
alloy-rlp.workspace = true
|
alloy-rlp.workspace = true
|
||||||
alloy-rpc-types.workspace = true
|
alloy-rpc-types.workspace = true
|
||||||
|
alloy-rpc-types-beacon.workspace = true
|
||||||
alloy-rpc-types-eth = { workspace = true, features = ["jsonrpsee-types"] }
|
alloy-rpc-types-eth = { workspace = true, features = ["jsonrpsee-types"] }
|
||||||
alloy-rpc-types-debug.workspace = true
|
alloy-rpc-types-debug.workspace = true
|
||||||
alloy-rpc-types-trace.workspace = true
|
alloy-rpc-types-trace.workspace = true
|
||||||
|
|||||||
@ -42,7 +42,9 @@ mod reth;
|
|||||||
mod rpc;
|
mod rpc;
|
||||||
mod trace;
|
mod trace;
|
||||||
mod txpool;
|
mod txpool;
|
||||||
|
mod validation;
|
||||||
mod web3;
|
mod web3;
|
||||||
|
|
||||||
pub use admin::AdminApi;
|
pub use admin::AdminApi;
|
||||||
pub use debug::DebugApi;
|
pub use debug::DebugApi;
|
||||||
pub use engine::{EngineApi, EngineEthApi};
|
pub use engine::{EngineApi, EngineEthApi};
|
||||||
@ -53,4 +55,5 @@ pub use reth::RethApi;
|
|||||||
pub use rpc::RPCApi;
|
pub use rpc::RPCApi;
|
||||||
pub use trace::TraceApi;
|
pub use trace::TraceApi;
|
||||||
pub use txpool::TxPoolApi;
|
pub use txpool::TxPoolApi;
|
||||||
|
pub use validation::ValidationApi;
|
||||||
pub use web3::Web3Api;
|
pub use web3::Web3Api;
|
||||||
|
|||||||
94
crates/rpc/rpc/src/validation.rs
Normal file
94
crates/rpc/rpc/src/validation.rs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
use alloy_rpc_types_beacon::relay::{
|
||||||
|
BuilderBlockValidationRequest, BuilderBlockValidationRequestV2, BuilderBlockValidationRequestV3,
|
||||||
|
};
|
||||||
|
use async_trait::async_trait;
|
||||||
|
use jsonrpsee::core::RpcResult;
|
||||||
|
use reth_chainspec::ChainSpecProvider;
|
||||||
|
use reth_provider::{
|
||||||
|
AccountReader, BlockReaderIdExt, HeaderProvider, StateProviderFactory, WithdrawalsProvider,
|
||||||
|
};
|
||||||
|
use reth_rpc_api::BlockSubmissionValidationApiServer;
|
||||||
|
use reth_rpc_server_types::result::internal_rpc_err;
|
||||||
|
use std::sync::Arc;
|
||||||
|
use tracing::warn;
|
||||||
|
|
||||||
|
/// The type that implements the `validation` rpc namespace trait
|
||||||
|
pub struct ValidationApi<Provider> {
|
||||||
|
inner: Arc<ValidationApiInner<Provider>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<Provider> ValidationApi<Provider>
|
||||||
|
where
|
||||||
|
Provider: BlockReaderIdExt
|
||||||
|
+ ChainSpecProvider
|
||||||
|
+ StateProviderFactory
|
||||||
|
+ HeaderProvider
|
||||||
|
+ AccountReader
|
||||||
|
+ WithdrawalsProvider
|
||||||
|
+ Clone
|
||||||
|
+ 'static,
|
||||||
|
{
|
||||||
|
/// The provider that can interact with the chain.
|
||||||
|
pub fn provider(&self) -> Provider {
|
||||||
|
self.inner.provider.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a new instance of the [`ValidationApi`]
|
||||||
|
pub fn new(provider: Provider) -> Self {
|
||||||
|
let inner = Arc::new(ValidationApiInner { provider });
|
||||||
|
Self { inner }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl<Provider> BlockSubmissionValidationApiServer for ValidationApi<Provider>
|
||||||
|
where
|
||||||
|
Provider: BlockReaderIdExt
|
||||||
|
+ ChainSpecProvider
|
||||||
|
+ StateProviderFactory
|
||||||
|
+ HeaderProvider
|
||||||
|
+ AccountReader
|
||||||
|
+ WithdrawalsProvider
|
||||||
|
+ Clone
|
||||||
|
+ 'static,
|
||||||
|
{
|
||||||
|
async fn validate_builder_submission_v1(
|
||||||
|
&self,
|
||||||
|
_request: BuilderBlockValidationRequest,
|
||||||
|
) -> RpcResult<()> {
|
||||||
|
Err(internal_rpc_err("unimplemented"))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn validate_builder_submission_v2(
|
||||||
|
&self,
|
||||||
|
_request: BuilderBlockValidationRequestV2,
|
||||||
|
) -> RpcResult<()> {
|
||||||
|
Err(internal_rpc_err("unimplemented"))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Validates a block submitted to the relay
|
||||||
|
async fn validate_builder_submission_v3(
|
||||||
|
&self,
|
||||||
|
request: BuilderBlockValidationRequestV3,
|
||||||
|
) -> RpcResult<()> {
|
||||||
|
warn!("flashbots_validateBuilderSubmissionV3: blindly accepting request without validation {:?}", request);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<Provider> std::fmt::Debug for ValidationApi<Provider> {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.debug_struct("ValidationApi").finish_non_exhaustive()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<Provider> Clone for ValidationApi<Provider> {
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
Self { inner: Arc::clone(&self.inner) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ValidationApiInner<Provider> {
|
||||||
|
/// The provider that can interact with the chain.
|
||||||
|
provider: Provider,
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user