Skip to content

Commit

Permalink
fix(core): differentiate l2 to l1 logs tree size for pre and post boo…
Browse files Browse the repository at this point in the history
…jum batches (#538)

## What ❔

Fixes proofs L2ToL1Logs for pre-boojum blocks.
  • Loading branch information
montekki authored Nov 23, 2023
1 parent a49b61d commit 1e9e556
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion core/lib/zksync_core/src/api_server/web3/namespaces/zks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,27 @@ impl<G: L1GasPriceProvider> ZksNamespace<G> {
return Ok(None);
};

let Some(batch) = storage
.blocks_dal()
.get_l1_batch_header(l1_batch_number)
.await
.map_err(|err| internal_error(method_name, err))?
else {
return Ok(None);
};

let merkle_tree_leaves = all_l1_logs_in_batch.iter().map(L2ToL1Log::to_bytes);
let min_tree_size = Some(L2ToL1Log::MIN_L2_L1_LOGS_TREE_SIZE);

let min_tree_size = if batch
.protocol_version
.map(|v| v.is_pre_boojum())
.unwrap_or(true)
{
Some(L2ToL1Log::PRE_BOOJUM_MIN_L2_L1_LOGS_TREE_SIZE)
} else {
Some(L2ToL1Log::MIN_L2_L1_LOGS_TREE_SIZE)
};

let (root, proof) = MiniMerkleTree::new(merkle_tree_leaves, min_tree_size)
.merkle_root_and_path(l1_log_index);
Ok(Some(L2ToL1LogProof {
Expand Down

0 comments on commit 1e9e556

Please sign in to comment.