Skip to content
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

Matchmaker Client #18

Merged
merged 13 commits into from
Jun 2, 2023
Merged

Matchmaker Client #18

merged 13 commits into from
Jun 2, 2023

Conversation

FrankieIsLost
Copy link
Collaborator

An client implementation of MEV-share's matchmaker. We implement flashbots-style authentication as a tower middleware

/// Create a new client with the given signer and chain
pub fn new(signer: S, chain: Chain) -> Self {
let url = match chain {
Chain::Mainnet => "https://relay.flashbots.net:443",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a good idea to add a constants file for the relay urls and other urls that are common amongst MEV strategies even though the relay url is passed into the flashbots executor as a parameter

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a small suggestion but it works well!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Will pull out into a constants file once these start appearing in the codebase more often

crates/clients/matchmaker/Cargo.toml Outdated Show resolved Hide resolved
crates/clients/matchmaker/src/types.rs Outdated Show resolved Hide resolved
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
))]

//! Client library for Flashbots MEV-share Matchmaker, fulfilling the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good!

// mock service that returns the request headers
let svc = FlashbotsSigner {
signer: fb_signer.clone(),
inner: service_fn(|_req: Request<Body>| async {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Comment on lines +16 to +20
/// Matchmaker client to interact with MEV-share
pub struct Client<S> {
/// Underlying HTTP client
pub http_client: HttpClient<FlashbotsSigner<S, HttpBackend>>,
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is 👍 given you use jsonrpsee, you could also have done it this way: https://github.com/onbjerg/ethers-flashbots/blob/master/src/relay.rs#L83-L101, just using reqwest, but maybe you had other reasons not to?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep! Writing the tower middleware felt a bit cleaner since it allowed us to take advantage of jsonrpsee instead of copying in snippets of json-rpc code, but both work

FrankieIsLost and others added 3 commits June 2, 2023 16:39
* executor

* lints
Co-authored-by: Georgios Konstantopoulos <[email protected]>
Co-authored-by: Georgios Konstantopoulos <[email protected]>
@FrankieIsLost FrankieIsLost merged commit 5311f4b into main Jun 2, 2023
@FrankieIsLost FrankieIsLost deleted the frankie--matchmaker-client branch June 3, 2023 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants