Skip to content

Conversation

@algonautshant
Copy link
Contributor

Enhance the error reporting in prefetcher

resolves https://github.com/algorand/go-algorand-internal/issues/1921

}

// GroupTaskError indicates the group index of the unfulfilled resource
type GroupTaskError struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

two requests:

  1. move the GroupTaskError to the prefetcher package.
  2. Make GroupTaskError be used with &GroupTaskError, and have the Unwrap() error implemented, so that the caller could use the errors.Is and errors.As.

func (l *prefetcherTestLedger) LookupWithoutRewards(_ basics.Round, addr basics.Address) (ledgercore.AccountData, basics.Round, error) {
func (l *prefetcherTestLedger) LookupWithoutRewards(rnd basics.Round, addr basics.Address) (ledgercore.AccountData, basics.Round, error) {
if _, has := l.errorAddress[addr]; has {
return ledgercore.AccountData{}, l.round, fmt.Errorf("Lookup Error")
Copy link
Contributor

Choose a reason for hiding this comment

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

you might want to use a custom error type here so that you could make errors.Is when testing.

return ledgercore.AppResource{}, nil
}
func (l *prefetcherTestLedger) LookupAsset(rnd basics.Round, addr basics.Address, aidx basics.AssetIndex) (ledgercore.AssetResource, error) {
if aidx > 1000000 {
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of using a threshold, make a given asset index invalid ( i.e. const errorTriggeringAssetIndex = 1000000 )


// Test for the GroupIdx in the returned error
tc := testCases[3]
t.Run(tc.name, func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if you're repeating the same test case name, please have this implemented in a separate Test function.

// if there is an error, report the error to the output channel.
p.outChan <- LoadedTransactionGroup{
Err: done.err,
Err: ledgercore.GroupTaskError{Err: done.err, GroupIdx: done.groupIdx},
Copy link
Contributor

Choose a reason for hiding this comment

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

With your change, the Err is always either of type ledgercore.GroupTaskError or nil. It sounds as if you should change the Err datatype to be *GroupTaskError.

tc := testCases[3]
t.Run(tc.name, func(t *testing.T) {
errorReceived := false
groups := make([][]transactions.SignedTxnWithAD, 5)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that this test would be much more readable if you'll use explicit use cases ( as above ), instead of programmatically modifying the test cases.

@algonautshant algonautshant marked this pull request as ready for review March 23, 2022 16:09
algorandskiy
algorandskiy previously approved these changes Mar 25, 2022
@codecov-commenter
Copy link

codecov-commenter commented Mar 25, 2022

Codecov Report

Merging #3815 (8b16d9c) into master (32cfc42) will increase coverage by 0.02%.
The diff coverage is 86.66%.

@@            Coverage Diff             @@
##           master    #3815      +/-   ##
==========================================
+ Coverage   49.99%   50.01%   +0.02%     
==========================================
  Files         392      393       +1     
  Lines       68495    68503       +8     
==========================================
+ Hits        34242    34265      +23     
+ Misses      30497    30487      -10     
+ Partials     3756     3751       -5     
Impacted Files Coverage Δ
data/abi/abi_encode.go 61.94% <ø> (+0.68%) ⬆️
ledger/internal/prefetcher/error.go 33.33% <33.33%> (ø)
ledger/internal/prefetcher/prefetcher.go 96.74% <100.00%> (+7.29%) ⬆️
ledger/blockqueue.go 82.18% <0.00%> (-2.88%) ⬇️
data/abi/abi_type.go 87.67% <0.00%> (-0.95%) ⬇️
data/transactions/verify/txn.go 44.15% <0.00%> (-0.87%) ⬇️
catchup/service.go 68.88% <0.00%> (-0.75%) ⬇️
ledger/acctupdates.go 68.51% <0.00%> (-0.66%) ⬇️
network/wsPeer.go 68.05% <0.00%> (-0.56%) ⬇️
catchup/peerSelector.go 100.00% <0.00%> (+1.04%) ⬆️
... and 5 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 17c0fee...8b16d9c. Read the comment docs.

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