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

New DA verification logic #1768

Closed
eyusufatik opened this issue Jan 30, 2025 · 0 comments · Fixed by #1804
Closed

New DA verification logic #1768

eyusufatik opened this issue Jan 30, 2025 · 0 comments · Fixed by #1804
Assignees
Labels
P-high High priority
Milestone

Comments

@eyusufatik
Copy link
Member

The current DA layer verification logic is something we inherited from sov-sdk. It was written for DA-oriented blockchains, not Bitcoin. In this logic, the circuits are passed blobs of data from the DA layer + inclusion and completeness proofs.

**Inclusion proof**: Proves that given blobs are included in the DA block.

**Completeness proof**: Proves that no relevant transaction from DA was left out.

**Relevant transaction**: DA layer transactions that are relevant to the rollup.

And the DaVerifier trait is defined as:

pub trait DaVerifier: Send + Sync {
    /// The set of types required by the DA layer.
    type Spec: DaSpec;

    /// The error type returned by the DA layer's verification function
    /// TODO: Should we add `std::Error` bound so it can be `()?` ?
    type Error: Debug;

    /// Create a new da verifier with the given chain parameters
    fn new(params: <Self::Spec as DaSpec>::ChainParams) -> Self;

    /// Verify a claimed set of transactions of the given namespace against a block header.
    fn verify_transactions(
        &self,
        block_header: &<Self::Spec as DaSpec>::BlockHeader,
        txs: &[<Self::Spec as DaSpec>::BlobTransaction],
        inclusion_proof: <Self::Spec as DaSpec>::InclusionMultiProof,
        completeness_proof: <Self::Spec as DaSpec>::CompletenessProof,
        namespace: DaNamespace,
    ) -> Result<(), Self::Error>;

    /// Verify that the block header is valid for the given previous light client proof output
    fn verify_header_chain(
        &self,
        latest_da_state: Option<&LatestDaState>,
        block_header: &<Self::Spec as DaSpec>::BlockHeader,
        network: Network,
    ) -> Result<LatestDaState, Self::Error>;

    /// Decompress chunks to complete
    fn decompress_chunks(&self, complete_chunks: &[u8]) -> Result<Vec<u8>, Self::Error>;
}

For a DA layer like Celestia, inclusion and completeness proofs won’t contain the actual contents of the blob. Rather, you supply the blobs, there is some verification logic of blobs against the proofs.

In the Bitcoin case, inclusion proofs and completeness proofs are defined as:

**Inclusion proof**: List of wtxid's in the Bitcoin block, the coinbase transaction (first tx in Bitcoin block), and coinbase transaction txid merkle proof with respect to the block header.

**Completeness proof**: List of relevant transactions in the block. 

**Relevant transaction**: Any transaction with wtxid starting with 0x0101 or 0x0202.

Blobs are of course derived from the Bitcoin transaction, specifically extracted from the witness field of the Bitcoin transaction.

Now realize that, we are passing the data we are interested to the circuits twice, once in the txs (blobs) field in the verify_transaction function and in the CompletenessProof field (in the form of a Bitcoin transaction), which is defined as complete list of Bitcoin transactions relevant to us.

We can parse the “blobs” from the CompletenessProof while we are verifying it, and we actually already do, we check that it is equal to the blob (named tx in the function). So we can skip supplying the circuits with already parsed data, and parse them from the CompletenessProof.

Then we would be left with:

    /// Verify a claimed set of transactions of the given namespace against a block header.
    fn verify_transactions(
        &self,
        block_header: &<Self::Spec as DaSpec>::BlockHeader,
        inclusion_proof: <Self::Spec as DaSpec>::InclusionMultiProof,
        completeness_proof: <Self::Spec as DaSpec>::CompletenessProof,
        namespace: DaNamespace,
    ) -> Result<Vec<<Self::Spec as DaSpec>::BlobTransaction>, Self::Error>;
@eyusufatik eyusufatik added this to the Mainnet Must milestone Jan 30, 2025
@eyusufatik eyusufatik added the P-high High priority label Feb 3, 2025
@eyusufatik eyusufatik self-assigned this Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-high High priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant