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

V31 consensus upgrade #3553

Merged
merged 8 commits into from
Feb 10, 2022
Merged

Conversation

id-ms
Copy link
Contributor

@id-ms id-ms commented Feb 2, 2022

Summary

Create an update path that would enable the following features:

  1. Batch Verification (batch verification: add ed25519 batch verification implementation #3031)
  2. State Proof Keys (Integrate State Proof keys #2990)
  3. TEAL 6 (Feature/contract to contract -> master #3397)
  4. Expired Participation Keys (Added Participation Key Expiration Check #2924)
  5. Fix rewards calculation bug (ledger: fix NextRewardsState() #3403)

Test Plan

Unit tests added.

@id-ms id-ms changed the title create v31 consensus version. create v31 consensus version Feb 2, 2022
Copy link
Contributor

@tsachiherman tsachiherman left a comment

Choose a reason for hiding this comment

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

Four more requests here:

  1. Don't forget to update ConsensusCurrentVersion to ConsensusV30
  2. Add v30.ApprovedUpgrades[protocol.ConsensusV31] = 140000
  3. Add v31.RewardsCalculationFix to true ( and remove from vFuture )
  4. Add v31.MaxProposedExpiredOnlineAccounts to 32 ( and remove from vFuture )

@codecov-commenter
Copy link

codecov-commenter commented Feb 2, 2022

Codecov Report

Merging #3553 (00e75f8) into master (18b5ccb) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3553      +/-   ##
==========================================
+ Coverage   47.74%   47.77%   +0.02%     
==========================================
  Files         370      370              
  Lines       60262    60266       +4     
==========================================
+ Hits        28773    28790      +17     
+ Misses      28183    28170      -13     
  Partials     3306     3306              
Impacted Files Coverage Δ
protocol/consensus.go 0.00% <ø> (ø)
config/consensus.go 84.98% <100.00%> (+0.19%) ⬆️
data/transactions/verify/txn.go 44.15% <0.00%> (-0.87%) ⬇️
network/wsNetwork.go 62.79% <0.00%> (-0.20%) ⬇️
ledger/acctupdates.go 66.60% <0.00%> (+0.18%) ⬆️
network/wsPeer.go 68.88% <0.00%> (+0.83%) ⬆️
data/abi/abi_type.go 88.62% <0.00%> (+0.94%) ⬆️
network/requestTracker.go 71.55% <0.00%> (+1.29%) ⬆️
ledger/tracker.go 75.75% <0.00%> (+1.29%) ⬆️
ledger/blockqueue.go 85.05% <0.00%> (+2.87%) ⬆️

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 18b5ccb...00e75f8. Read the comment docs.

config/consensus.go Outdated Show resolved Hide resolved
algoidan and others added 2 commits February 2, 2022 20:35
Co-authored-by: Pavel Zbitskiy <65323360+algorandskiy@users.noreply.github.com>
@tsachiherman tsachiherman dismissed their stale review February 2, 2022 19:15

looks good, thanks for the changes.

@tsachiherman tsachiherman changed the title create v31 consensus version V31 consensus upgrade Feb 10, 2022
jannotti
jannotti previously approved these changes Feb 10, 2022
Copy link
Contributor

@jannotti jannotti left a comment

Choose a reason for hiding this comment

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

Looks ok from AVM 1.1 perspective. My other comments are very minor.

ledger/apply/keyreg_test.go Outdated Show resolved Hide resolved
ledger/apply/keyreg_test.go Outdated Show resolved Hide resolved
@@ -76,7 +76,7 @@ func testExpirationAccounts(t *testing.T, fixture *fixtures.RestClientFixture, f
_, currentRound := fixture.GetBalanceAndRound(richAccount)
// account adds part key
partKeyFirstValid := uint64(0)
partKeyValidityPeriod := uint64(150)
partKeyValidityPeriod := uint64(150) // TODO: maybe increase?
Copy link
Contributor

Choose a reason for hiding this comment

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

What are the units? I would have guessed rounds, but that would be very short.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes they are rounds and it is very short, maybe we should put 1000-3000 there instead, as no State Proof keys will be generated for such a short interval.

Copy link
Contributor

@Aharonee Aharonee left a comment

Choose a reason for hiding this comment

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

I've added some minor fixes here: id-ms#15

@@ -76,7 +76,7 @@ func testExpirationAccounts(t *testing.T, fixture *fixtures.RestClientFixture, f
_, currentRound := fixture.GetBalanceAndRound(richAccount)
// account adds part key
partKeyFirstValid := uint64(0)
partKeyValidityPeriod := uint64(150)
partKeyValidityPeriod := uint64(150) // TODO: maybe increase?
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes they are rounds and it is very short, maybe we should put 1000-3000 there instead, as no State Proof keys will be generated for such a short interval.

Copy link
Contributor

@gmalouf gmalouf left a comment

Choose a reason for hiding this comment

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

Non-blocking FYI, didn't update a few references to ConsensusFuture - quick find in IDE will turn some up.

participationRegistry_test.go
accountdb_test.go

I'm opening an issue for the general case - we should have a single approach to referencing the ConsensusParams protocol inclusive of current+future that does not have to change when we bump the version.

v31.EnableStateProofKeyregCheck = true

// Maximum validity period for key registration, to prevent generating too many StateProof keys
v31.MaxKeyregValidPeriod = 256*(1<<16) - 1
Copy link
Contributor

Choose a reason for hiding this comment

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

I was about to ask some questions about the numbers going into this formula, seems like intent is to address this in a follow on issue: #3257 cc @algonautshant

Copy link
Contributor

Choose a reason for hiding this comment

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

The assumption is that the source of the truth is here: v31.MaxKeyregValidPeriod = 256*(1<<16) - 1
Anywhere else should be referencing this parameter.

The issue in #3257 is to make sure this variable is used for testing (instead of hardcoding the same value elsewhere), and fix the package dependency issue.

This is not a blocking issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

MaxKeyregValidPeriod combines 256 and 16, which are based on two different limits.
for example:
merklearray/merkle.go: MaxEncodedTreeDepth = 16

@@ -590,6 +594,7 @@ func TestAccountParticipationInfo(t *testing.T) {
a.Equal(uint64(firstRound), account.Participation.VoteFirst, "API must print correct first participation round")
a.Equal(uint64(lastRound), account.Participation.VoteLast, "API must print correct last participation round")
a.Equal(dilution, account.Participation.VoteKeyDilution, "API must print correct key dilution")
// TODO: should we update the v1 API to support state proof? Currently it does not return this field.
Copy link
Contributor

Choose a reason for hiding this comment

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

@tsachiherman did we already address this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I copied this comment from @Aharonee 's PR, but I believe that the answer is no, and I think it's fine. We want to avoid updating the v1 endpoint any further.

Copy link
Contributor

Choose a reason for hiding this comment

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

agreed, if we are using v1 somewhere internally that needs it, we should just convert it to using v2 instead

@Aharonee
Copy link
Contributor

Non-blocking FYI, didn't update a few references to ConsensusFuture - quick find in IDE will turn some up.

participationRegistry_test.go accountdb_test.go

I'm opening an issue for the general case - we should have a single approach to referencing the ConsensusParams protocol inclusive of current+future that does not have to change when we bump the version.

@gmalouf If you're referring to data/account/participationRegistry_test.go:45 then it should remain ConsensusFuture still, since it references a consensus parameter which will only be enabled when we enable the Compact Certificates.

In ledger/accountdb_test.go:293 the ConsensusFuture can change in my opinion and the test won't break. I'll push a fix into id-ms#15.

@tsachiherman
Copy link
Contributor

Non-blocking FYI, didn't update a few references to ConsensusFuture - quick find in IDE will turn some up.
participationRegistry_test.go accountdb_test.go
I'm opening an issue for the general case - we should have a single approach to referencing the ConsensusParams protocol inclusive of current+future that does not have to change when we bump the version.

@gmalouf If you're referring to data/account/participationRegistry_test.go:45 then it should remain ConsensusFuture still, since it references a consensus parameter which will only be enabled when we enable the Compact Certificates.

In ledger/accountdb_test.go:293 the ConsensusFuture can change in my opinion and the test won't break. I'll push a fix into algoidan#15.

@Aharonee I agree with @gmalouf here; the proper way to test this before the protocol is created is to take an existing protocol version, and "add" the needed flags to its parameters in order to test using a custom protocol. I know that this might mean slightly more work, but it's the "cleaner" way to accomplish that. It also means that there won't be any changes when we apply new protocol version.

Aharonee
Aharonee previously approved these changes Feb 10, 2022
@gmalouf
Copy link
Contributor

gmalouf commented Feb 10, 2022 via email

@tsachiherman tsachiherman merged commit 71e39cd into algorand:master Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants