Skip to content

Commit

Permalink
Merge pull request ralexstokes#222 from ralexstokes/builder/initial-p…
Browse files Browse the repository at this point in the history
…olish

some polish on the builder refactor
  • Loading branch information
ralexstokes authored Apr 30, 2024
2 parents 0d28337 + 4ac4d2d commit f840d88
Show file tree
Hide file tree
Showing 30 changed files with 1,589 additions and 1,339 deletions.
1,063 changes: 637 additions & 426 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ default-members = ["bin/mev"]
version = "0.3.0"

[workspace.dependencies]
ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "6c7305336397b1cfa1c780812a51c97bd025d052" }
beacon-api-client = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "6c7305336397b1cfa1c780812a51c97bd025d052" }
ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "0919f02435e1b64e27c53931cac8e08edaad5f8b" }
beacon-api-client = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "0919f02435e1b64e27c53931cac8e08edaad5f8b" }

reth = { git = "https://github.com/paradigmxyz/reth", rev = "71f8e678aa53f75c2c35badaa5848262de594cdc" }
reth-db = { git = "https://github.com/paradigmxyz/reth", rev = "71f8e678aa53f75c2c35badaa5848262de594cdc" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "71f8e678aa53f75c2c35badaa5848262de594cdc" }
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "71f8e678aa53f75c2c35badaa5848262de594cdc" }
reth-basic-payload-builder = { git = "https://github.com/paradigmxyz/reth", rev = "71f8e678aa53f75c2c35badaa5848262de594cdc" }
alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "188c4f8" }
alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "188c4f8" }
reth = { git = "https://github.com/paradigmxyz/reth", rev = "6d7cd53ad25f0b79c89fd60a4db2a0f2fe097efe" }
reth-db = { git = "https://github.com/paradigmxyz/reth", rev = "6d7cd53ad25f0b79c89fd60a4db2a0f2fe097efe" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "6d7cd53ad25f0b79c89fd60a4db2a0f2fe097efe" }
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "6d7cd53ad25f0b79c89fd60a4db2a0f2fe097efe" }
reth-basic-payload-builder = { git = "https://github.com/paradigmxyz/reth", rev = "6d7cd53ad25f0b79c89fd60a4db2a0f2fe097efe" }
alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "4e22b9e" }
alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "4e22b9e" }

eyre = "0.6.8"
futures-util = "0.3.30"
Expand Down
3 changes: 2 additions & 1 deletion bin/mev/src/cmd/boost.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::cmd::config::Config;
use clap::Args;
use eyre::OptionExt;
use mev_boost_rs::Service;
use tracing::info;

Expand All @@ -16,7 +17,7 @@ impl Command {

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

let network = config.network;
let network = config.network.ok_or_eyre("missing `network` from configuration)")?;
info!("configured for `{network}`");

if let Some(config) = config.boost {
Expand Down
2 changes: 1 addition & 1 deletion bin/mev/src/cmd/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use tracing::{info, trace};

#[derive(Debug, Deserialize)]
pub struct Config {
pub network: Network,
pub network: Option<Network>,
#[cfg(feature = "boost")]
pub boost: Option<BoostConfig>,
#[cfg(feature = "build")]
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,5 +1,6 @@
use crate::cmd::config::Config;
use clap::{Args, Subcommand};
use eyre::OptionExt;
use mev_relay_rs::Service;
use tracing::info;

Expand Down Expand Up @@ -30,7 +31,7 @@ impl Command {

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

let network = config.network;
let network = config.network.ok_or_eyre("missing `network` from configuration)")?;
info!("configured for `{network}`");

if let Some(config) = config.relay {
Expand Down
34 changes: 26 additions & 8 deletions bin/mev/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
mod cmd;

use clap::{Parser, Subcommand};
use std::future::Future;
use clap::{CommandFactory, Parser, Subcommand};
use eyre::OptionExt;
use std::{future::Future, path::PathBuf};
use tokio::signal;
use tracing::warn;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

#[derive(Debug, Parser)]
Expand Down Expand Up @@ -51,7 +53,25 @@ fn run_task_until_signal(task: impl Future<Output = eyre::Result<()>>) -> eyre::
})
}

fn parse_custom_chain_config_directory() -> eyre::Result<Option<PathBuf>> {
let matches = Cli::command().get_matches();
let (_, matches) = matches.subcommand().ok_or_eyre("missing subcommand")?;
let iter = matches.try_get_raw("chain").transpose();

if let Some(Ok(mut iter)) = iter {
Ok(iter.next().and_then(|raw| {
raw.to_str().and_then(|s| {
let path = PathBuf::from(s);
path.parent().map(PathBuf::from)
})
}))
} else {
Ok(None)
}
}

fn main() -> eyre::Result<()> {
let custom_chain_config_directory = parse_custom_chain_config_directory()?;
let cli = Cli::parse();

match cli.command {
Expand All @@ -60,13 +80,11 @@ fn main() -> eyre::Result<()> {
#[cfg(feature = "build")]
Commands::Build(cmd) => cmd.run(|node_builder, cli_args| async move {
let config: cmd::config::Config = cli_args.try_into()?;
let network = config.network;

if let Some(config) = config.builder {
mev_build_rs::launch(node_builder, network, config).await
} else {
Err(eyre::eyre!("missing `builder` configuration"))
if let Some(network) = config.network {
warn!(%network, "`network` option provided in configuration but ignored in favor of `reth` configuration");
}
let config = config.builder.ok_or_eyre("missing `builder` configuration")?;
mev_build_rs::launch(node_builder, custom_chain_config_directory, config).await
}),
#[cfg(feature = "relay")]
Commands::Relay(cmd) => run_task_until_signal(cmd.execute()),
Expand Down
26 changes: 16 additions & 10 deletions example.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,31 @@ accepted_builders = [
]

[builder]
# number of milliseconds to submit bids ahead of the target slot
bidding_deadline_ms = 1000
# amount of value to bid as a fraction of the payload's revenue
bid_percent = 0.9
# amount to add to the bid on top of the payload's revenue,
# currently sourced from the builder's wallet authoring the payment transaction
subsidy_gwei = 100000000 # 0.1 eth

[builder.auctioneer]
# builder BLS secret key
secret_key = "0x14b6e79cbc6267c6e527b4bf7a71747d42a58b10279366cf0c7bb4e2aa455901"
# list of relays to connect to
relays = [
"https://0x845bd072b7cd566f02faeb0a4033ce9399e42839ced64e8b2adcfc859ed1e8e1a5a293336a49feac6d9a5edb779be53a@boost-relay-sepolia.flashbots.net",
]

[builder.builder]
# address to collect transaction fees
fee_recipient = "0x0000000000000000000000000000000000000000"
# [optional] address to collect transaction fees
# if missing, sender from `execution_mnemonic` is used
fee_recipient = "0x9858EfFD232B4033E47d90003D41EC34EcaEda94"
# [optional] extra data to write into built execution payload
extra_data = "0x68656C6C6F20776F726C640A" # "hello world"
# wallet seed for builder to author payment transactions
execution_mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"

[builder.bidder]
# amount in milliseconds of time to wait until submitting bids
wait_until_ms = 3000
# [optional] amount of value to bid as a fraction of the payload's revenue
# if missing, defaults to 1.0 (100%)
# validation: should be between [0, 1] inclusive.
bid_percent = 0.9
# [optional] amount to add to the bid on top of the payload's revenue,
# if missing, defaults to 0 wei
# currently sourced from the builder's wallet authoring the payment transaction
subsidy_wei = "0x0000000000000000000000000000000000000000000000000000000000000001"
Loading

0 comments on commit f840d88

Please sign in to comment.