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!: adapt tx inclusion proofs to use share inclusion proofs #1276

Merged
merged 44 commits into from
Jan 30, 2023

Conversation

rootulp
Copy link
Collaborator

@rootulp rootulp commented Jan 20, 2023

Closes celestiaorg/celestia-core#920
Closes #1226 b/c deletes that code
Closes #1049 b/c deletes that code

Description

Previously the logic to generate tx proofs was flawed because it did not accurately identify which shares a transaction belongs to. Additionally the struct TxProof (originally defined by Tendermint but later modified in celestia-core) was incomplete because it did not contain proofs for the inclusion of a set of rows to the data square root. This PR modifies the TxInclusion logic to return a share inclusion proof instead of a transaction inclusion proof. The share inclusion proof does contain proofs for the rows to the data square root. In order for txs to use share inclusion proofs, SplitTxs was updated to keep track of the range of shares that a tx occupies.

@rootulp rootulp self-assigned this Jan 20, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jan 20, 2023

Codecov Report

Merging #1276 (d1a8c89) into main (abfca15) will decrease coverage by 0.59%.
The diff coverage is 83.52%.

@@            Coverage Diff             @@
##             main    #1276      +/-   ##
==========================================
- Coverage   49.79%   49.20%   -0.59%     
==========================================
  Files          76       76              
  Lines        4374     4292      -82     
==========================================
- Hits         2178     2112      -66     
+ Misses       2014     2004      -10     
+ Partials      182      176       -6     
Impacted Files Coverage Δ
pkg/proof/querier.go 21.73% <0.00%> (ø)
pkg/proof/proof.go 67.46% <84.21%> (-8.49%) ⬇️
pkg/shares/share_splitting.go 75.78% <100.00%> (+2.53%) ⬆️
pkg/shares/split_compact_shares.go 88.12% <100.00%> (+1.69%) ⬆️

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

@rootulp
Copy link
Collaborator Author

rootulp commented Jan 24, 2023

Question: should NewTxInclusionProof return a proof of type TxProof? I read the issue as dropping support for TxProof in favor of SharesProof but while exploring follow-ups, I realized that celestia-core and tendermint support TxProof so we may want celestia-app to support creating them.

Options

A. If we want celestia-app to continue supporting them: update this PR to retrofit a SharesProof into a TxProof.
B. If we don't want celestia-app to continue supporting them: update celestia-core to handle SharesProof and delete TxProof.

Update: I went with option A in this PR

@rootulp rootulp marked this pull request as ready for review January 24, 2023 21:39
@MSevey MSevey requested a review from a team January 25, 2023 19:51
@rootulp rootulp marked this pull request as draft January 26, 2023 04:50
@rootulp
Copy link
Collaborator Author

rootulp commented Jan 26, 2023

golangci-lint is not happy 😞

Copy link
Contributor

@staheri14 staheri14 left a comment

Choose a reason for hiding this comment

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

Looks good to me! also made some nonblocking suggestions.

pkg/proof/proof.go Outdated Show resolved Hide resolved
pkg/shares/share_splitting.go Outdated Show resolved Hide resolved
pkg/shares/share_splitting.go Show resolved Hide resolved
@rootulp
Copy link
Collaborator Author

rootulp commented Jan 29, 2023

If I understand correctly the main change is to have tx inclusion proofs be the same as the proof of the inclusion of a range of shares that correspond to the tx share position.

Exactly @cmwaters. I updated the PR description

@rootulp rootulp marked this pull request as ready for review January 29, 2023 23:07
go.mod Outdated Show resolved Hide resolved
@MSevey MSevey requested a review from a team January 30, 2023 16: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.

nice! thanks for finally getting rid of the old code, it feels so much better w/o it

[only kinda related comment]
I'm still thinking about if we want to support proving multiple blobs at once. presumably just wrapping many ShareProofs, but perhaps we just shouldn't support that, and people can do that themselves if they need it.

assert.Equal(t, tc.want, got)
})
}
}

func TestExport(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

thanks for this!!

@rootulp
Copy link
Collaborator Author

rootulp commented Jan 30, 2023

Given we support multiple blobs in a single transaction, I think celestia-app should also consider supporting a single proof for the multiple blobs associated with a single tx. I think this would involve some form of multiple ShareProofs (one per share range that a blob occupies).

@rootulp rootulp merged commit 0b75c9c into celestiaorg:main Jan 30, 2023
@rootulp rootulp deleted the rp/transaction-inclusion-proofs branch January 30, 2023 19:53
evan-forbes pushed a commit that referenced this pull request Feb 27, 2023
Closes celestiaorg/celestia-core#920
Closes #1226 b/c
deletes that code
Closes #1049 b/c
deletes that code

## Description

Previously the logic to generate tx proofs was flawed because it did not
accurately identify which shares a transaction belongs to. Additionally
the struct `TxProof` (originally defined by Tendermint but later
modified in celestia-core) was incomplete because it did not contain
proofs for the inclusion of a set of rows to the data square root. This
PR modifies the TxInclusion logic to return a share inclusion proof
instead of a transaction inclusion proof. The share inclusion proof does
contain proofs for the rows to the data square root. In order for txs to
use share inclusion proofs, `SplitTxs` was updated to keep track of the
range of shares that a tx occupies.

---------

Co-authored-by: CHAMI Rachid <chamirachid1@gmail.com>
Co-authored-by: Sanaz Taheri <35961250+staheri14@users.noreply.github.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
6 participants