forked from matter-labs/zksync-era
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add new commitments (matter-labs#219)
# What ❔ - `events_queue_commitment` and `bootloader_initial_content_commitment` are calculated in full tree and saved into DB. - nightly rust is used - lints found by clippy are fixed ## Why ❔ Preparation for boojum upgrade ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. - [x] Code has been formatted via `zk fmt` and `zk lint`. --------- Co-authored-by: Stanislav Bezkorovainyi <[email protected]>
- Loading branch information
1 parent
afdfcb4
commit a19256e
Showing
41 changed files
with
3,228 additions
and
2,530 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "zksync_commitment_utils" | ||
version = "0.1.0" | ||
edition = "2018" | ||
authors = ["The Matter Labs Team <[email protected]>"] | ||
homepage = "https://zksync.io/" | ||
repository = "https://github.com/matter-labs/zksync-era" | ||
license = "MIT OR Apache-2.0" | ||
keywords = ["blockchain", "zksync"] | ||
categories = ["cryptography"] | ||
|
||
[dependencies] | ||
zksync_types = { path = "../../lib/types" } | ||
zksync_utils = { path = "../../lib/utils" } | ||
zkevm_test_harness = { git = "https://github.com/matter-labs/era-zkevm_test_harness.git", branch = "v1.4.0" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//! Utils for commitment calculation. | ||
use zkevm_test_harness::witness::utils::{ | ||
events_queue_commitment_fixed, initial_heap_content_commitment_fixed, | ||
}; | ||
use zksync_types::{LogQuery, ProtocolVersionId, H256, U256, USED_BOOTLOADER_MEMORY_BYTES}; | ||
use zksync_utils::expand_memory_contents; | ||
|
||
pub fn events_queue_commitment( | ||
events_queue: &Vec<LogQuery>, | ||
protocol_version: ProtocolVersionId, | ||
) -> Option<H256> { | ||
match protocol_version { | ||
id if id < ProtocolVersionId::Version17 => None, | ||
ProtocolVersionId::Version17 => Some(H256(events_queue_commitment_fixed(events_queue))), | ||
id => unimplemented!("events_queue_commitment is not implemented for {id:?}"), | ||
} | ||
} | ||
|
||
pub fn bootloader_initial_content_commitment( | ||
initial_bootloader_contents: &[(usize, U256)], | ||
protocol_version: ProtocolVersionId, | ||
) -> Option<H256> { | ||
match protocol_version { | ||
id if id < ProtocolVersionId::Version17 => None, | ||
ProtocolVersionId::Version17 => { | ||
let full_bootloader_memory = | ||
expand_memory_contents(initial_bootloader_contents, USED_BOOTLOADER_MEMORY_BYTES); | ||
Some(H256(initial_heap_content_commitment_fixed( | ||
&full_bootloader_memory, | ||
))) | ||
} | ||
id => unimplemented!("events_queue_commitment is not implemented for {id:?}"), | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
core/lib/dal/migrations/20231013085524_boojum-block-commitments.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DROP TABLE IF EXISTS commitments; | ||
DROP TABLE IF EXISTS events_queue; |
10 changes: 10 additions & 0 deletions
10
core/lib/dal/migrations/20231013085524_boojum-block-commitments.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CREATE TABLE IF NOT EXISTS commitments ( | ||
l1_batch_number BIGINT PRIMARY KEY REFERENCES l1_batches(number) ON DELETE CASCADE, | ||
events_queue_commitment BYTEA, | ||
bootloader_initial_content_commitment BYTEA | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS events_queue ( | ||
l1_batch_number BIGINT PRIMARY KEY REFERENCES l1_batches(number) ON DELETE CASCADE, | ||
serialized_events_queue JSONB NOT NULL | ||
); |
Oops, something went wrong.