Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
28 changes: 19 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -734,9 +734,9 @@ vergen-git2 = "1.0.5"
# op-alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/op-alloy", rev = "ad607c1" }
#
# revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev = "1207e33" }

jsonrpsee = { git = "https://github.com/paradigmxyz/jsonrpsee", branch = "matt/make-rpc-service-pub" }
jsonrpsee-core = { git = "https://github.com/paradigmxyz/jsonrpsee", branch = "matt/make-rpc-service-pub" }
jsonrpsee-server = { git = "https://github.com/paradigmxyz/jsonrpsee", branch = "matt/make-rpc-service-pub" }
jsonrpsee-http-client = { git = "https://github.com/paradigmxyz/jsonrpsee", branch = "matt/make-rpc-service-pub" }
jsonrpsee-types = { git = "https://github.com/paradigmxyz/jsonrpsee", branch = "matt/make-rpc-service-pub" }
#
# jsonrpsee = { git = "https://github.com/paradigmxyz/jsonrpsee", branch = "matt/make-rpc-service-pub" }
# jsonrpsee-core = { git = "https://github.com/paradigmxyz/jsonrpsee", branch = "matt/make-rpc-service-pub" }
# jsonrpsee-server = { git = "https://github.com/paradigmxyz/jsonrpsee", branch = "matt/make-rpc-service-pub" }
# jsonrpsee-http-client = { git = "https://github.com/paradigmxyz/jsonrpsee", branch = "matt/make-rpc-service-pub" }
# jsonrpsee-types = { git = "https://github.com/paradigmxyz/jsonrpsee", branch = "matt/make-rpc-service-pub" }
7 changes: 0 additions & 7 deletions book/sources/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,3 @@ reth-exex = { path = "../../crates/exex/exex" }
reth-node-ethereum = { path = "../../crates/ethereum/node" }
reth-tracing = { path = "../../crates/tracing" }
reth-node-api = { path = "../../crates/node/api" }

[patch.crates-io]
jsonrpsee = { git = "https://github.com/paradigmxyz/jsonrpsee", branch = "matt/make-rpc-service-pub" }
jsonrpsee-core = { git = "https://github.com/paradigmxyz/jsonrpsee", branch = "matt/make-rpc-service-pub" }
jsonrpsee-server = { git = "https://github.com/paradigmxyz/jsonrpsee", branch = "matt/make-rpc-service-pub" }
jsonrpsee-http-client = { git = "https://github.com/paradigmxyz/jsonrpsee", branch = "matt/make-rpc-service-pub" }
jsonrpsee-types = { git = "https://github.com/paradigmxyz/jsonrpsee", branch = "matt/make-rpc-service-pub" }
1 change: 1 addition & 0 deletions crates/e2e-test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ reth-db = { workspace = true, features = ["test-utils"] }
reth-network-api.workspace = true
reth-rpc-layer.workspace = true
reth-rpc-server-types.workspace = true
reth-rpc-builder.workspace = true
reth-rpc-eth-api.workspace = true
reth-rpc-api = { workspace = true, features = ["client"] }
reth-payload-builder = { workspace = true, features = ["test-utils"] }
Expand Down
13 changes: 4 additions & 9 deletions crates/e2e-test-utils/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ use alloy_rpc_types_engine::ForkchoiceState;
use alloy_rpc_types_eth::BlockNumberOrTag;
use eyre::Ok;
use futures_util::Future;
use jsonrpsee::{
core::middleware::layer::RpcLogger,
http_client::{transport::HttpBackend, HttpClient, RpcService},
};
use jsonrpsee::http_client::HttpClient;
use reth_chainspec::EthereumHardforks;
use reth_network_api::test_utils::PeersHandleProvider;
use reth_node_api::{
Expand All @@ -23,8 +20,8 @@ use reth_provider::{
BlockReader, BlockReaderIdExt, CanonStateNotificationStream, CanonStateSubscriptions,
StageCheckpointReader,
};
use reth_rpc_builder::auth::AuthServerHandle;
use reth_rpc_eth_api::helpers::{EthApiSpec, EthTransactions, TraceExt};
use reth_rpc_layer::AuthClientService;
use reth_stages_types::StageId;
use std::pin::Pin;
use tokio_stream::StreamExt;
Expand Down Expand Up @@ -305,9 +302,7 @@ where
}

/// Returns an Engine API client.
pub fn engine_api_client(
&self,
) -> HttpClient<RpcLogger<RpcService<AuthClientService<HttpBackend>>>> {
self.inner.auth_server_handle().http_client()
pub fn auth_server_handle(&self) -> AuthServerHandle {
self.inner.auth_server_handle().clone()
}
}
33 changes: 18 additions & 15 deletions crates/e2e-test-utils/src/testsuite/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ where

let node_client = &env.node_clients[self.node_idx];
let rpc_client = &node_client.rpc;
let engine_client = &node_client.engine;
let engine_client = node_client.engine.http_client();

// get the latest block to use as parent
let latest_block =
Expand All @@ -132,7 +132,7 @@ where
};

let fcu_result = EngineApiClient::<Engine>::fork_choice_updated_v2(
engine_client,
&engine_client,
fork_choice_state,
Some(self.payload_attributes.clone()),
)
Expand All @@ -148,7 +148,7 @@ where

// get the payload that was built
let _engine_payload =
EngineApiClient::<Engine>::get_payload_v2(engine_client, payload_id)
EngineApiClient::<Engine>::get_payload_v2(&engine_client, payload_id)
.await?;
Ok(())
} else {
Expand Down Expand Up @@ -284,7 +284,7 @@ where
.ok_or_else(|| eyre::eyre!("No payload attributes found for latest block"))?;

let fcu_result = EngineApiClient::<Engine>::fork_choice_updated_v3(
&env.node_clients[0].engine,
&env.node_clients[0].engine.http_client(),
fork_choice_state,
Some(payload_attributes.clone()),
)
Expand All @@ -301,10 +301,12 @@ where

sleep(Duration::from_secs(1)).await;

let built_payload: PayloadAttributes =
EngineApiClient::<Engine>::get_payload_v3(&env.node_clients[0].engine, payload_id)
.await?
.into();
let built_payload: PayloadAttributes = EngineApiClient::<Engine>::get_payload_v3(
&env.node_clients[0].engine.http_client(),
payload_id,
)
.await?
.into();
env.payload_id_history.insert(latest_block.number + 1, payload_id);
env.latest_payload_built = Some(built_payload);

Expand Down Expand Up @@ -350,10 +352,8 @@ where
);

for (idx, client) in env.node_clients.iter().enumerate() {
let engine_client = &client.engine;

match EngineApiClient::<Engine>::fork_choice_updated_v3(
engine_client,
&client.engine.http_client(),
fork_choice_state,
payload.clone(),
)
Expand Down Expand Up @@ -422,8 +422,11 @@ where
.as_ref()
.ok_or_else(|| eyre::eyre!("No next built payload found"))?;

let built_payload =
EngineApiClient::<Engine>::get_payload_v3(&client.engine, payload_id).await?;
let built_payload = EngineApiClient::<Engine>::get_payload_v3(
&client.engine.http_client(),
payload_id,
)
.await?;

let execution_payload_envelope: ExecutionPayloadEnvelopeV3 = built_payload;
let new_payload_block_hash = execution_payload_envelope
Expand Down Expand Up @@ -577,7 +580,7 @@ where
let mut successful_broadcast: bool = false;

for client in &env.node_clients {
let engine = &client.engine;
let engine = client.engine.http_client();
let rpc_client = &client.rpc;

// Get latest block from the client
Expand Down Expand Up @@ -635,7 +638,7 @@ where
// The latest block should contain the latest_payload_built
let execution_payload = ExecutionPayloadV3::from_block_slow(&latest_block);
let result = EngineApiClient::<Engine>::new_payload_v3(
engine,
&engine,
execution_payload,
vec![],
parent_beacon_block_root,
Expand Down
16 changes: 11 additions & 5 deletions crates/e2e-test-utils/src/testsuite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ use crate::{
};
use alloy_primitives::B256;
use eyre::Result;
use jsonrpsee::http_client::{transport::HttpBackend, HttpClient, RpcService};
use jsonrpsee::http_client::HttpClient;
use reth_engine_local::LocalPayloadAttributesBuilder;
use reth_node_api::{NodeTypes, PayloadTypes};
use reth_payload_builder::PayloadId;
use reth_rpc_layer::AuthClientService;
use setup::Setup;
use std::{collections::HashMap, marker::PhantomData};
pub mod actions;
pub mod setup;
use crate::testsuite::setup::Setup;
use alloy_rpc_types_engine::{ForkchoiceState, PayloadAttributes};
use jsonrpsee::core::middleware::layer::RpcLogger;
use reth_rpc_builder::auth::AuthServerHandle;

#[cfg(test)]
mod examples;
Expand All @@ -27,7 +26,14 @@ pub struct NodeClient {
/// Regular JSON-RPC client
pub rpc: HttpClient,
/// Engine API client
pub engine: HttpClient<RpcLogger<RpcService<AuthClientService<HttpBackend>>>>,
pub engine: AuthServerHandle,
}

impl NodeClient {
/// Instantiates a new [`NodeClient`] with the given handles
pub const fn new(rpc: HttpClient, engine: AuthServerHandle) -> Self {
Self { rpc, engine }
}
}

/// Represents the latest block information.
Expand Down
4 changes: 2 additions & 2 deletions crates/e2e-test-utils/src/testsuite/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ impl<I> Setup<I> {
let rpc = node
.rpc_client()
.ok_or_else(|| eyre!("Failed to create HTTP RPC client for node"))?;
let engine = node.engine_api_client();
let auth = node.auth_server_handle();

node_clients.push(crate::testsuite::NodeClient { rpc, engine });
node_clients.push(crate::testsuite::NodeClient::new(rpc, auth));
}

// spawn a separate task just to handle the shutdown
Expand Down
11 changes: 6 additions & 5 deletions crates/rpc/rpc-builder/src/auth.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use crate::error::{RpcError, ServerKind};
use http::header::AUTHORIZATION;
use jsonrpsee::{
core::{middleware::layer::RpcLogger, RegisterMethodError},
http_client::{transport::HttpBackend, HeaderMap, HttpClient, RpcService},
core::{client::SubscriptionClientT, RegisterMethodError},
http_client::HeaderMap,
server::{AlreadyStoppedError, RpcModule},
Methods,
};
use reth_rpc_api::servers::*;
use reth_rpc_eth_types::EthSubscriptionIdProvider;
use reth_rpc_layer::{
secret_to_bearer_header, AuthClientLayer, AuthClientService, AuthLayer, JwtAuthValidator,
JwtSecret,
secret_to_bearer_header, AuthClientLayer, AuthLayer, JwtAuthValidator, JwtSecret,
};
use reth_rpc_server_types::constants;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
Expand Down Expand Up @@ -301,7 +300,9 @@ impl AuthServerHandle {
}

/// Returns a http client connected to the server.
pub fn http_client(&self) -> HttpClient<RpcLogger<RpcService<AuthClientService<HttpBackend>>>> {
///
/// This client uses the JWT token to authenticate requests.
pub fn http_client(&self) -> impl SubscriptionClientT + Clone + Send + Sync + Unpin + 'static {
// Create a middleware that adds a new JWT token to every request.
let secret_layer = AuthClientLayer::new(self.secret);
let middleware = tower::ServiceBuilder::default().layer(secret_layer);
Expand Down
Loading