fix: skip tipset if it's part of current chain in chain follower#7019
fix: skip tipset if it's part of current chain in chain follower#7019hanabi1224 merged 1 commit intomainfrom
Conversation
WalkthroughThis PR optimizes chain synchronization by adding an early-exit check to ChangesChain Follower Duplicate Tipset Avoidance
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/chain_sync/chain_follower.rs (1)
701-709: ⚡ Quick winReuse the existing
heaviestsnapshot in this guard.Line 704 fetches head again even though
heaviestwas already read at Line 688. Reusing it avoids mixed-head decisions and an extra lookup.Suggested diff
- if let Ok(Some(ts)) = self.cs.chain_index().tipset_by_height( + if let Ok(Some(ts)) = self.cs.chain_index().tipset_by_height( tipset.epoch(), - self.cs.heaviest_tipset(), + heaviest.clone(), ResolveNullTipset::TakeOlder, ) && ts.key() == tipset.key() { return; }🤖 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/chain_follower.rs` around lines 701 - 709, The guard is re-fetching the current head instead of reusing the previously read `heaviest` snapshot, which can cause mixed-head decisions and an extra lookup; change the call to `self.cs.chain_index().tipset_by_height(..., self.cs.heaviest_tipset(), ...)` to pass the existing `heaviest` variable (the one read at line 688) into `self.cs.chain_index().tipset_by_height(tipset.epoch(), heaviest, ResolveNullTipset::TakeOlder)` so the comparison `ts.key() == tipset.key()` uses a consistent snapshot.
🤖 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/chain_follower.rs`:
- Around line 701-709: The guard is re-fetching the current head instead of
reusing the previously read `heaviest` snapshot, which can cause mixed-head
decisions and an extra lookup; change the call to
`self.cs.chain_index().tipset_by_height(..., self.cs.heaviest_tipset(), ...)` to
pass the existing `heaviest` variable (the one read at line 688) into
`self.cs.chain_index().tipset_by_height(tipset.epoch(), heaviest,
ResolveNullTipset::TakeOlder)` so the comparison `ts.key() == tipset.key()` uses
a consistent snapshot.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8f23e39d-42bb-4aff-a9d8-f01124f67f54
📒 Files selected for processing (1)
src/chain_sync/chain_follower.rs
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 Sentry.
🚀 New features to boost your workflow:
|
Summary of changes
Changes introduced in this pull request:
Reference issue to close (if applicable)
Closes
Other information and links
Change checklist
Outside contributions
Summary by CodeRabbit