Skip to content

Conversation

@akundaz
Copy link
Contributor

@akundaz akundaz commented Feb 10, 2026

📝 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:

  • Run make lint
  • Run make test
  • Added tests (if applicable)

@akundaz akundaz self-assigned this Feb 10, 2026
@akundaz akundaz requested a review from julio4 February 10, 2026 22:36
@akundaz akundaz force-pushed the ash-ktzqwkozszqm branch 3 times, most recently from e7f4fe1 to 98fe236 Compare February 11, 2026 02:46
@avalonche
Copy link
Collaborator

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());
Copy link
Member

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?

Copy link
Contributor Author

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.

@akundaz
Copy link
Contributor Author

akundaz commented Feb 11, 2026

we can remove --flashblocks.build-at-interval-end --flashblocks.leeway-time and --flashblocks.fixed flags to simplify the logic

Done

};
}

// FLASHBLOCK TIMING SCENARIOS
Copy link
Collaborator

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

@avalonche avalonche enabled auto-merge (squash) February 12, 2026 00:46
@avalonche avalonche disabled auto-merge February 12, 2026 01:13
@avalonche avalonche merged commit 329be9a into main Feb 12, 2026
4 checks passed
@avalonche avalonche deleted the ash-ktzqwkozszqm branch February 12, 2026 01:13
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.

3 participants