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

chore: share encoding refactor #1462

Merged
merged 19 commits into from
Mar 16, 2023
Merged

chore: share encoding refactor #1462

merged 19 commits into from
Mar 16, 2023

Conversation

mojtaba-esk
Copy link
Member

context in the issue #1443

Overview

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

@MSevey MSevey requested a review from a team March 9, 2023 21:24
@codecov-commenter
Copy link

codecov-commenter commented Mar 10, 2023

Codecov Report

Merging #1462 (33da3e9) into main (651b1cf) will increase coverage by 1.43%.
The diff coverage is 79.22%.

@@            Coverage Diff             @@
##             main    #1462      +/-   ##
==========================================
+ Coverage   49.22%   50.66%   +1.43%     
==========================================
  Files          79       82       +3     
  Lines        4477     4719     +242     
==========================================
+ Hits         2204     2391     +187     
- Misses       2089     2134      +45     
- Partials      184      194      +10     
Impacted Files Coverage Δ
pkg/shares/padding.go 84.00% <62.50%> (-9.11%) ⬇️
pkg/shares/split_sparse_shares.go 46.55% <72.72%> (-18.62%) ⬇️
pkg/shares/parse_compact_shares.go 70.00% <75.60%> (-1.67%) ⬇️
pkg/shares/merge.go 77.35% <76.92%> (-3.90%) ⬇️
pkg/shares/share_builder.go 79.31% <79.31%> (ø)
pkg/shares/shares.go 79.82% <82.60%> (-7.68%) ⬇️
pkg/shares/split_compact_shares.go 82.72% <83.33%> (-4.56%) ⬇️
pkg/proof/proof.go 67.46% <100.00%> (ø)
pkg/shares/parse.go 82.00% <100.00%> (-0.36%) ⬇️
pkg/shares/parse_sparse_shares.go 63.79% <100.00%> (-0.62%) ⬇️

... and 14 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

Overall I like this approach! I think the builder would benefit from unit tests.

In a separate PR we may consider enforcing invariants on the share type (i.e. is a byte slice of length 512) and on a related note enforce that the share type can only be constructed through this share builder. Thoughts?

pkg/shares/compact_shares_test.go Outdated Show resolved Hide resolved
pkg/shares/share_builder.go Outdated Show resolved Hide resolved
pkg/shares/share_builder.go Outdated Show resolved Hide resolved
pkg/shares/share_builder.go Outdated Show resolved Hide resolved
pkg/shares/share_builder.go Outdated Show resolved Hide resolved
pkg/shares/share_builder.go Show resolved Hide resolved
Co-authored-by: Rootul P <rootulp@gmail.com>
@MSevey MSevey requested a review from a team March 10, 2023 16:06
@mojtaba-esk
Copy link
Member Author

Overall I like this approach! I think the builder would benefit from unit tests.

In a separate PR we may consider enforcing invariants on the share type (i.e. is a byte slice of length 512) and on a related note enforce that the share type can only be constructed through this share builder. Thoughts?

Yeah, totally agreed.
And I let's make a separate PR for error propagation thing.

@evan-forbes
Copy link
Member

evan-forbes commented Mar 13, 2023

will review this by eod!! apologies for the delay

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.

overall this is a really really good refactor!! well done @mojtaba-esk and and good idea @rootulp

I do think there are some instances where we are panicking, and if we want this to be a library that can be used by others outside of celestia-app, then I think those need to be removed. Otherwise its way too easy to accidently write a bug where someone can shutdown your light node/whatever. I also think most can be bubbled easily or with little consequence to other current apis, but even if that's not the case, we should avoid panics at all costs for all user facing things. We can definitely do this in a different PR though!

since this is a refactor and we're not in a particular rush, we could take advantage of the new design to add unit tests where previously we couldn't. Addional fuzzers would also be huge bonus, but very optional given our existing high level ones and certainly can be done in a different PR

app/test/process_proposal_test.go Outdated Show resolved Hide resolved
pkg/shares/split_compact_shares.go Show resolved Hide resolved
pkg/shares/share_builder.go Show resolved Hide resolved
@MSevey MSevey requested a review from a team March 15, 2023 15:55
evan-forbes
evan-forbes previously approved these changes Mar 15, 2023
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.

:shipit: !

rootulp
rootulp previously approved these changes Mar 15, 2023
pkg/shares/parse_compact_shares.go Outdated Show resolved Hide resolved
pkg/shares/parse_compact_shares.go Outdated Show resolved Hide resolved
pkg/shares/share_builder_test.go Outdated Show resolved Hide resolved
Co-authored-by: Rootul P <rootulp@gmail.com>
@mojtaba-esk mojtaba-esk dismissed stale reviews from rootulp and evan-forbes via 6fd2c16 March 16, 2023 11:14
@MSevey MSevey requested a review from a team March 16, 2023 11:15
mojtaba-esk and others added 2 commits March 16, 2023 12:15
Co-authored-by: Rootul P <rootulp@gmail.com>
Co-authored-by: Rootul P <rootulp@gmail.com>
@mojtaba-esk mojtaba-esk merged commit 71ab161 into main Mar 16, 2023
@mojtaba-esk mojtaba-esk deleted the mojtaba/share-refactor branch March 16, 2023 14:06
@gitpoap-bot
Copy link

gitpoap-bot bot commented Mar 16, 2023

Congrats, your important contribution to this open-source project has earned you a GitPOAP!

GitPOAP: 2023 Celestia Contributor:

GitPOAP: 2023 Celestia Contributor GitPOAP Badge

Head to gitpoap.io & connect your GitHub account to mint!

Learn more about GitPOAPs here.

rootulp added a commit to rootulp/celestia-app that referenced this pull request May 8, 2023
rootulp added a commit that referenced this pull request May 12, 2023
Thanks @cmwaters for discovering. Appears residual after
#1462.

Co-authored-by: Callum Waters <cmwaters19@gmail.com>
cmwaters added a commit to celestiaorg/go-square that referenced this pull request Dec 14, 2023
Thanks @cmwaters for discovering. Appears residual after
celestiaorg/celestia-app#1462.

Co-authored-by: Callum Waters <cmwaters19@gmail.com>
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.

None yet

4 participants