-
Notifications
You must be signed in to change notification settings - Fork 246
feat: p2p exchange wrapper #2855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest Buf updates on your PR. Results from workflow CI / buf-check (pull_request).
|
|
Claude finished @tac0turtle's task in 2m 1s —— View job Comprehensive Code ReviewI've completed a detailed review of the P2P exchange wrapper implementation. Overall, this is a solid architectural improvement that addresses the missing blocks issue by checking the DA store before making network requests. Below are my findings organized by category: Architecture & Design ⭐Strengths:
Concerns:
Error Handling & ResilienceStrengths:
Concerns:
Concurrency & PerformanceStrengths:
Concerns:
Testing CoverageStrengths:
Concerns:
Code Quality & Go IdiomsStrengths:
Concerns:
Security ConsiderationsStrengths:
Concerns:
Documentation & Developer ExperienceConcerns:
Response to Review CommentsAddressing julienrbrt's review comments:
Specific File Issuespkg/sync/sync_service.go:164-175
pkg/sync/sync_service.go:319-325
pkg/sync/sync_service.go:356-387
Recommendations SummaryMust Fix (High Priority):
Should Fix (Medium Priority): Nice to Have (Low Priority): VerdictThis PR provides a solid architectural improvement with a clean wrapper pattern. The main concerns are:
The implementation is production-ready after addressing the error handling and observability concerns. The test coverage gaps are concerning given codecov shows 14 uncovered lines. Suggested Action: Address the high-priority issues (error logging, context handling, tests) before merging, and file follow-up issues for the medium-priority improvements. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2855 +/- ##
==========================================
- Coverage 65.94% 63.27% -2.68%
==========================================
Files 87 91 +4
Lines 7990 8544 +554
==========================================
+ Hits 5269 5406 +137
- Misses 2147 2553 +406
- Partials 574 585 +11
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:
|
|
|
||
| func (ew *exchangeWrapper[H]) Get(ctx context.Context, hash header.Hash) (H, error) { | ||
| // Check DA store first | ||
| if ew.daStore != nil && ew.getter != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't you by default pass daStore to constructor of exchangeWrapper for all node types? If so, you can assume it exists and don't need to nest this call
Although exchangeWrapper start should ensure that DA datastore is started (so that get calls won't fail)
| type storeGetter[H header.Header[H]] func(context.Context, store.Store, header.Hash) (H, error) | ||
| type storeGetterByHeight[H header.Header[H]] func(context.Context, store.Store, uint64) (H, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't you just define these as functions that don't take the store, and just pass the function itself into the constructor so u don't need to store DA ds on the exchangeWrapper?
| return ew.p2pExchange.Head(ctx, opts...) | ||
| } | ||
|
|
||
| func (ew *exchangeWrapper[H]) GetRangeByHeight(ctx context.Context, from H, to uint64) ([]H, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to actually implement this method w/ the p2p as a fallback system bc this is the method called by syncer.
So here, check da store + pull out whatever contiguous range it has + request remainder from network (if there is remainder)
| dsStore ds.Batching, | ||
| daStore store.Store, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confusing naming here, hard to follow which is which
| logger zerolog.Logger, | ||
| ) (*DataSyncService, error) { | ||
| return newSyncService[*types.Data](store, dataSync, conf, genesis, p2p, logger) | ||
| getter := func(ctx context.Context, s store.Store, hash header.Hash) (*types.Data, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exactly, just pass in these functions (pref named better) to the constructor and no need to pass the DA ds
Overview
This pr was an idea from @renaynay in which we create an exchange wrapper so that the exchange can check our store before making public requests for data. This would help the edge case i ran into today where the p2p store was missing 40 blocks randomly