-
Notifications
You must be signed in to change notification settings - Fork 215
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
[Merged by Bors] - feat: hare preround proposal compaction #6129
Closed
Closed
Changes from 13 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
afbea8d
chore: copy existing protocol into new
acud 3ad6a2d
feat: use shorter ids (eligibility proofs) for proposals
acud c6c3f44
chore: address pr comments
acud 598c46c
chore: housekeeping
acud d132d19
chore: address pr comments
acud c9aa9f5
Merge branch 'develop' of github.com:spacemeshos/go-spacemesh into ha…
acud 4da1875
fix build
acud 45745c7
chore: make gen
acud be7806b
chore: disable hare4
acud 823a4e5
chore: move panic
acud 3fcb975
chore: address pr comment
acud 77b5702
reinstate CommitteeUpgrade
acud f75c44c
test: remove compact function injection
acud 39efcec
remove mainnet fork
acud a61c7e8
Merge branch 'develop' of github.com:spacemeshos/go-spacemesh into ha…
acud 6a0d120
Update hare4/hare.go
acud 11d82a7
Update hare4/hare_test.go
acud 9b39e4b
fix build
acud 59fe1b1
lint
acud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
As above, can't we just encode
resp
into the stream instead of using an intermediate 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.
To do this one must know to which length the type is going to encode into without really encoding it (since you must encode how many bytes are in the response before actually writing them into the response). While it is possible, it's probably something that the scale package should offer instead of writing it by hand which would be fragile. Any ideas on how to do 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.
Why do you need to encode the length first?
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.
Because you need to know how many bytes to read out of the stream.
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.
AFAIR, the scale decoding would fail if the response had the wrong length anyway.
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.
well, while we could do smth like this in
go-scale
, it is not really fragile if the data are an array of fixed-size IDs.pls check how it's done in the
fetch
package, e.g. epoch stream handlergo-spacemesh/fetch/handler.go
Line 115 in 13dfb49
go-spacemesh/fetch/handler.go
Lines 140 to 185 in 13dfb49
and the client part
go-spacemesh/fetch/mesh_data.go
Line 275 in 13dfb49
go-spacemesh/fetch/mesh_data.go
Lines 461 to 481 in 13dfb49
The client part is not perfect b/c we could be handling each ID right away instead of waiting for the whole slice to be sent, but that would require further refactoring of the fetcher code; not sure whether it is applicable here.
Nevertheless, the server side can be improved here I think
Maybe we could move some helpers to the
codec
packageThere 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.
So the reason it is done this way is the following:
When you read a response from a peer you want to avoid a situation where you read a stream until an EOF - this is generally bad because you put yourself in the risk of having a malicious peer to just feed you data which is read all into memory, resulting in the node memory usage going through the roof.
That's why you want to know how long is the data in advance.
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.
@ivan4th the
server.ReadResponse
part implicitly reads therespLen
which encodes the whole message size in advance https://github.com/spacemeshos/go-spacemesh/blob/develop/p2p/server/server.go#L511Which is exactly what I'm doing here, except I don't want to use the leaky
server
abstraction because it does a bunch of things I'm not interested in.