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

Make IPLD plugin a package, not a sub-module #294

Merged
merged 7 commits into from
Apr 23, 2021

Conversation

Wondertan
Copy link
Member

@Wondertan Wondertan commented Apr 20, 2021

The PR:

  • Actually makes IPLD plugin a package (closes: ipld: make sub-module a package instead #291)
  • Updates plugin code to conform gofmt and golangci-lint`
  • Changes NMTNodeAdder to catch possible errors when plugin nodes are added.
  • Updates .so plugin building for IPFS in Makefile

@Wondertan
Copy link
Member Author

So it seems like both go fmt and golangci-lint run were ignoring that code...

@liamsi
Copy link
Member

liamsi commented Apr 20, 2021

So it seems like both go fmt and golangci-lint run were ignoring that code...

Ouch, ouch. Can you fix those lints here too?

p2p/ipld/plugin/Makefile Outdated Show resolved Hide resolved
@Wondertan
Copy link
Member Author

@liamsi, golangcilint opened an issue about not checking errors when we add nodes to Batch here. In my opinion, this could silently produce undefined behaviors, so I would fix this now, rather than debug myself to death when the unobvious bug appears, as an error was silently ignored. However, it is not obvious how to handle errors here. Options:

  • Extend VisitorFunc and tree.Root to return errors. In general, Visitors can do some funky stuff that can return errors, so adding optional erroring would enhance NMT API IMO.
  • Introduce another Visitor that would be called on Push, though that does not work for intermediate nodes.
  • Update NmtNodeAdder struct to have an error, similar to Batch and introduce Commit method that would wrap Batch.Commit, check for errors if any, and be used here.

@liamsi
Copy link
Member

liamsi commented Apr 21, 2021

Cool, that you wrote up different alternatives 👌🏼

Update NmtNodeAdder struct to have an error, similar to Batch and introduce Commit method that would wrap Batch.Commit, check for errors if any, and be used here.

I think that is the best approach.

Pros:

  • least invasive and only adds errors / error-handling where it's necessary; in other words very local change
  • follows an already well-established pattern of the used underlying data structure (Batch)

Cons:

  • not generalizable to other cases (no a biggie as I don't see us adding a bunch of erroring funky visitors)

Regarding the other two:

  • Extend VisitorFunc and tree.Root to return errors. In general, Visitors can do some funky stuff that can return errors, so adding optional erroring would enhance NMT API IMO.
  • Introduce another Visitor that would be called on Push, though that does not work for intermediate nodes.

I'm not really sure the second would work and the first requires changing the tree interface which we should avoid (at least in this PR imo).

@codecov-commenter
Copy link

codecov-commenter commented Apr 21, 2021

Codecov Report

Merging #294 (c8aea32) into master (93c88a1) will decrease coverage by 0.42%.
The diff coverage is 59.80%.

@@            Coverage Diff             @@
##           master     #294      +/-   ##
==========================================
- Coverage   62.27%   61.85%   -0.43%     
==========================================
  Files         260      270      +10     
  Lines       23218    23890     +672     
==========================================
+ Hits        14460    14776     +316     
- Misses       7265     7578     +313     
- Partials     1493     1536      +43     
Impacted Files Coverage Δ
cmd/tendermint/commands/light.go 16.66% <0.00%> (ø)
cmd/tendermint/commands/run_node.go 0.00% <ø> (ø)
config/config.go 77.74% <ø> (-0.15%) ⬇️
config/toml.go 60.86% <ø> (ø)
consensus/replay_file.go 0.00% <0.00%> (ø)
consensus/state.go 67.52% <0.00%> (+0.27%) ⬆️
crypto/merkle/proof_value.go 0.00% <0.00%> (ø)
crypto/random.go 50.00% <ø> (ø)
evidence/pool.go 65.35% <ø> (ø)
libs/db/memdb/batch.go 0.00% <0.00%> (ø)
... and 61 more

@liamsi
Copy link
Member

liamsi commented Apr 21, 2021

p2p/ipld/read_test.go Outdated Show resolved Hide resolved
Copy link
Member

@liamsi liamsi left a comment

Choose a reason for hiding this comment

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

This looks great! Thanks @Wondertan

Left a minor nit regarding a private function.

@Wondertan Wondertan merged commit 8524627 into master Apr 23, 2021
@Wondertan Wondertan deleted the hlib/ipld-plugin-as-package branch April 23, 2021 09:32
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.

ipld: make sub-module a package instead
4 participants