Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion crates/node-core/src/version.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
//! Version information for reth.

use reth_db::models::client_version::ClientVersion;

// The client code for Reth
pub const CLIENT_CODE : &str = env!("RH");
// The human readable name of the client
pub const NAME_CLIENT: &str = env!("reth");
Comment thread
guha-rahul marked this conversation as resolved.
Outdated

/// The latest version from Cargo.toml.
pub const CARGO_PKG_VERSION: &str = env!("CARGO_PKG_VERSION");

Expand All @@ -11,6 +15,39 @@ pub const VERGEN_GIT_SHA: &str = env!("VERGEN_GIT_SHA");
/// The build timestamp.
pub const VERGEN_BUILD_TIMESTAMP: &str = env!("VERGEN_BUILD_TIMESTAMP");

//The identification of the client
/// - The two letter client code
/// - The human readable name of the client
/// - The version string of the current implementation
/// - first four bytes of the latest commit hash of this build
///
/// # Example
///
/// ```text
// {
// code: "RH",
// name: "Reth",
// version: "v0.2.0-beta.5",
// commit: "defa64b2"
// }
/// ```
struct ClientVersionV1<'a> {
code: &'a str,
name: &'a str,
version: &'a str,
commit: &'a str,
}

pub const CLIENTVERSIONV1: ClientVersionV1<'_> = ClientVersionV1 {
code: env!("CLIENT_CODE"),
name: env!("NAME_CLIENT"),
Comment thread
guha-rahul marked this conversation as resolved.
Outdated
version: &const_str::concat!(
env!("CARGO_PKG_VERSION"),
env!("RETH_VERSION_SUFFIX")
),
commit: env!("VERGEN_GIT_SHA"),
};

/// The short version information for reth.
///
/// - The latest version from Cargo.toml
Expand Down
11 changes: 10 additions & 1 deletion crates/rpc/rpc-api/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use reth_primitives::{Address, BlockHash, BlockId, BlockNumberOrTag, Bytes, B256
use reth_rpc_types::{
engine::{
ExecutionPayloadBodiesV1, ExecutionPayloadInputV2, ExecutionPayloadV1, ExecutionPayloadV3,
ForkchoiceState, ForkchoiceUpdated, PayloadId, PayloadStatus, TransitionConfiguration,
ForkchoiceState, ForkchoiceUpdated, PayloadId, PayloadStatus, TransitionConfiguration,ClientVersionV1
},
state::StateOverride,
BlockOverrides, Filter, Log, RichBlock, SyncStatus, TransactionRequest,
Expand Down Expand Up @@ -154,6 +154,15 @@ pub trait EngineApi<Engine: EngineTypes> {
transition_configuration: TransitionConfiguration,
) -> RpcResult<TransitionConfiguration>;

/// This function will return the ClientVersionV1 object.
/// <https://github.com/ethereum/execution-apis/blob/main/src/engine/identification.md#engine_getclientversionv1> See also
///
/// - When connected to a single execution client, the consensus client **MUST** receive an array with a single `ClientVersionV1` object.
/// - When connected to multiple execution clients via a multiplexer, the multiplexer **MUST** concatenate the responses from each execution client into a single,
/// flat array before returning the response to the consensus client.
#[method(name = "getClientVersionV1")]
async fn get_client_version_v1(&self, client_version:ClientVersionV1) -> RpcResult<Vec<ClientVersionV1>>;

/// See also <https://github.com/ethereum/execution-apis/blob/6452a6b194d7db269bf1dbd087a267251d3cc7f8/src/engine/common.md#capabilities>
#[method(name = "exchangeCapabilities")]
async fn exchange_capabilities(&self, capabilities: Vec<String>) -> RpcResult<Vec<String>>;
Expand Down
18 changes: 15 additions & 3 deletions crates/rpc/rpc-engine-api/src/engine_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ use reth_primitives::{BlockHash, BlockHashOrNumber, BlockNumber, ChainSpec, Hard
use reth_provider::{BlockReader, EvmEnvProvider, HeaderProvider, StateProviderFactory};
use reth_rpc_api::EngineApiServer;
use reth_rpc_types::engine::{
CancunPayloadFields, ExecutionPayload, ExecutionPayloadBodiesV1, ExecutionPayloadInputV2,
ExecutionPayloadV1, ExecutionPayloadV3, ForkchoiceState, ForkchoiceUpdated, PayloadId,
PayloadStatus, TransitionConfiguration, CAPABILITIES,
CancunPayloadFields, ClientVersionV1, ExecutionPayload, ExecutionPayloadBodiesV1, ExecutionPayloadInputV2, ExecutionPayloadV1, ExecutionPayloadV3, ForkchoiceState, ForkchoiceUpdated, PayloadId, PayloadStatus, TransitionConfiguration, CAPABILITIES
};
use reth_rpc_types_compat::engine::payload::{
convert_payload_input_v2_to_payload, convert_to_payload_body_v1,
Expand Down Expand Up @@ -48,6 +46,8 @@ struct EngineApiInner<Provider, EngineT: EngineTypes> {
task_spawner: Box<dyn TaskSpawner>,
/// The latency and response type metrics for engine api calls
metrics: EngineApiMetrics,
/// Identification of the execution client used by the consensus client
client: ClientVersionV1,
}

impl<Provider, EngineT> EngineApi<Provider, EngineT>
Expand All @@ -62,6 +62,7 @@ where
beacon_consensus: BeaconConsensusEngineHandle<EngineT>,
payload_store: PayloadStore<EngineT>,
task_spawner: Box<dyn TaskSpawner>,
client: ClientVersionV1,
) -> Self {
let inner = Arc::new(EngineApiInner {
provider,
Expand All @@ -70,6 +71,7 @@ where
payload_store,
task_spawner,
metrics: EngineApiMetrics::default(),
client,
});
Self { inner }
}
Expand Down Expand Up @@ -690,6 +692,16 @@ where
self.inner.metrics.latency.exchange_transition_configuration.record(start.elapsed());
Ok(res?)
}
/// Handler for `engine_getClientVersionV1`
///
/// See also <https://github.com/ethereum/execution-apis/blob/main/src/engine/identification.md>
async fn get_client_version_v1(&self, client:ClientVersionV1) -> RpcResult<Vec<ClientVersionV1>> {
trace!(target: "rpc::engine", "Serving engine_getClientVersionV1");
let start = Instant::now();
let res = EngineApi::get_client_version_v1(self, client).await;

Ok(res?)
}

/// Handler for `engine_exchangeCapabilitiesV1`
/// See also <https://github.com/ethereum/execution-apis/blob/6452a6b194d7db269bf1dbd087a267251d3cc7f8/src/engine/common.md#capabilities>
Expand Down