-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: pool server abstraction and local server #268
Conversation
14430ff
to
c70a7da
Compare
1ce0f80
to
4a7a0d9
Compare
c70a7da
to
1d6bc1e
Compare
8f18040
to
92f591b
Compare
@@ -39,7 +46,7 @@ pub trait Mempool: Send + Sync + 'static { | |||
) -> MempoolResult<H256>; | |||
|
|||
/// Removes a set of operations from the pool. | |||
fn remove_operations<'a>(&self, hashes: impl IntoIterator<Item = &'a H256>); | |||
fn remove_operations(&self, hashes: &[H256]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
automock doesn't handle impl Trait
😢
4a7a0d9
to
431f84d
Compare
92f591b
to
70e375d
Compare
70e375d
to
4d08016
Compare
@@ -171,6 +178,102 @@ impl PoolOperation { | |||
} | |||
} | |||
|
|||
pub struct MempoolGroup<M> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New class
#[derive(Debug)] | ||
pub struct Settings { | ||
pub replacement_fee_percent_increase: u64, | ||
pub max_fee_increases: u64, | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct BundleSender<P, E, T> | ||
pub struct BundleSenderImpl<P, E, T, C> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sender is now generic on PoolClient
@@ -66,13 +65,14 @@ pub trait BundleProposer: Send + Sync + 'static { | |||
} | |||
|
|||
#[derive(Debug)] | |||
pub struct BundleProposerImpl<S, E, P> | |||
pub struct BundleProposerImpl<S, E, P, C> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proposer is now generic on PoolClient
}; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct LocalPoolClient { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New class
}; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct RemotePoolClient { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New class
Ok(handle) | ||
} | ||
|
||
pub struct LocalPoolServer<M> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New class
src/op_pool/server/remote/protos.rs
Outdated
@@ -0,0 +1,210 @@ | |||
use anyhow::{bail, Context}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all just moved out of common
src/op_pool/server/remote/server.rs
Outdated
@@ -0,0 +1,317 @@ | |||
use std::{collections::HashMap, net::SocketAddr, sync::Arc}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is all moved
@@ -46,16 +43,13 @@ pub trait DebugApi { | |||
async fn bundler_dump_reputation(&self, entry_point: Address) -> RpcResult<Vec<RpcReputation>>; | |||
} | |||
|
|||
pub struct DebugApi { | |||
op_pool_client: op_pool_client::OpPoolClient<Channel>, | |||
pub struct DebugApi<P> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now generic on PoolClient
@@ -98,23 +97,24 @@ where | |||
} | |||
|
|||
#[derive(Debug)] | |||
pub struct EthApi<C: JsonRpcClient + 'static> { | |||
pub struct EthApi<C: JsonRpcClient + 'static, P: PoolClient> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now generic on pool client
4d08016
to
962879c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Some initial thoughts, will look more in a bit.
962879c
to
9877ee0
Compare
9877ee0
to
1cde0bc
Compare
let _builder_loop_guard = { | ||
SpawnGuard::spawn_with_guard(async move { bundle_sender.send_bundles_in_loop().await }) | ||
let mut builder: Box<dyn BundleSender> = match &self.args.pool_client_mode { | ||
PoolClientMode::Local { sender } => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only difference between the two blocks here is pool_client
, right? It's a bit hard to tell visually, unfortunately.
Something I'd like to see is if we can just box the pool client and have an impl
impl PoolClient for Box<dyn PoolClient>
That way we could have the branch just give us a Box<dyn PoolClient>
and have all the rest of the config written once outside of the branch. The auto_impl crate might help with this.
But these trait impl macros tend to not work for us, so maybe it won't help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I actually played with this code for a while trying to make this cleaner. auto_impl
and async_trait
don't seem to work well together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Closes #85