fix: prevent invalid header response routing#439
Conversation
After a `Segment` reaches its checkpoint, its `current_tip_hash` equals the next segment's `start_hash`. Since segments are iterated in order, the completed segment matches first and consumes responses meant for the next segment, buffering headers past its target height. This advanced the storage tip beyond the next segment's start, causing a validation failure and the header sync getting stuck. Skip completed non-tip segments when routing incoming headers, and reject headers in `receive_headers()` if the segment is already complete.
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughThe changes add logic to prevent header routing to completed non-tip segments and reset tip segments in post-sync scenarios. A field visibility change allows parent module access to Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
After a
Segmentreaches its checkpoint, itscurrent_tip_hashequals the next segment'sstart_hash. Since segments are iterated in order, the completed segment matches first and consumes responses meant for the next segment, buffering headers past its target height. This advanced the storage tip beyond the next segment's start, causing a validation failure and the header sync getting stuck.Skip completed non-tip segments when routing incoming headers, and reject headers in
receive_headers()if the segment is already complete.Summary by CodeRabbit
Improvements
Tests