Skip to content

Commit 75bdfcc

Browse files
feat: BWIP (#2258)
## What ❔ Remove Core db connection from prover subsystems Create new component - BasicWitnessInputProducer, that will run VM in the background and produce necessary inputs for basic witness generation ## Why ❔ We want to separate accesses to DB in core/prover subsystems ## 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`. - [x] Spellcheck has been run via `zk spellcheck`. --------- Co-authored-by: perekopskiy <53865202+perekopskiy@users.noreply.github.com>
1 parent 2c8cf35 commit 75bdfcc

File tree

79 files changed

+1307
-513
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1307
-513
lines changed

.github/workflows/ci-core-reusable.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ jobs:
135135
base_token: ["Eth", "Custom"]
136136
deployment_mode: ["Rollup", "Validium"]
137137
env:
138-
SERVER_COMPONENTS: "api,tree,eth,state_keeper,housekeeper,commitment_generator,vm_runner_protective_reads,da_dispatcher,base_token_ratio_persister${{ matrix.consensus && ',consensus' || '' }}"
138+
SERVER_COMPONENTS: "api,tree,eth,state_keeper,housekeeper,commitment_generator,vm_runner_protective_reads,vm_runner_bwip,da_dispatcher,base_token_ratio_persister${{ matrix.consensus && ',consensus' || '' }}"
139139

140140
runs-on: [matterlabs-ci-runner]
141141
steps:
@@ -309,7 +309,7 @@ jobs:
309309
runs-on: [matterlabs-ci-runner]
310310

311311
env:
312-
SERVER_COMPONENTS: "api,tree,eth,state_keeper,housekeeper,commitment_generator,vm_runner_protective_reads,da_dispatcher,base_token_ratio_persister${{ matrix.consensus && ',consensus' || '' }}"
312+
SERVER_COMPONENTS: "api,tree,eth,state_keeper,housekeeper,commitment_generator,vm_runner_protective_reads,vm_runner_bwip,da_dispatcher,base_token_ratio_persister${{ matrix.consensus && ',consensus' || '' }}"
313313
EXT_NODE_FLAGS: "${{ matrix.consensus && '-- --enable-consensus' || '' }}"
314314

315315
steps:

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/bin/zksync_server/src/main.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ use zksync_config::{
1111
},
1212
fri_prover_group::FriProverGroupConfig,
1313
house_keeper::HouseKeeperConfig,
14-
ContractsConfig, DatabaseSecrets, FriProofCompressorConfig, FriProverConfig,
15-
FriProverGatewayConfig, FriWitnessGeneratorConfig, FriWitnessVectorGeneratorConfig,
16-
L1Secrets, ObservabilityConfig, PrometheusConfig, ProofDataHandlerConfig,
17-
ProtectiveReadsWriterConfig, Secrets,
14+
BasicWitnessInputProducerConfig, ContractsConfig, DatabaseSecrets,
15+
FriProofCompressorConfig, FriProverConfig, FriProverGatewayConfig,
16+
FriWitnessGeneratorConfig, FriWitnessVectorGeneratorConfig, L1Secrets, ObservabilityConfig,
17+
PrometheusConfig, ProofDataHandlerConfig, ProtectiveReadsWriterConfig, Secrets,
1818
},
1919
ApiConfig, BaseTokenAdjusterConfig, ContractVerifierConfig, DADispatcherConfig, DBConfig,
2020
EthConfig, EthWatchConfig, GasAdjusterConfig, GenesisConfig, ObjectStoreConfig, PostgresConfig,
@@ -271,6 +271,7 @@ fn load_env_config() -> anyhow::Result<TempConfigStore> {
271271
snapshot_creator: SnapshotsCreatorConfig::from_env().ok(),
272272
da_dispatcher_config: DADispatcherConfig::from_env().ok(),
273273
protective_reads_writer_config: ProtectiveReadsWriterConfig::from_env().ok(),
274+
basic_witness_input_producer_config: BasicWitnessInputProducerConfig::from_env().ok(),
274275
core_object_store: ObjectStoreConfig::from_env().ok(),
275276
base_token_adjuster_config: BaseTokenAdjusterConfig::from_env().ok(),
276277
commitment_generator: None,

core/bin/zksync_server/src/node_builder.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ use zksync_node_framework::{
4848
output_handler::OutputHandlerLayer, RocksdbStorageOptions, StateKeeperLayer,
4949
},
5050
tee_verifier_input_producer::TeeVerifierInputProducerLayer,
51-
vm_runner::protective_reads::ProtectiveReadsWriterLayer,
51+
vm_runner::{
52+
bwip::BasicWitnessInputProducerLayer, protective_reads::ProtectiveReadsWriterLayer,
53+
},
5254
web3_api::{
5355
caches::MempoolCacheLayer,
5456
server::{Web3ServerLayer, Web3ServerOptionalConfig},
@@ -503,6 +505,17 @@ impl MainNodeBuilder {
503505
Ok(self)
504506
}
505507

508+
fn add_vm_runner_bwip_layer(mut self) -> anyhow::Result<Self> {
509+
let basic_witness_input_producer_config =
510+
try_load_config!(self.configs.basic_witness_input_producer_config);
511+
self.node.add_layer(BasicWitnessInputProducerLayer::new(
512+
basic_witness_input_producer_config,
513+
self.genesis_config.l2_chain_id,
514+
));
515+
516+
Ok(self)
517+
}
518+
506519
fn add_base_token_ratio_persister_layer(mut self) -> anyhow::Result<Self> {
507520
let config = try_load_config!(self.configs.base_token_adjuster);
508521
self.node
@@ -604,6 +617,9 @@ impl MainNodeBuilder {
604617
Component::BaseTokenRatioPersister => {
605618
self = self.add_base_token_ratio_persister_layer()?;
606619
}
620+
Component::VmRunnerBwip => {
621+
self = self.add_vm_runner_bwip_layer()?;
622+
}
607623
}
608624
}
609625
Ok(self.node.build()?)

core/lib/basic_types/src/prover_dal.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ pub struct ProverJobFriInfo {
267267
pub struct BasicWitnessGeneratorJobInfo {
268268
pub l1_batch_number: L1BatchNumber,
269269
pub merkle_tree_paths_blob_url: Option<String>,
270+
pub witness_inputs_blob_url: Option<String>,
270271
pub attempts: u32,
271272
pub status: WitnessJobStatus,
272273
pub error: Option<String>,

core/lib/config/src/configs/general.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{
77
house_keeper::HouseKeeperConfig,
88
pruning::PruningConfig,
99
snapshot_recovery::SnapshotRecoveryConfig,
10-
vm_runner::ProtectiveReadsWriterConfig,
10+
vm_runner::{BasicWitnessInputProducerConfig, ProtectiveReadsWriterConfig},
1111
CommitmentGeneratorConfig, FriProofCompressorConfig, FriProverConfig,
1212
FriProverGatewayConfig, FriWitnessGeneratorConfig, FriWitnessVectorGeneratorConfig,
1313
ObservabilityConfig, PrometheusConfig, ProofDataHandlerConfig,
@@ -40,6 +40,7 @@ pub struct GeneralConfig {
4040
pub observability: Option<ObservabilityConfig>,
4141
pub da_dispatcher_config: Option<DADispatcherConfig>,
4242
pub protective_reads_writer_config: Option<ProtectiveReadsWriterConfig>,
43+
pub basic_witness_input_producer_config: Option<BasicWitnessInputProducerConfig>,
4344
pub commitment_generator: Option<CommitmentGeneratorConfig>,
4445
pub snapshot_recovery: Option<SnapshotRecoveryConfig>,
4546
pub pruning: Option<PruningConfig>,

core/lib/config/src/configs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub use self::{
2525
snapshot_recovery::SnapshotRecoveryConfig,
2626
snapshots_creator::SnapshotsCreatorConfig,
2727
utils::PrometheusConfig,
28-
vm_runner::ProtectiveReadsWriterConfig,
28+
vm_runner::{BasicWitnessInputProducerConfig, ProtectiveReadsWriterConfig},
2929
};
3030

3131
pub mod api;

core/lib/config/src/configs/vm_runner.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,20 @@ impl ProtectiveReadsWriterConfig {
1717
"./db/protective_reads_writer".to_owned()
1818
}
1919
}
20+
21+
#[derive(Debug, Deserialize, Clone, PartialEq, Default)]
22+
pub struct BasicWitnessInputProducerConfig {
23+
/// Path to the RocksDB data directory that serves state cache.
24+
#[serde(default = "BasicWitnessInputProducerConfig::default_db_path")]
25+
pub db_path: String,
26+
/// How many max batches should be processed at the same time.
27+
pub window_size: u32,
28+
/// All batches before this one (inclusive) are always considered to be processed.
29+
pub first_processed_batch: L1BatchNumber,
30+
}
31+
32+
impl BasicWitnessInputProducerConfig {
33+
fn default_db_path() -> String {
34+
"./db/basic_witness_input_producer".to_owned()
35+
}
36+
}

core/lib/dal/.sqlx/query-05c2a77d9f65d435e2df63a300850e42abbaf365a1b041d0e7a809796ef0fe63.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/lib/dal/.sqlx/query-11af69fc254e54449b64c086667700a95e4c37a7a18531b3cdf120394cb055b9.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)