Skip to content
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

ledger: Implement LookupAgreement #3046

Merged
merged 6 commits into from
Oct 13, 2021

Conversation

algorandskiy
Copy link
Contributor

@algorandskiy algorandskiy commented Oct 12, 2021

Summary

  1. Add a new OnlineAccountData data type
  2. Implement LookupAgreement

Test Plan

Fixed existed tests: added LookupAgreement to mocked ledgers

@algorandskiy algorandskiy self-assigned this Oct 12, 2021
@algorandskiy algorandskiy changed the title Implement LookupAgreement ledger: Implement LookupAgreement Oct 12, 2021
data, err := l.accts.LookupWithRewards(rnd, addr)
if err != nil {
return basics.OnlineAccountData{}, err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny nit, would you want to have this call Ledger.Lookup() for now just to remove the duplication, or maybe it doesn't matter because it will be refactored soon

Copy link
Contributor

@tsachiherman tsachiherman Oct 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hoping that in the context of this PR, we'd better get off to the account update level - and stop there.
That would ensure that when we make the next changes, these won't "leak" outside the account updates.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just meant that this new LookupAgreement() is mostly a copy-paste of the Lookup() function above, whether it was less repetitive to call it directly for now.. not a big issue though

@codecov-commenter
Copy link

codecov-commenter commented Oct 12, 2021

Codecov Report

Merging #3046 (8f30f5e) into master (a516544) will increase coverage by 0.01%.
The diff coverage is 44.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3046      +/-   ##
==========================================
+ Coverage   43.65%   43.67%   +0.01%     
==========================================
  Files         391      391              
  Lines       86779    86792      +13     
==========================================
+ Hits        37887    37909      +22     
+ Misses      42864    42859       -5     
+ Partials     6028     6024       -4     
Impacted Files Coverage Δ
agreement/abstractions.go 50.00% <ø> (ø)
daemon/algod/api/server/v2/handlers.go 0.00% <0.00%> (ø)
data/committee/committee.go 0.00% <ø> (ø)
ledger/ledger.go 63.04% <0.00%> (-1.41%) ⬇️
node/impls.go 0.00% <0.00%> (ø)
node/netprio.go 0.00% <0.00%> (ø)
data/basics/userBalance.go 27.65% <88.88%> (+8.11%) ⬆️
agreement/proposal.go 71.96% <100.00%> (ø)
agreement/selector.go 68.00% <100.00%> (ø)
cmd/algoh/blockWatcher.go 77.77% <0.00%> (-3.18%) ⬇️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a516544...8f30f5e. Read the comment docs.

@algorandskiy
Copy link
Contributor Author

Removed Lookup() from node and datatest, the only place it is used is REST API to retrieve user balance with rewards (default behavior).

func (u AccountData) VotingStake() MicroAlgos {
// OnlineAccountData returns subset of AccountData as OnlineAccountData data structure.
// Account is expected to be Online otherwise its stake is cleared out
func (u AccountData) OnlineAccountData() OnlineAccountData {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code here suggest that you could have a situation where you have a non-online account which has any of the VoteID/SelectionID/VoteFirstValid/VoteLastValid/VoteKeyDilution non-zero, which isn't correct.
If Status is online, then all these fields are valid. Otherwise, they are all empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also thought about it but decided to keep the same as before. But I agree, returning empty if not online looks correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cce opinion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good — assuming in the current code these AccountData fields are currently always zero when Status is non-online, the agreement side will behave the same either way.

Copy link
Contributor

@tsachiherman tsachiherman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, but I'd like @cce to take a look as well.

@tsachiherman tsachiherman merged commit a957519 into algorand:master Oct 13, 2021
tsachiherman pushed a commit that referenced this pull request Oct 13, 2021
## Summary

Use LookupAgreement in AlgorandFullNode.VotingKeys()

Post #3046 fixes.
cce pushed a commit to cce/go-algorand that referenced this pull request Oct 28, 2021
## Summary

1. Add  a new `OnlineAccountData` data type
2. Implement `LookupAgreement`

## Test Plan

Fixed existed tests: added `LookupAgreement` to mocked ledgers
cce pushed a commit to cce/go-algorand that referenced this pull request Oct 28, 2021
## Summary

Use LookupAgreement in AlgorandFullNode.VotingKeys()

Post algorand#3046 fixes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants