Skip to content
Open
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
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ name = "zenith-builder-example"
path = "bin/builder.rs"

[dependencies]
init4-bin-base = { version = "0.13.1", features = ["perms", "aws", "flashbots"] }
init4-bin-base = { version = "0.13.1", features = ["perms", "aws" ] }

signet-constants = { version = "0.11.2" }
signet-sim = { version = "0.11.2" }
Expand Down
49 changes: 16 additions & 33 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use init4_bin_base::{
perms::{Authenticator, OAuthConfig, SharedToken},
utils::{
calc::SlotCalculator,
flashbots::Flashbots,
from_env::FromEnv,
provider::{ProviderConfig, PubSubConfig},
signer::{LocalOrAws, SignerError},
Expand Down Expand Up @@ -110,8 +109,17 @@ pub struct BuilderConfig {
)]
pub tx_broadcast_urls: Vec<Cow<'static, str>>,

/// Flashbots configuration for privately submitting rollup blocks.
pub flashbots: init4_bin_base::utils::flashbots::FlashbotsConfig,
/// Configuration for the Flashbots provider.
/// * If set, the builder will submit blocks as MEV bundles to Flashbots instead of
/// submitting them directly to the Host chain.
/// * If not set, the builder defaults to submitting blocks directly to the Host chain
/// using the Builder Helper contract.
#[from_env(
var = "FLASHBOTS_ENDPOINT",
desc = "Flashbots endpoint for privately submitting rollup blocks",
optional
)]
pub flashbots_endpoint: Option<url::Url>,

/// Address of the Zenith contract on Host.
#[from_env(var = "ZENITH_ADDRESS", desc = "address of the Zenith contract on Host")]
Expand Down Expand Up @@ -235,31 +243,13 @@ impl BuilderConfig {
.connect_provider(provider?))
}

/// Connect to a Flashbots bundle provider
/// Connect to a Flashbots bundle provider.
pub async fn connect_flashbots(
&self,
config: &BuilderConfig,
) -> Result<
FillProvider<
JoinFill<
JoinFill<
Identity,
JoinFill<
GasFiller,
JoinFill<BlobGasFiller, JoinFill<NonceFiller, ChainIdFiller>>,
>,
>,
WalletFiller<EthereumWallet>,
>,
providers::RootProvider,
>,
eyre::Error,
> {
let endpoint = config
.clone()
.flashbots
.flashbots_endpoint
.expect("flashbots endpoint must be configured");
) -> Result<FlashbotsProvider, eyre::Error> {
let endpoint =
config.clone().flashbots_endpoint.expect("flashbots endpoint must be configured");
let signer = config.connect_builder_signer().await?;
let flashbots: FlashbotsProvider =
ProviderBuilder::new().wallet(signer).connect_http(endpoint);
Expand Down Expand Up @@ -332,21 +322,14 @@ impl BuilderConfig {
})
}

/// Connect to a Flashbots provider.
pub async fn flashbots_provider(&self) -> eyre::Result<Flashbots> {
self.flashbots
.build(self.connect_builder_signer().await?)
.ok_or_else(|| eyre::eyre!("Flashbots is not configured"))
}

/// Spawn a submit task, either Flashbots or BuilderHelper depending on
/// configuration.
pub async fn spawn_submit_task(
&self,
tx_channel: UnboundedSender<TxHash>,
) -> eyre::Result<(UnboundedSender<SimResult>, JoinHandle<()>)> {
// If we have a flashbots endpoint, use that
if self.flashbots.flashbots_endpoint.is_some() {
if self.flashbots_endpoint.is_some() {
debug!("spawning flashbots submit task");
// Make a Flashbots submission task
let submit = FlashbotsTask::new(self.clone(), tx_channel).await?;
Expand Down
6 changes: 2 additions & 4 deletions src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use init4_bin_base::{
EnvFilter, Layer, fmt, layer::SubscriberExt, registry, util::SubscriberInitExt,
},
perms::OAuthConfig,
utils::{calc::SlotCalculator, flashbots::FlashbotsConfig, provider::ProviderConfig},
utils::{calc::SlotCalculator, provider::ProviderConfig},
};
use signet_constants::SignetSystemConstants;
use std::env;
Expand All @@ -35,9 +35,7 @@ pub fn setup_test_config() -> Result<BuilderConfig> {
.try_into()
.unwrap(),
tx_broadcast_urls: vec!["http://localhost:9000".into()],
flashbots: FlashbotsConfig {
flashbots_endpoint: Some("https://relay-sepolia.flashbots.net:443".parse().unwrap()),
}, // NB: Flashbots API default
flashbots_endpoint: Some("https://relay-sepolia.flashbots.net:443".parse().unwrap()),
zenith_address: Address::default(),
quincey_url: "http://localhost:8080".into(),
sequencer_key: None,
Expand Down
Loading