Skip to content

Commit

Permalink
Update prover workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
popzxc committed Nov 8, 2023
1 parent 9575982 commit ebb2560
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 51 deletions.
15 changes: 9 additions & 6 deletions prover/circuit_synthesizer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ use structopt::StructOpt;
use tokio::{sync::oneshot, sync::watch};

use zksync_config::configs::{
AlertsConfig, CircuitSynthesizerConfig, ObjectStoreConfig, ProverGroupConfig,
AlertsConfig, CircuitSynthesizerConfig, ObjectStoreConfig, PostgresConfig, ProverGroupConfig,
};
use zksync_dal::connection::DbVariant;
use zksync_dal::ConnectionPool;
use zksync_env_config::FromEnv;
use zksync_object_store::ObjectStoreFactory;
Expand Down Expand Up @@ -47,10 +46,14 @@ async fn main() -> anyhow::Result<()> {
let opt = Opt::from_args();
let config: CircuitSynthesizerConfig =
CircuitSynthesizerConfig::from_env().context("CircuitSynthesizerConfig::from_env()")?;
let pool = ConnectionPool::builder(DbVariant::Prover)
.build()
.await
.context("failed to build a connection pool")?;
let postgres_config = PostgresConfig::from_env().context("PostgresConfig::from_env()")?;
let pool = ConnectionPool::builder(
postgres_config.prover_url()?,
posgres_config.max_connections()?,
)
.build()
.await
.context("failed to build a connection pool")?;
let vk_commitments = get_cached_commitments();

let object_store_config =
Expand Down
15 changes: 9 additions & 6 deletions prover/proof_fri_compressor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use tokio::{sync::oneshot, sync::watch};
use std::time::Duration;

use prometheus_exporter::PrometheusExporterConfig;
use zksync_config::configs::FriProofCompressorConfig;
use zksync_dal::connection::DbVariant;
use zksync_config::configs::{FriProofCompressorConfig, PostgresConfig};
use zksync_dal::ConnectionPool;
use zksync_env_config::{object_store::ProverObjectStoreConfig, FromEnv};
use zksync_object_store::ObjectStoreFactory;
Expand Down Expand Up @@ -49,10 +48,14 @@ async fn main() -> anyhow::Result<()> {

let opt = Opt::from_args();
let config = FriProofCompressorConfig::from_env().context("FriProofCompressorConfig")?;
let pool = ConnectionPool::builder(DbVariant::Prover)
.build()
.await
.context("failed to build a connection pool")?;
let postgres_config = PostgresConfig::from_env().context("PostgresConfig::from_env()")?;
let pool = ConnectionPool::builder(
postgres_config.prover_url()?,
posgres_config.max_connections()?,
)
.build()
.await
.context("failed to build a connection pool")?;
let object_store_config =
ProverObjectStoreConfig::from_env().context("ProverObjectStoreConfig::from_env()")?;
let blob_store = ObjectStoreFactory::new(object_store_config.0)
Expand Down
7 changes: 4 additions & 3 deletions prover/prover/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use tokio::runtime::Handle;
use zkevm_test_harness::abstract_zksync_circuit::concrete_circuits::ZkSyncProof;
use zkevm_test_harness::pairing::bn256::Bn256;

use zksync_config::ProverConfig;
use zksync_config::{PostgresConfig, ProverConfig};
use zksync_dal::ConnectionPool;
use zksync_dal::StorageProcessor;
use zksync_dal::{connection::DbVariant, ConnectionPool};
use zksync_object_store::{Bucket, ObjectStore, ObjectStoreFactory};
use zksync_types::proofs::ProverJobMetadata;

Expand All @@ -30,12 +30,13 @@ fn assembly_debug_blob_url(job_id: usize, circuit_id: u8) -> String {

impl ProverReporter {
pub(crate) fn new(
posgres_config: PostgresConfig,
config: ProverConfig,
store_factory: &ObjectStoreFactory,
rt_handle: Handle,
) -> anyhow::Result<Self> {
let pool = rt_handle
.block_on(ConnectionPool::singleton(DbVariant::Prover).build())
.block_on(ConnectionPool::singleton(posgres_config.prover_url()?).build())
.context("failed to build a connection pool")?;
Ok(Self {
pool,
Expand Down
17 changes: 10 additions & 7 deletions prover/prover/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use zksync_config::{
configs::{
api::PrometheusConfig, prover_group::ProverGroupConfig, AlertsConfig, ObjectStoreConfig,
},
ApiConfig, ProverConfig, ProverConfigs,
ApiConfig, PostgresConfig, ProverConfig, ProverConfigs,
};
use zksync_dal::{connection::DbVariant, ConnectionPool};
use zksync_dal::ConnectionPool;
use zksync_env_config::FromEnv;
use zksync_object_store::ObjectStoreFactory;
use zksync_prover_utils::region_fetcher::{get_region, get_zone};
Expand All @@ -26,7 +26,8 @@ use crate::socket_listener::incoming_socket_listener;
use crate::synthesized_circuit_provider::SynthesizedCircuitProvider;

async fn graceful_shutdown() -> anyhow::Result<impl Future<Output = ()>> {
let pool = ConnectionPool::singleton(DbVariant::Prover)
let postgres_config = PostgresConfig::from_env().context("PostgresConfig::from_env()")?;
let pool = ConnectionPool::singleton(posgres_config.prover_url()?)
.build()
.await
.context("failed to build a connection pool")?;
Expand Down Expand Up @@ -178,11 +179,12 @@ pub async fn run() -> anyhow::Result<()> {
};
tracing::info!("local IP address is: {:?}", local_ip);

let postgres_config = PostgresConfig::from_env().context("PostgresConfig::from_env()")?;
tasks.push(tokio::task::spawn(incoming_socket_listener(
local_ip,
prover_config.assembly_receiver_port,
producer,
ConnectionPool::singleton(DbVariant::Prover)
ConnectionPool::singleton(posgres_config.prover_url()?)
.build()
.await
.context("failed to build a connection pool")?,
Expand All @@ -197,7 +199,7 @@ pub async fn run() -> anyhow::Result<()> {
ObjectStoreConfig::from_env().context("ObjectStoreConfig::from_env()")?;
let store_factory = ObjectStoreFactory::new(object_store_config);

let circuit_provider_pool = ConnectionPool::singleton(DbVariant::Prover)
let circuit_provider_pool = ConnectionPool::singleton(posgres_config.prover_url()?)
.build()
.await
.context("failed to build circuit_provider_pool")?;
Expand All @@ -211,8 +213,9 @@ pub async fn run() -> anyhow::Result<()> {
zone,
rt_handle.clone(),
);
let prover_job_reporter = ProverReporter::new(prover_config, &store_factory, rt_handle)
.context("ProverReporter::new()")?;
let prover_job_reporter =
ProverReporter::new(posgres_config, prover_config, &store_factory, rt_handle)
.context("ProverReporter::new()")?;
prover_service::run_prover::run_prover_with_remote_synthesizer(
synthesized_circuit_provider,
ProverArtifactProvider,
Expand Down
18 changes: 11 additions & 7 deletions prover/prover_fri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use tokio::task::JoinHandle;

use prometheus_exporter::PrometheusExporterConfig;
use zksync_config::configs::fri_prover_group::FriProverGroupConfig;
use zksync_config::configs::{FriProverConfig, ProverGroupConfig};
use zksync_dal::connection::DbVariant;
use zksync_config::configs::{FriProverConfig, PostgresConfig, ProverGroupConfig};
use zksync_dal::ConnectionPool;
use zksync_env_config::{
object_store::{ProverObjectStoreConfig, PublicObjectStoreConfig},
Expand All @@ -31,7 +30,8 @@ mod socket_listener;
mod utils;

async fn graceful_shutdown(port: u16) -> anyhow::Result<impl Future<Output = ()>> {
let pool = ConnectionPool::singleton(DbVariant::Prover)
let postgres_config = PostgresConfig::from_env().context("PostgresConfig::from_env()")?;
let pool = ConnectionPool::singleton(postgres_config.prover_url()?)
.build()
.await
.context("failed to build a connection pool")?;
Expand Down Expand Up @@ -115,10 +115,14 @@ async fn main() -> anyhow::Result<()> {
specialized_group_id,
circuit_ids_for_round_to_be_proven.clone()
);
let pool = ConnectionPool::builder(DbVariant::Prover)
.build()
.await
.context("failed to build a connection pool")?;
let postgres_config = PostgresConfig::from_env().context("PostgresConfig::from_env()")?;
let pool = ConnectionPool::builder(
postgres_config.prover_url()?,
posgres_config.max_connections()?,
)
.build()
.await
.context("failed to build a connection pool")?;
let port = prover_config.witness_vector_receiver_port;
let prover_tasks = get_prover_tasks(
prover_config,
Expand Down
15 changes: 9 additions & 6 deletions prover/prover_fri_gateway/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use tokio::{sync::oneshot, sync::watch};

use crate::api_data_fetcher::{PeriodicApiStruct, PROOF_GENERATION_DATA_PATH, SUBMIT_PROOF_PATH};
use prometheus_exporter::PrometheusExporterConfig;
use zksync_config::configs::FriProverGatewayConfig;
use zksync_dal::connection::DbVariant;
use zksync_config::configs::{FriProverGatewayConfig, PostgresConfig};
use zksync_dal::ConnectionPool;
use zksync_env_config::{object_store::ProverObjectStoreConfig, FromEnv};
use zksync_object_store::ObjectStoreFactory;
Expand Down Expand Up @@ -36,10 +35,14 @@ async fn main() -> anyhow::Result<()> {

let config =
FriProverGatewayConfig::from_env().context("FriProverGatewayConfig::from_env()")?;
let pool = ConnectionPool::builder(DbVariant::Prover)
.build()
.await
.context("failed to build a connection pool")?;
let postgres_config = PostgresConfig::from_env().context("PostgresConfig::from_env()")?;
let pool = ConnectionPool::builder(
postgres_config.prover_url()?,
posgres_config.max_connections()?,
)
.build()
.await
.context("failed to build a connection pool")?;
let object_store_config =
ProverObjectStoreConfig::from_env().context("ProverObjectStoreConfig::from_env()")?;
let store_factory = ObjectStoreFactory::new(object_store_config.0);
Expand Down
27 changes: 17 additions & 10 deletions prover/witness_generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use prometheus_exporter::PrometheusExporterConfig;
use std::time::Instant;
use structopt::StructOpt;
use tokio::sync::watch;
use zksync_config::configs::{FriWitnessGeneratorConfig, PrometheusConfig};
use zksync_dal::{connection::DbVariant, ConnectionPool};
use zksync_config::configs::{FriWitnessGeneratorConfig, PostgresConfig, PrometheusConfig};
use zksync_dal::ConnectionPool;
use zksync_env_config::{
object_store::{ProverObjectStoreConfig, PublicObjectStoreConfig},
FromEnv,
Expand Down Expand Up @@ -80,14 +80,21 @@ async fn main() -> anyhow::Result<()> {
let config =
FriWitnessGeneratorConfig::from_env().context("FriWitnessGeneratorConfig::from_env()")?;
let prometheus_config = PrometheusConfig::from_env().context("PrometheusConfig::from_env()")?;
let connection_pool = ConnectionPool::builder(DbVariant::Master)
.build()
.await
.context("failed to build a connection_pool")?;
let prover_connection_pool = ConnectionPool::builder(DbVariant::Prover)
.build()
.await
.context("failed to build a prover_connection_pool")?;
let postgres_config = PostgresConfig::from_env().context("PostgresConfig::from_env()")?;
let connection_pool = ConnectionPool::builder(
postgres_config.master_url()?,
posgres_config.max_connections()?,
)
.build()
.await
.context("failed to build a connection_pool")?;
let prover_connection_pool = ConnectionPool::builder(
postgres_config.prover_url()?,
posgres_config.max_connections()?,
)
.build()
.await
.context("failed to build a prover_connection_pool")?;
let (stop_sender, stop_receiver) = watch::channel(false);
let vk_commitments = get_cached_commitments();
let protocol_versions = prover_connection_pool
Expand Down
15 changes: 9 additions & 6 deletions prover/witness_vector_generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use tokio::{sync::oneshot, sync::watch};

use crate::generator::WitnessVectorGenerator;
use zksync_config::configs::fri_prover_group::FriProverGroupConfig;
use zksync_config::configs::{FriWitnessVectorGeneratorConfig, ProverGroupConfig};
use zksync_dal::connection::DbVariant;
use zksync_config::configs::{FriWitnessVectorGeneratorConfig, PostgresConfig, ProverGroupConfig};
use zksync_dal::ConnectionPool;
use zksync_env_config::{object_store::ProverObjectStoreConfig, FromEnv};
use zksync_object_store::ObjectStoreFactory;
Expand Down Expand Up @@ -55,10 +54,14 @@ async fn main() -> anyhow::Result<()> {
let specialized_group_id = config.specialized_group_id;
let exporter_config = PrometheusExporterConfig::pull(config.prometheus_listener_port);

let pool = ConnectionPool::builder(DbVariant::Prover)
.build()
.await
.context("failed to build a connection pool")?;
let postgres_config = PostgresConfig::from_env().context("PostgresConfig::from_env()")?;
let pool = ConnectionPool::builder(
postgres_config.prover_url()?,
posgres_config.max_connections()?,
)
.build()
.await
.context("failed to build a connection pool")?;
let object_store_config =
ProverObjectStoreConfig::from_env().context("ProverObjectStoreConfig::from_env()")?;
let blob_store = ObjectStoreFactory::new(object_store_config.0)
Expand Down

0 comments on commit ebb2560

Please sign in to comment.