-
Notifications
You must be signed in to change notification settings - Fork 8
feat(driver
): BundleDriver
for driving bundles to completion
#34
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
driver
: BundleDriver
for driving bundles to completiondriver
): BundleDriver
for driving bundles to completion
e9ea919
to
9ec0ac7
Compare
027b68b
to
1d1772e
Compare
|
||
let bundle_filler = BundleBlockFiller::from(self.clone()); | ||
|
||
let run_result = trevm.try_with_block(&bundle_filler, |trevm| { |
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.
the way this is implemented will cause anything not set by the filler to be default value. do we want that to be the case? or should we not use std::mem::take
in with_block/try_with_block
?
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 think we should remove the mem::take
s and instead clone the env
37e53c6
to
02bbba0
Compare
cf0772f
to
299fb4b
Compare
6b2dbd3
to
7d37311
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.
looking good. Almost done
also needs try_with_cfg
and try_with_tx
(unless I'm blind)
Adds a simple
BundleDriver
trait, which can drive bundles to completion.Conceptually, it starts from an
EvmNeedsTx
state, and ends there. This means that this driver simply allows to run a group of transactions, while applying post-multi-tx logic after. It does not open or close blocks. This also allows us to run several bundles, one after another.This
BundleDriver
trait is then composed with aBlockProcessor
struct, which then takes charge of implementing aBundleDriver
for a combination of a bundle type, and a response type. This allows us, for example, to quickly grab bundles that conform to flashbots bundles, simulate them, and return a properly calculated & formatted response. Vanilla impls forEthCallBundle
&EthSendBundle
are also provided which do not accumulate results.A few macros were also added, mirroring eyre macros:
unwrap_or_trevm_err!
: Unwraps a Result, returning the value if successful, or returning an erroredTrevm
if not.trevm_ensure!
: Executes a condition, returning an erroredTrevm
if not successful.trevm_bail!
: Returns an erroredTrevm
with the provided error.And lastly,
try_with_*
fns were added to have falliblewith_*
functions. The behavior of these was modified as well to useclone
instead ofmem::take
to avoid having default values, which might be unexpected for the user.fixes ENG-311