Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
feat(sync-layer): adapt MiniMerkleTree to manage priority queue (matt…
Browse files Browse the repository at this point in the history
…er-labs#2068)

## What ❔

Enables the MiniMerkleTree to be used for priority queue to efficiently
calculate merkle proofs for priority transactions.

## Why ❔

As part of the preparation for the priority queue migration to sync
layer.

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [ ] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [ ] Tests for the changes have been added / updated.
- [ ] Documentation comments have been added / updated.
- [ ] Code has been formatted via `zk fmt` and `zk lint`.
- [ ] Spellcheck has been run via `zk spellcheck`.
  • Loading branch information
ly0va authored Jun 7, 2024
1 parent 551cdc2 commit 3e72364
Show file tree
Hide file tree
Showing 4 changed files with 397 additions and 84 deletions.
2 changes: 2 additions & 0 deletions checks-config/era.dic
Original file line number Diff line number Diff line change
Expand Up @@ -969,5 +969,7 @@ preloaded
e2e
upcasting
foundryup
uncached
untrimmed
UNNEST
semver
16 changes: 3 additions & 13 deletions core/lib/mini_merkle_tree/benches/tree.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
//! Basic benchmarks for `MiniMerkleTree`.
use criterion::{
criterion_group, criterion_main, BatchSize, Bencher, BenchmarkId, Criterion, Throughput,
};
use criterion::{criterion_group, criterion_main, Bencher, BenchmarkId, Criterion, Throughput};
use zksync_mini_merkle_tree::MiniMerkleTree;

const TREE_SIZES: &[usize] = &[32, 64, 128, 256, 512, 1_024];

fn compute_merkle_root(bencher: &mut Bencher<'_>, tree_size: usize) {
let leaves = (0..tree_size).map(|i| [i as u8; 88]);
let tree = MiniMerkleTree::new(leaves, None);
bencher.iter_batched(
|| tree.clone(),
MiniMerkleTree::merkle_root,
BatchSize::SmallInput,
);
bencher.iter(|| tree.merkle_root());
}

fn compute_merkle_path(bencher: &mut Bencher<'_>, tree_size: usize) {
let leaves = (0..tree_size).map(|i| [i as u8; 88]);
let tree = MiniMerkleTree::new(leaves, None);
bencher.iter_batched(
|| tree.clone(),
|tree| tree.merkle_root_and_path(tree_size / 3),
BatchSize::SmallInput,
);
bencher.iter(|| tree.merkle_root_and_path(tree_size / 3));
}

fn basic_benches(criterion: &mut Criterion) {
Expand Down
Loading

0 comments on commit 3e72364

Please sign in to comment.