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: got rid of most panics in share pkg #1512

Merged
merged 3 commits into from
Mar 22, 2023

Conversation

mojtaba-esk
Copy link
Member

@mojtaba-esk mojtaba-esk commented Mar 21, 2023

Context here: #1490

closes #1490

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 21, 2023 13:52
@github-actions
Copy link

PR Preview Action v1.3.0
🚀 Deployed preview to https://celestiaorg.github.io/celestia-app/pr-preview/pr-1512/
on branch gh-pages at 2023-03-21 13:52 UTC

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.

LGTM after .Init() removal

pkg/shares/share_builder.go Outdated Show resolved Hide resolved
@rootulp
Copy link
Collaborator

rootulp commented Mar 21, 2023

Does this close #1490 ?

@MSevey MSevey requested a review from a team March 21, 2023 15:42
rootulp
rootulp previously approved these changes Mar 21, 2023
evan-forbes
evan-forbes previously approved these changes Mar 22, 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.

nice!

@@ -182,6 +185,10 @@ func MinDataAvailabilityHeader() DataAvailabilityHeader {
}

// MinShares returns one tail-padded share.
func MinShares() [][]byte {
return shares.ToBytes(shares.TailPaddingShares(appconsts.MinShareCount))
func MinShares() ([][]byte, error) {
Copy link
Member

Choose a reason for hiding this comment

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

[nice to have, but optional]
we could add some documentation here to when an error is thrown to avoid having to dig through the tailpadding shares function.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure will add it

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator

Choose a reason for hiding this comment

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

[no change needed] on re-review it seems strange to return an error from this function because there are no function parameters. I expect MinShares() to never return an error. It could panic() if shares.TailPaddingShares(appconsts.MinShareCount) returns an error but I don't think such a change is blocking.

@mojtaba-esk mojtaba-esk dismissed stale reviews from evan-forbes and rootulp via cd1e910 March 22, 2023 09:27
@MSevey MSevey requested a review from a team March 22, 2023 09:27
@codecov-commenter
Copy link

Codecov Report

Merging #1512 (cd1e910) into main (71ab161) will decrease coverage by 0.81%.
The diff coverage is 44.93%.

@@            Coverage Diff             @@
##             main    #1512      +/-   ##
==========================================
- Coverage   50.70%   49.90%   -0.81%     
==========================================
  Files          82       82              
  Lines        4723     4813      +90     
==========================================
+ Hits         2395     2402       +7     
- Misses       2134     2193      +59     
- Partials      194      218      +24     
Impacted Files Coverage Δ
pkg/proof/proof.go 65.89% <25.00%> (-1.57%) ⬇️
pkg/shares/share_splitting.go 62.83% <33.33%> (-12.96%) ⬇️
pkg/shares/split_sparse_shares.go 42.46% <40.00%> (-4.09%) ⬇️
x/blob/types/payforblob.go 79.55% <40.00%> (-2.73%) ⬇️
pkg/da/data_availability_header.go 75.65% <44.44%> (-3.25%) ⬇️
pkg/shares/split_compact_shares.go 67.88% <46.93%> (-14.85%) ⬇️
pkg/shares/share_builder.go 76.31% <53.84%> (-3.00%) ⬇️
pkg/shares/padding.go 63.63% <57.89%> (-20.37%) ⬇️
pkg/shares/powers_of_two.go 88.00% <75.00%> (-3.67%) ⬇️

... and 1 file 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.

@@ -182,6 +185,10 @@ func MinDataAvailabilityHeader() DataAvailabilityHeader {
}

// MinShares returns one tail-padded share.
func MinShares() [][]byte {
return shares.ToBytes(shares.TailPaddingShares(appconsts.MinShareCount))
func MinShares() ([][]byte, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

[no change needed] on re-review it seems strange to return an error from this function because there are no function parameters. I expect MinShares() to never return an error. It could panic() if shares.TailPaddingShares(appconsts.MinShareCount) returns an error but I don't think such a change is blocking.

@mojtaba-esk mojtaba-esk merged commit 0023930 into main Mar 22, 2023
@mojtaba-esk mojtaba-esk deleted the mojtaba/panic-share-encoding branch March 22, 2023 10:45
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.

chore: error propagation refactore for the share package
4 participants