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

Add validation at the beginning of func:RandomSamplingWithPriority #496

Merged

Conversation

Mdaiki0730
Copy link
Member

Description

I think we need adding independent input validation of the parameters at the beginning of the function RandomSamplingWithPriority() instead of relying on the selection algorithm to validate them.

PR Check List

  • Is this enough for validate type?
  • Won't it cause a predictable critical panic?

@Mdaiki0730 Mdaiki0730 added the C: enhancement Classification: New feature or its request, or improvement in maintainability of code label Nov 11, 2022
@Mdaiki0730 Mdaiki0730 self-assigned this Nov 11, 2022
@codecov
Copy link

codecov bot commented Nov 11, 2022

Codecov Report

Merging #496 (50dfb9a) into main (a2effec) will decrease coverage by 0.08%.
The diff coverage is 89.65%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #496      +/-   ##
==========================================
- Coverage   65.53%   65.44%   -0.09%     
==========================================
  Files         278      278              
  Lines       37916    37936      +20     
==========================================
- Hits        24847    24828      -19     
- Misses      11264    11295      +31     
- Partials     1805     1813       +8     
Impacted Files Coverage Δ
libs/rand/sampling.go 95.23% <89.65%> (-4.77%) ⬇️
crypto/sr25519/pubkey.go 35.89% <0.00%> (-7.70%) ⬇️
libs/events/events.go 93.23% <0.00%> (-5.27%) ⬇️
privval/signer_endpoint.go 72.52% <0.00%> (-4.40%) ⬇️
types/tx.go 90.24% <0.00%> (-3.66%) ⬇️
blockchain/v0/pool.go 81.13% <0.00%> (-3.36%) ⬇️
statesync/snapshots.go 93.71% <0.00%> (-1.26%) ⬇️
mempool/reactor.go 78.57% <0.00%> (-1.10%) ⬇️
types/voter_set.go 84.77% <0.00%> (-0.85%) ⬇️
p2p/conn/connection.go 79.80% <0.00%> (-0.58%) ⬇️
... and 10 more

@Mdaiki0730 Mdaiki0730 marked this pull request as ready for review November 11, 2022 08:26
@ulbqb ulbqb self-requested a review November 11, 2022 08:31
libs/rand/sampling.go Outdated Show resolved Hide resolved
libs/rand/sampling.go Outdated Show resolved Hide resolved
Copy link
Member

@ulbqb ulbqb left a comment

Choose a reason for hiding this comment

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

What about simple error messages?

libs/rand/sampling.go Outdated Show resolved Hide resolved
libs/rand/sampling.go Outdated Show resolved Hide resolved
tnasu
tnasu previously approved these changes Nov 11, 2022
@Mdaiki0730
Copy link
Member Author

@ulbqb
Thank you for your suggestion. I just translated it directly into English, so I'll reflect your simpler comment.

@Mdaiki0730 Mdaiki0730 merged commit 0681636 into Finschia:main Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: enhancement Classification: New feature or its request, or improvement in maintainability of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants