mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-27 08:08:15 -05:00
Added wrapper type defaulting to prague engine caps (#9413)
This commit is contained in:
@@ -25,7 +25,7 @@ use reth_node_core::{
|
||||
use reth_node_events::{cl::ConsensusLayerHealthEvents, node};
|
||||
use reth_primitives::format_ether;
|
||||
use reth_provider::providers::BlockchainProvider;
|
||||
use reth_rpc_engine_api::EngineApi;
|
||||
use reth_rpc_engine_api::{capabilities::EngineCapabilities, EngineApi};
|
||||
use reth_rpc_types::engine::ClientVersionV1;
|
||||
use reth_tasks::TaskExecutor;
|
||||
use reth_tracing::tracing::{debug, info};
|
||||
@@ -299,6 +299,7 @@ where
|
||||
ctx.components().payload_builder().clone().into(),
|
||||
Box::new(ctx.task_executor().clone()),
|
||||
client,
|
||||
EngineCapabilities::default(),
|
||||
);
|
||||
info!(target: "reth::cli", "Engine API handler initialized");
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ use reth_rpc_builder::{
|
||||
auth::{AuthRpcModule, AuthServerConfig, AuthServerHandle},
|
||||
EthApiBuild, RpcModuleBuilder, RpcServerConfig, RpcServerHandle, TransportRpcModuleConfig,
|
||||
};
|
||||
use reth_rpc_engine_api::EngineApi;
|
||||
use reth_rpc_engine_api::{capabilities::EngineCapabilities, EngineApi};
|
||||
use reth_rpc_layer::JwtSecret;
|
||||
use reth_rpc_server_types::RpcModuleSelection;
|
||||
use reth_rpc_types::engine::{ClientCode, ClientVersionV1};
|
||||
@@ -44,6 +44,7 @@ pub async fn launch_auth(secret: JwtSecret) -> AuthServerHandle {
|
||||
spawn_test_payload_service().into(),
|
||||
Box::<TokioTaskExecutor>::default(),
|
||||
client,
|
||||
EngineCapabilities::default(),
|
||||
);
|
||||
let module = AuthRpcModule::new(engine_api);
|
||||
module.start_server(config).await.unwrap()
|
||||
|
||||
48
crates/rpc/rpc-engine-api/src/capabilities.rs
Normal file
48
crates/rpc/rpc-engine-api/src/capabilities.rs
Normal file
@@ -0,0 +1,48 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
/// The list of all supported Engine capabilities available over the engine endpoint.
|
||||
pub const CAPABILITIES: &[&str] = &[
|
||||
"engine_forkchoiceUpdatedV1",
|
||||
"engine_forkchoiceUpdatedV2",
|
||||
"engine_forkchoiceUpdatedV3",
|
||||
"engine_exchangeTransitionConfigurationV1",
|
||||
"engine_getClientVersionV1",
|
||||
"engine_getPayloadV1",
|
||||
"engine_getPayloadV2",
|
||||
"engine_getPayloadV3",
|
||||
"engine_getPayloadV4",
|
||||
"engine_newPayloadV1",
|
||||
"engine_newPayloadV2",
|
||||
"engine_newPayloadV3",
|
||||
"engine_newPayloadV4",
|
||||
"engine_getPayloadBodiesByHashV1",
|
||||
"engine_getPayloadBodiesByRangeV1",
|
||||
"engine_getPayloadBodiesByHashV2",
|
||||
"engine_getPayloadBodiesByRangeV2",
|
||||
];
|
||||
|
||||
// The list of all supported Engine capabilities available over the engine endpoint.
|
||||
///
|
||||
/// Latest spec: Prague
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct EngineCapabilities {
|
||||
inner: HashSet<String>,
|
||||
}
|
||||
|
||||
impl EngineCapabilities {
|
||||
/// Returns the list of all supported Engine capabilities for Prague spec.
|
||||
fn prague() -> Self {
|
||||
Self { inner: CAPABILITIES.iter().cloned().map(str::to_owned).collect() }
|
||||
}
|
||||
|
||||
/// Returns the list of all supported Engine capabilities.
|
||||
pub fn list(&self) -> Vec<String> {
|
||||
self.inner.iter().cloned().collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for EngineCapabilities {
|
||||
fn default() -> Self {
|
||||
Self::prague()
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
use crate::{metrics::EngineApiMetrics, EngineApiError, EngineApiResult};
|
||||
use crate::{
|
||||
capabilities::EngineCapabilities, metrics::EngineApiMetrics, EngineApiError, EngineApiResult,
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use jsonrpsee_core::RpcResult;
|
||||
use reth_beacon_consensus::BeaconConsensusEngineHandle;
|
||||
@@ -18,7 +20,7 @@ use reth_rpc_types::engine::{
|
||||
CancunPayloadFields, ClientVersionV1, ExecutionPayload, ExecutionPayloadBodiesV1,
|
||||
ExecutionPayloadBodiesV2, ExecutionPayloadInputV2, ExecutionPayloadV1, ExecutionPayloadV3,
|
||||
ExecutionPayloadV4, ForkchoiceState, ForkchoiceUpdated, PayloadId, PayloadStatus,
|
||||
TransitionConfiguration, CAPABILITIES,
|
||||
TransitionConfiguration,
|
||||
};
|
||||
use reth_rpc_types_compat::engine::payload::{
|
||||
convert_payload_input_v2_to_payload, convert_to_payload_body_v1, convert_to_payload_body_v2,
|
||||
@@ -56,6 +58,8 @@ struct EngineApiInner<Provider, EngineT: EngineTypes> {
|
||||
metrics: EngineApiMetrics,
|
||||
/// Identification of the execution client used by the consensus client
|
||||
client: ClientVersionV1,
|
||||
/// The list of all supported Engine capabilities available over the engine endpoint.
|
||||
capabilities: EngineCapabilities,
|
||||
}
|
||||
|
||||
impl<Provider, EngineT> EngineApi<Provider, EngineT>
|
||||
@@ -71,6 +75,7 @@ where
|
||||
payload_store: PayloadStore<EngineT>,
|
||||
task_spawner: Box<dyn TaskSpawner>,
|
||||
client: ClientVersionV1,
|
||||
capabilities: EngineCapabilities,
|
||||
) -> Self {
|
||||
let inner = Arc::new(EngineApiInner {
|
||||
provider,
|
||||
@@ -80,6 +85,7 @@ where
|
||||
task_spawner,
|
||||
metrics: EngineApiMetrics::default(),
|
||||
client,
|
||||
capabilities,
|
||||
});
|
||||
Self { inner }
|
||||
}
|
||||
@@ -896,7 +902,7 @@ where
|
||||
/// Handler for `engine_exchangeCapabilitiesV1`
|
||||
/// See also <https://github.com/ethereum/execution-apis/blob/6452a6b194d7db269bf1dbd087a267251d3cc7f8/src/engine/common.md#capabilities>
|
||||
async fn exchange_capabilities(&self, _capabilities: Vec<String>) -> RpcResult<Vec<String>> {
|
||||
Ok(CAPABILITIES.iter().cloned().map(str::to_owned).collect())
|
||||
Ok(self.inner.capabilities.list())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -949,6 +955,7 @@ mod tests {
|
||||
payload_store.into(),
|
||||
task_executor,
|
||||
client,
|
||||
EngineCapabilities::default(),
|
||||
);
|
||||
let handle = EngineApiTestHandle { chain_spec, provider, from_api: engine_rx };
|
||||
(handle, api)
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
/// The Engine API implementation.
|
||||
mod engine_api;
|
||||
|
||||
/// Engine API capabilities.
|
||||
pub mod capabilities;
|
||||
|
||||
/// The Engine API message type.
|
||||
mod message;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user