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

Optimize DA verify_transactions #1481

Merged
merged 13 commits into from
Nov 19, 2024

Conversation

yaziciahmet
Copy link
Contributor

@yaziciahmet yaziciahmet commented Nov 18, 2024

Description

Optimizes verify_transactions method of DA verifier.

Previously:

  1. Iterate over completeness proof (Verifying each tx in completeness also exist in inclusion)
    1.1. Validate wtxid
    1.2. Ensure corresponding tx exists in inclusion proof
    1.3. Collect completeness proof wtxids into a BTreeSet
  2. Iterate over inclusion proof (Verifying each relevant tx in inclusion also exist in completeness)
    2.1 If prefix matches, verify it also exists in collected completeness proof wtxids BTreeSet and remove it
  3. If completeness proof wtxids BTreeSet not empty, there is extra tx in completeness, hence invalid

New:

  1. Filter out nonrelevant transactions from inclusion proof
  2. ZipEq filtered out inclusion and completeness, they must be of same length
    1.1 Verify wtxids match

With the new version, collecting and later removing wtxids into an BTreeSet is removed, and there is now only 1 iteration over proofs.

Linked Issues

  • Fixes # (issue, if applicable)
  • Related to # (issue)

Testing

Describe how these changes were tested. If you've added new features, have you added unit tests?

Docs

Describe where this code is documented. If it changes a documented interface, have the docs been updated?

Copy link

codecov bot commented Nov 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.6%. Comparing base (9168c87) to head (0bcd68b).
Report is 1 commits behind head on nightly.

Additional details and impacted files
Files with missing lines Coverage Δ
crates/bitcoin-da/src/verifier.rs 81.8% <100.0%> (-0.7%) ⬇️

... and 2 files with indirect coverage changes

---- 🚨 Try these New Features:

@yaziciahmet
Copy link
Contributor Author

I did some benchmarks locally, and on average optimized version consumes 0.5% less cycles. This test was only with 1 sequencer commitment, hence, I can safely say that more commitments will result in a greater cycle difference.

@eyusufatik eyusufatik merged commit cd31467 into nightly Nov 19, 2024
13 of 14 checks passed
@eyusufatik eyusufatik deleted the yaziciahmet/optimize-verify-transactions branch November 19, 2024 09:30
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.

4 participants