Skip to content

Commit da0f0c8

Browse files
Enable upgrade delay tuning. (#902) (#929)
* [betanet] Enable upgrade delay tuning. * Use official spec commit hash. * Bump ConsensusCurrentVersion. * Fix old failing test. Co-authored-by: Derek Leung <[email protected]>
1 parent d22acbe commit da0f0c8

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

config/consensus.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -542,12 +542,19 @@ func initConsensusProtocols() {
542542
// v20 can be upgraded to v21.
543543
v20.ApprovedUpgrades[protocol.ConsensusV21] = 0
544544

545+
// v22 is an upgrade which allows tuning the number of rounds to wait to execute upgrades.
546+
v22 := v21
547+
v22.ApprovedUpgrades = map[protocol.ConsensusVersion]uint64{}
548+
v22.MinUpgradeWaitRounds = 10000
549+
v22.MaxUpgradeWaitRounds = 150000
550+
Consensus[protocol.ConsensusV22] = v22
551+
// v21 can be upgraded to v22.
552+
v21.ApprovedUpgrades[protocol.ConsensusV22] = 0
553+
545554
// ConsensusFuture is used to test features that are implemented
546555
// but not yet released in a production protocol version.
547-
vFuture := v21
556+
vFuture := v22
548557
vFuture.ApprovedUpgrades = map[protocol.ConsensusVersion]uint64{}
549-
vFuture.MinUpgradeWaitRounds = 10000
550-
vFuture.MaxUpgradeWaitRounds = 150000
551558
Consensus[protocol.ConsensusFuture] = vFuture
552559
}
553560

data/bookkeeping/block.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ func ProcessUpgradeParams(prev BlockHeader) (uv UpgradeVote, us UpgradeState, er
394394
}
395395
}
396396

397-
// If there is a proposal being voted on, see if we approve it and its delay
397+
// If there is a proposal being voted on, see if we approve it
398398
round := prev.Round + 1
399399
if round < prev.NextProtocolVoteBefore {
400400
_, ok := prevParams.ApprovedUpgrades[prev.NextProtocol]

data/bookkeeping/block_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ func init() {
4242
params1.ApprovedUpgrades = map[protocol.ConsensusVersion]uint64{
4343
proto2: 0,
4444
}
45+
params1.MinUpgradeWaitRounds = 0
46+
params1.MaxUpgradeWaitRounds = 0
4547
config.Consensus[proto1] = params1
4648

4749
params2 := config.Consensus[protocol.ConsensusCurrentVersion]

protocol/consensus.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ const ConsensusV21 = ConsensusVersion(
118118
"https://github.com/algorandfoundation/specs/tree/8096e2df2da75c3339986317f9abe69d4fa86b4b",
119119
)
120120

121+
// ConsensusV22 allows tuning the upgrade delay.
122+
const ConsensusV22 = ConsensusVersion(
123+
"https://github.com/algorandfoundation/specs/tree/57016b942f6d97e6d4c0688b373bb0a2fc85a1a2",
124+
)
125+
121126
// ConsensusFuture is a protocol that should not appear in any production
122127
// network, but is used to test features before they are released.
123128
const ConsensusFuture = ConsensusVersion(
@@ -130,7 +135,7 @@ const ConsensusFuture = ConsensusVersion(
130135

131136
// ConsensusCurrentVersion is the latest version and should be used
132137
// when a specific version is not provided.
133-
const ConsensusCurrentVersion = ConsensusV21
138+
const ConsensusCurrentVersion = ConsensusV22
134139

135140
// Error is used to indicate that an unsupported protocol has been detected.
136141
type Error ConsensusVersion

0 commit comments

Comments
 (0)