-
Notifications
You must be signed in to change notification settings - Fork 2
fix(sim): Make simulation process actually continuous #86
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
This stack of pull requests is managed by Graphite. Learn more about stacking. |
62da5ad
to
dbfc062
Compare
Right now, the simulator stops as soon as there are no more items to simulate. This actually is not correct behavior, as we could be early in the slot, with more items coming in later in the slot which could yield a higher total payout on the block. What we actually want, is to simply skip doing the round at all if there are no items, sleep for a certain amount of time (bounded by the deadline), and either break (if we slept until the deadline) or continue if there's still time remaining. The resulting behavior is that the simulator always runs until the deadline, ensuring that items that come later in the slot, up until the deadline, can be simulated and included in the block.
dbfc062
to
00c4075
Compare
use tracing::{debug, info_span, trace, Instrument}; | ||
use trevm::{ | ||
helpers::Ctx, | ||
revm::{inspector::NoOpInspector, DatabaseRef, Inspector}, | ||
Block, Cfg, | ||
}; | ||
|
||
/// The amount of time to sleep between simulation rounds when there are no items to simulate. | ||
pub(crate) const SIM_SLEEP_MS: u64 = 50; |
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.
future idea: make the sim-cache return a future that resolves when it has more items to sim
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.
oh i like that
fix(sim): Make simulation process actually continuous
Right now, the simulator stops as soon as there are no more items to simulate. This actually is not correct behavior, as we could be early in the slot, with more items coming in later in the slot which could yield a higher total payout on the block.
What we actually want, is to simply skip doing the round at all if there are no items, sleep for a certain amount of time (bounded by the deadline), and either break (if we slept until the deadline) or continue if there's still time remaining.
The resulting behavior is that the simulator always runs until the deadline, ensuring that items that come later in the slot, up until the deadline, can be simulated and included in the block.
chore: properly break if we sleep until deadline