Skip to content

refactor: move LatestBlockInner into core to be able to expose subscribe in LatestBlockProvider trait#1405

Open
taco-paco wants to merge 1 commit into
masterfrom
feat/move-latest-block-inner
Open

refactor: move LatestBlockInner into core to be able to expose subscribe in LatestBlockProvider trait#1405
taco-paco wants to merge 1 commit into
masterfrom
feat/move-latest-block-inner

Conversation

@taco-paco

@taco-paco taco-paco commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

…ibe method in LatestBlockProvider

Summary

Committor service needs an ability to implement SlotTimer, the easiest way is to implement using broadcast::Receiver<Slot> return by subscribe in LatestBlock.

To expose this method in LatestBlockProvider trait we have to move LatestBlockInner in magicblock-core

Breaking Changes

  • None
  • Yes — migration path described below

Test Plan

Summary by CodeRabbit

  • New Features

    • Introduced a shared block snapshot type and subscription support so components can receive the latest block updates consistently.
  • Refactor

    • Consolidated block-related imports across the codebase to use a single source of truth.
    • Updated block handling to use the shared type throughout core, ledger, processor, and tests.
  • Bug Fixes

    • Improved consistency around block metadata and update delivery.

@taco-paco taco-paco requested review from bmuddha and thlorenz July 9, 2026 06:06
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a LatestBlockInner struct with a new constructor to magicblock-core::link::blocks, and extends the LatestBlockProvider trait with a subscribe method returning a broadcast::Receiver<LatestBlockInner>. Removes the equivalent local struct and constructor from magicblock-ledger, implementing subscribe on LatestBlock instead. Updates import paths across magicblock-ledger, magicblock-processor, magicblock-aperture, test-kit, and related tests to reference LatestBlockInner from magicblock-core. Enables the agave-unstable-api feature for solana-account-decoder and solana-transaction-status-client-types in magicblock-core/Cargo.toml.

Suggested reviewers: GabrielePicco, lucacillario

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/move-latest-block-inner

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@magicblock-core/src/traits.rs`:
- Line 33: The new `subscribe` requirement on the public `LatestBlockProvider`
trait is a breaking API change for downstream implementors. Update the
`LatestBlockProvider` trait in `traits.rs` so `subscribe` has a default
implementation or is otherwise optional, and adjust any related implementations
of `subscribe`/`LatestBlockProvider` to preserve backward compatibility unless
you intend to version this as a breaking change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ec642033-d533-4d7f-969d-b0b463e752c9

📥 Commits

Reviewing files that changed from the base of the PR and between 5f5926e and 950332e.

📒 Files selected for processing (14)
  • magicblock-aperture/src/geyser.rs
  • magicblock-aperture/src/processor.rs
  • magicblock-aperture/src/state/blocks.rs
  • magicblock-core/Cargo.toml
  • magicblock-core/src/link/blocks.rs
  • magicblock-core/src/traits.rs
  • magicblock-ledger/src/blockstore_processor/mod.rs
  • magicblock-ledger/src/lib.rs
  • magicblock-ledger/src/store/api.rs
  • magicblock-ledger/tests/get_block.rs
  • magicblock-ledger/tests/test_ledger_truncator.rs
  • magicblock-processor/src/executor/mod.rs
  • magicblock-processor/src/scheduler/mod.rs
  • test-kit/src/lib.rs

fn slot(&self) -> Slot;
fn blockhash(&self) -> Hash;
fn clock(&self) -> Clock;
fn subscribe(&self) -> broadcast::Receiver<LatestBlockInner>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Find all implementors of LatestBlockProvider across the codebase.

rg -nP --type=rust -C3 'impl\s+LatestBlockProvider\s+for' .

Repository: magicblock-labs/magicblock-validator

Length of output: 529


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== traits.rs =="
cat -n magicblock-core/src/traits.rs | sed -n '1,120p'

echo
echo "== LatestBlockProvider implementors =="
rg -nP --type=rust -C3 'impl\s+LatestBlockProvider\s+for' .

echo
echo "== trait visibility / exports =="
rg -nP --type=rust -C2 'pub\s+trait\s+LatestBlockProvider|pub\s+use\s+.*LatestBlockProvider' magicblock-core magicblock-ledger

Repository: magicblock-labs/magicblock-validator

Length of output: 5055


Adding subscribe breaks the public trait API
LatestBlockProvider is public, and this new required method will break downstream implementors at compile time. Add a default implementation or treat this as a breaking change.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@magicblock-core/src/traits.rs` at line 33, The new `subscribe` requirement on
the public `LatestBlockProvider` trait is a breaking API change for downstream
implementors. Update the `LatestBlockProvider` trait in `traits.rs` so
`subscribe` has a default implementation or is otherwise optional, and adjust
any related implementations of `subscribe`/`LatestBlockProvider` to preserve
backward compatibility unless you intend to version this as a breaking change.

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.

1 participant