-
Notifications
You must be signed in to change notification settings - Fork 23
Refactor payload builder to accept generic builder tx #217
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
if let Some(flashtestations_builder_tx) = &self.flashtestations_builder_tx { | ||
// We only include flashtestations txs in the last flashblock | ||
|
||
let mut simulation_state = self.simulate_builder_txs_state::<FlashblocksExtraCtx>( |
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.
returns empty vec for now
} | ||
} | ||
|
||
pub fn simulate_builder_tx<ExtraCtx: Debug + Default>( |
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.
replace with flashblocks builder tx contract call
4e28c2e
to
c461c24
Compare
} | ||
} | ||
|
||
pub trait BuilderTransactions<ExtraCtx: Debug + Default = ()>: Debug { |
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'd be a lot cleaner to have this as an enum as opposed to a trait, so you don't need to use generic BuilderTransactions
everywhere.
eg.
pub enum BuilderTransactions {
Flashblocks(FlashblocksBuilderTx),
Standard(StandardBuilderTx),
Flashtestations(FlashtestationsBuilderTx),
}
impl BuilderTransactions {
pub fn simulate_builder_txs(&self, ...) {
match self {
Self::Flashblocks(inner) => inner.simulate_builder_txs(...),
Self::Standard(inner) => inner.simulate_builder_txs(...),
Self::Flashtestations(inner) => inner.simulate_builder_txs(...),
}
}
pub fn add_builder_txs(&self, ...) { ... }
pub fn simulate_builder_txs_state(&self, ...) {...}
}
you can also get rid of the ExtraCtx
generic param as well with this, as each type (FlashblocksBuilderTx, etc) can contain its own context.
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.
Sounds good but I would try the enum approach in a follow up PR to refactor the existing generic builder tx
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.
that would be great!
Co-authored-by: Solar Mithril <[email protected]>
Co-authored-by: Solar Mithril <[email protected]>
Co-authored-by: Solar Mithril <[email protected]>
Co-authored-by: Solar Mithril <[email protected]>
c461c24
to
6c8681d
Compare
0afece5
to
a95aae2
Compare
📝 Summary
Refactor to allow the payload builder accept generics for how to construct the builder tx.
💡 Motivation and Context
Easier to add custom logic to builder tx based on the payload builder such as contract calls etc.
✅ I have completed the following steps:
make lint
make test