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

Fix marshalling error #53

Merged
merged 1 commit into from
Apr 28, 2020
Merged

Fix marshalling error #53

merged 1 commit into from
Apr 28, 2020

Conversation

hannahhoward
Copy link
Collaborator

Goals

This bug manifested as an issue in Graphsync's IPLD prime upgrade where it appeared the created blockchain structure was not working. As it turns out, the issue was not the structure of nodes created but encode/decode from CBOR. I tracked it to an ErrInvalidMultibase error in decode, but eventually figured out the error was on a node that was created as bytes. Eventually, I noticed that during the NodeAssembler upgrade, we switched from marshall using a local token variable at each recursive level to a single token variable passed down the recursion tree as a pointer. Eventually, that led me to realize that once a link was encountered during traverse, tk.Tagged was set true and never unset (along with tk.Tag = linkTag). If there was a subsequent Bytes node encountered, it was written as a Link, which would later error when decoding.

Implementation

  • create a minimal repro test
  • fix by just clearing the Tagged boolean after the link is written

Fix an error with marshalling that causes bytes nodes to get written as links if they are written
after a link, because the tag was never reset
@codecov
Copy link

codecov bot commented Apr 28, 2020

Codecov Report

Merging #53 into master will increase coverage by 0.48%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #53      +/-   ##
==========================================
+ Coverage   51.26%   51.74%   +0.48%     
==========================================
  Files          69       69              
  Lines        4836     4837       +1     
==========================================
+ Hits         2479     2503      +24     
+ Misses       2252     2225      -27     
- Partials      105      109       +4     
Impacted Files Coverage Δ
codec/dagcbor/marshal.go 51.45% <100.00%> (+16.16%) ⬆️
codec/dagcbor/unmarshal.go 44.89% <0.00%> (+7.14%) ⬆️

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 50e2df1...2edb45a. Read the comment docs.

@warpfork
Copy link
Collaborator

warpfork commented Apr 28, 2020

Uuf, I'm embarrassed this bug made its way out to you. Great sleuthing and thanks for the fix and test.

@warpfork warpfork merged commit bd40287 into master Apr 28, 2020
@warpfork warpfork deleted the bugs/cbor-marshall branch April 28, 2020 10:07
@aschmahmann aschmahmann mentioned this pull request Sep 22, 2020
72 tasks
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.

3 participants