-
Notifications
You must be signed in to change notification settings - Fork 54
refactor: extract flashblock timing code and test it #380
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
e7f4fe1 to
98fe236
Compare
|
we can remove --flashblocks.build-at-interval-end --flashblocks.leeway-time and --flashblocks.fixed flags to simplify the logic |
| // lag=300-500ms: 3-4 flashblocks each | ||
| // lag=600-800ms: 2-3 flashblocks each | ||
| // Total = 42 flashblocks across all 9 blocks. | ||
| assert_eq!(42, flashblocks.len()); |
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.
What exactly changed that made the total flashblocks jump from 34 to 42?
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.
This old test used leeway_time to calculate the deadline and I think I ported the calculation using that field slightly incorrectly.
With the deprecation of leeway_time though I added the equivalent test using the end buffer: progressive_lag_reduces_flashblocks. It also has assertions for the number of flashblocks for each block so we'll be able to catch this kind of drift more precisely in the future.
98fe236 to
a0220d7
Compare
Done |
a0220d7 to
45d7222
Compare
| }; | ||
| } | ||
|
|
||
| // FLASHBLOCK TIMING SCENARIOS |
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.
could we keep this visualisation in the code or docs? I think its easier to understand when visualised like this
15a22f9 to
fec8153
Compare
fec8153 to
ab15ea4
Compare
ab15ea4 to
c2cb471
Compare
📝 Summary
Extracts flashblock timing logic from payload.rs into a dedicated timing.rs module. Consolidates duplicate timing calculation code paths into pure functions with clear branching.
Also precomputes the times at which we trigger flashblock builds. This allows for thorough unit testing and decouples the trigger loop from the timing calculations. So the tests don't need any kind of mocking or interaction with tokio.
In addition to all the unit tests for computing flashblock send times I also manually tested locally using builder playground.
This also deprecates the following flags
--flashblocks.fixed-- we only support dynamics timing calculations--flashblocks.build-at-interval-end-- always choose to build at the end--flashblocks.leeway-time-- only was used when building at the start💡 Motivation and Context
The flashblock timing code is currently tangled with less related code in payload.rs. There are also separate code paths for build_at_interval_end and fixed/dynamic mode, leading to duplicated logic. This PR addresses these quality concerns.
As we're working on making flashblocks more reliable, we need to have code clear, isolated, and testable enough so we can make changes quickly.
✅ I have completed the following steps:
make lintmake test