Skip to content

Commit

Permalink
fix(middleware): change mod visibility to pass build. (#815)
Browse files Browse the repository at this point in the history
  • Loading branch information
andysim3d authored and dancoombs committed Sep 30, 2024
1 parent 83ba4ef commit 67c384e
Show file tree
Hide file tree
Showing 29 changed files with 523 additions and 490 deletions.
5 changes: 4 additions & 1 deletion Cargo.lock

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

10 changes: 7 additions & 3 deletions crates/pool/src/server/remote/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use alloy_primitives::{Address, B256};
use async_trait::async_trait;
use futures_util::StreamExt;
use rundler_task::{
grpc::{grpc_metrics::HttpMethodExtractor, protos::from_bytes},
metrics::{MetricsLayer, RequestMethodNameInfo},
grpc::{grpc_metrics::GrpcMethodExtractor, protos::from_bytes},
metrics::MetricsLayer,
};
use rundler_types::{
chain::ChainSpec,
Expand Down Expand Up @@ -81,7 +81,11 @@ pub(crate) async fn spawn_remote_mempool_server(
.set_serving::<OpPoolServer<OpPoolImpl>>()
.await;

let metrics_layer = MetricsLayer::<HttpMethodExtractor, http::Request>::new("op_pool_service".to_string(), "http-grpc".to_string());
let metrics_layer = MetricsLayer::<GrpcMethodExtractor, _>::new(
"op_pool_service".to_string(),
"http-grpc".to_string(),
);

let handle = tokio::spawn(async move {
Server::builder()
.layer(metrics_layer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@
// You should have received a copy of the GNU General Public License along with Rundler.
// If not, see https://www.gnu.org/licenses/.

use alloy_json_rpc::RequestPacket;
/// Method extractor
use rundler_types::task::traits::RequestExtractor;
use alloy_json_rpc::RequestPacket;

/// Method extractor for Alloy providers
#[derive(Clone, Copy)]
struct AlloyMethodExtractor;
pub struct AlloyMethodExtractor;

impl RequestExtractor<RequestPacket> for RPCMethodExtractor {
impl RequestExtractor<RequestPacket> for AlloyMethodExtractor {
fn get_method_name(req: &RequestPacket) -> String {
match req {
RequestPacket::Single(request) => {
request.method().to_string()
}
RequestPacket::Single(request) => request.method().to_string(),
_ => {
// can't extract method name for batch.
"batch".to_string()
Expand Down
1 change: 1 addition & 0 deletions crates/provider/src/alloy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@

pub(crate) mod entry_point;
pub(crate) mod evm;
pub(crate) mod metrics;
1 change: 1 addition & 0 deletions crates/provider/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub use alloy::{
},
},
evm::AlloyEvmProvider,
metrics::AlloyMethodExtractor,
};

mod traits;
Expand Down
6 changes: 5 additions & 1 deletion crates/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ repository.workspace = true
publish = false

[dependencies]
rundler-contracts = { path = "../contracts" }
rundler-provider = { path = "../provider" }
rundler-sim = { path = "../sim" }
rundler-task = { path = "../task" }
rundler-types = { path = "../types" }
rundler-utils = { path = "../utils" }

alloy-primitives.workspace = true
alloy-sol-types.workspace = true

anyhow.workspace = true
async-trait.workspace = true
ethers.workspace = true
jsonrpsee = { workspace = true , features = ["client", "macros", "server"] }
metrics.workspace = true
thiserror.workspace = true
Expand All @@ -32,6 +35,7 @@ futures-util.workspace = true

[dev-dependencies]
mockall.workspace = true
alloy-consensus.workspace = true
rundler-provider = { path = "../provider", features = ["test-utils"]}
rundler-sim = { path = "../sim", features = ["test-utils"] }
rundler-types= { path = "../types", features = ["test-utils"]}
4 changes: 2 additions & 2 deletions crates/rpc/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
// You should have received a copy of the GNU General Public License along with Rundler.
// If not, see https://www.gnu.org/licenses/.

use alloy_primitives::Address;
use anyhow::Context;
use async_trait::async_trait;
use ethers::types::Address;
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
use rundler_types::pool::Pool;

Expand Down Expand Up @@ -51,7 +51,7 @@ impl<P> AdminApi<P> {
#[async_trait]
impl<P> AdminApiServer for AdminApi<P>
where
P: Pool,
P: Pool + 'static,
{
async fn clear_state(&self, clear_params: RpcAdminClearState) -> RpcResult<String> {
utils::safe_call_rpc_handler(
Expand Down
24 changes: 14 additions & 10 deletions crates/rpc/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
// You should have received a copy of the GNU General Public License along with Rundler.
// If not, see https://www.gnu.org/licenses/.

use alloy_primitives::{Address, B256, U64};
use anyhow::Context;
use async_trait::async_trait;
use ethers::types::{Address, H256};
use futures_util::StreamExt;
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
use rundler_types::{
Expand Down Expand Up @@ -48,7 +48,7 @@ pub trait DebugApi {
///
/// Note that the bundling mode must be set to `Manual` else this will fail.
#[method(name = "bundler_sendBundleNow")]
async fn bundler_send_bundle_now(&self) -> RpcResult<H256>;
async fn bundler_send_bundle_now(&self) -> RpcResult<B256>;

/// Sets the bundling mode.
#[method(name = "bundler_setBundlingMode")]
Expand Down Expand Up @@ -103,8 +103,8 @@ impl<P, B> DebugApi<P, B> {
#[async_trait]
impl<P, B> DebugApiServer for DebugApi<P, B>
where
P: Pool,
B: Builder,
P: Pool + 'static,
B: Builder + 'static,
{
async fn bundler_clear_state(&self) -> RpcResult<String> {
utils::safe_call_rpc_handler("bundler_clearState", DebugApi::bundler_clear_state(self))
Expand All @@ -127,7 +127,7 @@ where
.await
}

async fn bundler_send_bundle_now(&self) -> RpcResult<H256> {
async fn bundler_send_bundle_now(&self) -> RpcResult<B256> {
utils::safe_call_rpc_handler(
"bundler_sendBundleNow",
DebugApi::bundler_send_bundle_now(self),
Expand Down Expand Up @@ -235,7 +235,7 @@ where
.collect::<Vec<RpcUserOperation>>())
}

async fn bundler_send_bundle_now(&self) -> InternalRpcResult<H256> {
async fn bundler_send_bundle_now(&self) -> InternalRpcResult<B256> {
tracing::debug!("Sending bundle");

let mut new_heads = self
Expand Down Expand Up @@ -318,8 +318,8 @@ where

let reputation = RpcReputationOutput {
address: r.address,
ops_seen: r.ops_seen.into(),
ops_included: r.ops_included.into(),
ops_seen: U64::from(r.ops_seen),
ops_included: U64::from(r.ops_included),
status,
};

Expand All @@ -344,8 +344,12 @@ where
is_staked: result.is_staked,
stake_info: RpcStakeInfo {
addr: address,
stake: result.stake_info.stake.as_u128(),
unstake_delay_sec: result.stake_info.unstake_delay_sec.as_u32(),
stake: result
.stake_info
.stake
.try_into()
.context("stake should fit in u128")?,
unstake_delay_sec: result.stake_info.unstake_delay_sec,
},
})
}
Expand Down
Loading

0 comments on commit 67c384e

Please sign in to comment.