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

FillDBWithParticipationKeys return object on error #3184

Conversation

algonautshant
Copy link
Contributor

Summary

enhance comment for Signer struct
fix ordering of imports in keystore_test
FillDBWithParticipationKeys return on error changes

Test Plan

enhance comment for Signer struct
fix ordering of imports in keystore_test
FillDBWithParticipationKeys return on error changes
@codecov-commenter
Copy link

codecov-commenter commented Nov 3, 2021

Codecov Report

Merging #3184 (c23ab54) into feature/dilithium-scheme-integration (ad2853a) will decrease coverage by 0.04%.
The diff coverage is 66.66%.

Impacted file tree graph

@@                           Coverage Diff                            @@
##           feature/dilithium-scheme-integration    #3184      +/-   ##
========================================================================
- Coverage                                 43.80%   43.76%   -0.05%     
========================================================================
  Files                                       403      403              
  Lines                                     89955    89954       -1     
========================================================================
- Hits                                      39405    39364      -41     
- Misses                                    44270    44299      +29     
- Partials                                   6280     6291      +11     
Impacted Files Coverage Δ
crypto/merklekeystore/keystore.go 76.92% <ø> (ø)
data/account/participation.go 59.00% <66.66%> (+1.57%) ⬆️
cmd/algoh/blockWatcher.go 77.77% <0.00%> (-3.18%) ⬇️
util/metrics/gauge.go 68.00% <0.00%> (-2.67%) ⬇️
util/metrics/counter.go 78.57% <0.00%> (-2.39%) ⬇️
crypto/merkletrie/trie.go 66.42% <0.00%> (-2.19%) ⬇️
ledger/acctupdates.go 62.87% <0.00%> (-1.99%) ⬇️
crypto/merkletrie/node.go 91.62% <0.00%> (-1.87%) ⬇️
catchup/peerSelector.go 98.42% <0.00%> (-1.58%) ⬇️
ledger/blockqueue.go 81.03% <0.00%> (-1.15%) ⬇️
... and 3 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 ad2853a...c23ab54. Read the comment docs.

if err != nil {
return PersistedParticipation{}, err
if err == nil {
err = stateProofSecrets.Persist() // must be called after part.Persist()
Copy link
Contributor

Choose a reason for hiding this comment

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

If Persist() function is not written well, you will return a PersistedParticipation struct which might be filled with wrong data. I think, In order to protect ourselves, we should return empty struct.

for the err value- this change is great.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The expectations should be that if error is returned, there are no guarantees on anything else returned (this was something I fixed on master).

When you say "protect ourselves", what are the risks? Maybe, we should make sure Persist is safe when it returns an error.

I have no problem with returning PersistedParticipation{} in case of an error. However, if there are risks with returning part, we need to understand that,

}

err = stateProofSecrets.Persist() // must be called after part.Persist() !

return part, err
Copy link
Contributor Author

@algonautshant algonautshant Nov 4, 2021

Choose a reason for hiding this comment

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

notice here, without my change, in the case of stateProofSecrets.Persist returning an error, it is still returning part with err not nil.
If we want to return PersistedParticipation{} in case of an error, we need to check err in two places. I think this will unnecessarily complicate the code.

Copy link
Contributor

@id-ms id-ms left a comment

Choose a reason for hiding this comment

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

looks good!

@tsachiherman
Copy link
Contributor

small request - when you're creating a pr, could you please try and give the PR a more informal title ?

@algonautshant algonautshant changed the title Tiny updates FillDBWithParticipationKeys return object on error Nov 8, 2021
@algonautshant algonautshant merged commit 76f9648 into algorand:feature/dilithium-scheme-integration Nov 9, 2021
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.

4 participants