Skip to content
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

fix(lib/scale): Handle eof in scale decoding. #1675

Closed
wants to merge 2 commits into from
Closed

Conversation

arijitAD
Copy link
Contributor

@arijitAD arijitAD commented Jul 5, 2021

Changes

  • Node crashed during adding authority nodes.
  • Handle eof in scale decoding.

Tests

TestDecodeNilPublicKey
TestDecodeNilVote

Issues

@arijitAD arijitAD changed the title Handle eof in scale decoding. fix(lib/scale): Handle eof in scale decoding. Jul 5, 2021
@codecov
Copy link

codecov bot commented Jul 5, 2021

Codecov Report

Merging #1675 (33e0a62) into development (028d25e) will increase coverage by 0.69%.
The diff coverage is 59.41%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #1675      +/-   ##
===============================================
+ Coverage        58.50%   59.19%   +0.69%     
===============================================
  Files              160      181      +21     
  Lines            15899    18501    +2602     
===============================================
+ Hits              9301    10952    +1651     
- Misses            4924     5638     +714     
- Partials          1674     1911     +237     
Flag Coverage Δ
unit-tests 59.19% <59.41%> (+0.69%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
cmd/gossamer/flags.go 57.14% <ø> (ø)
dot/network/transaction.go 46.34% <0.00%> (+2.43%) ⬆️
dot/rpc/modules/api_mocks.go 0.00% <0.00%> (ø)
dot/rpc/modules/state.go 81.66% <ø> (ø)
dot/state/bloom.go 0.00% <0.00%> (ø)
dot/state/offline_pruner.go 0.00% <0.00%> (ø)
dot/types/babe.go 48.38% <ø> (ø)
dot/types/digest.go 55.55% <0.00%> (-0.48%) ⬇️
dot/types/extrinsic.go 31.57% <0.00%> (-22.97%) ⬇️
dot/types/grandpa.go 9.52% <ø> (ø)
... and 185 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d36c3b7...33e0a62. Read the comment docs.

Comment on lines +74 to +76
if errors.Is(err, io.EOF) {
return b, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems wrong - if there's an EOF it's because there weren't enough bytes in the reader to create the public key, so there should be an error or else this will create an invalid public key

Copy link
Contributor

@noot noot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR will likely fix any EOF issues you encountered #1662

we shouldn't be ignoring the EOFs as it will result in invalid votes/public keys

@arijitAD
Copy link
Contributor Author

arijitAD commented Jul 7, 2021

we shouldn't be ignoring the EOFs as it will result in invalid votes/public keys

Yes, I agree that we should return the error. But the node was panicking due to incorrect data from another peer. We should handle these errors gracefully in such cases.

@noot
Copy link
Contributor

noot commented Jul 7, 2021

@arijitAD please update this to handle the error instead of ignoring, then should be good

@arijitAD arijitAD marked this pull request as draft July 28, 2021 12:46
@arijitAD
Copy link
Contributor Author

arijitAD commented Aug 3, 2021

No longer seeing this issue.

@arijitAD arijitAD closed this Aug 3, 2021
@noot noot deleted the handle-eof branch November 16, 2021 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants