Skip to content

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

Merged
merged 8 commits into from
Jul 8, 2025

Conversation

Evalir
Copy link
Member

@Evalir Evalir commented Jul 4, 2025

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

@Evalir Evalir requested a review from a team as a code owner July 4, 2025 13:39
Copy link
Member Author

Evalir commented Jul 4, 2025

@Evalir Evalir force-pushed the evalir/make-sim-continous branch 2 times, most recently from 62da5ad to dbfc062 Compare July 4, 2025 15:06
@Evalir Evalir requested a review from prestwich July 7, 2025 18:17
Evalir added 5 commits July 7, 2025 20:17
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.
@Evalir Evalir changed the base branch from evalir/correct-ru-orders-address to graphite-base/86 July 7, 2025 18:17
@Evalir Evalir force-pushed the graphite-base/86 branch from 5362971 to 5d2495c Compare July 7, 2025 18:17
@Evalir Evalir force-pushed the evalir/make-sim-continous branch from dbfc062 to 00c4075 Compare July 7, 2025 18:17
@Evalir Evalir changed the base branch from graphite-base/86 to main July 7, 2025 18:17
@Evalir Evalir requested a review from prestwich July 7, 2025 18:23
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;
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh i like that

@Evalir Evalir merged commit 226b98c into main Jul 8, 2025
7 checks passed
@anna-carroll anna-carroll deleted the evalir/make-sim-continous branch July 16, 2025 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants