Skip to content

Commit 937c559

Browse files
authored
Consensus: Upgrade to consensus version v39. (algorand#5868)
1 parent ec60b11 commit 937c559

22 files changed

+107
-74
lines changed

agreement/player_permutation_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -811,17 +811,16 @@ func TestPlayerPermutation(t *testing.T) {
811811
}
812812

813813
func playerPermutationCheck(t *testing.T, enableDynamicFilterTimeout bool) {
814-
// create a protocol version where dynamic filter is enabled
815-
version, _, configCleanup := createDynamicFilterConfig()
814+
// create a protocol where dynamic filter is set based on the enableDynamicFilterTimeout flag
815+
dynamicFilterOverriddenProtocol, _, configCleanup := overrideConfigWithDynamicFilterParam(enableDynamicFilterTimeout)
816816
defer configCleanup()
817817

818818
for i := 0; i < 7; i++ {
819819
for j := 0; j < 14; j++ {
820820
_, pMachine, helper := getPlayerPermutation(t, i)
821821
inMsg := getMessageEventPermutation(t, j, helper)
822-
if enableDynamicFilterTimeout {
823-
inMsg.Proto = ConsensusVersionView{Version: version}
824-
}
822+
inMsg.Proto = ConsensusVersionView{Version: dynamicFilterOverriddenProtocol}
823+
825824
err, panicErr := pMachine.transition(inMsg)
826825
fmt.Println(pMachine.getTrace().events)
827826
fmt.Println("")

agreement/player_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func init() {
3737
}
3838

3939
func makeTimeoutEvent() timeoutEvent {
40-
return timeoutEvent{T: timeout, RandomEntropy: crypto.RandUint64()}
40+
return timeoutEvent{T: timeout, RandomEntropy: crypto.RandUint64(), Proto: ConsensusVersionView{Version: protocol.ConsensusCurrentVersion}}
4141
}
4242

4343
func generateProposalEvents(t *testing.T, player player, accs testAccountData, f testBlockFactory, ledger Ledger) (voteBatch []event, payloadBatch []event, lowestProposal proposalValue) {
@@ -3240,7 +3240,7 @@ func TestPlayerAlwaysResynchsPinnedValue(t *testing.T) {
32403240
func TestPlayerRetainsReceivedValidatedAtOneSample(t *testing.T) {
32413241
partitiontest.PartitionTest(t)
32423242

3243-
version := protocol.ConsensusFuture
3243+
version := protocol.ConsensusCurrentVersion
32443244
const r = round(20239)
32453245
const p = period(131)
32463246
pWhite, pM, helper := setupP(t, r-1, p, soft)
@@ -3262,7 +3262,7 @@ func TestPlayerRetainsReceivedValidatedAtOneSample(t *testing.T) {
32623262
func TestPlayerRetainsReceivedValidatedAtCredentialHistory(t *testing.T) {
32633263
partitiontest.PartitionTest(t)
32643264

3265-
version := protocol.ConsensusFuture
3265+
version := protocol.ConsensusCurrentVersion
32663266
const r = round(20239)
32673267
const p = period(0)
32683268
pWhite, pM, helper := setupP(t, r-credentialRoundLag-1, p, soft)
@@ -3301,7 +3301,7 @@ func TestPlayerRetainsReceivedValidatedAtCredentialHistory(t *testing.T) {
33013301
func TestPlayerRetainsEarlyReceivedValidatedAtOneSample(t *testing.T) {
33023302
partitiontest.PartitionTest(t)
33033303

3304-
version := protocol.ConsensusFuture
3304+
version := protocol.ConsensusCurrentVersion
33053305
const r = round(20239)
33063306
const p = period(0)
33073307
pWhite, pM, helper := setupP(t, r-1, p, soft)
@@ -3339,7 +3339,7 @@ func testClockForRound(t *testing.T, pWhite *player, fixedDur time.Duration, cur
33393339
func TestPlayerRetainsLateReceivedValidatedAtOneSample(t *testing.T) {
33403340
partitiontest.PartitionTest(t)
33413341

3342-
version := protocol.ConsensusFuture
3342+
version := protocol.ConsensusCurrentVersion
33433343
const r = round(20239)
33443344
const p = period(0)
33453345
pWhite, pM, helper := setupP(t, r-1, p, soft)
@@ -3382,7 +3382,7 @@ func TestPlayerRetainsReceivedValidatedAtForHistoryWindowLateBetter(t *testing.T
33823382
}
33833383

33843384
func testPlayerRetainsReceivedValidatedAtForHistoryWindow(t *testing.T, addBetterLate bool) {
3385-
version := protocol.ConsensusFuture
3385+
version := protocol.ConsensusCurrentVersion
33863386
const r = round(20239)
33873387
const p = period(0)
33883388
pWhite, pM, helper := setupP(t, r-1, p, soft)
@@ -3449,7 +3449,7 @@ func testPlayerRetainsReceivedValidatedAtForHistoryWindow(t *testing.T, addBette
34493449
func TestPlayerRetainsReceivedValidatedAtPPOneSample(t *testing.T) {
34503450
partitiontest.PartitionTest(t)
34513451

3452-
version, _, configCleanup := createDynamicFilterConfig()
3452+
version, _, configCleanup := overrideConfigWithDynamicFilterParam(true)
34533453
defer configCleanup()
34543454
const r = round(20239)
34553455
const p = period(0)
@@ -3505,7 +3505,7 @@ func TestPlayerRetainsReceivedValidatedAtPPOneSample(t *testing.T) {
35053505
func TestPlayerRetainsEarlyReceivedValidatedAtPPOneSample(t *testing.T) {
35063506
partitiontest.PartitionTest(t)
35073507

3508-
version, _, configCleanup := createDynamicFilterConfig()
3508+
version, _, configCleanup := overrideConfigWithDynamicFilterParam(true)
35093509
defer configCleanup()
35103510

35113511
const r = round(20239)
@@ -3559,7 +3559,7 @@ func TestPlayerRetainsEarlyReceivedValidatedAtPPOneSample(t *testing.T) {
35593559
func TestPlayerRetainsLateReceivedValidatedAtPPOneSample(t *testing.T) {
35603560
partitiontest.PartitionTest(t)
35613561

3562-
version, _, configCleanup := createDynamicFilterConfig()
3562+
version, _, configCleanup := overrideConfigWithDynamicFilterParam(true)
35633563
defer configCleanup()
35643564
const r = round(20239)
35653565
const p = period(0)
@@ -3613,7 +3613,7 @@ func TestPlayerRetainsLateReceivedValidatedAtPPOneSample(t *testing.T) {
36133613
func TestPlayerRetainsReceivedValidatedAtPPForHistoryWindow(t *testing.T) {
36143614
partitiontest.PartitionTest(t)
36153615

3616-
version := protocol.ConsensusFuture
3616+
version := protocol.ConsensusCurrentVersion
36173617
const r = round(20239)
36183618
const p = period(0)
36193619
pWhite, pM, helper := setupP(t, r-1, p, soft)
@@ -3655,7 +3655,7 @@ func TestPlayerRetainsReceivedValidatedAtAVPPOneSample(t *testing.T) {
36553655
partitiontest.PartitionTest(t)
36563656

36573657
// create a protocol version where dynamic lambda is enabled
3658-
version, _, configCleanup := createDynamicFilterConfig()
3658+
version, _, configCleanup := overrideConfigWithDynamicFilterParam(true)
36593659
defer configCleanup()
36603660
const r = round(20239)
36613661
const p = period(0)
@@ -3710,7 +3710,7 @@ func TestPlayerRetainsReceivedValidatedAtAVPPOneSample(t *testing.T) {
37103710
func TestPlayerRetainsEarlyReceivedValidatedAtAVPPOneSample(t *testing.T) {
37113711
partitiontest.PartitionTest(t)
37123712

3713-
version := protocol.ConsensusFuture
3713+
version := protocol.ConsensusCurrentVersion
37143714
const r = round(20239)
37153715
const p = period(0)
37163716
pWhite, pM, helper := setupP(t, r-1, p, soft)
@@ -3729,7 +3729,7 @@ func TestPlayerRetainsEarlyReceivedValidatedAtAVPPOneSample(t *testing.T) {
37293729
require.Equal(t, pWhite.lowestCredentialArrivals.writePtr, 0)
37303730

37313731
// create a protocol version where dynamic filter is enabled
3732-
version, _, configCleanup := createDynamicFilterConfig()
3732+
version, _, configCleanup := overrideConfigWithDynamicFilterParam(true)
37333733
defer configCleanup()
37343734

37353735
// send votePresent message (mimicking the first AV message validating)
@@ -3767,7 +3767,7 @@ func TestPlayerRetainsEarlyReceivedValidatedAtAVPPOneSample(t *testing.T) {
37673767
func TestPlayerRetainsLateReceivedValidatedAtAVPPOneSample(t *testing.T) {
37683768
partitiontest.PartitionTest(t)
37693769

3770-
version := protocol.ConsensusFuture
3770+
version := protocol.ConsensusCurrentVersion
37713771
const r = round(20239)
37723772
const p = period(0)
37733773
pWhite, pM, helper := setupP(t, r-1, p, soft)
@@ -3786,7 +3786,7 @@ func TestPlayerRetainsLateReceivedValidatedAtAVPPOneSample(t *testing.T) {
37863786
require.Equal(t, pWhite.lowestCredentialArrivals.writePtr, 0)
37873787

37883788
// create a protocol version where dynamic filter is enabled
3789-
version, _, configCleanup := createDynamicFilterConfig()
3789+
version, _, configCleanup := overrideConfigWithDynamicFilterParam(true)
37903790
defer configCleanup()
37913791

37923792
// send votePresent message (mimicking the first AV message validating)
@@ -3821,7 +3821,7 @@ func TestPlayerRetainsLateReceivedValidatedAtAVPPOneSample(t *testing.T) {
38213821
func TestPlayerRetainsReceivedValidatedAtAVPPHistoryWindow(t *testing.T) {
38223822
partitiontest.PartitionTest(t)
38233823

3824-
version := protocol.ConsensusFuture
3824+
version := protocol.ConsensusCurrentVersion
38253825
const r = round(20239)
38263826
const p = period(0)
38273827
pWhite, pM, helper := setupP(t, r-1, p, soft)

agreement/service_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,10 +1050,10 @@ func TestAgreementHistoricalClocksCleanup(t *testing.T) {
10501050
simulateAgreement(t, 5, int(credentialRoundLag)+10, disabled)
10511051
}
10521052

1053-
func createDynamicFilterConfig() (version protocol.ConsensusVersion, consensusVersion func(r basics.Round) (protocol.ConsensusVersion, error), configCleanup func()) {
1053+
func overrideConfigWithDynamicFilterParam(dynamicFilterTimeoutEnabled bool) (version protocol.ConsensusVersion, consensusVersion func(r basics.Round) (protocol.ConsensusVersion, error), configCleanup func()) {
10541054
version = protocol.ConsensusVersion("test-protocol-filtertimeout")
10551055
protoParams := config.Consensus[protocol.ConsensusCurrentVersion]
1056-
protoParams.DynamicFilterTimeout = true
1056+
protoParams.DynamicFilterTimeout = dynamicFilterTimeoutEnabled
10571057
config.Consensus[version] = protoParams
10581058

10591059
consensusVersion = func(r basics.Round) (protocol.ConsensusVersion, error) {
@@ -1074,7 +1074,7 @@ func TestAgreementSynchronousFuture5_DynamicFilterRounds(t *testing.T) {
10741074
t.Skip("Skipping agreement integration test")
10751075
}
10761076

1077-
_, consensusVersion, configCleanup := createDynamicFilterConfig()
1077+
_, consensusVersion, configCleanup := overrideConfigWithDynamicFilterParam(true)
10781078
defer configCleanup()
10791079

10801080
if dynamicFilterCredentialArrivalHistory <= 0 {
@@ -1105,7 +1105,7 @@ func TestDynamicFilterTimeoutResets(t *testing.T) {
11051105
t.Skip("Skipping agreement integration test")
11061106
}
11071107

1108-
version, consensusVersion, configCleanup := createDynamicFilterConfig()
1108+
version, consensusVersion, configCleanup := overrideConfigWithDynamicFilterParam(true)
11091109
defer configCleanup()
11101110

11111111
if dynamicFilterCredentialArrivalHistory <= 0 {

catchup/service_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ func TestDownloadBlocksToSupportStateProofs(t *testing.T) {
11351135

11361136
lookback := lookbackForStateproofsSupport(&topBlk)
11371137
oldestRound := topBlk.BlockHeader.Round.SubSaturate(basics.Round(lookback))
1138-
assert.Equal(t, uint64(oldestRound), 512-config.Consensus[protocol.ConsensusFuture].StateProofInterval-config.Consensus[protocol.ConsensusFuture].StateProofVotersLookback)
1138+
assert.Equal(t, uint64(oldestRound), 512-config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval-config.Consensus[protocol.ConsensusCurrentVersion].StateProofVotersLookback)
11391139

11401140
// the network has made progress and now it is on round 8000. in this case we would not download blocks to cover 512.
11411141
// instead, we will download blocks to confirm only the recovery period lookback.
@@ -1150,7 +1150,7 @@ func TestDownloadBlocksToSupportStateProofs(t *testing.T) {
11501150
oldestRound = topBlk.BlockHeader.Round.SubSaturate(basics.Round(lookback))
11511151

11521152
lowestRoundToRetain := 8000 - (8000 % config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval) -
1153-
config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval*(config.Consensus[protocol.ConsensusCurrentVersion].StateProofMaxRecoveryIntervals+1) - config.Consensus[protocol.ConsensusFuture].StateProofVotersLookback
1153+
config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval*(config.Consensus[protocol.ConsensusCurrentVersion].StateProofMaxRecoveryIntervals+1) - config.Consensus[protocol.ConsensusCurrentVersion].StateProofVotersLookback
11541154

11551155
assert.Equal(t, uint64(oldestRound), lowestRoundToRetain)
11561156

config/consensus.go

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,22 +1383,34 @@ func initConsensusProtocols() {
13831383
// for the sake of future manual calculations, we'll round that down a bit :
13841384
v37.ApprovedUpgrades[protocol.ConsensusV38] = 10000
13851385

1386-
// ConsensusFuture is used to test features that are implemented
1387-
// but not yet released in a production protocol version.
1388-
vFuture := v38
1386+
v39 := v38
1387+
v39.ApprovedUpgrades = map[protocol.ConsensusVersion]uint64{}
13891388

1390-
vFuture.ApprovedUpgrades = map[protocol.ConsensusVersion]uint64{}
1389+
v39.LogicSigVersion = 10
1390+
v39.EnableLogicSigCostPooling = true
1391+
1392+
v39.AgreementDeadlineTimeoutPeriod0 = 4 * time.Second
1393+
1394+
v39.DynamicFilterTimeout = true
13911395

1392-
vFuture.LogicSigVersion = 10 // When moving this to a release, put a new higher LogicSigVersion here
1393-
vFuture.EnableLogicSigCostPooling = true
1396+
v39.StateProofBlockHashInLightHeader = true
13941397

1395-
vFuture.AgreementDeadlineTimeoutPeriod0 = 4 * time.Second
1398+
// For future upgrades, round times will likely be shorter so giving ourselves some buffer room
1399+
v39.MaxUpgradeWaitRounds = 250000
13961400

1397-
vFuture.StateProofBlockHashInLightHeader = true
1401+
Consensus[protocol.ConsensusV39] = v39
1402+
1403+
// v38 can be upgraded to v39, with an update delay of 7d:
1404+
// 157000 = (7 * 24 * 60 * 60 / 3.3 round times currently)
1405+
// but our current max is 150000 so using that :
1406+
v38.ApprovedUpgrades[protocol.ConsensusV39] = 150000
1407+
1408+
// ConsensusFuture is used to test features that are implemented
1409+
// but not yet released in a production protocol version.
1410+
vFuture := v39
1411+
vFuture.ApprovedUpgrades = map[protocol.ConsensusVersion]uint64{}
13981412

1399-
// Setting DynamicFilterTimeout in vFuture will impact e2e test performance
1400-
// by reducing round time. Hence, it is commented out for now.
1401-
vFuture.DynamicFilterTimeout = true
1413+
vFuture.LogicSigVersion = 11 // When moving this to a release, put a new higher LogicSigVersion here
14021414

14031415
Consensus[protocol.ConsensusFuture] = vFuture
14041416

data/bookkeeping/block_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,9 +832,9 @@ func TestBlock_ContentsMatchHeader(t *testing.T) {
832832
copy(block.BlockHeader.TxnCommitments.Sha256Commitment[:], rootSliceSHA256)
833833
a.False(block.ContentsMatchHeader())
834834

835-
/* Test Consensus Future */
835+
/* Test Consensus Current */
836836
// Create a block with SHA256 TxnCommitments
837-
block.CurrentProtocol = protocol.ConsensusFuture
837+
block.CurrentProtocol = protocol.ConsensusCurrentVersion
838838

839839
block.BlockHeader.TxnCommitments.NativeSha512_256Commitment = crypto.Digest{}
840840
block.BlockHeader.TxnCommitments.Sha256Commitment = crypto.Digest{}

0 commit comments

Comments
 (0)