-
Notifications
You must be signed in to change notification settings - Fork 0
feat: adds a flashbots provider #158
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
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
91e0f7c to
178ed31
Compare
178ed31 to
7f24250
Compare
26149ac to
d275db4
Compare
d275db4 to
514db31
Compare
a308c0a to
b83f0e2
Compare
514db31 to
14fa362
Compare
b83f0e2 to
60c3b30
Compare
14fa362 to
cb97db3
Compare
0d8762a to
017a945
Compare
bbde89d to
a6aac19
Compare
- adds a Flashbots provider with the alloy MEV API extensions - adds the logic for building Flashbots bundles in the builder - adds the Flashbots submission task
a6aac19 to
bf0b272
Compare
bf0b272 to
25f69fa
Compare
| Ok(Some(hash)) => { | ||
| tracing::info!(host_block_number = sim_result.host_block_number(), bundle_hash = ?hash, "bundle submitted to flashbots"); | ||
| span_debug!(span, "bundle submitted to flashbots"); | ||
| } | ||
| Ok(None) => { | ||
| tracing::info!( | ||
| host_block_number = sim_result.host_block_number(), | ||
| "bundle submitted to flashbots without error" | ||
| ); | ||
| }) | ||
| .inspect_err(|err| { | ||
| span_error!(span, %err, "failed to send bundle to Flashbots"); | ||
| }); | ||
| span_debug!(span, "bundle submitted to flashbots"); | ||
| } |
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.
There is some weirdness here because the rbuilder response doesn't adhere to the Flashbots spec and returns a completely empty response instead of a bundle hash when successfully submitted, but we also want to handle the case where the endpoint does return the expected response. So we log both.
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.
duplicate event
src/tasks/submit/flashbots.rs
Outdated
| let bundle = match self.prepare(&sim_result).instrument(span.clone()).await { | ||
| Ok(b) => b, | ||
| Err(e) => { | ||
| tracing::error!(error = %e, "failed to prepare MEV bundle"); |
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.
duplicate event
| Ok(Some(hash)) => { | ||
| tracing::info!(host_block_number = sim_result.host_block_number(), bundle_hash = ?hash, "bundle submitted to flashbots"); | ||
| span_debug!(span, "bundle submitted to flashbots"); | ||
| } | ||
| Ok(None) => { | ||
| tracing::info!( | ||
| host_block_number = sim_result.host_block_number(), | ||
| "bundle submitted to flashbots without error" | ||
| ); | ||
| }) | ||
| .inspect_err(|err| { | ||
| span_error!(span, %err, "failed to send bundle to Flashbots"); | ||
| }); | ||
| span_debug!(span, "bundle submitted to flashbots"); | ||
| } |
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.
duplicate event
src/tasks/submit/flashbots.rs
Outdated
| match response { | ||
| Ok(Some(hash)) => { | ||
| tracing::info!(host_block_number = sim_result.host_block_number(), bundle_hash = ?hash, "bundle submitted to flashbots"); | ||
| span_debug!(span, "bundle submitted to flashbots"); |
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.
duplicate event
src/tasks/submit/flashbots.rs
Outdated
| span_debug!(span, "bundle submitted to flashbots"); | ||
| } | ||
| Ok(None) => { | ||
| tracing::info!( |
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.
duplicate event
| impl BuilderConfig { | ||
| /// Connect to the Builder signer. | ||
| pub async fn connect_builder_signer(&self) -> Result<LocalOrAws, SignerError> { | ||
| pub async fn connect_builder_signer(&self) -> eyre::Result<LocalOrAws> { |
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.
why is this type changing?
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.
To make it work with the error type try_join expects. The other connect_* functions return eyre::Result types, so it must match the others' return signatures.
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.
ah ya makes sense
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.
ffr, you can use the FutureExt trait to map future output types in-line
https://docs.rs/futures/latest/futures/future/trait.TryFutureExt.html#method.or_else
in this case something like config.connect_builder_signer().or_else(|e| Err(e.into()))
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.
try_join!(
async_fn_1(),
async_fn_2().or_else(|e| Err(e.into)),
)
src/tasks/submit/flashbots.rs
Outdated
| span_debug!(span, "bundle submitted to flashbots"); | ||
| } | ||
| Err(e) => { | ||
| tracing::error!(error = %e, "failed to submit MEV bundle to flashbots"); |
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.
duplicate event

feat: adds a Flashbots provider and submitter
This PR adds a Flashbots provider and submit task to the Builder.
It configures the Flashbots provider from the configured relay URL and uses the builder's signer key to sign all of the bundles it submits to Flashbots.
The Flashbots
rbuilder endpoint on Pecorino does not return a properEthBundleHash when a bundle is submitted, in fact it simply returns an empty response upon success. The endpoint also does not support simulation, so the Flashbots submit task blindly sends the prepared bundle and logs any errors that are returned.Closes ENG-1414
Closes ENG-1403