Skip to content

Commit

Permalink
solution for EN to not use prover pool
Browse files Browse the repository at this point in the history
  • Loading branch information
AnastasiiaVashchuk committed Nov 7, 2023
1 parent e61cf74 commit 2cfa2c4
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 31 deletions.
3 changes: 1 addition & 2 deletions core/bin/external_node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ async fn init_tasks(
.build()
.await
.context("failed to build a tree_pool")?;
let tree_handle =
task::spawn(metadata_calculator.run(tree_pool, prover_tree_pool, tree_stop_receiver));
let tree_handle = task::spawn(metadata_calculator.run(tree_pool, None, tree_stop_receiver));

let consistency_checker_handle = tokio::spawn(consistency_checker.run(stop_receiver.clone()));

Expand Down
3 changes: 2 additions & 1 deletion core/lib/zksync_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,8 @@ async fn run_tree(
.await
.context("failed to build prover_pool")?;

let tree_task = tokio::spawn(metadata_calculator.run(server_pool, prover_pool, stop_receiver));
let tree_task =
tokio::spawn(metadata_calculator.run(server_pool, Some(prover_pool), stop_receiver));
task_futures.push(tree_task);

let elapsed = started_at.elapsed();
Expand Down
5 changes: 3 additions & 2 deletions core/lib/zksync_core/src/metadata_calculator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//! stores them in the DB.

use tokio::sync::watch;
use zksync_prover_dal::ProverConnectionPool;

use std::time::Duration;

Expand Down Expand Up @@ -141,14 +142,14 @@ impl MetadataCalculator {
pub async fn run(
self,
pool: ServerConnectionPool,
prover_pool: ServerConnectionPool,
prover_pool: Option<ProverConnectionPool>,
stop_receiver: watch::Receiver<bool>,
) -> anyhow::Result<()> {
self.updater
.loop_updating_tree(
self.delayer,
&pool,
&prover_pool,
prover_pool.as_ref(),
stop_receiver,
self.health_updater,
)
Expand Down
60 changes: 35 additions & 25 deletions core/lib/zksync_core/src/metadata_calculator/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl TreeUpdater {
async fn process_multiple_batches(
&mut self,
storage: &mut ServerStorageProcessor<'_>,
prover_storage: &mut ProverStorageProcessor<'_>,
prover_storage: &mut Option<ProverStorageProcessor<'_>>,
l1_batch_numbers: ops::RangeInclusive<u32>,
) -> L1BatchNumber {
let start = Instant::now();
Expand Down Expand Up @@ -182,27 +182,30 @@ impl TreeUpdater {
.get_batch_protocol_version_id(l1_batch_number)
.await
.unwrap();
if let Some(id) = protocol_version_id {
if !prover_storage
.prover_protocol_versions_dal()
.prover_protocol_version_exists(id)
.await
{
let protocol_version = storage
.protocol_versions_dal()
.get_protocol_version(id)
.await
.unwrap();
prover_storage
if let Some(prover_storage) = prover_storage {
if let Some(id) = protocol_version_id {
if !prover_storage
.prover_protocol_versions_dal()
.save_prover_protocol_version(protocol_version)
.await;
.prover_protocol_version_exists(id)
.await
{
let protocol_version = storage
.protocol_versions_dal()
.get_protocol_version(id)
.await
.unwrap();
prover_storage
.prover_protocol_versions_dal()
.save_prover_protocol_version(protocol_version)
.await;
}
}

prover_storage
.witness_generator_dal()
.save_witness_inputs(l1_batch_number, object_key, protocol_version_id)
.await;
}
prover_storage
.witness_generator_dal()
.save_witness_inputs(l1_batch_number, object_key, protocol_version_id)
.await;
storage
.basic_witness_input_producer_dal()
.create_basic_witness_input_producer_job(l1_batch_number)
Expand Down Expand Up @@ -269,7 +272,7 @@ impl TreeUpdater {
async fn step(
&mut self,
mut storage: ServerStorageProcessor<'_>,
mut prover_storage: ProverStorageProcessor<'_>,
mut prover_storage: Option<ProverStorageProcessor<'_>>,
next_l1_batch_to_seal: &mut L1BatchNumber,
) {
let last_sealed_l1_batch = storage
Expand Down Expand Up @@ -298,7 +301,7 @@ impl TreeUpdater {
mut self,
delayer: Delayer,
pool: &ServerConnectionPool,
prover_pool: &ProverConnectionPool,
prover_pool: Option<&ProverConnectionPool>,
mut stop_receiver: watch::Receiver<bool>,
health_updater: HealthUpdater,
) -> anyhow::Result<()> {
Expand Down Expand Up @@ -373,11 +376,18 @@ impl TreeUpdater {
.access_storage_tagged("metadata_calculator")
.await
.unwrap();
let prover_storage = prover_pool
.access_storage_tagged("metadata_calculator")
.await
.unwrap();

let prover_storage: Option<ProverStorageProcessor>;
if let Some(prover_pool) = prover_pool {
prover_storage = Some(
prover_pool
.access_storage_tagged("metadata_calculator")
.await
.unwrap(),
);
} else {
prover_storage = None;
}
let snapshot = *next_l1_batch_to_seal;
self.step(storage, prover_storage, &mut next_l1_batch_to_seal)
.await;
Expand Down
2 changes: 1 addition & 1 deletion prover/prover_dal/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl ProverConnectionPoolBuilder {
pub async fn build_inner(&self, database_url: &str) -> anyhow::Result<ProverConnectionPool> {
let max_connections = self
.max_size
.unwrap_or_else(|| parse_env("PROVER_DB_POOL_SIZE"));
.unwrap_or_else(|| parse_env("HOUSE_KEEPER_PROVER_DB_POOL_SIZE"));

let options = PgPoolOptions::new().max_connections(max_connections);
let mut connect_options: PgConnectOptions = database_url
Expand Down

0 comments on commit 2cfa2c4

Please sign in to comment.