refactor: move LatestBlockInner into core to be able to expose subscribe in LatestBlockProvider trait#1405
refactor: move LatestBlockInner into core to be able to expose subscribe in LatestBlockProvider trait#1405taco-paco wants to merge 1 commit into
Conversation
…ibe method in LatestBlockProvider
📝 WalkthroughWalkthroughAdds a Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (14)
magicblock-aperture/src/geyser.rsmagicblock-aperture/src/processor.rsmagicblock-aperture/src/state/blocks.rsmagicblock-core/Cargo.tomlmagicblock-core/src/link/blocks.rsmagicblock-core/src/traits.rsmagicblock-ledger/src/blockstore_processor/mod.rsmagicblock-ledger/src/lib.rsmagicblock-ledger/src/store/api.rsmagicblock-ledger/tests/get_block.rsmagicblock-ledger/tests/test_ledger_truncator.rsmagicblock-processor/src/executor/mod.rsmagicblock-processor/src/scheduler/mod.rstest-kit/src/lib.rs
| fn slot(&self) -> Slot; | ||
| fn blockhash(&self) -> Hash; | ||
| fn clock(&self) -> Clock; | ||
| fn subscribe(&self) -> broadcast::Receiver<LatestBlockInner>; |
There was a problem hiding this comment.
📐 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-ledgerRepository: 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.
…ibe method in LatestBlockProvider
Summary
Committor service needs an ability to implement SlotTimer, the easiest way is to implement using
broadcast::Receiver<Slot>return bysubscribeinLatestBlock.To expose this method in LatestBlockProvider trait we have to move LatestBlockInner in
magicblock-coreBreaking Changes
Test Plan
Summary by CodeRabbit
New Features
Refactor
Bug Fixes