fix: integrate EC finality into chain follower#7171
Conversation
WalkthroughThe PR integrates the EC finality calculator into block validation and chain synchronization workflows. The error type is updated to carry both epochs; the validator API is simplified to accept a single finalized_epoch; and the chain follower is wired to use ec_calculator_finalized_epoch() for pre-fetch validation and finality-window rejection logic. ChangesEC Finality Calculator Integration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
1c77904 to
35a58f5
Compare
35a58f5 to
bd7e7b7
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/chain_sync/validation.rs (1)
511-517: ⚡ Quick winPin the finalized-epoch boundary in this test.
This only proves the
epoch < finalized_epochpath and ignores the new payload fields. Matching the concrete{ epoch, finalized_epoch }values and adding anepoch == finalized_epochcase would lock down the off-by-one contract this PR introduces.🤖 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 `@src/chain_sync/validation.rs` around lines 511 - 517, The test currently only asserts that validate_pre_fetch returns GossipBlockRejectReason::EpochBeyondFinality but doesn't assert the concrete epoch/finalized_epoch values nor test the boundary case; update the test that calls GossipBlockValidator::new(&block).validate_pre_fetch(&genesis, 30, 100, None, &seen).unwrap_err() to assert the concrete GossipBlockRejectReason::EpochBeyondFinality { epoch: X, finalized_epoch: Y } values (pin the finalized_epoch boundary) and add an additional assertion or separate case where epoch == finalized_epoch to ensure the off-by-one behavior is locked down (use the same functions/structs: GossipBlockValidator, validate_pre_fetch, and GossipBlockRejectReason).
🤖 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.
Nitpick comments:
In `@src/chain_sync/validation.rs`:
- Around line 511-517: The test currently only asserts that validate_pre_fetch
returns GossipBlockRejectReason::EpochBeyondFinality but doesn't assert the
concrete epoch/finalized_epoch values nor test the boundary case; update the
test that calls GossipBlockValidator::new(&block).validate_pre_fetch(&genesis,
30, 100, None, &seen).unwrap_err() to assert the concrete
GossipBlockRejectReason::EpochBeyondFinality { epoch: X, finalized_epoch: Y }
values (pin the finalized_epoch boundary) and add an additional assertion or
separate case where epoch == finalized_epoch to ensure the off-by-one behavior
is locked down (use the same functions/structs: GossipBlockValidator,
validate_pre_fetch, and GossipBlockRejectReason).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: ad26f426-9f02-468b-82a0-3902cb6464a0
📒 Files selected for processing (2)
src/chain_sync/chain_follower.rssrc/chain_sync/validation.rs
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
filecoin-project/lotus(manual)
Codecov Report❌ Patch coverage is
Additional details and impacted files
... and 8 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
Summary of changes
Changes introduced in this pull request:
Reference issue to close (if applicable)
Closes #7170
Other information and links
Change checklist
Outside contributions
Summary by CodeRabbit