From 2de09df80fc8a90d321a9e1b7973800214700136 Mon Sep 17 00:00:00 2001 From: Daniel Xifra Date: Mon, 4 Nov 2024 17:44:12 -0300 Subject: [PATCH] new flag disable_relay_submit --- config-live-example.toml | 2 + .../src/live_builder/block_output/mod.rs | 1 + .../block_output/null_builder_sink_factory.rs | 39 +++++++++++++++++++ crates/rbuilder/src/live_builder/config.rs | 27 ++++++++++--- 4 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 crates/rbuilder/src/live_builder/block_output/null_builder_sink_factory.rs diff --git a/config-live-example.toml b/config-live-example.toml index c295f71c..c392ebfb 100644 --- a/config-live-example.toml +++ b/config-live-example.toml @@ -20,6 +20,8 @@ jsonrpc_server_ip = "0.0.0.0" el_node_ipc_path = "/tmp/reth.ipc" extra_data = "⚡🤖" +disable_relay_submit = false + blocklist_file_path = "./blocklist.json" dry_run = true diff --git a/crates/rbuilder/src/live_builder/block_output/mod.rs b/crates/rbuilder/src/live_builder/block_output/mod.rs index 3c7c5f31..b01429aa 100644 --- a/crates/rbuilder/src/live_builder/block_output/mod.rs +++ b/crates/rbuilder/src/live_builder/block_output/mod.rs @@ -2,4 +2,5 @@ pub mod bid_observer; pub mod bid_value_source; pub mod bidding; pub mod block_sealing_bidder_factory; +pub mod null_builder_sink_factory; pub mod relay_submit; diff --git a/crates/rbuilder/src/live_builder/block_output/null_builder_sink_factory.rs b/crates/rbuilder/src/live_builder/block_output/null_builder_sink_factory.rs new file mode 100644 index 00000000..d3fad13a --- /dev/null +++ b/crates/rbuilder/src/live_builder/block_output/null_builder_sink_factory.rs @@ -0,0 +1,39 @@ +//! Null implementation for BuilderSinkFactory. It just throws away the bids. +//! Useful for testing. + +use crate::building::builders::Block; +use reth_primitives::format_ether; +use tracing::info; + +use super::relay_submit::{BlockBuildingSink, BuilderSinkFactory}; + +#[derive(Debug)] +pub struct NullBuilderSinkFactory {} + +impl BuilderSinkFactory for NullBuilderSinkFactory { + fn create_builder_sink( + &self, + _slot_data: crate::live_builder::payload_events::MevBoostSlotData, + _competition_bid_value_source: std::sync::Arc< + dyn super::bid_value_source::interfaces::BidValueSource + Send + Sync, + >, + _cancel: tokio_util::sync::CancellationToken, + ) -> Box { + Box::new(NullBuilderSink {}) + } +} + +#[derive(Debug)] +struct NullBuilderSink {} + +impl BlockBuildingSink for NullBuilderSink { + fn new_block(&self, block: Block) { + info!( + true_bid_value = format_ether(block.trace.true_bid_value), + buidler_name = block.builder_name, + fill_time_ms = block.trace.fill_time.as_millis(), + finalize_time_ms = block.trace.finalize_time.as_millis(), + "NullBuilderSink received new block" + ); + } +} diff --git a/crates/rbuilder/src/live_builder/config.rs b/crates/rbuilder/src/live_builder/config.rs index 4cbbe30d..72e8275b 100644 --- a/crates/rbuilder/src/live_builder/config.rs +++ b/crates/rbuilder/src/live_builder/config.rs @@ -27,8 +27,12 @@ use crate::{ Sorting, }, live_builder::{ - base_config::EnvOrValue, block_output::relay_submit::BuilderSinkFactory, - cli::LiveBuilderConfig, payload_events::MevBoostSlotDataGenerator, + base_config::EnvOrValue, + block_output::{ + null_builder_sink_factory::NullBuilderSinkFactory, relay_submit::BuilderSinkFactory, + }, + cli::LiveBuilderConfig, + payload_events::MevBoostSlotDataGenerator, }, mev_boost::BLSBlockSigner, primitives::mev_boost::{MevBoostRelay, RelayConfig}, @@ -131,6 +135,12 @@ pub struct L1Config { /// Genesis fork version for the chain. If not provided it will be fetched from the beacon client. pub genesis_fork_version: Option, + + /// @Pending: mix this with dry_run? + /// If disable_relay_submit the the whole final submition state is dropped. + /// This way we can test knowing no bid is going to the relay and there is no need to configure dry_run_validation_url. + /// Notice that at relays are still needed to get the final fee recipient for PBS. + pub disable_relay_submit: bool, } impl Default for L1Config { @@ -147,6 +157,7 @@ impl Default for L1Config { cl_node_url: vec![EnvOrValue::from("http://127.0.0.1:3500")], max_concurrent_seals: DEFAULT_MAX_CONCURRENT_SEALS, genesis_fork_version: None, + disable_relay_submit: false, } } } @@ -276,10 +287,14 @@ impl L1Config { ); let relays = self.create_relays()?; - let sink_factory: Box = Box::new(RelaySubmitSinkFactory::new( - submission_config, - relays.clone(), - )); + let sink_factory: Box = if self.disable_relay_submit { + Box::new(NullBuilderSinkFactory {}) + } else { + Box::new(RelaySubmitSinkFactory::new( + submission_config, + relays.clone(), + )) + }; Ok((sink_factory, relays)) } }