Skip to content

docs: add inclusion proofs documentation #160

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

Merged
merged 37 commits into from
Sep 25, 2023
Merged

docs: add inclusion proofs documentation #160

merged 37 commits into from
Sep 25, 2023

Conversation

rach-id
Copy link
Member

@rach-id rach-id commented Jul 26, 2023

Overview

Closes #143 and #193

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

@rach-id rach-id added the documentation Improvements or additions to documentation label Jul 26, 2023
@rach-id rach-id requested review from adlerjohn and evan-forbes July 26, 2023 13:33
@rach-id rach-id self-assigned this Jul 26, 2023
@rach-id rach-id requested a review from adlerjohn July 28, 2023 08:26
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.

This is a good start, and there's a lot of good info here, but I think it would be helpful to devs to make a clearer distinction between what the qgb contracts are doing, inclusion proofs, and then talk more about an example fraud proof system that uses those inclusion proofs to prove fraud (and not necessarily a bunch of different new fraud proof types).

If we want to discuss the details of what inclusion proofs actually look like under the hood, then we should specify that (which would also be useful)

Comment on lines 9 to 11
Fraud proofs is the mechanism used to inform light clients in the case of an invalid rollup state transition or unavailable rollup block data. They rely on rollup full nodes getting the data that was published to Celestia, and executing all the state transitions to verify the rollup state. If they discover an invalid state transition or unavailable rollup data, they emit a fraud proof with the necessary information to convince light clients that fraud happened. This allows for trust-minimized light clients, as the network only needs one honest full node to create the fraud proof and propagate it.

If the Celestium is settlement smart contract based, then the contract would only need to receive a fraud proof to decide whether data was published correctly or not.
Copy link
Member

Choose a reason for hiding this comment

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

are there types of celestiums that aren't smart contract based?

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 guess they all are smart contract based, but light clients also can verify the proofs before the settlement smart contract executes them.

Comment on lines 25 to 33
## Unavailable data fraud proof

By construction, the rollup block data is the sequence of spans defined in the header. Thus, proving that the data is unavailable goes back to proving that the sequence of spans doesn't belong to the Celestia block, i.e. the span is out of bounds.

We could prove that via creating a binary [Merkle proof](https://github.com/celestiaorg/celestia-core/blob/c3ab251659f6fe0f36d10e0dbd14c29a78a85352/crypto/merkle/proof.go#L19-L31) of any row/column to the Celestia data root. This proof will provide the `Total` which is the number of rows/columns in the extended data square. And, we can use that to calculate the square size.

Then, we will use that information to check if the provided transaction index, in the header, is out of the square size bounds.

For the data root, we will use a binary Merkle proof to prove its inclusion in a data root tuple root that was committed to by the QGB smart contract. More on this in [here](#1-data-root-inclusion-proof).
Copy link
Member

Choose a reason for hiding this comment

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

this is important info! but I'm not sure making it its own type of fraud proof is our best option. Or imo we pick a different name for the proof.

The main reasoning I'm seeing not to is because we want fraud proofs to be as normal as possible. The only thing that changes here is if an error is thrown when checking for inclusion, then we know that the data was not posted to celestia. This is essentially all we need to communicate, that there is an edge case where the location in the header doesn't exist, in which case no further action is required to verify the normal fraud proof.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is just providing a distinction of the type of frauds that can happen from the QGB/Celestia perspective so that rollups can incorporate them in their proofs.

What do you think about switching the titles:
## Unavailable data fraud proof => ## Proving unavailable data?

> [!NOTE]
> The sequence of spans can be defined using the following: `Height`, `start index`, and `length` in the Celestia block, in the case of a single Celestia block. However, it could be generalized to span over multiple blocks.

For the rest of the document, we will suppose that the sequence of spans only references one Celestia block.
Copy link
Member

Choose a reason for hiding this comment

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

sequence of spans

sequence of data?

Copy link
Member Author

Choose a reason for hiding this comment

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

Rollups can adopt many approaches to prove that fraud happened. One of which could be having the following fields in the rollup header:

- Rollup block state root
- A sequence of spans in Celestia: which references where the rollup data was published in the Celestia chain.
Copy link
Member

Choose a reason for hiding this comment

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

A sequence of spans

what is a span?

Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines 48 to 62
### 1. Data root inclusion proof

To prove the data root is committed to by the QGB smart contract, we will need to provide a Merkle proof of the data root tuple to a data root tuple root. This can be created using the [`data_root_inclusion_proof`](https://github.com/celestiaorg/celestia-core/blob/c3ab251659f6fe0f36d10e0dbd14c29a78a85352/rpc/client/http/http.go#L492-L511) query.

### 2. Transaction inclusion proof

To prove that a rollup transaction is part of the data root, we will need to provide two proofs: a namespace Merkle proof of the transaction to a row root. This could be done via proving the shares that contain the transaction to the row root using a namespace Merkle proof. And, a binary Merkle proof of the row root to the data root.

These proofs can be generated using the [`ProveShares`](https://github.com/celestiaorg/celestia-core/blob/c3ab251659f6fe0f36d10e0dbd14c29a78a85352/rpc/client/http/http.go#L526-L543) query.

### 3. Transaction part of the rollup sequence

The Celestia block is a 2d matrix of rows and columns, where the row roots and column roots are committed to in the data root. We can use this property to point which rows and columns does the transaction shares belong to. Then, we will use those coordinates to calculate the row major index of the transaction, and verify if it is part of the sequence span.

The coordinates can be gotten using a namespace Merkle proof of the shares to the row root, and also to the column root. Then, we will create Merkle proofs of that row root and column root to the data root. These [proofs](https://github.com/celestiaorg/celestia-core/blob/c3ab251659f6fe0f36d10e0dbd14c29a78a85352/crypto/merkle/proof.go#L19-L31) will contain the [`Index`](https://github.com/celestiaorg/celestia-core/blob/c3ab251659f6fe0f36d10e0dbd14c29a78a85352/crypto/merkle/proof.go#L28) of the row/column, and the [`Total`](https://github.com/celestiaorg/celestia-core/blob/c3ab251659f6fe0f36d10e0dbd14c29a78a85352/crypto/merkle/proof.go#L27) number of rows/columns in the proofs which would allow us to calculate the row major index of the transaction.
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this is the best spot for this or if the user needs to know these things when thinking about fraud proofs.

mostly, we just need to communicate what can possibly occur when using the fraud proofs. Either the inclusion proof is valid or invalid, and if its invalid what are the reasons for it being invalid (the portion about the data not being posted to the square).

I think this document is generally not making a clear enough distinction between what the qgb contracts are doing, which is just inclusion proofs, not really fraud proofs.

Fraud proofs are important, but I think keeping those more separate is good.

Copy link
Member Author

Choose a reason for hiding this comment

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

this part was removed and a different explanation is provided

> [!NOTE]
> The sequence of spans can be defined using the following: `Height`, `start index`, and `length` in the Celestia block, in the case of a single Celestia block. However, it could be generalized to span over multiple blocks.

For the rest of the document, we will suppose that the sequence of spans only references one Celestia block.
Copy link
Member

Choose a reason for hiding this comment

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

what occurs when the celestium needs to prove inclusion to multiple chunks of data?

Copy link
Member Author

Choose a reason for hiding this comment

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

That depends on how they want to separate their data. Generally, they would have multiple references to data in Celestia blocks and they would prove inclusion to one of them

@rach-id
Copy link
Member Author

rach-id commented Jul 28, 2023

@evan-forbes This is just the first part of the documentation that gives a general overview of how the fraud proofs for QGB work. I am working on an example rollup, in a test, where I will use real Celestia blocks, and create each type of fraud proofs + write comments explaining each step. This will be in a subsequent PR

@rach-id rach-id linked an issue Sep 12, 2023 that may be closed by this pull request
rach-id and others added 4 commits September 12, 2023 17:51
@rach-id rach-id marked this pull request as draft September 12, 2023 18:33
@rach-id rach-id marked this pull request as ready for review September 13, 2023 12:59
@rach-id rach-id requested a review from evan-forbes September 13, 2023 12:59
@rach-id rach-id changed the title docs: add fraud proofs documentation docs: add inclusion proofs documentation Sep 13, 2023
@rach-id
Copy link
Member Author

rach-id commented Sep 18, 2023

CI will be fixed in here: #197

rach-id added a commit that referenced this pull request Sep 19, 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

<!-- 
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. 
-->

closes #193

The test that fails if this fix is absent is in here:
#160

## 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.
-->

- [ ] 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
@rach-id rach-id requested a review from adlerjohn September 22, 2023 20:17
@rach-id
Copy link
Member Author

rach-id commented Sep 25, 2023

Merging, if there are any hanging questions or fixes, we can create separate issues for them.

Thanks a lot guys for the reviews 👍 👍

@rach-id rach-id merged commit 22b310c into master Sep 25, 2023
@rach-id rach-id deleted the fraud_proofs_docs branch September 25, 2023 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid row root namespace node when verifying proofs Document the fraud proof mechanism
3 participants