-
Notifications
You must be signed in to change notification settings - Fork 111
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
feat(dot/network): Add warp sync request handler #4186
base: development
Are you sure you want to change the base?
Conversation
99bf75a
to
a7e03f7
Compare
0e840fc
to
592876a
Compare
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.
LGTM
@@ -66,6 +66,7 @@ type Config struct { | |||
// Service interfaces | |||
BlockState BlockState | |||
Syncer Syncer | |||
warpSyncProvider WarpSyncProvider |
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.
This will probably need to be public right?
} | ||
|
||
// Decode decodes the message into a WarpProofRequest | ||
func (wsr *WarpProofRequest) Decode(in []byte) 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.
func (wsr *WarpProofRequest) Decode(in []byte) error { | |
func (wpr *WarpProofRequest) Decode(in []byte) error { |
same for below receivers
// Encode encodes the warp sync request | ||
func (wsr *WarpProofRequest) Encode() ([]byte, error) { | ||
buffer := bytes.NewBuffer(nil) | ||
encoder := scale.NewEncoder(buffer) |
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.
For both encoding and decoding here, do we need to create the encoder/decoder object? Can we not just call scale.Marshal and scale.Unmarshal?
stream.Conn().RemotePeer(), | ||
resp, | ||
) | ||
} |
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.
Should we add a log or something for the !ok case?
|
||
// Test encoding | ||
reqEnc, err := testWarpReqMessage.Encode() | ||
require.NoError(t, err) |
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.
Are there any tests in substrate with hardcoded bytes that we could use here? We have run into a problem before in serialization tests where we can encode and decode to an expected type, but the actual byte representation is incorrect.
However giving how simple this is, probably is not the end of the world. I just wanted to make a note of this
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.
Small questions/comments, but overall great work and LGTM!
Changes
Adds warp sync request handler.
/sync/warp
This implementation is slightly different from the one proposed in #4052, but I think it's more straightforward and less complex, which will help us achieve a quick warp sync implementation. We can discuss or revisit this later.
Tests
go test ./dot/network
Issues
closing: #4052