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

feat(shwap): Add ODS file #3482

Merged
merged 13 commits into from
Jun 19, 2024
Merged

feat(shwap): Add ODS file #3482

merged 13 commits into from
Jun 19, 2024

Conversation

walldiss
Copy link
Member

This PR adds ods file, that implements eds.Accessor interface. The file stores ods part of eds on disk and lazily reads data upon request. If requested data is from Q4, it reads full ods in single read and stores it in-memory for later re-use.

Based on #3425

@walldiss walldiss added kind:feat Attached to feature PRs shwap labels Jun 10, 2024
@walldiss walldiss self-assigned this Jun 10, 2024
@walldiss
Copy link
Member Author

Lint will be get fixed after linter upgrade #3483

@walldiss walldiss force-pushed the ods-accessor branch 2 times, most recently from 8164195 to dda1b17 Compare June 10, 2024 07:36
@walldiss walldiss changed the title feat(shwap): Ods file accessor feat(shwap): Add ODS file Jun 10, 2024
@walldiss walldiss requested a review from cristaloleg as a code owner June 10, 2024 11:54
@walldiss walldiss force-pushed the shwap branch 3 times, most recently from c4550bf to 60e757e Compare June 10, 2024 11:58
store/file/codec_test.go Show resolved Hide resolved
store/file/header.go Outdated Show resolved Hide resolved
store/file/square.go Outdated Show resolved Hide resolved
store/file/header.go Outdated Show resolved Hide resolved
store/file/ods.go Outdated Show resolved Hide resolved
store/file/ods_test.go Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Jun 11, 2024

Codecov Report

Attention: Patch coverage is 71.75325% with 87 lines in your changes missing coverage. Please review.

Please upload report for BASE (shwap@c78f081). Learn more about missing BASE report.

Files Patch % Lines
store/file/ods.go 71.94% 21 Missing and 18 partials ⚠️
share/shwap/sample.go 0.00% 14 Missing ⚠️
store/file/square.go 77.77% 7 Missing and 7 partials ⚠️
store/file/header.go 75.60% 6 Missing and 4 partials ⚠️
share/new_eds/axis_half.go 70.37% 4 Missing and 4 partials ⚠️
store/file/codec.go 84.61% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             shwap    #3482   +/-   ##
========================================
  Coverage         ?   44.10%           
========================================
  Files            ?      291           
  Lines            ?    16891           
  Branches         ?        0           
========================================
  Hits             ?     7450           
  Misses           ?     8572           
  Partials         ?      869           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@Wondertan Wondertan left a comment

Choose a reason for hiding this comment

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

First look, still have to go over the logic in square and the file

Comment on lines +45 to +48
shares := make([]share.Share, len(original)*2)
copy(shares, original)
copy(shares[len(original):], parity)
return shares, nil
Copy link
Member

Choose a reason for hiding this comment

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

Feels like there is an optimization opportunity to avoid copying that we can return to later

Copy link
Member Author

Choose a reason for hiding this comment

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

Need to prealloc shares anyway, so copying is necessary. Can do implicitly by append tho

Comment on lines +168 to +172
namespaceBytes := share.GetNamespace(sh)
leave := make([]byte, len(sh)+len(namespaceBytes))
copy(leave, namespaceBytes)
copy(leave[len(namespaceBytes):], sh)
leaves = append(leaves, leave)
Copy link
Member

Choose a reason for hiding this comment

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

Is this a refactoring from appends to copies?

Copy link
Member Author

Choose a reason for hiding this comment

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

I like that you noticed. There was a very nasty mutations bug that took me few hours to fix.

store/file/codec.go Show resolved Hide resolved
store/file/ods.go Outdated Show resolved Hide resolved
store/file/header.go Show resolved Hide resolved
store/file/header.go Show resolved Hide resolved
store/file/header.go Show resolved Hide resolved
store/file/header.go Outdated Show resolved Hide resolved
store/file/ods.go Outdated Show resolved Hide resolved
store/file/header.go Outdated Show resolved Hide resolved
store/file/ods.go Outdated Show resolved Hide resolved
store/file/ods.go Show resolved Hide resolved
store/file/ods.go Outdated Show resolved Hide resolved
store/file/ods.go Outdated Show resolved Hide resolved
store/file/ods.go Outdated Show resolved Hide resolved
store/file/square.go Outdated Show resolved Hide resolved
store/file/square.go Show resolved Hide resolved
store/file/square.go Outdated Show resolved Hide resolved
store/file/ods.go Outdated Show resolved Hide resolved
store/file/ods.go Outdated Show resolved Hide resolved
store/file/square.go Outdated Show resolved Hide resolved
store/file/square.go Outdated Show resolved Hide resolved
store/file/square.go Outdated Show resolved Hide resolved
Comment on lines 200 to 212
col, err := f.readCol(axisIdx, 0)
return eds.AxisHalf{
Shares: col,
IsParity: false,
}, err
case rsmt2d.Row:
return f.readRow(axisIdx)
row, err := f.readRow(axisIdx)
return eds.AxisHalf{
Shares: row,
IsParity: false,
}, err
}
return nil, fmt.Errorf("unknown axis")
return eds.AxisHalf{}, fmt.Errorf("unknown axis")
Copy link
Member

Choose a reason for hiding this comment

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

uber optional nit: dedup

store/file/ods.go Outdated Show resolved Hide resolved
store/file/header.go Outdated Show resolved Hide resolved
store/file/header.go Show resolved Hide resolved
store/file/header.go Outdated Show resolved Hide resolved
@walldiss walldiss merged commit 114e0f5 into celestiaorg:shwap Jun 19, 2024
12 checks passed
walldiss added a commit to walldiss/celestia-node that referenced this pull request Jul 6, 2024
This PR adds ods file, that implements eds.Accessor interface. The file stores ods part of eds on disk and lazily reads data upon request. If requested data is from Q4, it reads full ods in single read and stores it in-memory for later re-use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:feat Attached to feature PRs shwap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants