Uh oh!
There was an error while loading. Please reload this page.
refactor: try CN approach - #2812
Conversation
Claude finished @tac0turtle's task —— View job Comprehensive Code ReviewI've completed my analysis of this P2P synchronization refactoring PR. This is a significant simplification that removes the notifier pattern (~663 lines deleted) in favor of a more direct "CN approach" (likely coordination/notification). Overall, this is a cleaner architecture with some excellent improvements, but there are several areas that warrant attention. Todo List
1. Code Quality & ArchitectureStrengths ✅
Concerns |
The latest Buf updates on your PR. Results from workflow CI and Release / buf-check (pull_request).
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## marko/p2p_refactor #2812 +/- ##
======================================================
+ Coverage 64.33% 64.41% +0.08%
======================================================
Files 81 80 -1 Lines 7250 7147 -103 ======================================================
- Hits 4664 4604 -60 + Misses 2044 2007 -37 + Partials 542 536 -6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I generally prefer this over the notifer and current main. The simplification makes sense to me. |
alpe
left a comment
There was a problem hiding this comment.
Very nice work. Much cleaner code and easier to follow.
With the changes, I believe that we can reduce heightInCh size to save some memory.
The P2P loop can only move 1 message ahead of the consumer now.
| } | ||
| if waitCtx.Err() == nil { | ||
| logger.Warn().Err(err).Uint64("height", targetHeight).Msg("P2P handler failed to process height") |
There was a problem hiding this comment.
I would assume that we run into this quite often when the height is not available, yet. IMHO it is worth to ignore the not found error
There was a problem hiding this comment.
if a height it not available then we block on waiting for it. should not get hit unless we have a different issue.
| s.p2pWaitMu.Lock() | ||
| defer s.p2pWaitMu.Unlock() | ||
| if s.p2pWaitState.cancel != nil && (height == 0 || s.p2pWaitState.height == height) { |
There was a problem hiding this comment.
IMHO it would be safe to cancel p2pWaitState.height <= height, just in case p2p is falling behind
| func (s *Syncer) clearP2PWaitState(height uint64) { | ||
| s.p2pWaitMu.Lock() | ||
| if s.p2pWaitState.height == height { |
There was a problem hiding this comment.
Just wondering, is the height important? There should not be concurrent calls
| err = s.p2pHandler.ProcessHeight(waitCtx, targetHeight, s.heightInCh) | ||
| s.clearP2PWaitState(targetHeight) | ||
| cancel() |
There was a problem hiding this comment.
personal preference: cancelP2PWait could be used to clear the state
| } | ||
| // Cancel any P2P wait that might still be blocked on this height | ||
| s.cancelP2PWait(height) |
There was a problem hiding this comment.
Would it also make sense to cancel in the error case? We have the block in the cache now. 🤔 But the p2p handler height was not updated so it would return the block again
Uh oh!
There was an error while loading. Please reload this page.
Overview