Skip to content

v2.3: fix: enable on-demand leader schedule computation in get_slot_leaders (backport of #7765)#7798

Closed
mergify[bot] wants to merge 1 commit intov2.3from
mergify/bp/v2.3/pr-7765
Closed

v2.3: fix: enable on-demand leader schedule computation in get_slot_leaders (backport of #7765)#7798
mergify[bot] wants to merge 1 commit intov2.3from
mergify/bp/v2.3/pr-7765

Conversation

@mergify
Copy link
Copy Markdown

@mergify mergify Bot commented Aug 29, 2025

Fix get_slot_leaders epoch transition failures

Problem

get_slot_leaders RPC was failing with "Invalid slot range: leader schedule for epoch X is unavailable" for approximately 31 slots during every epoch transition. This occurred because:

  • get_slot_leaders only checked leader_schedule_cache.get_epoch_leader_schedule(epoch)
  • During epoch transitions, the new epoch's leader schedule isn't cached until the first slot of that epoch is rooted
  • This created a ~31 slot window where valid requests would fail
  • Caused network spam as clients sent transactions to wrong leaders during transitions

Solution

  • Add fallback to leader_schedule_utils::leader_schedule() on cache miss
  • Enables on-demand computation when bank has stake information available
  • Preserves all existing behavior and error handling
  • No performance impact for cached schedules

Closes #6845 , can you pls check. @KirillLykov


This is an automatic backport of pull request #7765 done by [Mergify](https://mergify.com).

…#7765)

get_slot_leaders RPC was failing with "Invalid slot range: leader schedule for epoch X is unavailable" for approximately 31 slots during every epoch transition. This PR fixes it by doing the following:
* Add fallback to leader_schedule_utils::leader_schedule() on cache miss
* Enables on-demand computation when bank has stake information available
* Preserves all existing behavior and error handling
* No performance impact for cached schedules

(cherry picked from commit ce1e9b3)
@mergify mergify Bot requested a review from a team as a code owner August 29, 2025 15:57
@mergify
Copy link
Copy Markdown
Author

mergify Bot commented Aug 29, 2025

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 @mergify[bot].

@KirillLykov
Copy link
Copy Markdown

KirillLykov commented Aug 29, 2025

To address why I think it worth backporting -- because this long existing bug breaks leader targeting for clients using ConnectionCache (or tpu-client-next with default leader targeting) after the epoch change.

@KirillLykov
Copy link
Copy Markdown

lets backport it only on 3.0

@KirillLykov KirillLykov closed this Sep 3, 2025
@yihau yihau deleted the mergify/bp/v2.3/pr-7765 branch December 5, 2025 12: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.

2 participants