Skip to content

ledger: Require leader schedules to be repeat-aligned#10047

Merged
vadorovsky merged 1 commit into
anza-xyz:masterfrom
vadorovsky:validate-epoch-slots
Jan 16, 2026
Merged

ledger: Require leader schedules to be repeat-aligned#10047
vadorovsky merged 1 commit into
anza-xyz:masterfrom
vadorovsky:validate-epoch-slots

Conversation

@vadorovsky
Copy link
Copy Markdown
Member

Problem

Tests were constructing schedules with repeat > 1 but feeding arrays whose length wasn’t a multiple of repeat, so some leaders never repeated the expected number of times. That inconsistency also blocks follow-up work on optimizing the schedule calculation (see #9126).

Summary of Changes

Add a debug assert that the schedule length is divisible by repeat, and fix the tests to generate properly aligned schedules.

Change TEST_SLOTS_PER_EPOCH in rpc from 129 (an incorrect, unaligned value) to 256, which stays above the delinquent-slot threshold while keeping the tests fast.

Ref: #8280

@mergify
Copy link
Copy Markdown

mergify Bot commented Jan 15, 2026

If this PR represents a change to the public RPC API:

  1. Make sure it includes a complementary update to rpc-client/ (example)
  2. Open a follow-up PR to update the JavaScript client @solana/kit (example)

Thank you for keeping the RPC clients in sync with the server API @vadorovsky.

@@ -192,7 +196,6 @@ mod tests {
#[test_case(457470, &[10, 20, 30], 12, 1, &[2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 2])]
#[test_case(3466545, &[10, 20, 30], 12, 1, &[2, 2, 0, 0, 2, 1, 1, 1, 0, 0, 2, 2])]
#[test_case(3466545, &[10, 20, 30], 13, 1, &[2, 2, 0, 0, 2, 1, 1, 1, 0, 0, 2, 2, 1])]
#[test_case(3466545, &[10, 20, 30], 13, 2, &[2, 2, 2, 2, 0, 0, 0, 0, 2, 2, 1, 1, 1])]
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This test case makes no sense - the last 1 is repeated 3 times and the whole thing is not divisible by 2. Given that there are many other cases which are correct, I'm just removing it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The test case was supposed to test exactly the scenario you are forbidding - using len that is not a multiple of repeat. I agree though, that is impractical "feature", so should be fine to remove.

Comment thread rpc/src/rpc.rs
@@ -4608,7 +4608,7 @@ pub mod tests {

const TEST_MINT_LAMPORTS: u64 = 1_000_000_000;
const TEST_SIGNATURE_FEE: u64 = 5_000;
const TEST_SLOTS_PER_EPOCH: u64 = DELINQUENT_VALIDATOR_SLOT_DISTANCE + 1;
const TEST_SLOTS_PER_EPOCH: u64 = 256;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Happy to change it to some other value if anyone has strong feelings. What I know for sure is that using the validator's default (432_000) would make the tests running multiple minutes each.

Tests were constructing schedules with `repeat > 1` but feeding arrays
whose length wasn’t a multiple of `repeat`, so some leaders never
repeated the expected number of times. That inconsistency also blocks
follow-up work on optimizing the schedule calculation (see
anza-xyz#9126).

Add a debug assert that the schedule length is divisible by `repeat`,
and fix the tests to generate properly aligned schedules.

Change `TEST_SLOTS_PER_EPOCH` in rpc from 129 (an incorrect, unaligned
value) to 256, which stays above the delinquent-slot threshold while
keeping the tests fast.

Ref: anza-xyz#8280
@vadorovsky vadorovsky force-pushed the validate-epoch-slots branch from dfdfbd2 to a77055a Compare January 15, 2026 14:35
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 15, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.6%. Comparing base (bd0b3d3) to head (a77055a).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##           master   #10047     +/-   ##
=========================================
- Coverage    82.6%    82.6%   -0.1%     
=========================================
  Files         844      844             
  Lines      316630   316633      +3     
=========================================
- Hits       261595   261593      -2     
- Misses      55035    55040      +5     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vadorovsky vadorovsky marked this pull request as ready for review January 15, 2026 15:14
Copy link
Copy Markdown

@kskalski kskalski left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -192,7 +196,6 @@ mod tests {
#[test_case(457470, &[10, 20, 30], 12, 1, &[2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 2])]
#[test_case(3466545, &[10, 20, 30], 12, 1, &[2, 2, 0, 0, 2, 1, 1, 1, 0, 0, 2, 2])]
#[test_case(3466545, &[10, 20, 30], 13, 1, &[2, 2, 0, 0, 2, 1, 1, 1, 0, 0, 2, 2, 1])]
#[test_case(3466545, &[10, 20, 30], 13, 2, &[2, 2, 2, 2, 0, 0, 0, 0, 2, 2, 1, 1, 1])]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The test case was supposed to test exactly the scenario you are forbidding - using len that is not a multiple of repeat. I agree though, that is impractical "feature", so should be fine to remove.

Copy link
Copy Markdown

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

Looks good to me too. I'll defer final approval to @jstarry.

@vadorovsky vadorovsky added this pull request to the merge queue Jan 16, 2026
Merged via the queue into anza-xyz:master with commit 4f5928e Jan 16, 2026
47 checks passed
@vadorovsky vadorovsky deleted the validate-epoch-slots branch January 16, 2026 16:00
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.

5 participants