Skip to content

Commit

Permalink
feat: Extract commitment generator into a separate crate (#1636)
Browse files Browse the repository at this point in the history
## What ❔

Extract `zksync_core::commitment_generator` to separate the crate in the
node folder
Put `zksync_commitment_utils` to `zksync_commitment_generator ` (reason:
utils are used only by generator)

## Why ❔

Part of the "modularize the codebase" process, required for legolizer
and publishing on crates.io.

## 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`.
- [ ] Linkcheck has been run via `zk linkcheck`.
  • Loading branch information
AnastasiiaVashchuk committed Apr 12, 2024
1 parent 45164fa commit f763d1f
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 13 deletions.
15 changes: 13 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ members = [
"core/bin/genesis_generator",
# Node services
"core/node/node_framework",
"core/node/commitment_generator",
# Libraries
"core/lib/db_connection",
"core/lib/zksync_core",
Expand All @@ -21,7 +22,6 @@ members = [
"core/lib/contracts",
"core/lib/crypto",
"core/lib/circuit_breaker",
"core/lib/commitment_utils",
"core/lib/dal",
"core/lib/env_config",
"core/lib/eth_client",
Expand Down Expand Up @@ -191,7 +191,6 @@ vm-benchmark-harness = { path = "core/tests/vm-benchmark/harness" }
zksync = { path = "sdk/zksync-rs" }
zksync_basic_types = { path = "core/lib/basic_types" }
zksync_circuit_breaker = { path = "core/lib/circuit_breaker" }
zksync_commitment_utils = { path = "core/lib/commitment_utils" }
zksync_config = { path = "core/lib/config" }
zksync_contracts = { path = "core/lib/contracts" }
zksync_core = { path = "core/lib/zksync_core" }
Expand Down Expand Up @@ -224,3 +223,4 @@ zksync_crypto_primitives = { path = "core/lib/crypto_primitives" }
zksync_node_framework = { path = "core/node/node_framework" }
zksync_eth_watch = { path = "core/node/eth_watch" }
zksync_shared_metrics = { path = "core/node/shared_metrics" }
zksync_commitment_generator = { path = "core/node/commitment_generator" }
1 change: 1 addition & 0 deletions core/bin/external_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ publish = false

[dependencies]
zksync_core.workspace = true
zksync_commitment_generator.workspace = true
zksync_dal.workspace = true
zksync_db_connection.workspace = true
zksync_config.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion core/bin/external_node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use tokio::{
sync::{watch, RwLock},
task::{self, JoinHandle},
};
use zksync_commitment_generator::CommitmentGenerator;
use zksync_concurrency::{ctx, scope};
use zksync_config::configs::{
api::MerkleTreeApiConfig, chain::L1BatchCommitDataGeneratorMode, database::MerkleTreeMode,
Expand All @@ -21,7 +22,6 @@ use zksync_core::{
web3::{mempool_cache::MempoolCache, ApiBuilder, Namespace},
},
block_reverter::{BlockReverter, BlockReverterFlags, L1ExecutedBatchesRevert, NodeRole},
commitment_generator::CommitmentGenerator,
consensus,
consistency_checker::ConsistencyChecker,
db_pruner::{
Expand Down
2 changes: 1 addition & 1 deletion core/lib/zksync_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ zksync_protobuf_config.workspace = true
zksync_utils.workspace = true
zksync_contracts.workspace = true
zksync_system_constants.workspace = true
zksync_commitment_utils.workspace = true
zksync_eth_client.workspace = true
zksync_eth_signer.workspace = true
zksync_l1_contract_interface.workspace = true
Expand All @@ -45,6 +44,7 @@ zksync_health_check.workspace = true
vlog.workspace = true
zksync_eth_watch.workspace = true
zksync_shared_metrics.workspace = true
zksync_commitment_generator.workspace = true

multivm.workspace = true

Expand Down
3 changes: 1 addition & 2 deletions core/lib/zksync_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use zksync_circuit_breaker::{
l1_txs::FailedL1TransactionChecker, replication_lag::ReplicationLagChecker,
CircuitBreakerChecker, CircuitBreakers,
};
use zksync_commitment_generator::CommitmentGenerator;
use zksync_concurrency::{ctx, scope};
use zksync_config::{
configs::{
Expand Down Expand Up @@ -62,7 +63,6 @@ use crate::{
web3::{self, mempool_cache::MempoolCache, state::InternalApiConfig, Namespace},
},
basic_witness_input_producer::BasicWitnessInputProducer,
commitment_generator::CommitmentGenerator,
eth_sender::{
l1_batch_commit_data_generator::{
L1BatchCommitDataGenerator, RollupModeL1BatchCommitDataGenerator,
Expand Down Expand Up @@ -99,7 +99,6 @@ use crate::{
pub mod api_server;
pub mod basic_witness_input_producer;
pub mod block_reverter;
pub mod commitment_generator;
pub mod consensus;
pub mod consistency_checker;
pub mod db_pruner;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "zksync_commitment_utils"
name = "zksync_commitment_generator"
version = "0.1.0"
edition.workspace = true
authors.workspace = true
Expand All @@ -10,13 +10,24 @@ keywords.workspace = true
categories.workspace = true

[dependencies]
vise.workspace = true
zksync_types.workspace = true
zksync_dal.workspace = true
zksync_health_check.workspace = true
zksync_l1_contract_interface.workspace = true
zksync_utils.workspace = true
multivm.workspace = true
circuit_sequencer_api_1_4_0.workspace = true
circuit_sequencer_api_1_4_1.workspace = true
circuit_sequencer_api_1_5_0.workspace = true

zk_evm_1_5_0.workspace = true
zk_evm_1_4_1.workspace = true
zk_evm_1_3_3.workspace = true
multivm.workspace = true

tokio = { workspace = true, features = ["time"] }
anyhow.workspace = true
tracing.workspace = true
itertools.workspace = true
serde_json.workspace = true

4 changes: 4 additions & 0 deletions core/node/commitment_generator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# zkSync Era commitment generator

This crate contains an implementation of the zkSync Era commitment generator component, which is responsible for the
calculation commitment info for L1 batches.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ use std::time::Duration;

use anyhow::Context;
use itertools::Itertools;
use metrics::{CommitmentStage, METRICS};
use multivm::zk_evm_latest::ethereum_types::U256;
use tokio::{sync::watch, task::JoinHandle};
use zksync_commitment_utils::{bootloader_initial_content_commitment, events_queue_commitment};
use zksync_dal::{ConnectionPool, Core, CoreDal};
use zksync_health_check::{Health, HealthStatus, HealthUpdater, ReactiveHealthCheck};
use zksync_l1_contract_interface::i_executor::commit::kzg::pubdata_to_blob_commitments;
Expand All @@ -18,7 +16,13 @@ use zksync_types::{
};
use zksync_utils::h256_to_u256;

use crate::{
metrics::{CommitmentStage, METRICS},
utils::{bootloader_initial_content_commitment, events_queue_commitment},
};

mod metrics;
mod utils;

const SLEEP_INTERVAL: Duration = Duration::from_millis(100);

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions core/node/node_framework/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ zksync_utils.workspace = true
zksync_circuit_breaker.workspace = true
zksync_concurrency.workspace = true
zksync_eth_watch.workspace = true
zksync_commitment_generator.workspace = true

tracing.workspace = true
thiserror.workspace = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use zksync_core::commitment_generator::CommitmentGenerator;
use zksync_commitment_generator::CommitmentGenerator;

use crate::{
implementations::resources::{healthcheck::AppHealthCheckResource, pools::MasterPoolResource},
Expand Down

0 comments on commit f763d1f

Please sign in to comment.