-
Notifications
You must be signed in to change notification settings - Fork 149
Split storage sync P2P protocol #6262
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
Changes from all commits
28979a5
916410a
f5fe8ac
57ff38b
d2f53ce
96be6bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| go: Split storage sync p2p protocol | ||
|
|
||
| Storage sync protocol was split into two independent protocols (checkpoint | ||
| and diff sync). | ||
|
|
||
| This change was made since there may be fewer nodes that expose checkpoints | ||
| than storage diff. Previously, this could lead to issues with state sync | ||
| when a node was connected with peers that supported storage sync protocol | ||
| but had no checkpoints available. | ||
|
|
||
| This was done in backwards compatible manner, so that both protocols are still | ||
| advertised and used. Eventually, we plan to remove legacy protocol. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -269,8 +269,8 @@ type Client interface { | |
| } | ||
|
|
||
| type client struct { | ||
| host core.Host | ||
| protocolID protocol.ID | ||
| host core.Host | ||
| protocolIDs []protocol.ID | ||
|
|
||
| listeners struct { | ||
| sync.RWMutex | ||
|
|
@@ -486,7 +486,7 @@ func (c *client) call( | |
| stream, err := c.host.NewStream( | ||
| ctx, | ||
| peerID, | ||
| c.protocolID, | ||
| c.protocolIDs..., | ||
| ) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to open stream: %w", err) | ||
|
|
@@ -612,15 +612,15 @@ func retryFn(ctx context.Context, fn func() error, maxRetries uint64, retryInter | |
| } | ||
|
|
||
| // NewClient creates a new RPC client for the given protocol. | ||
| func NewClient(h host.Host, p protocol.ID) Client { | ||
| func NewClient(h host.Host, p protocol.ID, fallback ...protocol.ID) Client { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you need to accept
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this just syntactic sugar for slice? The main problem as you point out is that interface does not promise order. In practice, implementation favors protocols from left to right. Ideally, we should not rely on this. If we had many methods as part of our protocol likely this would be the only sensible approach. But we don't, so maybe we can make it simpler. |
||
| if h == nil { | ||
| // No P2P service, use the no-op client. | ||
| return &nopClient{} | ||
| } | ||
|
|
||
| return &client{ | ||
| host: h, | ||
| protocolID: p, | ||
| host: h, | ||
| protocolIDs: append([]protocol.ID{p}, fallback...), | ||
| listeners: struct { | ||
| sync.RWMutex | ||
| m map[ClientListener]struct{} | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.