-
Notifications
You must be signed in to change notification settings - Fork 245
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 4s —— View job Code Review CompleteI've completed a comprehensive code review of the P2P exchange wrapper implementation. Here are my findings: Critical Issues1. Incomplete Implementation of
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2855 +/- ##
==========================================
- Coverage 57.88% 57.78% -0.11%
==========================================
Files 97 98 +1
Lines 9306 9344 +38
==========================================
+ Hits 5387 5399 +12
- Misses 3315 3339 +24
- Partials 604 606 +2
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