Skip to content

Commit

Permalink
patch up mev-build-rs to reflect Network type upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
ralexstokes committed Oct 19, 2023
1 parent 3e4ff1d commit cbc2f9d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 34 deletions.
13 changes: 8 additions & 5 deletions bin/mev/src/cmd/build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::cmd::config::Config;
use anyhow::{anyhow, Result};
use clap::Args;
use ethereum_consensus::networks::Network;
use mev_build_rs::reth_builder::Service;
use tracing::info;

#[derive(Debug, Args)]
#[clap(about = "🛠️ building blocks since 2023")]
Expand All @@ -12,14 +12,17 @@ pub struct Command {
}

impl Command {
pub async fn execute(&self, network: Network) -> Result<()> {
pub async fn execute(&self) -> Result<()> {
let config_file = &self.config_file;

let config = Config::from_toml_file(config_file)?;

if let Some(mut config) = config.build {
config.network = network;
Ok(Service::from(config).spawn().await)
let network = config.network;
info!("configured for {network}");

if let Some(config) = config.build {
Service::from(network, config).spawn().await;
Ok(())
} else {
Err(anyhow!("missing boost config from file provided"))
}
Expand Down
21 changes: 0 additions & 21 deletions bin/mev/src/cmd/build/mod.rs

This file was deleted.

3 changes: 0 additions & 3 deletions mev-build-rs/src/reth_builder/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::reth_builder::{
use ethereum_consensus::{
clock::{Clock, SystemTimeProvider},
crypto::SecretKey,
networks::Network,
state_transition::Context,
};
use ethers::signers::{coins_bip39::English, MnemonicBuilder, Signer};
Expand All @@ -22,8 +21,6 @@ const DEFAULT_BID_PERCENT: f64 = 0.9;

#[derive(Deserialize, Debug, Default, Clone)]
pub struct Config {
#[serde(default)]
pub network: Network,
pub secret_key: SecretKey,
pub relays: Vec<String>,
pub extra_data: String,
Expand Down
12 changes: 7 additions & 5 deletions mev-build-rs/src/reth_builder/service_ext.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::reth_builder::{service::Service, Config, DeadlineBidder};
use clap::{Args, Parser};
use ethereum_consensus::{
networks::{self},
networks::{self, Network},
state_transition::Context,
};
use reth::{
Expand All @@ -16,21 +16,23 @@ use tracing::warn;

#[derive(Debug, Args)]
pub struct ServiceExt {
#[clap(skip)]
network: Network,
#[clap(skip)]
config: Config,
}

impl ServiceExt {
pub fn from(config: Config) -> Self {
Self { config }
pub fn from(network: Network, config: Config) -> Self {
Self { network, config }
}

pub async fn spawn(self) {
let task_manager = TaskManager::new(tokio::runtime::Handle::current());
let task_executor = task_manager.executor();
let ctx = CliContext { task_executor };

let network = &self.config.network;
let network = &self.network;
let network_name = format!("{0}", network);

let mut params =
Expand Down Expand Up @@ -73,7 +75,7 @@ impl RethNodeCommandConfig for ServiceExt {
Tasks: reth::tasks::TaskSpawner + Clone + Unpin + 'static,
{
let build_config = self.config.clone();
let network = &build_config.network;
let network = &self.network;
let context = Arc::new(Context::try_from(network)?);
let clock = context.clock().unwrap_or_else(|| {
let genesis_time = networks::typical_genesis_time(&context);
Expand Down

0 comments on commit cbc2f9d

Please sign in to comment.