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

prefetcher: add Eval vs prefetcher alignment tests #3729

Merged
merged 4 commits into from
Mar 9, 2022

Conversation

tolikzinovyev
Copy link
Contributor

Summary

Tests for eval prefetcher checking that the prefetcher loads the same data (with some exceptions) that the evaluator requests.

Closes https://github.com/algorand/go-algorand-internal/issues/1922.

Test Plan

This is tests.

}

accounts, apps, assets, creators := prefetch(t, l, txn)
runEval(t, l, txn)
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't runEval clear out the previously loaded requestedBalances ? otherwise, it wouldn't be able to properly compare the groups.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Each test has its own l.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, of course. But when you call the runEval, you should have a clean slate. Otherwise, you're testing commulative sum rather than distinct groups.
( don't forget that the prefetcher is calling the ledger to perform the loading of the resources.. which fills up the requestedBalances fields.. )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, will fix it

@codecov-commenter
Copy link

codecov-commenter commented Mar 8, 2022

Codecov Report

Merging #3729 (6c4dc46) into master (d3dc437) will increase coverage by 0.00%.
The diff coverage is 70.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3729   +/-   ##
=======================================
  Coverage   49.68%   49.68%           
=======================================
  Files         392      392           
  Lines       68588    68591    +3     
=======================================
+ Hits        34076    34078    +2     
- Misses      30766    30768    +2     
+ Partials     3746     3745    -1     
Impacted Files Coverage Δ
ledger/internal/eval.go 67.02% <0.00%> (+0.57%) ⬆️
ledger/internal/evalprefetcher.go 89.16% <87.50%> (+4.91%) ⬆️
crypto/merkletrie/trie.go 66.42% <0.00%> (-2.19%) ⬇️
crypto/merkletrie/node.go 91.62% <0.00%> (-1.87%) ⬇️
node/node.go 23.33% <0.00%> (-1.86%) ⬇️
data/abi/abi_type.go 87.67% <0.00%> (-0.95%) ⬇️
data/transactions/verify/txn.go 44.15% <0.00%> (-0.87%) ⬇️
network/requestTracker.go 70.25% <0.00%> (-0.87%) ⬇️
ledger/acctupdates.go 68.42% <0.00%> (-0.67%) ⬇️
network/wsPeer.go 68.05% <0.00%> (ø)
... and 7 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 d3dc437...6c4dc46. Read the comment docs.

if !stxn.Txn.AssetSender.IsZero() {
loadAccountsAddResourceTask(nil, basics.CreatableIndex(stxn.Txn.XferAsset), basics.AssetCreatable, task, resourceTasks, queue)
Copy link
Contributor

Choose a reason for hiding this comment

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

in the case of AssetTransferTx with non-zero AssetSender, you've removed the loading of the Txn.Sender asset resource loading ( i.e. clawback ). I'm pretty sure that in case of a clawback, we need to load the sender resources ( so we can claw them back ).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Clawback will claw back AssetSender resources, not Sender.

@@ -32,6 +32,22 @@ import (
"github.com/algorand/go-algorand/test/partitiontest"
)

func acctAddrPtr(i int) (o *basics.Address) {
Copy link
Contributor

Choose a reason for hiding this comment

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

these function names were fine when these were local to a single benchmark. However, if you've moving these to the global space, please make sure the method name concisely describe the function behavior; i.e. makeTestingAddressPtr(addressSeed int)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@tsachiherman tsachiherman changed the title Eval prefetcher alignment tests prefetcher: add Eval vs prefetcher alignment tests Mar 9, 2022
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.

Reviewing the changes here - I think that the test itself is well written, and cover what we need.

One thing that I'd like to address here is the usage of global variable/function names. In this PR you've introduced few of them. While it's true that these apply only for testing, as the package grows, the global namespace pollution grows along. Since this is one of our most critical packages, I'd like to make sure it's very well maintained. When we have global variables defined in a test file, we need to name these in a way so that it won't collide with other tests. Examples for names that we should avoid in this PR are : "proto", "feeSink", "run".

If you were to make these scope-dependent, or just name them differently, i.e. makeTestingAddress, it would be just fine.

@tolikzinovyev
Copy link
Contributor Author

Reviewing the changes here - I think that the test itself is well written, and cover what we need.

One thing that I'd like to address here is the usage of global variable/function names. In this PR you've introduced few of them. While it's true that these apply only for testing, as the package grows, the global namespace pollution grows along. Since this is one of our most critical packages, I'd like to make sure it's very well maintained. When we have global variables defined in a test file, we need to name these in a way so that it won't collide with other tests. Examples for names that we should avoid in this PR are : "proto", "feeSink", "run".

If you were to make these scope-dependent, or just name them differently, i.e. makeTestingAddress, it would be just fine.

Agree, but I think the right solution is to split eval into many packages. Let me know what you think.

@tsachiherman tsachiherman merged commit 6c52126 into algorand:master Mar 9, 2022
jannotti pushed a commit to jannotti/go-algorand that referenced this pull request Mar 13, 2022
## Summary

Tests for eval prefetcher checking that the prefetcher loads the same data (with some exceptions) that the evaluator requests.

Closes algorand/go-algorand-internal#1922.

## Test Plan

This is tests.
@algojack algojack mentioned this pull request Mar 15, 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.

3 participants