Skip to content

Commit

Permalink
make prover_dal compile
Browse files Browse the repository at this point in the history
  • Loading branch information
Artemka374 committed Mar 11, 2024
1 parent 1bb55c5 commit 2060921
Show file tree
Hide file tree
Showing 78 changed files with 2,264 additions and 280 deletions.
2 changes: 1 addition & 1 deletion core/lib/db_connection/src/instrument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl<'a> InstrumentedData<'a> {
let output = match output {
Ok(output) => output,
Err(_) => {
let connection_tags = StorageProcessorTags::display(connection_tags);
// let connection_tags = StorageProcessorTags::display(connection_tags);
if slow_query_reporting_enabled {
// todo: uncomment
// tracing::warn!(
Expand Down
5 changes: 3 additions & 2 deletions core/lib/db_connection/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ use std::{
time::{Instant, SystemTime},
};

use crate::{connection::ConnectionPool, metrics::CONNECTION_METRICS};
use sqlx::{pool::PoolConnection, types::chrono, Connection, PgConnection, Postgres, Transaction};
use zksync_health_check::async_trait;

use crate::{connection::ConnectionPool, metrics::CONNECTION_METRICS};
// todo: for some reason I can't import this from crate directly
pub use zksync_health_check::async_trait;

/// Tags that can be associated with a connection.
#[derive(Debug, Clone, Copy, PartialEq)]
Expand Down
1 change: 1 addition & 0 deletions core/lib/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub mod api;
pub mod eth_sender;
pub mod helpers;
pub mod proto;
pub mod prover_dal;
pub mod transaction_request;
pub mod utils;
pub mod vm_version;
Expand Down
216 changes: 216 additions & 0 deletions core/lib/types/src/prover_dal.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
//! Types exposed by the prover DAL for general-purpose use.
use crate::{basic_fri_types::AggregationRound, L1BatchNumber};
use chrono::{DateTime, Duration, Utc};
use std::{net::IpAddr, ops::Add};

// This currently lives in `zksync_prover_types` -- we don't want a dependency between prover types (`zkevm_test_harness`) and DAL.
// This will be gone as part of 1.5.0, when EIP4844 becomes normal jobs, rather than special cased ones.
// todo: should it be public?
pub const EIP_4844_CIRCUIT_ID: u8 = 255;

#[derive(Debug, Clone)]
pub struct FriProverJobMetadata {
pub id: u32,
pub block_number: L1BatchNumber,
pub circuit_id: u8,
pub aggregation_round: AggregationRound,
pub sequence_number: usize,
pub depth: u16,
pub is_node_final_proof: bool,
}

#[derive(Debug, Clone, Copy, Default)]
pub struct JobCountStatistics {
pub queued: usize,
pub in_progress: usize,
pub failed: usize,
pub successful: usize,
}

impl Add for JobCountStatistics {
type Output = JobCountStatistics;

fn add(self, rhs: Self) -> Self::Output {
Self {
queued: self.queued + rhs.queued,
in_progress: self.in_progress + rhs.in_progress,
failed: self.failed + rhs.failed,
successful: self.successful + rhs.successful,
}
}
}

#[derive(Debug)]
pub struct StuckJobs {
pub id: u64,
pub status: String,
pub attempts: u64,
}

// TODO (PLA-774): Redundant structure, should be replaced with `std::net::SocketAddr`.
#[derive(Debug, Clone)]
pub struct SocketAddress {
pub host: IpAddr,
pub port: u16,
}

impl From<SocketAddress> for std::net::SocketAddr {
fn from(socket_address: SocketAddress) -> Self {
Self::new(socket_address.host, socket_address.port)
}
}

impl From<std::net::SocketAddr> for SocketAddress {
fn from(socket_address: std::net::SocketAddr) -> Self {
Self {
host: socket_address.ip(),
port: socket_address.port(),
}
}
}

#[derive(Debug, Clone)]
pub struct LeafAggregationJobMetadata {
pub id: u32,
pub block_number: L1BatchNumber,
pub circuit_id: u8,
pub prover_job_ids_for_proofs: Vec<u32>,
}

#[derive(Debug, Clone)]
pub struct NodeAggregationJobMetadata {
pub id: u32,
pub block_number: L1BatchNumber,
pub circuit_id: u8,
pub depth: u16,
pub prover_job_ids_for_proofs: Vec<u32>,
}

#[derive(Debug)]
pub struct JobPosition {
pub aggregation_round: AggregationRound,
pub sequence_number: usize,
}

#[derive(Debug, Default)]
pub struct ProverJobStatusFailed {
pub started_at: DateTime<Utc>,
pub error: String,
}

#[derive(Debug)]
pub struct ProverJobStatusSuccessful {
pub started_at: DateTime<Utc>,
pub time_taken: Duration,
}

impl Default for ProverJobStatusSuccessful {
fn default() -> Self {
ProverJobStatusSuccessful {
started_at: DateTime::default(),
time_taken: Duration::zero(),
}
}
}

#[derive(Debug, Default)]
pub struct ProverJobStatusInProgress {
pub started_at: DateTime<Utc>,
}

#[derive(Debug)]
pub struct WitnessJobStatusSuccessful {
pub started_at: DateTime<Utc>,
pub time_taken: Duration,
}

impl Default for WitnessJobStatusSuccessful {
fn default() -> Self {
WitnessJobStatusSuccessful {
started_at: DateTime::default(),
time_taken: Duration::zero(),
}
}
}

#[derive(Debug, Default)]
pub struct WitnessJobStatusFailed {
pub started_at: DateTime<Utc>,
pub error: String,
}

#[derive(Debug, strum::Display, strum::EnumString, strum::AsRefStr)]
pub enum ProverJobStatus {
#[strum(serialize = "queued")]
Queued,
#[strum(serialize = "in_progress")]
InProgress(ProverJobStatusInProgress),
#[strum(serialize = "successful")]
Successful(ProverJobStatusSuccessful),
#[strum(serialize = "failed")]
Failed(ProverJobStatusFailed),
#[strum(serialize = "skipped")]
Skipped,
#[strum(serialize = "ignored")]
Ignored,
}

#[derive(Debug, strum::Display, strum::EnumString, strum::AsRefStr)]
pub enum WitnessJobStatus {
#[strum(serialize = "failed")]
Failed(WitnessJobStatusFailed),
#[strum(serialize = "skipped")]
Skipped,
#[strum(serialize = "successful")]
Successful(WitnessJobStatusSuccessful),
#[strum(serialize = "waiting_for_artifacts")]
WaitingForArtifacts,
#[strum(serialize = "waiting_for_proofs")]
WaitingForProofs,
#[strum(serialize = "in_progress")]
InProgress,
#[strum(serialize = "queued")]
Queued,
}

#[derive(Debug)]
pub struct WitnessJobInfo {
pub block_number: L1BatchNumber,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub status: WitnessJobStatus,
pub position: JobPosition,
}

#[derive(Debug)]
pub struct ProverJobInfo {
pub id: u32,
pub block_number: L1BatchNumber,
pub circuit_type: String,
pub position: JobPosition,
pub input_length: u64,
pub status: ProverJobStatus,
pub attempts: u32,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}

#[derive(Debug)]
pub struct JobExtendedStatistics {
pub successful_padding: L1BatchNumber,
pub queued_padding: L1BatchNumber,
pub queued_padding_len: u32,
pub active_area: Vec<ProverJobInfo>,
}

#[derive(Debug, Copy, Clone)]
pub enum GpuProverInstanceStatus {
// The instance is available for processing.
Available,
// The instance is running at full capacity.
Full,
// The instance is reserved by an synthesizer.
Reserved,
// The instance is not alive anymore.
Dead,
}
1 change: 1 addition & 0 deletions prover/Cargo.lock

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

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

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

Loading

0 comments on commit 2060921

Please sign in to comment.