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: replace Ledger.LookupResource with Lookup{Application,Asset} #3708

Merged
merged 5 commits into from
Mar 4, 2022

Conversation

cce
Copy link
Contributor

@cce cce commented Mar 2, 2022

Summary

This replaces the various Ledger interfaces' LookupResource method with two more specific LookupApplication and LookupAsset methods. Following up on code review feedback from #3652.

Test Plan

Existing tests should pass, including the ones that implement their own mock ledger.

@cce cce added the Enhancement label Mar 2, 2022
@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2022

Codecov Report

Merging #3708 (e9b6670) into master (09b6c38) will increase coverage by 0.01%.
The diff coverage is 71.87%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3708      +/-   ##
==========================================
+ Coverage   49.56%   49.57%   +0.01%     
==========================================
  Files         391      391              
  Lines       68535    68560      +25     
==========================================
+ Hits        33970    33991      +21     
- Misses      30829    30832       +3     
- Partials     3736     3737       +1     
Impacted Files Coverage Δ
daemon/algod/api/server/v1/handlers/handlers.go 0.63% <0.00%> (ø)
daemon/algod/api/server/v2/handlers.go 0.00% <0.00%> (ø)
daemon/algod/api/spec/v2/model.go 0.00% <ø> (ø)
ledger/ledgercore/accountresource.go 0.00% <ø> (ø)
ledger/evalindexer.go 53.33% <50.00%> (-0.19%) ⬇️
daemon/algod/api/server/v2/dryrun.go 68.59% <53.33%> (-0.33%) ⬇️
cmd/tealdbg/localLedger.go 65.62% <93.33%> (-0.62%) ⬇️
ledger/acctupdates.go 68.42% <100.00%> (+0.74%) ⬆️
ledger/internal/eval.go 66.44% <100.00%> (ø)
ledger/internal/evalprefetcher.go 84.25% <100.00%> (+0.62%) ⬆️
... 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 09b6c38...e9b6670. Read the comment docs.

if task.creatableType == basics.AppCreatable {
var appResource ledgercore.AppResource
appResource, err = p.ledger.LookupApplication(p.rnd, *task.address, basics.AppIndex(task.creatableIndex))
resource.AppParams = appResource.AppParams
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks that with your change, we should also change the loadedTransactionGroup.resources into the two explicit lists of assets and applications. This could be done later on, though.

Copy link
Contributor Author

@cce cce Mar 3, 2022

Choose a reason for hiding this comment

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

yes, I wasn't sure if that was in scope or whether it was OK for behind-the-scenes implementations further away from the external-facing ledger interfaces to deal with resources. But yes it would mean splitting loadAccountsAddResourceTask into two functions/tasks and maybe could be put off for when someone works on the harness to catch differences between calls to apply.Balances from a suite of test transactions and the resources that are queued for prefetching.

}

// lookupResource loads a resource that matches the request parameters from the accounts update
func (l *Ledger) lookupResource(rnd basics.Round, addr basics.Address, aidx basics.CreatableIndex, ctype basics.CreatableType) (ledgercore.AccountResource, error) {
l.trackerMu.RLock()
defer l.trackerMu.RUnlock()

Copy link
Contributor

Choose a reason for hiding this comment

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

what rewards is this talking about?

Copy link
Contributor

Choose a reason for hiding this comment

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

you're correct, the comment is wrong and need to be removed. ( regardless of this change )

@tsachiherman tsachiherman merged commit f919bb8 into algorand:master Mar 4, 2022
@egieseke egieseke mentioned this pull request Mar 6, 2022
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