-
Notifications
You must be signed in to change notification settings - Fork 39
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
[WIP]Send bundles (txs) to Flashbots #165
Conversation
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.
Left some comments
crates/bundler/Cargo.toml
Outdated
@@ -17,3 +17,6 @@ aa-bundler-primitives = { path = "../primitives" } | |||
anyhow = "1" | |||
ethers = { workspace = true } | |||
tracing = { workspace = true } | |||
ethers-flashbots = "0.13.1" |
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.
sort deps
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.
what are the formatting and sorting rules for Cargo.toml
Even if I sorted the deps alphabetically, it when run make lint
it still says not sorted
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.
Hmm, it should be alphabetically and nothing else. Is there any error text?
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.
error: Cargo.toml for bundler is not formatted
Checking bundler...
error: Dependencies for bundler are not sorted
Checking contracts...
Checking grpc...
Checking primitives...
Checking rpc...
Checking uopool...
Checking examples...
error: Cargo.toml for examples is not formatted
If you check the example/Cargo.tomal
, and bin/bundler/Cargo.toml
in the latest commit, they should be alphabetically sorted.
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.
It's not sorted because tokio should be before tracing
examples/Cargo.toml
Outdated
|
||
|
||
[dependencies] | ||
jsonrpsee = {version = "0.18.2", features = ["server", "http-client"]} |
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.
Is not formatted error is because features are not sorted and there is no whitespace between {version
-> { version
and "http-client"]}
-> "http-client"] }
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.
Thanks for pointing it out!
I've added cargo sort --workspace
command to the Makefile
in the latest commit. Otherwise, it's a pain in the ass to sort & format deps manually.
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.
Yeah, that makes sense, cool
crates/bundler/Cargo.toml
Outdated
@@ -17,3 +17,6 @@ aa-bundler-primitives = { path = "../primitives" } | |||
anyhow = "1" | |||
ethers = { workspace = true } | |||
tracing = { workspace = true } | |||
ethers-flashbots = "0.13.1" |
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.
It's not sorted because tokio should be before tracing
For the latest update, other than addressing the previous issues, I also added some comments for Rustdoc generation. Let me know what you think so that I could know if it's the correct format to go about adding rustdocs to other files. @Vid201 |
Hey, I checked and it looks good, it would be perfect to have that |
crates/grpc/src/bundler.rs
Outdated
@@ -49,6 +49,7 @@ impl BundlerService { | |||
Ok(uos) | |||
} | |||
|
|||
// TODO: add send 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.
add CLI mode: ./bundler --send-bundle flashbots
or ./bundler --send-bundle eth-client
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.
For this, here's how I could implement it
add the send-bundle
command in bin/bundler/bundler
. If flashbots
, bundler
should use the send_next_bundle_flashbots
method by default. There are three places I could indicate the intent to send bundle via flashbots
- adding an additional field to the send_bundle function
- adding an additional field to the Bundler struct;
- adding an additional field to the bundler_service_run
Let me know which is the best option
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.
I would make SendBundleMode
enum and add an additional field to the Bundler struct. Enum is parsed from CLI and passed as an additiona field to the bundler_service_run which pushes it to the Bundler struct constructor.
As for testing, do you have any suggestions? I could use Alternatively, I could send an |
Makes sense. I think simulating is enough for the tests. Do you mean this endpoint: https://docs.flashbots.net/flashbots-auction/searchers/advanced/rpc-endpoint#eth_callbundle ? We can also have a test that is skipped during CI, but has to be manually run. |
Description
Sending bundles to Flashbot's Relay has the benefit of avoiding front-run and sandwich attacks. Currently, the
bundler
only supports sending transaction bundles through the public mempool, which is vulnerable to the said attacks above. As the volume ofUserOperations
picks up, each bundle submitted will likely generate more MEV, hence attracting more MEV bots.Allowing the bundlers to submit bundles through Flashbots has the following benefits:
Things changed
crates/bundler/.env.example
FLASHBOTS_IDENTIFIER
as it is required by Flashbots(see How to send your first Flashbots bundle)crates/bundler/Cargo.toml
ethers-flashbot
,url
,tokio
crates to support functionalities in thesend_next_bundle_flashbots
functioncrates/bundler/src/bundler.rs
RELAY_ENDPOINTS
for most of the commonly used block builder endpointsend_next_bundle_flashbots
functionPending Issues
There is no good way to test sending bundle using Flashbots unless a remote endpoint is used, such as Flashbots' Bundle Relay API on Goerli or Sepolia