Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
28338ff
incentives: cache top online accounts and use when building AbsentPar…
cce Oct 30, 2024
8de2829
incentives: handle round 0 "top voters" lookups for easier testing (#…
cce Nov 5, 2024
b2cc8fe
Incentives: Use agreement round when estimating a node's proposal int…
jannotti Nov 6, 2024
0588296
incentives: update GetKnockOfflineCandidates to return current Online…
cce Nov 6, 2024
fb748a6
Incentive fixes (#6166)
jannotti Nov 6, 2024
de1c241
Incentives: Heartbeat transaction type (#6149)
jannotti Nov 27, 2024
d2954e5
Eval: Prefetching for heartbeat transactions (#6182)
jannotti Dec 3, 2024
d55951a
Eval: Make the absenteeism factor = 20 instead of 10 (#6186)
jannotti Dec 4, 2024
6eb6ad2
Only heartbeat with current VoterID (#6188)
jannotti Dec 4, 2024
35d32b0
code review
jannotti Dec 5, 2024
cab07e3
Merge remote-tracking branch 'upstream/master' into feature/heartbeats
jannotti Dec 5, 2024
957364a
Comment: Payout Comment Tweak (#6191)
gmalouf Dec 5, 2024
d5286e3
Do not suspend !IncentiveEligible
jannotti Dec 9, 2024
573ec73
Eval: Move heartbeat verification earlier (#6194)
jannotti Dec 11, 2024
e3fbe16
Only heartbeat for IncentiveEligible accounts
jannotti Dec 11, 2024
240fe33
use t.Log instead of fmt.Print in heartbeat/service_test.go
cce Dec 17, 2024
d989fa4
remove TODO now that !IncentiveEligible can't be suspended
cce Dec 17, 2024
fc55e26
CR for partAddrs.Contains
cce Dec 17, 2024
1277f9b
Waste less space in the main Transaction type (#6199)
jannotti Dec 17, 2024
6e93262
make accountUpdatesLedgerEvaluator.GetKnockOfflineCandidates return e…
cce Dec 18, 2024
39cf79e
code review
jannotti Dec 18, 2024
d8f3be6
code review
jannotti Dec 18, 2024
475cd5e
cr request for comment
jannotti Dec 18, 2024
9cf40d0
compare whole bytes without loop
jannotti Dec 18, 2024
b94f083
simplify client.WaitForRoundWithTimeout
jannotti Dec 18, 2024
567780a
remove knockOfflineCandidates from roundCowParent interface
cce Dec 19, 2024
242f3f5
Use `x.rnd` properly as the _previous_ round.
jannotti Dec 19, 2024
ca381bc
Inadvertant double Stop()
jannotti Dec 19, 2024
821c9ab
further simplify WaitForRoundWithTimeout
jannotti Dec 19, 2024
f3424a8
CR request for more detailed comment
jannotti Dec 19, 2024
ec3007f
Adjustments for proper lookback in `voter_param_get`
jannotti Dec 19, 2024
923a514
Use LookupAgreement to hit caches
jannotti Dec 19, 2024
2d65f00
change GetKnockOfflineCandidates to skip accounts with 0 algos (offli…
cce Dec 19, 2024
9a5386d
version fix
jannotti Dec 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions daemon/algod/api/client/restClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,11 @@ func (client RestClient) WaitForRoundWithTimeout(roundToWaitFor uint64) error {
return err
}

for lastRound := status.LastRound; lastRound < roundToWaitFor; {
stat, err := client.WaitForRound(lastRound+1, singleRoundMaxTime)
for lastRound := status.LastRound; lastRound < roundToWaitFor; lastRound = status.LastRound {
status, err = client.WaitForRound(lastRound+1, singleRoundMaxTime)
if err != nil {
return fmt.Errorf("client.WaitForRound took too long between round %d and %d", lastRound, lastRound+1)
}
lastRound = stat.LastRound
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion data/transactions/logic/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@ func (fs voterParamsFieldSpec) Note() string {
}

var voterParamsFieldSpecs = [...]voterParamsFieldSpec{
{VoterBalance, StackUint64, 6, "Online stake in microalgos"},
{VoterBalance, StackUint64, incentiveVersion, "Online stake in microalgos"},
{VoterIncentiveEligible, StackBoolean, incentiveVersion, "Had this account opted into block payouts"},
}

Expand Down
2 changes: 2 additions & 0 deletions heartbeat/abstractions.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ type ledger interface {

// LookupAccount allows the Service to observe accounts for suspension
LookupAccount(round basics.Round, addr basics.Address) (data ledgercore.AccountData, validThrough basics.Round, withoutRewards basics.MicroAlgos, err error)

LookupAgreement(rnd basics.Round, addr basics.Address) (basics.OnlineAccountData, error)
}

// participants captures the aspects of the AccountManager that are used by this
Expand Down
14 changes: 9 additions & 5 deletions heartbeat/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (s *Service) findChallenged(rules config.ProposerPayoutRules, current basic

var found []account.ParticipationRecordForRound
for _, pr := range s.accts.Keys(current) { // only look at accounts we have part keys for
acct, _, _, err := s.ledger.LookupAccount(current, pr.Account)
acct, err := s.ledger.LookupAgreement(current, pr.Account)
if err != nil {
s.log.Errorf("error looking up %v: %v", pr.Account, err)
continue
Expand All @@ -97,14 +97,18 @@ func (s *Service) findChallenged(rules config.ProposerPayoutRules, current basic
if acct.VoteID != pr.Voting.OneTimeSignatureVerifier {
continue
}
if acct.Status == basics.Online && acct.IncentiveEligible {
if ch.Failed(pr.Account, acct.LastSeen()) {
// We want to match the logic in generateKnockOfflineAccountsList, but
// don't need to check Online status because we obtained records from
// LookupAgreement, which only returns Online accounts (or empty, which
// will not be IncentiveEligible) If we ever decide to knockoff accounts
// that are not IncentiveEligoible, this code should remember to check
// acct.MicroAlgosWithRewards > 0 to ensure we need a heartbeat.
if acct.IncentiveEligible {
if ch.Failed(pr.Account, max(acct.LastHeartbeat, acct.LastProposed)) {
s.log.Infof(" %v needs a heartbeat\n", pr.Account)
found = append(found, pr)
}
}
/* If we add a grace period to suspension for absenteeism, then we could
also make it free to heartbeat during that period. */
}
return found
}
Expand Down
23 changes: 23 additions & 0 deletions heartbeat/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,29 @@ func (l *mockedLedger) LookupAccount(round basics.Round, addr basics.Address) (l
return ledgercore.AccountData{}, round, basics.MicroAlgos{}, nil
}

func (l *mockedLedger) LookupAgreement(round basics.Round, addr basics.Address) (basics.OnlineAccountData, error) {
l.mu.Lock()
defer l.mu.Unlock()

if round > l.lastRound() {
panic("mockedLedger.LookupAgreement: future round")
}

for r := round; r <= round; r-- {
if acct, ok := l.history[r][addr]; ok {
oad := basics.OnlineAccountData{
MicroAlgosWithRewards: acct.MicroAlgos,
VotingData: acct.VotingData,
IncentiveEligible: acct.IncentiveEligible,
LastProposed: acct.LastProposed,
LastHeartbeat: acct.LastHeartbeat,
}
return oad, nil
}
}
return basics.OnlineAccountData{}, nil
}

// waitFor confirms that the Service made it through the last block in the
// ledger and is waiting for the next. The Service is written such that it
// operates properly without this sort of wait, but for testing, we often want
Expand Down
5 changes: 4 additions & 1 deletion ledger/apply/challenge.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ func (ch challenge) IsZero() bool {
}

// Failed returns true iff ch is in effect, matches address, and lastSeen is
// before the challenge issue.
// before the challenge issue. When an address "Fails" in this way, the
// _meaning_ depends on how the challenged was obtained. If it was "risky" then
// it means the address is at risk, not that it should be suspended. It it's an
// "active" challenge, then the account should be suspended.
func (ch challenge) Failed(address basics.Address, lastSeen basics.Round) bool {
return ch.round != 0 && bitsMatch(ch.seed[:], address[:], ch.bits) && lastSeen < ch.round
}
Expand Down
2 changes: 1 addition & 1 deletion ledger/eval/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -1690,7 +1690,7 @@ func (eval *BlockEvaluator) generateKnockOfflineAccountsList(participating []bas
candidates[accountAddr] = candidateData{
VoteLastValid: acctData.VoteLastValid,
VoteID: acctData.VoteID,
Status: basics.Online, // from lookupOnlineAccountData, which only returns online accounts
Status: basics.Online, // GetKnockOfflineCandidates only returns online accounts
LastProposed: acctData.LastProposed,
LastHeartbeat: acctData.LastHeartbeat,
MicroAlgosWithRewards: acctData.MicroAlgosWithRewards,
Expand Down
14 changes: 7 additions & 7 deletions ledger/eval_simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,14 +633,14 @@ func TestAbsentTracking(t *testing.T) {
// to avoid complications from advancing an extra round, we only do this check for 100 rounds
}

// addr[1] spent 10A on a fee in rnd 3, so online stake and eligibility adjusted in 323
if rnd == addr1Keyreg-1+lookback {
checkState(addrs[1], true, false, 833_333_333_333_333)
checkState(addrs[1], true, true, 833_333_323_333_333)
// addr[1] spent 10A on a fee in rnd 1, so online stake and eligibility adjusted in 323
if rnd == addr1Keyreg-2+lookback {
checkState(addrs[1], true, false, 833_333_333_333_333) // check occurs during reg+lookback-1
checkState(addrs[1], true, true, 833_333_323_333_333) // check occurs during reg+lookback
}

// watch the change across the round that addr2 becomes eligible (by spending 2A in keyreg)
if rnd == addr2Eligible-1+lookback {
if rnd == addr2Eligible-2+lookback {
checkState(addrs[2], true, false, 833_333_333_429_333)
checkState(addrs[2], true, true, 833_333_331_429_333) // after keyreg w/ 2A is effective
}
Expand Down Expand Up @@ -672,14 +672,14 @@ func TestAbsentTracking(t *testing.T) {
rnd := vb.Block().Round()

// observe addr1 stake going to zero 320 rounds after knockoff
if rnd == addr1off+lookback-1 {
if rnd == addr1off+lookback-2 {
checkState(addrs[1], true, true, 833_333_323_188_333)
checkState(addrs[1], false, false, 0)
addr1check = true
}

// observe addr2 stake going to zero 320 rounds after knockoff
if rnd == addr2off+lookback-1 {
if rnd == addr2off+lookback-2 {
checkState(addrs[2], true, true, 833_333_331_427_333) // still "online"
checkState(addrs[2], false, false, 0)
addr2check = true
Expand Down
2 changes: 1 addition & 1 deletion ledger/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ func (l *Ledger) GetKnockOfflineCandidates(rnd basics.Round, proto config.Consen
ret := make(map[basics.Address]basics.OnlineAccountData)
for _, addr := range addrs {
data, err := l.acctsOnline.lookupOnlineAccountData(rnd, addr)
if err != nil {
if err != nil || data.MicroAlgosWithRewards.IsZero() {
continue // skip missing / not online accounts
}
ret[addr] = data
Expand Down
Loading