-
Notifications
You must be signed in to change notification settings - Fork 534
incentives: cache top online accounts and use when building AbsentParticipationAccounts #6085
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
Changes from 1 commit
21db44d
e968515
8587b28
38d4b8d
9740ddc
b8b9673
0b7fbad
b2f1130
5242990
0baf81f
be464cf
97d0bcf
55d5068
01b150a
0f954d1
c24e809
c252d95
bb82a97
04c0a84
c41a49a
e476730
9115aae
23b9996
9bc39aa
c558d59
9d46fa6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,6 +89,7 @@ type Ledger struct { | |
| notifier blockNotifier | ||
| metrics metricsTracker | ||
| spVerification spVerificationTracker | ||
| topOnlineCache topOnlineCache | ||
|
|
||
| trackers trackerRegistry | ||
| trackerMu deadlock.RWMutex | ||
|
|
@@ -635,10 +636,35 @@ func (l *Ledger) LookupAgreement(rnd basics.Round, addr basics.Address) (basics. | |
| defer l.trackerMu.RUnlock() | ||
|
|
||
| // Intentionally apply (pending) rewards up to rnd. | ||
| data, err := l.acctsOnline.LookupOnlineAccountData(rnd, addr) | ||
| data, err := l.acctsOnline.lookupOnlineAccountData(rnd, addr) | ||
| return data, err | ||
| } | ||
|
|
||
| // GetIncentiveKickoffCandidates retrieves a list of online accounts who may not have | ||
| // proposed or sent a heartbeat recently. | ||
| func (l *Ledger) GetIncentiveKickoffCandidates(rnd basics.Round, proto config.ConsensusParams, rewardsLevel uint64) (map[basics.Address]basics.OnlineAccountData, error) { | ||
| l.trackerMu.RLock() | ||
| defer l.trackerMu.RUnlock() | ||
|
|
||
| // get cached list of top N addresses | ||
| addrs, err := l.topOnlineCache.topN(&l.acctsOnline, rnd, proto, rewardsLevel) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // fetch data for this round from online account cache. These accounts should all | ||
| // be in cache, as long as topOnlineCacheSize < onlineAccountsCacheMaxSize. | ||
| ret := make(map[basics.Address]basics.OnlineAccountData) | ||
| for _, addr := range addrs { | ||
| data, err := l.acctsOnline.lookupOnlineAccountData(rnd, addr) | ||
| if err != nil { | ||
| continue // skip missing / not online accounts | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why would voters ever return non-online account?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the voters are only calculating Top N every 256 rounds, so if a lookup for the current round (for the cached addr from the last state proof interval) being requested is that the account was closed/deleted, you could hit an error here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I should add a comment and write a test exercising this case, realizing it is kind of complicated now after writing it out |
||
| } | ||
| ret[addr] = data | ||
| } | ||
| return ret, nil | ||
| } | ||
|
|
||
| // LookupWithoutRewards is like Lookup but does not apply pending rewards up | ||
| // to the requested round rnd. | ||
| func (l *Ledger) LookupWithoutRewards(rnd basics.Round, addr basics.Address) (ledgercore.AccountData, basics.Round, error) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.