Skip to content

Commit fd56363

Browse files
AlgoStephenAkikicce
authored andcommitted
Added Participation Key Expiration Check (algorand#2924)
## Summary Resolves algorand#2738 Adds the following: - consensus.go: Adds the default MaxExpiredAccountsToProcess value for the new consensus protocol - block.go: Adds necessary block header entries - eval.go: Scans for expired accounts, modifies them to be offline and adds validation for this use case - eval_test.go: Basic unit tests - participationExpiration_test.go: Added e2e tests that verify that different consensus protocols behave differently ## Test Plan Unit test and e2e tests added
1 parent da06f19 commit fd56363

File tree

12 files changed

+2233
-828
lines changed

12 files changed

+2233
-828
lines changed

agreement/msgp_gen.go

+756-527
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/consensus.go

+11
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,10 @@ type ConsensusParams struct {
391391
EnableKeyregCoherencyCheck bool
392392

393393
EnableExtraPagesOnAppUpdate bool
394+
395+
// MaxProposedExpiredOnlineAccounts is the maximum number of online accounts, which need
396+
// to be taken offline, that would be proposed to be taken offline.
397+
MaxProposedExpiredOnlineAccounts int
394398
}
395399

396400
// PaysetCommitType enumerates possible ways for the block header to commit to
@@ -465,6 +469,10 @@ var MaxExtraAppProgramLen int
465469
//supported supported by any of the consensus protocols. used for decoding purposes.
466470
var MaxAvailableAppProgramLen int
467471

472+
// MaxProposedExpiredOnlineAccounts is the maximum number of online accounts, which need
473+
// to be taken offline, that would be proposed to be taken offline.
474+
var MaxProposedExpiredOnlineAccounts int
475+
468476
func checkSetMax(value int, curMax *int) {
469477
if value > *curMax {
470478
*curMax = value
@@ -501,6 +509,7 @@ func checkSetAllocBounds(p ConsensusParams) {
501509
// Its value is much larger than any possible reasonable MaxLogCalls value in future
502510
checkSetMax(p.MaxAppProgramLen, &MaxLogCalls)
503511
checkSetMax(p.MaxInnerTransactions, &MaxInnerTransactions)
512+
checkSetMax(p.MaxProposedExpiredOnlineAccounts, &MaxProposedExpiredOnlineAccounts)
504513
}
505514

506515
// SaveConfigurableConsensus saves the configurable protocols file to the provided data directory.
@@ -1045,6 +1054,8 @@ func initConsensusProtocols() {
10451054
// Enable TEAL 6 / AVM 1.1
10461055
vFuture.LogicSigVersion = 6
10471056

1057+
vFuture.MaxProposedExpiredOnlineAccounts = 32
1058+
10481059
Consensus[protocol.ConsensusFuture] = vFuture
10491060
}
10501061

data/basics/userBalance.go

+10
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,16 @@ func MakeAccountData(status Status, algos MicroAlgos) AccountData {
397397
return AccountData{Status: status, MicroAlgos: algos}
398398
}
399399

400+
// ClearOnlineState resets the account's fields to indicate that the account is an offline account
401+
func (u *AccountData) ClearOnlineState() {
402+
u.Status = Offline
403+
u.VoteFirstValid = Round(0)
404+
u.VoteLastValid = Round(0)
405+
u.VoteKeyDilution = 0
406+
u.VoteID = crypto.OneTimeSignatureVerifier{}
407+
u.SelectionID = crypto.VRFVerifier{}
408+
}
409+
400410
// Money returns the amount of MicroAlgos associated with the user's account
401411
func (u AccountData) Money(proto config.ConsensusParams, rewardsLevel uint64) (money MicroAlgos, rewards MicroAlgos) {
402412
e := u.WithUpdatedRewards(proto, rewardsLevel)

data/bookkeeping/block.go

+15
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,21 @@ type (
125125
// for multiple types of certs.
126126
//msgp:sort protocol.CompactCertType protocol.SortCompactCertType
127127
CompactCert map[protocol.CompactCertType]CompactCertState `codec:"cc,allocbound=protocol.NumCompactCertTypes"`
128+
129+
// ParticipationUpdates contains the information needed to mark
130+
// certain accounts offline because their participation keys expired
131+
ParticipationUpdates
132+
}
133+
134+
// ParticipationUpdates represents participation account data that
135+
// needs to be checked/acted on by the network
136+
ParticipationUpdates struct {
137+
_struct struct{} `codec:",omitempty,omitemptyarray"`
138+
139+
// ExpiredParticipationAccounts contains a list of online accounts
140+
// that needs to be converted to offline since their
141+
// participation key expired.
142+
ExpiredParticipationAccounts []basics.Address `codec:"partupdrmv,allocbound=config.MaxProposedExpiredOnlineAccounts"`
128143
}
129144

130145
// RewardsState represents the global parameters controlling the rate

0 commit comments

Comments
 (0)