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

Limit the longest validity period allowed for key registration to pre… #3181

Conversation

Aharonee
Copy link
Contributor

@Aharonee Aharonee commented Nov 3, 2021

…vent merklekeystore tree from being too big

Summary

Test Plan

@Aharonee Aharonee requested a review from id-ms November 3, 2021 12:55
@codecov-commenter
Copy link

codecov-commenter commented Nov 3, 2021

Codecov Report

Merging #3181 (eff1253) into feature/dilithium-scheme-integration (ea61ca0) will decrease coverage by 0.00%.
The diff coverage is 88.88%.

Impacted file tree graph

@@                           Coverage Diff                            @@
##           feature/dilithium-scheme-integration    #3181      +/-   ##
========================================================================
- Coverage                                 47.62%   47.61%   -0.01%     
========================================================================
  Files                                       381      381              
  Lines                                     61460    61466       +6     
========================================================================
- Hits                                      29268    29265       -3     
- Misses                                    28796    28804       +8     
- Partials                                   3396     3397       +1     
Impacted Files Coverage Δ
crypto/merklekeystore/keystore.go 74.68% <ø> (ø)
data/account/participation.go 65.21% <83.33%> (+0.93%) ⬆️
config/consensus.go 84.74% <100.00%> (+0.04%) ⬆️
data/transactions/transaction.go 37.07% <100.00%> (+0.47%) ⬆️
ledger/blockqueue.go 82.18% <0.00%> (-2.88%) ⬇️
cmd/tealdbg/debugger.go 72.86% <0.00%> (-1.01%) ⬇️
data/abi/abi_type.go 92.03% <0.00%> (-1.00%) ⬇️
ledger/acctupdates.go 65.01% <0.00%> (-0.96%) ⬇️
network/requestTracker.go 70.25% <0.00%> (-0.87%) ⬇️
data/transactions/verify/txn.go 44.29% <0.00%> (ø)
... 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 ea61ca0...eff1253. Read the comment docs.

Copy link
Contributor

@algonautshant algonautshant left a comment

Choose a reason for hiding this comment

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

Can you please merge/rebase from feature/dilithium-scheme-integration?

crypto/merklekeystore/keystore.go Outdated Show resolved Hide resolved
@Aharonee Aharonee force-pushed the limit-max-merkletree-depth branch 2 times, most recently from 0df5c4f to be56ec4 Compare November 16, 2021 20:12
@Aharonee Aharonee force-pushed the limit-max-merkletree-depth branch from 43cd29f to 8b4eaba Compare November 22, 2021 11:28
@Aharonee Aharonee force-pushed the limit-max-merkletree-depth branch from 8b4eaba to bd074ea Compare November 23, 2021 14:01
Copy link
Contributor

@algonautshant algonautshant left a comment

Choose a reason for hiding this comment

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

Looks great.
Just some minor changes are needed.

crypto/merklekeystore/keystore.go Outdated Show resolved Hide resolved
crypto/merklekeystore/keystore.go Outdated Show resolved Hide resolved
crypto/merklekeystore/keystore.go Outdated Show resolved Hide resolved
crypto/merklekeystore/keystore.go Outdated Show resolved Hide resolved

for _, params := range Consensus {
if params.CompactCertRounds != 0 {
require.Equal(t, uint64(1<<16), (params.MaxKeyregValidPeriod+1)/params.CompactCertRounds,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the "16" be replaced by an existing variable representing that value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can use merklearray.MaxTreeDepth, but what about the consensus parameters (MaxKeyregValidPeriod for example), should it use that as well? If not there might be some inconsistency in the future.

Copy link
Contributor

@algonautshant algonautshant Nov 30, 2021

Choose a reason for hiding this comment

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

Let's postpone this parameter issue to a later PR. #3257

crypto/merklekeystore/keystore_test.go Outdated Show resolved Hide resolved
crypto/merklekeystore/keystore_test.go Outdated Show resolved Hide resolved
crypto/merklekeystore/keystore_test.go Outdated Show resolved Hide resolved
crypto/merklekeystore/keystore_test.go Outdated Show resolved Hide resolved
crypto/merklekeystore/keystore_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@algonautshant algonautshant left a comment

Choose a reason for hiding this comment

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

Merge Aharonee#1 if you agree with it.
Then should be good to go.

@algonautshant
Copy link
Contributor

  • Some casting to uint64 (e.g. for firstValid/lastValid) are not needed.
  • I think firstValid/lastValid parameters in New and other interfaces should be basics.Round. Casting form basics.Round to uint64 should not be done.

crypto/compactcert/builder_test.go Show resolved Hide resolved
crypto/compactcert/builder_test.go Show resolved Hide resolved
crypto/compactcert/builder_test.go Show resolved Hide resolved
@@ -117,11 +121,11 @@ func TestBuildVerify(t *testing.T) {
ProvenWeight: uint64(totalWeight / 2),
SigRound: currentRound,
SecKQ: 128,
Copy link
Contributor

Choose a reason for hiding this comment

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

It is a sound design to have crypto independent of the consensus parameters.

However, the hard-coded values in the tests which are repeating the consensus values does not look right. And since the compiler-enforced link of these values to the consensus parameters is broken, this can be problematic in the event the consensus values change.

CompactCertRounds is getting its value from go-algorand/config, but SecKQ is not. They need to be uniform.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's postpone this #3257

data/account/participation.go Outdated Show resolved Hide resolved
data/account/participation.go Outdated Show resolved Hide resolved
data/account/participation.go Outdated Show resolved Hide resolved
@@ -609,10 +609,29 @@ func TestKeyReg(t *testing.T) {
`
ep, ledger := makeSampleEnv()
ep.Proto.EnableStateProofKeyregCheck = true
ep.Proto.MaxKeyregValidPeriod = (1<<16)*128 - 1 // 2^16 StateProof keys times CompactCertRounds (interval)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe not in this PR, but we need to find a way to consolidate these hard-coded values into a variable in a single location and use that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that would definitely be better, we need a single source of truth for all these place to inherit from

Copy link
Contributor

Choose a reason for hiding this comment

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

crypto/merklekeystore/keystore.go Show resolved Hide resolved
@algonautshant algonautshant merged commit 5a71da5 into algorand:feature/dilithium-scheme-integration Nov 30, 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.

5 participants