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: support parsing out of context compact shares #1770

Merged

Conversation

Manav-Aggarwal
Copy link
Member

@Manav-Aggarwal Manav-Aggarwal commented May 15, 2023

Overview

Adds logic to handle out of context compact shares and uses it in parseCompactShares. Also, adds a corresponding test with different random slices of list of shares to check they are interpretable back into Txs.

Closes: #802

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

@rootulp rootulp added this to the Post-mainnet milestone May 15, 2023
@Manav-Aggarwal Manav-Aggarwal changed the title Manav/support out of context shares Support parsing out of context compact shares May 15, 2023
@codecov-commenter
Copy link

codecov-commenter commented May 15, 2023

Codecov Report

Merging #1770 (1139a4e) into main (5443e5f) will increase coverage by 0.20%.
The diff coverage is 53.65%.

@@            Coverage Diff             @@
##             main    #1770      +/-   ##
==========================================
+ Coverage   51.60%   51.81%   +0.20%     
==========================================
  Files         107      107              
  Lines        6647     6680      +33     
==========================================
+ Hits         3430     3461      +31     
+ Misses       2862     2860       -2     
- Partials      355      359       +4     
Impacted Files Coverage Δ
pkg/shares/shares.go 69.00% <40.62%> (-6.54%) ⬇️
pkg/shares/parse_compact_shares.go 76.47% <100.00%> (+12.47%) ⬆️

... and 2 files with indirect coverage changes

@Manav-Aggarwal Manav-Aggarwal marked this pull request as ready for review May 15, 2023 19:45
rootulp
rootulp previously approved these changes May 15, 2023
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 LGTM! Great work

test/util/testfactory/txs.go Outdated Show resolved Hide resolved
test/util/testfactory/txs.go Outdated Show resolved Hide resolved
@@ -112,6 +112,23 @@ func Test_processCompactShares(t *testing.T) {
}
}

func TestParseOutOfContextShares(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

[optional] in addition to this test, should we consider adding a test case for https://github.com/rootulp/celestia-app/blob/01282c42a8b1d7ea2cfd325c2ed10aed4c317966/pkg/shares/parse.go#L12 that tests out of context shares?

Motivation: parseCompactShares is private and ParseTxs is public.

Copy link
Member Author

Choose a reason for hiding this comment

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

SinceParseTxs uses parseCompactShares under the hood so instead of adding another test, modified this test using ParseTxsto make it simpler.

rootulp
rootulp previously approved these changes May 17, 2023
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.

🚢

@rootulp rootulp changed the title Support parsing out of context compact shares feat: support parsing out of context compact shares May 17, 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.

thanks for adding this @Manav-Aggarwal!!! 🙂

mostly just had a few questions. In future PRs, I think we might be able to test this a bit more thoroughly by incorporating it into some integration tests

pkg/shares/shares.go Show resolved Hide resolved
pkg/shares/shares.go Outdated Show resolved Hide resolved
pkg/shares/shares.go Show resolved Hide resolved
pkg/shares/shares.go Show resolved Hide resolved
test/util/testfactory/txs.go Outdated Show resolved Hide resolved
pkg/shares/compact_shares_test.go Show resolved Hide resolved
@evan-forbes
Copy link
Member

evan-forbes commented May 18, 2023

ahh nvm, the fact that it was picked up in a square test threw me off, fortunately its not that bad, do we need to check that its a compact share
in https://github.com/Manav-Aggarwal/celestia-app/blob/8d6e812c504dc4fdfa2bb8cc0759592a42ea839f/pkg/shares/shares.go#L218-L224 ?

should we perform that check earlier somehow?

@Manav-Aggarwal
Copy link
Member Author

ahh nvm, the fact that it was picked up in a square test threw me off, fortunately its that bad, do we need to check that its a compact share in https://github.com/Manav-Aggarwal/celestia-app/blob/8d6e812c504dc4fdfa2bb8cc0759592a42ea839f/pkg/shares/shares.go#L218-L224 ?

should we perform that check earlier somehow?

Removed the commit that introduced that check for now. I don't think we necessarily need to have that check since the assumption that ParseTxs is only being used with compactShares as input is incorrect. So we can keep the rawDataStartIndex method be more versatile and just process non-compact shares without using reserved bytes.

evan-forbes
evan-forbes previously approved these changes May 19, 2023
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.

Apologies for comments after already approving this. On re-review I have a few questions

pkg/shares/parse_compact_shares.go Outdated Show resolved Hide resolved
pkg/shares/parse_compact_shares.go Show resolved Hide resolved
pkg/shares/shares.go Show resolved Hide resolved
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.

Discussed in-person. Thanks for adding the comments!

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.

Discussed in-person. Thanks for adding the comments!

@MSevey MSevey requested a review from a team May 22, 2023 19:35
@evan-forbes evan-forbes enabled auto-merge (squash) May 22, 2023 19:36
@evan-forbes evan-forbes merged commit 243fb72 into celestiaorg:main May 22, 2023
@Manav-Aggarwal Manav-Aggarwal deleted the manav/support_out_of_context_shares branch May 22, 2023 23:45
rach-id pushed a commit to rach-id/celestia-app that referenced this pull request May 23, 2023
<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before
submitting your
first PR.
-->

## Overview

Adds logic to handle out of context compact shares and uses it in
`parseCompactShares`. Also, adds a corresponding test with different
random slices of list of shares to check they are interpretable back
into Txs.

Closes: celestiaorg#802 
<!-- 
Please provide an explanation of the PR, including the appropriate
context,
background, goal, and rationale. If there is an issue with this
information,
please provide a tl;dr and link the issue. 
-->

## Checklist

<!-- 
Please complete the checklist to ensure that the PR is ready to be
reviewed.

IMPORTANT:
PRs should be left in Draft until the below checklist is completed.
-->

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

---------

Co-authored-by: Rootul P <[email protected]>
Co-authored-by: Evan Forbes <[email protected]>
github-merge-queue bot pushed a commit to rollkit/rollkit that referenced this pull request Oct 3, 2023
Adds ability to:
- Convert `TxWithISRs` to Shares
- Convert Shares to byte array (that will be posted on celestia)
- Convert above byte array back to Shares
- Convert Shares back to `TxWithISRs`
- Parse Out of Context Shares

Adds relevant roundtrip tests

Resolves #881 
Resolves #934 
Resolves #886 
Resolves #925 

Note: All shares are written and interpreted as compact shares so they
contain reserved bytes (see
https://celestiaorg.github.io/celestia-app/specs/data_structures.html#compact-share)

Related PR in `celestia-app`:
celestiaorg/celestia-app#1770
chandiniv1 pushed a commit to chandiniv1/rollkit that referenced this pull request Oct 19, 2023
Adds ability to:
- Convert `TxWithISRs` to Shares
- Convert Shares to byte array (that will be posted on celestia)
- Convert above byte array back to Shares
- Convert Shares back to `TxWithISRs`
- Parse Out of Context Shares

Adds relevant roundtrip tests

Resolves rollkit#881 
Resolves rollkit#934 
Resolves rollkit#886 
Resolves rollkit#925 

Note: All shares are written and interpreted as compact shares so they
contain reserved bytes (see
https://celestiaorg.github.io/celestia-app/specs/data_structures.html#compact-share)

Related PR in `celestia-app`:
celestiaorg/celestia-app#1770
gupadhyaya pushed a commit to rollkit/rollkit that referenced this pull request Oct 20, 2023
Adds ability to:
- Convert `TxWithISRs` to Shares
- Convert Shares to byte array (that will be posted on celestia)
- Convert above byte array back to Shares
- Convert Shares back to `TxWithISRs`
- Parse Out of Context Shares

Adds relevant roundtrip tests

Resolves #881 
Resolves #934 
Resolves #886 
Resolves #925 

Note: All shares are written and interpreted as compact shares so they
contain reserved bytes (see
https://celestiaorg.github.io/celestia-app/specs/data_structures.html#compact-share)

Related PR in `celestia-app`:
celestiaorg/celestia-app#1770
chandiniv1 pushed a commit to chandiniv1/rollkit that referenced this pull request Oct 31, 2023
Adds ability to:
- Convert `TxWithISRs` to Shares
- Convert Shares to byte array (that will be posted on celestia)
- Convert above byte array back to Shares
- Convert Shares back to `TxWithISRs`
- Parse Out of Context Shares

Adds relevant roundtrip tests

Resolves rollkit#881
Resolves rollkit#934
Resolves rollkit#886
Resolves rollkit#925

Note: All shares are written and interpreted as compact shares so they
contain reserved bytes (see
https://celestiaorg.github.io/celestia-app/specs/data_structures.html#compact-share)

Related PR in `celestia-app`:
celestiaorg/celestia-app#1770
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.

Implement API for parsing out of context shares with explicit tests for reserved bytes
4 participants