Skip to content

alpamayo: fix get_blocks to respect end_slot boundary#99

Merged
fanatid merged 4 commits intomasterfrom
fix-get-blocks
Feb 3, 2026
Merged

alpamayo: fix get_blocks to respect end_slot boundary#99
fanatid merged 4 commits intomasterfrom
fix-get-blocks

Conversation

@fanatid
Copy link
Member

@fanatid fanatid commented Feb 3, 2026

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in the get_blocks function where it wasn't respecting the end_slot boundary parameter, along with several refactoring improvements and a rustls crypto provider setup.

Changes:

  • Fixed get_blocks to check block.slot > end_slot to prevent returning blocks beyond the confirmed/finalized boundary
  • Refactored tokio::select! branches to use guard conditions instead of pending() futures
  • Replaced .boxed_local() with Box::pin() for future boxing
  • Added rustls crypto provider initialization at startup

Reviewed changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/storage/blocks.rs Adds end_slot boundary check and refactors dead block handling in get_blocks loop
src/storage/read.rs Refactors tokio::select! to use guard conditions, removes pending import
src/storage/files.rs Replaces .boxed_local() with Box::pin(), removes FutureExt import
src/bin/alpamayo.rs Adds rustls crypto provider initialization
Cargo.toml Adds rustls dependency, bumps version to 0.18.1
Cargo.lock Updates version and dependencies
CHANGELOG.md Documents the fix in version 0.18.1

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +357 to 361
if let RpcRequestBlocksUntil::Limit(limit) = until
&& blocks.len() == limit
{
break;
}
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The limit check only handles RpcRequestBlocksUntil::Limit but doesn't handle RpcRequestBlocksUntil::EndSlot. The old code checked for both cases - when until was EndSlot(end_slot) it would break when end_slot == block.slot. Without this check, the function will continue iterating past the requested end slot when until is EndSlot with a value less than the end_slot parameter. This could return more blocks than requested or loop unnecessarily.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

@fanatid fanatid Feb 3, 2026

Choose a reason for hiding this comment

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

@copilot this check was moved, line 354

Copy link

Copilot AI commented Feb 3, 2026

@fanatid I've opened a new pull request, #100, to work on those changes. Once the pull request is ready, I'll request review from you.

@fanatid fanatid merged commit 1e4bce9 into master Feb 3, 2026
8 checks passed
@fanatid fanatid deleted the fix-get-blocks branch February 3, 2026 09:31
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