-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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: Two new cheatcodes to enable Forge scripts to send Flashbots bundles #4948
Conversation
2705d79
to
e34c505
Compare
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.
Just a few small comments for now but so excited to see this!
cli/Cargo.toml
Outdated
@@ -25,6 +25,7 @@ ui = { path = "../ui" } | |||
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say it's best to either:
- remove this trace and just keep the full
transactions
trace on L90 or - remove the trace on L90 and add a trace for
flashbots_sequence
here.
|
||
let client = FlashbotsMiddleware::new( | ||
provider.clone(), | ||
Url::parse("https://relay.flashbots.net")?, |
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.
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.
@@ -41,6 +41,8 @@ pub struct TransactionWithMetadata { | |||
pub transaction: TypedTransaction, | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -39,6 +39,8 @@ pub const DEFAULT_CREATE2_DEPLOYER: H160 = H160([ | |||
#[derive(Debug, Clone, Default)] | |||
pub struct BroadcastableTransaction { | |||
pub rpc: Option<RpcUrl>, | |||
pub bundle_block: Option<U64>, | |||
pub bundle_gas: Option<U256>, |
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.
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.