WIP: Two new cheatcodes to enable Forge scripts to send Flashbots bundles#4948
WIP: Two new cheatcodes to enable Forge scripts to send Flashbots bundles#4948ape-dev-cs wants to merge 7 commits intofoundry-rs:masterfrom
Conversation
2705d79 to
e34c505
Compare
devanoneth
left a comment
There was a problem hiding this comment.
Just a few small comments for now but so excited to see this!
cli/Cargo.toml
Outdated
| # eth | ||
| ethers = { workspace = true, features = ["rustls"] } | ||
| solang-parser = "=0.2.4" | ||
| ethers-flashbots = { git = "https://github.com/onbjerg/ethers-flashbots" } |
There was a problem hiding this comment.
Should tie it to a specific version e.g. 0.13.0.
| }) | ||
| .collect::<Result<Vec<_>>>()?; | ||
|
|
||
| trace!(target: "script", "sequence: {:#?}", &sequence); |
There was a problem hiding this comment.
I would say it's best to either:
- remove this trace and just keep the full
transactionstrace on L90 or - remove the trace on L90 and add a trace for
flashbots_sequencehere.
|
|
||
| let client = FlashbotsMiddleware::new( | ||
| provider.clone(), | ||
| Url::parse("https://relay.flashbots.net")?, |
There was a problem hiding this comment.
We should probably also support the goerli flashbots relay, even though it can be annoying to get a tx in there, people might want to test against that.
| pub additional_contracts: Vec<AdditionalContract>, | ||
| pub is_fixed_gas_limit: bool, | ||
| pub bundle_block: Option<U64>, | ||
| pub bundle_gas: Option<U256>, |
There was a problem hiding this comment.
Might be overkill, but I do think having the bundle details in a separate struct and then wrapped in one Option would be nicer because it seems they are both always checked together and also both must always be present.
| pub struct BroadcastableTransaction { | ||
| pub rpc: Option<RpcUrl>, | ||
| pub bundle_block: Option<U64>, | ||
| pub bundle_gas: Option<U256>, |
There was a problem hiding this comment.
Same here re having bundle details in one struct.
|
Leaving this PR open as I would like to see native support (tracking here: #4947) for private transactions but it will likely be better to start from scratch given the update to Alloy, deprecation of Related PR: #4931 introduces the Related Alloy Flashbots support: https://github.com/leruaa/alloy-mev |
|
Still supportive but given the required changes I think it makes sense that we go back to the drawing board before proceeding, leaving #4947 open to cover the request |
Motivation
I wanted to be able to easily send flashbots bundles within forge scripts for use-cases involving transactions that cannot hit public mempools for security reasons (e.g. MEV-able transactions, whitehat rescues, etc).
Solution
Two new cheatcodes,
vm.startBundle(target_block_number, gas_price)andvm.stopBundle(), which allow users to send flashbots bundles in foundry scripts, for example like this:This is a draft PR as this is a work in progress, and I'm also very new to Rust, so may not have built this optimally. I'd like to get feedback and code review from the community if possible.