-
Notifications
You must be signed in to change notification settings - Fork 2
feat: fan out bundle submission to multiple MEV relay endpoints #257
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
Merged
+181
−98
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,8 +53,8 @@ pub type HostProvider = FillProvider< | |
| RootProvider, | ||
| >; | ||
|
|
||
| /// The provider type used to submit bundles to a Flashbots relay. | ||
| pub type FlashbotsProvider = FillProvider< | ||
| /// The provider type used to submit bundles to an MEV relay. | ||
| pub type RelayProvider = FillProvider< | ||
| JoinFill< | ||
| JoinFill< | ||
| Identity, | ||
|
|
@@ -91,14 +91,18 @@ pub struct BuilderConfig { | |
| #[from_env(var = "TX_POOL_URL", desc = "URL of the tx pool to poll for incoming transactions")] | ||
| pub tx_pool_url: url::Url, | ||
|
|
||
| /// Configuration for the Flashbots provider to submit | ||
| /// SignetBundles and Rollup blocks to the Host chain | ||
| /// as private MEV bundles via Flashbots. | ||
| /// Comma-separated list of MEV relay/builder endpoints for bundle | ||
| /// submission. The builder fans out each bundle to all endpoints | ||
| /// concurrently for maximum inclusion probability. | ||
| /// | ||
| /// At least one endpoint must be configured. Parsed from raw strings | ||
| /// into [`url::Url`] during [`sanitize`](Self::sanitize). | ||
| #[from_env( | ||
| var = "FLASHBOTS_ENDPOINT", | ||
| desc = "Flashbots endpoint for privately submitting Signet bundles" | ||
| var = "SUBMIT_ENDPOINTS", | ||
| desc = "Comma-separated list of MEV relay/builder RPC endpoints for bundle submission (at least one required)", | ||
| infallible | ||
| )] | ||
| pub flashbots_endpoint: url::Url, | ||
| pub submit_endpoints: Vec<String>, | ||
|
|
||
| /// URL for remote Quincey Sequencer server to sign blocks. | ||
| /// NB: Disregarded if a sequencer_signer is configured. | ||
|
|
@@ -220,6 +224,19 @@ impl BuilderConfig { | |
| if !self.tx_pool_url.path().ends_with('/') { | ||
| self.tx_pool_url.set_path(&format!("{}/", self.tx_pool_url.path())); | ||
| } | ||
|
|
||
| assert!( | ||
| !self.submit_endpoints.is_empty(), | ||
| "SUBMIT_ENDPOINTS must contain at least one URL" | ||
| ); | ||
|
|
||
| // Validate that every submit endpoint is a parseable URL. Fail fast | ||
| // on startup rather than at first block submission. | ||
| for raw in &self.submit_endpoints { | ||
| url::Url::parse(raw) | ||
| .unwrap_or_else(|e| panic!("invalid URL in SUBMIT_ENDPOINTS \"{raw}\": {e}")); | ||
| } | ||
|
Comment on lines
+233
to
+238
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we use |
||
|
|
||
| self | ||
| } | ||
|
|
||
|
|
@@ -274,11 +291,22 @@ impl BuilderConfig { | |
| .connect_provider(provider?)) | ||
| } | ||
|
|
||
| /// Connect to a Flashbots bundle provider. | ||
| pub async fn connect_flashbots(&self) -> Result<FlashbotsProvider> { | ||
| self.connect_builder_signer().await.map(|signer| { | ||
| ProviderBuilder::new().wallet(signer).connect_http(self.flashbots_endpoint.clone()) | ||
| }) | ||
| /// Connect to all configured MEV relay/builder endpoints. | ||
| /// | ||
| /// Returns one [`RelayProvider`] per URL in `submit_endpoints`. | ||
| /// URLs were already validated during [`sanitize`](Self::sanitize). | ||
| pub async fn connect_relays(&self) -> Result<Vec<(url::Url, RelayProvider)>> { | ||
| let signer = self.connect_builder_signer().await?; | ||
| Ok(self | ||
| .submit_endpoints | ||
| .iter() | ||
| .map(|raw| { | ||
| let url: url::Url = raw.parse().expect("validated in sanitize"); | ||
| let provider = | ||
| ProviderBuilder::new().wallet(signer.clone()).connect_http(url.clone()); | ||
| (url, provider) | ||
| }) | ||
| .collect()) | ||
| } | ||
|
|
||
| /// Connect to the Zenith instance, using the specified provider. | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we want this to fail at startup, we should just straight up use the type so it fails on parse instead of having to do it manually ourselves below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this might not work directly as
url::Urlwon't be directly convertible. I still think a better idea here is to have a newtype that trims and parses, such aswhich would then trim and parse the urls.