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

add 'group_imports' to rustfmt config #101

Closed
Closed
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
3 changes: 2 additions & 1 deletion bin/mev/src/cmd/boost.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::cmd::config::Config;
use anyhow::{anyhow, Result};
use clap::Args;
use mev_boost_rs::Service;
use mev_rs::Network;

use crate::cmd::config::Config;

#[derive(Debug, Args)]
#[clap(about = "🚀 connecting proposers to the external builder network")]
pub struct Command {
Expand Down
3 changes: 2 additions & 1 deletion bin/mev/src/cmd/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::cmd::config::Config;
use anyhow::{anyhow, Result};
use clap::{Args, Subcommand};
use mev_build_rs::Service;
use mev_rs::Network;

use crate::cmd::config::Config;

#[derive(Debug, Args)]
#[clap(about = "🛠️ building blocks since 2023", subcommand_negates_reqs = true)]
pub struct Command {
Expand Down
3 changes: 2 additions & 1 deletion bin/mev/src/cmd/config.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use std::{fmt, path::Path};

use anyhow::{Context, Result};
use clap::Args;
use mev_boost_rs::Config as BoostConfig;
use mev_build_rs::Config as BuildConfig;
use mev_relay_rs::Config as RelayConfig;
use mev_rs::Network;
use serde::Deserialize;
use std::{fmt, path::Path};

#[derive(Debug, Deserialize)]
pub struct Config {
Expand Down
3 changes: 2 additions & 1 deletion bin/mev/src/cmd/relay.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::cmd::config::Config;
use anyhow::{anyhow, Result};
use clap::{Args, Subcommand};
use mev_relay_rs::Service;
use mev_rs::Network;

use crate::cmd::config::Config;

#[derive(Debug, Args)]
#[clap(about = "🏗 connecting builders to proposers", subcommand_negates_reqs = true)]
pub struct Command {
Expand Down
3 changes: 2 additions & 1 deletion bin/mev/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
mod cmd;

use std::future::Future;

use anyhow::Result;
use clap::{ArgGroup, Parser, Subcommand};
use mev_rs::Network;
use std::future::Future;
use tokio::signal;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

Expand Down
10 changes: 5 additions & 5 deletions mev-boost-rs/src/relay.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::ops::Deref;

use beacon_api_client::Client as BeaconClient;
use ethereum_consensus::{
crypto::Error as CryptoError, primitives::BlsPublicKey, serde::try_bytes_from_hex_str,
};
use std::ops::Deref;
use url::Url;

use mev_rs::blinded_block_provider::Client;
use url::Url;

#[derive(Clone, Debug)]
pub struct RelayEndpoint {
Expand Down Expand Up @@ -47,10 +47,10 @@ impl From<RelayEndpoint> for Relay {

#[cfg(test)]
mod tests {
use super::*;

use ethereum_consensus::crypto::SecretKey;

use super::*;

const URL: &str = "https://relay.com";

#[test]
Expand Down
6 changes: 4 additions & 2 deletions mev-boost-rs/src/relay_mux.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::relay::Relay;
use std::{collections::HashMap, ops::Deref, sync::Arc, time::Duration};

use async_trait::async_trait;
use ethereum_consensus::{
primitives::{BlsPublicKey, Slot, U256},
Expand All @@ -14,7 +15,8 @@ use mev_rs::{
};
use parking_lot::Mutex;
use rand::prelude::*;
use std::{collections::HashMap, ops::Deref, sync::Arc, time::Duration};

use crate::relay::Relay;

// See note in the `mev-relay-rs::Relay` about this constant.
// TODO likely drop this feature...
Expand Down
12 changes: 7 additions & 5 deletions mev-boost-rs/src/service.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
use crate::{
relay::{Relay, RelayEndpoint},
relay_mux::RelayMux,
};
use std::{future::Future, net::Ipv4Addr, pin::Pin, task::Poll};

use ethereum_consensus::state_transition::Context;
use futures::StreamExt;
use mev_rs::{blinded_block_provider::Server as BlindedBlockProviderServer, Error, Network};
use serde::Deserialize;
use std::{future::Future, net::Ipv4Addr, pin::Pin, task::Poll};
use tokio::task::{JoinError, JoinHandle};
use url::Url;

use crate::{
relay::{Relay, RelayEndpoint},
relay_mux::RelayMux,
};

#[derive(Debug, Deserialize)]
pub struct Config {
pub host: Ipv4Addr,
Expand Down
11 changes: 5 additions & 6 deletions mev-boost-rs/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
use std::{
collections::HashMap,
time::{SystemTime, UNIX_EPOCH},
};

use beacon_api_client::{Client as ApiClient, ValidatorStatus, ValidatorSummary, Value};
use ethereum_consensus::{
bellatrix::mainnet as bellatrix,
Expand All @@ -17,13 +22,7 @@ use mev_rs::{
signing::sign_builder_message,
types::{BidRequest, ExecutionPayload, SignedBlindedBeaconBlock, SignedBuilderBid},
};

use rand::seq::SliceRandom;
use std::{
collections::HashMap,
time::{SystemTime, UNIX_EPOCH},
};

use url::Url;

fn setup_logging() {
Expand Down
3 changes: 2 additions & 1 deletion mev-build-rs/src/mempool_builder.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::{collections::HashMap, ops::Deref, sync::Arc};

use async_trait::async_trait;
use beacon_api_client::{mainnet::Client, BeaconProposerRegistration, ProposerDuty};
use ethereum_consensus::{
Expand All @@ -15,7 +17,6 @@ use mev_rs::{
BlindedBlockProvider, Error, ProposerScheduler, ValidatorRegistry,
};
use parking_lot::Mutex;
use std::{collections::HashMap, ops::Deref, sync::Arc};
use tokio::{sync::mpsc, task::JoinHandle};

#[derive(Clone)]
Expand Down
6 changes: 4 additions & 2 deletions mev-build-rs/src/service.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::mempool_builder::Builder;
use std::{fmt, future::Future, net::Ipv4Addr, pin::Pin, sync::Arc, task::Poll};

use beacon_api_client::Client;
use ethereum_consensus::{crypto::SecretKey, state_transition::Context};
use futures::StreamExt;
Expand All @@ -13,13 +14,14 @@ use mev_rs::{
Error, Network,
};
use serde::Deserialize;
use std::{fmt, future::Future, net::Ipv4Addr, pin::Pin, sync::Arc, task::Poll};
use tokio::{
sync::mpsc,
task::{JoinError, JoinHandle},
};
use url::Url;

use crate::mempool_builder::Builder;

const BUILD_JOB_BUFFER_SIZE: usize = 1;

#[derive(Deserialize)]
Expand Down
3 changes: 2 additions & 1 deletion mev-relay-rs/src/relay.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::{collections::HashMap, ops::Deref, sync::Arc};

use async_trait::async_trait;
use beacon_api_client::mainnet::Client;
use ethereum_consensus::{
Expand All @@ -17,7 +19,6 @@ use mev_rs::{
BlindedBlockProvider, Error, ValidatorRegistry,
};
use parking_lot::Mutex;
use std::{collections::HashMap, ops::Deref, sync::Arc};

// `PROPOSAL_TOLERANCE_DELAY` controls how aggresively the relay drops "old" execution payloads
// once they have been fetched from builders -- currently in response to an incoming request from a
Expand Down
6 changes: 4 additions & 2 deletions mev-relay-rs/src/service.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
use crate::relay::Relay;
use std::{fmt, future::Future, net::Ipv4Addr, pin::Pin, sync::Arc, task::Poll};

use beacon_api_client::mainnet::Client;
use ethereum_consensus::{crypto::SecretKey, state_transition::Context};
use futures::StreamExt;
use mev_rs::{blinded_block_provider::Server as BlindedBlockProviderServer, Error, Network};
use serde::Deserialize;
use std::{fmt, future::Future, net::Ipv4Addr, pin::Pin, sync::Arc, task::Poll};
use tokio::task::{JoinError, JoinHandle};
use url::Url;

use crate::relay::Relay;

#[derive(Deserialize)]
pub struct Config {
pub host: Ipv4Addr,
Expand Down
11 changes: 6 additions & 5 deletions mev-rs/src/blinded_block_provider/api/client.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
use axum::http::StatusCode;
use beacon_api_client::{
api_error_or_ok, mainnet::Client as BeaconApiClient, ApiResult, Error as ApiError,
VersionedValue,
};

use crate::{
blinded_block_provider::Error,
types::{
BidRequest, ExecutionPayload, SignedBlindedBeaconBlock, SignedBuilderBid,
SignedValidatorRegistration,
},
};
use axum::http::StatusCode;
use beacon_api_client::{
api_error_or_ok, mainnet::Client as BeaconApiClient, ApiResult, Error as ApiError,
VersionedValue,
};

/// A `Client` for a service implementing the Builder APIs.
/// Note that `Client` does not implement the `Builder` trait so that
Expand Down
20 changes: 11 additions & 9 deletions mev-rs/src/blinded_block_provider/api/server.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
use crate::{
blinded_block_provider::BlindedBlockProvider,
error::Error,
types::{
bellatrix, capella, BidRequest, ExecutionPayload, SignedBlindedBeaconBlock,
SignedBuilderBid, SignedValidatorRegistration,
},
};
use std::net::{Ipv4Addr, SocketAddr};

use axum::{
extract::{Json, Path, State},
http::StatusCode,
Expand All @@ -16,9 +10,17 @@ use axum::{
use beacon_api_client::{ApiError, Error as ApiClientError, VersionedValue};
use hyper::server::conn::AddrIncoming;
use serde::Deserialize;
use std::net::{Ipv4Addr, SocketAddr};
use tokio::task::JoinHandle;

use crate::{
blinded_block_provider::BlindedBlockProvider,
error::Error,
types::{
bellatrix, capella, BidRequest, ExecutionPayload, SignedBlindedBeaconBlock,
SignedBuilderBid, SignedValidatorRegistration,
},
};

/// Type alias for the configured axum server
pub type BlockProviderServer = axum::Server<AddrIncoming, IntoMakeService<Router>>;

Expand Down
2 changes: 1 addition & 1 deletion mev-rs/src/blinded_block_provider/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#[cfg(feature = "api")]
mod api;

use async_trait::async_trait;
#[cfg(feature = "api")]
pub use {api::client::Client, api::server::Server};

Expand All @@ -11,7 +12,6 @@ use crate::{
SignedValidatorRegistration,
},
};
use async_trait::async_trait;

#[async_trait]
pub trait BlindedBlockProvider {
Expand Down
14 changes: 8 additions & 6 deletions mev-rs/src/engine_api_proxy/client.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
use std::sync::Arc;

use anvil_rpc::request::{Id, RequestParams, RpcMethodCall, Version};
use ethereum_consensus::{capella::Withdrawal, primitives::ValidatorIndex};
use parking_lot::Mutex;
use serde::Deserialize;
use ssz_rs::prelude::U256;

use crate::{
engine_api_proxy::{
types::{self, BuildVersion, ExecutionPayloadWithValue, PayloadId},
Error,
},
types::{bellatrix, capella, ExecutionPayload},
};
use anvil_rpc::request::{Id, RequestParams, RpcMethodCall, Version};
use ethereum_consensus::{capella::Withdrawal, primitives::ValidatorIndex};
use parking_lot::Mutex;
use serde::Deserialize;
use ssz_rs::prelude::U256;
use std::sync::Arc;

const ENGINE_GET_PAYLOADV1_METHOD: &str = "engine_getPayloadV1";
const ENGINE_GET_PAYLOADV2_METHOD: &str = "engine_getPayloadV2";
Expand Down
16 changes: 9 additions & 7 deletions mev-rs/src/engine_api_proxy/server.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::engine_api_proxy::types::{
BuildJob, BuildVersion, ForkchoiceUpdatedV1Params, ForkchoiceUpdatedV1Response,
ForkchoiceUpdatedV2Params, PayloadAttributes,
use std::{
net::{Ipv4Addr, SocketAddr},
sync::Arc,
};

use axum::{
extract::State,
http::{uri::Uri, Request, Response},
Expand All @@ -11,12 +12,13 @@ use axum::{
use hyper::{body, client::HttpConnector, server::conn::AddrIncoming, Body};
use parking_lot::Mutex;
use serde::{Deserialize, Serialize};
use std::{
net::{Ipv4Addr, SocketAddr},
sync::Arc,
};
use tokio::{sync::mpsc, task::JoinHandle};

use crate::engine_api_proxy::types::{
BuildJob, BuildVersion, ForkchoiceUpdatedV1Params, ForkchoiceUpdatedV1Response,
ForkchoiceUpdatedV2Params, PayloadAttributes,
};

pub type EngineApiProxyServer = axum::Server<AddrIncoming, IntoMakeService<Router>>;
pub type Client = hyper::client::Client<HttpConnector, Body>;

Expand Down
3 changes: 2 additions & 1 deletion mev-rs/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use crate::types::BidRequest;
use beacon_api_client::Error as ApiError;
use ethereum_consensus::{
primitives::{BlsPublicKey, ExecutionAddress, Hash32},
state_transition::Error as ConsensusError,
};
use thiserror::Error;

use crate::types::BidRequest;

#[derive(Debug, Error)]
pub enum Error {
#[error("bid public key {bid} does not match relay public key {relay}")]
Expand Down
1 change: 0 additions & 1 deletion mev-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pub mod types;
mod validator_registry;

pub use blinded_block_provider::BlindedBlockProvider;

pub use error::Error;
pub use network::*;
pub use proposer_scheduler::ProposerScheduler;
Expand Down
3 changes: 2 additions & 1 deletion mev-rs/src/proposer_scheduler.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use std::collections::HashMap;

use beacon_api_client::{
mainnet::Client, BeaconProposerRegistration, Error as ApiError, ProposerDuty,
};
use ethereum_consensus::primitives::{BlsPublicKey, Epoch, Slot};
use parking_lot::Mutex;
use std::collections::HashMap;
use thiserror::Error;

#[derive(Debug, Error)]
Expand Down
Loading