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

Prevent double writes of samples to IPFS #271

Merged
merged 3 commits into from
Apr 7, 2021

Conversation

Wondertan
Copy link
Member

@Wondertan Wondertan commented Apr 7, 2021

Problem

As we compute the NMT tree for columns and rows of shares in an extended data square, we end up adding all the shares into IPFS two times, thus introducing unnecessary overhead, especially for IO. Considering how big blocks may become and how quickly they are generated, the overhead would scale significantly.

Solution

The PR introduces a simple patch in NMTNodeAdder to memoize added leaves not to be added a second time.

EDIT:
It also fixes incorrect use of BatchAdder

EDIT2:
Closes #204

@Wondertan Wondertan requested review from liamsi and evan-forbes April 7, 2021 01:06
@Wondertan Wondertan self-assigned this Apr 7, 2021
@Wondertan Wondertan requested a review from tac0turtle as a code owner April 7, 2021 01:07
Copy link
Member

@evan-forbes evan-forbes left a comment

Choose a reason for hiding this comment

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

I'd wait for another reviewer to comment before merging, but this LGTM 👍

IMO this closes #204 as well. Awesome find @Wondertan

Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com>
@codecov-io
Copy link

Codecov Report

Merging #271 (c3ce6f4) into master (93c88a1) will decrease coverage by 0.15%.
The diff coverage is 80.41%.

@@            Coverage Diff             @@
##           master     #271      +/-   ##
==========================================
- Coverage   62.27%   62.12%   -0.16%     
==========================================
  Files         260      262       +2     
  Lines       23218    23359     +141     
==========================================
+ Hits        14460    14512      +52     
- Misses       7265     7329      +64     
- Partials     1493     1518      +25     
Impacted Files Coverage Δ
types/shares.go 100.00% <ø> (+2.19%) ⬆️
types/block.go 77.58% <57.14%> (+0.96%) ⬆️
types/share_merging.go 72.54% <72.54%> (ø)
types/share_splitting.go 97.43% <97.43%> (ø)
types/tx.go 85.18% <100.00%> (ø)
privval/signer_listener_endpoint.go 82.35% <0.00%> (-7.06%) ⬇️
privval/socket_listeners.go 78.72% <0.00%> (-4.26%) ⬇️
blockchain/v0/pool.go 80.60% <0.00%> (-3.81%) ⬇️
privval/secret_connection.go 72.68% <0.00%> (-3.61%) ⬇️
privval/signer_endpoint.go 75.75% <0.00%> (-3.04%) ⬇️
... and 14 more

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.

Great find and great work! 🚀

@Wondertan Wondertan merged commit 2b2ce8a into master Apr 7, 2021
@Wondertan Wondertan deleted the hlib/prevent-double-writes branch April 7, 2021 17:52
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.

Write block data to IPFS asynchronously
4 participants