Skip to content

Implement Block range merkelization for Cardano transactions #1560

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
Mar 21, 2024

Conversation

jpraynaud
Copy link
Member

@jpraynaud jpraynaud commented Mar 8, 2024

Content

This PR includes the implementation of a merkelized map aka MKMap:

  • It takes keys such as BlockRange (also implemented in the PR) that implements the MKMapKey trait
  • And it takes values such as MKMap, MKTree or MKTreeNode (each represented as variants of a MKMapNode enum which implements the MKMapValue trait)
  • The keys and values are recursively provable which allows to built multi layers of Merkelization for improved commitment and proof generation
  • The MKMap also allows to:
    • Replace an existing value by an equivalent (i.e. same commitment) value
    • Insert a new value (provided the associated key is strictly greater than the existing keys) without recomputing completely the underlying Merkle tree
  • The implementation of the MKTree has also been enhanced:
    • Remove the need to create the underlying MKTreeStore externally
    • Allow instantiation from Into<MKTreeNode> instances
  • Also some benchmarks have been implemented for both the MKMap and the MKTree

Benchmarks

Run with:

  • 50 transactions per block
  • block range length of 15
  • 100M transactions
  • Proofs generated/verified for 100 transactions in 100 different block ranges
  • 100 samples

Signature generation:

~250ms
Screenshot from 2024-03-21 12-42-22

Proof generation:

~300ms
Screenshot from 2024-03-21 12-42-38

Proof verification:

~300µs
Screenshot from 2024-03-21 12-42-58

Pre-submit checklist

  • Branch
    • Tests are provided (if possible)
    • Crates versions are updated (if relevant)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
  • PR
    • No clippy warnings in the CI
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested

Issue(s)

Closes #1533

@jpraynaud jpraynaud self-assigned this Mar 8, 2024
Copy link

github-actions bot commented Mar 8, 2024

Test Results

    3 files  ± 0     42 suites  ±0   8m 41s ⏱️ ±0s
  945 tests +19    945 ✅ +19  0 💤 ±0  0 ❌ ±0 
1 039 runs  +19  1 039 ✅ +19  0 💤 ±0  0 ❌ ±0 

Results for commit dfbad9d. ± Comparison against base commit ffe19a9.

This pull request removes 1 and adds 20 tests. Note that renamed tests count towards both.
mithril-common ‑ messages::cardano_transactions_proof::tests::verify_hashes_from_verified_cardano_transaction_and_from_signable_builder_are_equals
mithril-common ‑ crypto_helper::merkle_map::tests::test_mk_map_should_accept_replacement_with_same_root_value
mithril-common ‑ crypto_helper::merkle_map::tests::test_mk_map_should_clone_and_compute_same_root
mithril-common ‑ crypto_helper::merkle_map::tests::test_mk_map_should_compute_and_verify_valid_proof
mithril-common ‑ crypto_helper::merkle_map::tests::test_mk_map_should_compute_and_verify_valid_proof_recursively
mithril-common ‑ crypto_helper::merkle_map::tests::test_mk_map_should_compute_same_root_when_replacing_entry_with_equivalent
mithril-common ‑ crypto_helper::merkle_map::tests::test_mk_map_should_find_value_correctly
mithril-common ‑ crypto_helper::merkle_map::tests::test_mk_map_should_list_keys_correctly
mithril-common ‑ crypto_helper::merkle_map::tests::test_mk_map_should_list_values_correctly
mithril-common ‑ crypto_helper::merkle_map::tests::test_mk_map_should_not_compute_proof_for_no_leaves
mithril-common ‑ crypto_helper::merkle_map::tests::test_mk_map_should_reject_out_of_order_insertion
…

♻️ This comment has been updated with latest results.

@jpraynaud jpraynaud force-pushed the jpraynaud/1533-block-range-merkle-tree-cardano-tx branch 2 times, most recently from c1c607e to 0257c98 Compare March 12, 2024 18:24
@jpraynaud jpraynaud temporarily deployed to testing-preview March 12, 2024 18:34 — with GitHub Actions Inactive
@jpraynaud jpraynaud temporarily deployed to testing-sanchonet March 12, 2024 18:34 — with GitHub Actions Inactive
@jpraynaud jpraynaud temporarily deployed to testing-preview March 13, 2024 17:37 — with GitHub Actions Inactive
@jpraynaud jpraynaud temporarily deployed to testing-sanchonet March 13, 2024 17:37 — with GitHub Actions Inactive
@jpraynaud jpraynaud force-pushed the jpraynaud/1533-block-range-merkle-tree-cardano-tx branch from 4f029d4 to e2c79bd Compare March 14, 2024 17:42
@jpraynaud jpraynaud temporarily deployed to testing-preview March 14, 2024 17:57 — with GitHub Actions Inactive
@jpraynaud jpraynaud temporarily deployed to testing-sanchonet March 14, 2024 17:57 — with GitHub Actions Inactive
@jpraynaud jpraynaud temporarily deployed to testing-preview March 15, 2024 15:38 — with GitHub Actions Inactive
@jpraynaud jpraynaud temporarily deployed to testing-sanchonet March 15, 2024 15:38 — with GitHub Actions Inactive
@jpraynaud jpraynaud temporarily deployed to testing-preview March 15, 2024 17:35 — with GitHub Actions Inactive
@jpraynaud jpraynaud temporarily deployed to testing-sanchonet March 15, 2024 17:35 — with GitHub Actions Inactive
@jpraynaud jpraynaud force-pushed the jpraynaud/1533-block-range-merkle-tree-cardano-tx branch from 6359518 to 603252d Compare March 18, 2024 16:21
@jpraynaud jpraynaud temporarily deployed to testing-preview March 18, 2024 16:28 — with GitHub Actions Inactive
@jpraynaud jpraynaud temporarily deployed to testing-sanchonet March 18, 2024 16:28 — with GitHub Actions Inactive
@jpraynaud jpraynaud changed the title Implement Block range Merkle tree for Cardano transactions Implement Block range merkelization for Cardano transactions Mar 18, 2024
@jpraynaud jpraynaud marked this pull request as ready for review March 18, 2024 18:00
@jpraynaud jpraynaud requested review from Alenar and sfauvel March 18, 2024 18:01
@jpraynaud jpraynaud force-pushed the jpraynaud/1533-block-range-merkle-tree-cardano-tx branch from 603252d to cb6aefc Compare March 19, 2024 12:05
Copy link
Collaborator

@sfauvel sfauvel left a comment

Choose a reason for hiding this comment

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

Its a good job. Just a few comments.

@jpraynaud jpraynaud force-pushed the jpraynaud/1533-block-range-merkle-tree-cardano-tx branch from 7f0bd19 to b4f962c Compare March 19, 2024 16:35
@jpraynaud jpraynaud force-pushed the jpraynaud/1533-block-range-merkle-tree-cardano-tx branch 2 times, most recently from d78b993 to 8ade6ab Compare March 21, 2024 12:16
@jpraynaud jpraynaud temporarily deployed to testing-preview March 21, 2024 12:23 — with GitHub Actions Inactive
@jpraynaud jpraynaud force-pushed the jpraynaud/1533-block-range-merkle-tree-cardano-tx branch 2 times, most recently from cdce1d2 to 94cab69 Compare March 21, 2024 14:25
@jpraynaud jpraynaud requested a review from Alenar March 21, 2024 14:26
@jpraynaud jpraynaud temporarily deployed to testing-preview March 21, 2024 14:42 — with GitHub Actions Inactive
@jpraynaud jpraynaud temporarily deployed to testing-sanchonet March 21, 2024 14:42 — with GitHub Actions Inactive
jpraynaud and others added 3 commits March 21, 2024 18:24
- 'mithril-aggregator' from '0.4.47' to '0.4.48'
- 'mithril-client' from '0.6.7' to '0.6.8'
- 'mithril-common' from '0.3.19' to '0.3.20'
@jpraynaud jpraynaud force-pushed the jpraynaud/1533-block-range-merkle-tree-cardano-tx branch from 94cab69 to dfbad9d Compare March 21, 2024 17:26
@jpraynaud jpraynaud temporarily deployed to testing-preview March 21, 2024 17:33 — with GitHub Actions Inactive
@jpraynaud jpraynaud temporarily deployed to testing-sanchonet March 21, 2024 17:33 — with GitHub Actions Inactive
@jpraynaud jpraynaud merged commit 1ddcd46 into main Mar 21, 2024
@jpraynaud jpraynaud deleted the jpraynaud/1533-block-range-merkle-tree-cardano-tx branch March 21, 2024 17:34
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 a Block Range Merkle Tree for Cardano Transactions
3 participants