Skip to content

fix: various traversal and verifier fixes#338

Merged
rvagg merged 1 commit intomainfrom
rvagg/validate-non-eof-error
Jul 4, 2023
Merged

fix: various traversal and verifier fixes#338
rvagg merged 1 commit intomainfrom
rvagg/validate-non-eof-error

Conversation

@rvagg
Copy link
Member

@rvagg rvagg commented Jun 29, 2023

Closes: #336

  • don't treat context cancellation as an ErrExtraneousBlock in the CAR verifier
  • capture and properly handle block load errors that are missed by the go-ipld-prime traverser, ref: fix: return error on LookupBySegment failure ipld/go-ipld-prime#524
  • fix flaky case(s) in verifiedcar test suite where multi-level sharded directory is assumed but only a single block dir is produced

The flaky one is really interesting, it became more flaky once we started properly and consistently reporting errors from the traversal, then it would flip between two error types. The fix was to ensure that the fixture data had a particular shape because certain forms produce certain errors. Fun fun.

@rvagg rvagg requested a review from hannahhoward June 29, 2023 05:38
@codecov-commenter
Copy link

codecov-commenter commented Jun 29, 2023

Codecov Report

Merging #338 (0958b2b) into main (e558f16) will increase coverage by 0.42%.
The diff coverage is 97.05%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #338      +/-   ##
==========================================
+ Coverage   75.94%   76.37%   +0.42%     
==========================================
  Files          85       85              
  Lines        6323     6378      +55     
==========================================
+ Hits         4802     4871      +69     
+ Misses       1248     1239       -9     
+ Partials      273      268       -5     
Impacted Files Coverage Δ
pkg/verifiedcar/verifiedcar.go 83.22% <91.30%> (+1.79%) ⬆️
pkg/internal/testutil/gen.go 90.83% <100.00%> (+1.74%) ⬆️
pkg/retriever/bitswapretriever.go 93.88% <100.00%> (+0.45%) ⬆️
pkg/retriever/httpretriever.go 85.59% <100.00%> (ø)
pkg/server/http/ipfs.go 65.96% <100.00%> (ø)
pkg/storage/duplicateaddercar.go 91.81% <100.00%> (-2.58%) ⬇️

... and 6 files with indirect coverage changes

Copy link
Collaborator

@hannahhoward hannahhoward left a comment

Choose a reason for hiding this comment

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

Generally looks reasonable. Couple suggestions. Curious why we can ignore context cancelled in the error func.

}
}

func (nbro *NextBlockReadOpener) StorageReadOpener(lc linking.LinkContext, l datamodel.Link) (io.Reader, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: make an internal function that just loads the block, wrap inside this function that just adds to count & sets the error if present. Will remove some repeated sets of the error and I think simplify

// make sure we don't have any extraneous data beyond what the traversal needs
_, err = cbr.Next()
if !errors.Is(err, io.EOF) {
if ctx.Err() == nil && !errors.Is(err, context.Canceled) && !errors.Is(err, io.EOF) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't we also need to return a seperate error for context cancelled? it's not a success no?

Copy link
Collaborator

@hannahhoward hannahhoward left a comment

Choose a reason for hiding this comment

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

Marking this LGTM but I'll leave merge up to you so you can address suggestions if you want.

@rvagg rvagg force-pushed the rvagg/validate-non-eof-error branch from 6ab45e5 to 0958b2b Compare July 3, 2023 01:14
@rvagg
Copy link
Member Author

rvagg commented Jul 3, 2023

I've reworked that NextBlockReadOpener thing a bit, from feedback and also to reduce the size of the struct itself.

A few other tweaks. PTAL @hannahhoward

Copy link
Collaborator

@hannahhoward hannahhoward left a comment

Choose a reason for hiding this comment

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

Thumbs up on refactor, good strategy. I like this.

Closes: #336

* don't treat context cancellation as an ErrExtraneousBlock in the CAR verifier
* capture and properly handle block load errors that are missed by the
  go-ipld-prime traverser, ref: ipld/go-ipld-prime#524
* fix flaky case(s) in verifiedcar test suite where multi-level sharded
  directory is assumed but only a single block dir is produced
@rvagg rvagg force-pushed the rvagg/validate-non-eof-error branch from 0958b2b to 59c5880 Compare July 4, 2023 23:36
@rvagg rvagg merged commit 013521e into main Jul 4, 2023
@rvagg rvagg deleted the rvagg/validate-non-eof-error branch July 4, 2023 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect error message being logged

3 participants