Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): Split object stores #2187

Merged
merged 4 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/bin/zksync_server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ fn load_env_config() -> anyhow::Result<TempConfigStore> {
eth_sender_config: EthConfig::from_env().ok(),
eth_watch_config: EthWatchConfig::from_env().ok(),
gas_adjuster_config: GasAdjusterConfig::from_env().ok(),
object_store_config: ObjectStoreConfig::from_env().ok(),
observability: ObservabilityConfig::from_env().ok(),
snapshot_creator: SnapshotsCreatorConfig::from_env().ok(),
protective_reads_writer_config: ProtectiveReadsWriterConfig::from_env().ok(),
core_object_store: ObjectStoreConfig::from_env().ok(),
})
}
4 changes: 1 addition & 3 deletions core/bin/zksync_server/src/node_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ impl MainNodeBuilder {
}

fn add_object_store_layer(mut self) -> anyhow::Result<Self> {
let object_store_config = try_load_config!(self.configs.prover_config)
.object_store
.context("object_store_config")?;
let object_store_config = try_load_config!(self.configs.core_object_store);
self.node
.add_layer(ObjectStoreLayer::new(object_store_config));
Ok(self)
Expand Down
3 changes: 2 additions & 1 deletion core/lib/config/src/configs/fri_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ pub struct FriProverConfig {

// whether to write to public GCS bucket for https://github.com/matter-labs/era-boojum-validator-cli
pub shall_save_to_public_bucket: bool,
pub object_store: Option<ObjectStoreConfig>,
pub prover_object_store: Option<ObjectStoreConfig>,
pub public_object_store: Option<ObjectStoreConfig>,
}

impl FriProverConfig {
Expand Down
4 changes: 3 additions & 1 deletion core/lib/config/src/configs/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use crate::{
FriWitnessGeneratorConfig, FriWitnessVectorGeneratorConfig, ObservabilityConfig,
PrometheusConfig, ProofDataHandlerConfig,
},
ApiConfig, ContractVerifierConfig, DBConfig, EthConfig, PostgresConfig, SnapshotsCreatorConfig,
ApiConfig, ContractVerifierConfig, DBConfig, EthConfig, ObjectStoreConfig, PostgresConfig,
SnapshotsCreatorConfig,
};

#[derive(Debug)]
Expand All @@ -34,4 +35,5 @@ pub struct GeneralConfig {
pub snapshot_creator: Option<SnapshotsCreatorConfig>,
pub observability: Option<ObservabilityConfig>,
pub protective_reads_writer_config: Option<ProtectiveReadsWriterConfig>,
pub core_object_store: Option<ObjectStoreConfig>,
}
3 changes: 2 additions & 1 deletion core/lib/config/src/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,8 @@ impl Distribution<configs::FriProverConfig> for EncodeDist {
zone_read_url: self.sample(rng),
shall_save_to_public_bucket: self.sample(rng),
availability_check_interval_in_secs: self.sample(rng),
object_store: self.sample(rng),
prover_object_store: self.sample(rng),
public_object_store: self.sample(rng),
}
}
}
Expand Down
27 changes: 22 additions & 5 deletions core/lib/env_config/src/fri_prover.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
use zksync_config::configs::FriProverConfig;

use crate::{envy_load, object_store::ProverObjectStoreConfig, FromEnv};
use crate::{
envy_load,
object_store::{ProverObjectStoreConfig, PublicObjectStoreConfig},
FromEnv,
};

impl FromEnv for FriProverConfig {
fn from_env() -> anyhow::Result<Self> {
let mut prover: FriProverConfig = envy_load("fri_prover", "FRI_PROVER_")?;
prover.object_store = ProverObjectStoreConfig::from_env().map(|a| a.0).ok();
prover.prover_object_store = ProverObjectStoreConfig::from_env().map(|a| a.0).ok();
prover.public_object_store = PublicObjectStoreConfig::from_env().map(|a| a.0).ok();
Ok(prover)
}
}
Expand Down Expand Up @@ -35,10 +40,18 @@ mod tests {
zone_read_url: "http://metadata.google.internal/computeMetadata/v1/instance/zone"
.to_string(),
shall_save_to_public_bucket: true,
object_store: Some(ObjectStoreConfig {
prover_object_store: Some(ObjectStoreConfig {
mode: ObjectStoreMode::GCSWithCredentialFile {
bucket_base_url: "/base/url".to_owned(),
gcs_credential_file_path: "/path/to/credentials.json".to_owned(),
gcs_credential_file_path: "/path/to/credentials1.json".to_owned(),
},
max_retries: 5,
local_mirror_path: None,
}),
public_object_store: Some(ObjectStoreConfig {
mode: ObjectStoreMode::GCSWithCredentialFile {
bucket_base_url: "/base/url".to_owned(),
gcs_credential_file_path: "/path/to/credentials2.json".to_owned(),
},
max_retries: 5,
local_mirror_path: None,
Expand All @@ -64,8 +77,12 @@ mod tests {
FRI_PROVER_AVAILABILITY_CHECK_INTERVAL_IN_SECS="1800"
PROVER_OBJECT_STORE_BUCKET_BASE_URL="/base/url"
PROVER_OBJECT_STORE_MODE="GCSWithCredentialFile"
PROVER_OBJECT_STORE_GCS_CREDENTIAL_FILE_PATH="/path/to/credentials.json"
PROVER_OBJECT_STORE_GCS_CREDENTIAL_FILE_PATH="/path/to/credentials1.json"
PROVER_OBJECT_STORE_MAX_RETRIES="5"
PUBLIC_OBJECT_STORE_BUCKET_BASE_URL="/base/url"
PUBLIC_OBJECT_STORE_MODE="GCSWithCredentialFile"
PUBLIC_OBJECT_STORE_GCS_CREDENTIAL_FILE_PATH="/path/to/credentials2.json"
PUBLIC_OBJECT_STORE_MAX_RETRIES="5"
"#;
lock.set_env(config);

Expand Down
5 changes: 4 additions & 1 deletion core/lib/protobuf_config/src/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ impl ProtoRepr for proto::GeneralConfig {
.context("snapshot_creator")?,
observability: read_optional_repr(&self.observability).context("observability")?,
protective_reads_writer_config: read_optional_repr(&self.protective_reads_writer)
.context("vm_runner")?,
.context("protective_reads_writer")?,
core_object_store: read_optional_repr(&self.core_object_store)
.context("core_object_store")?,
})
}

Expand Down Expand Up @@ -74,6 +76,7 @@ impl ProtoRepr for proto::GeneralConfig {
.protective_reads_writer_config
.as_ref()
.map(ProtoRepr::build),
core_object_store: this.core_object_store.as_ref().map(ProtoRepr::build),
}
}
}
2 changes: 2 additions & 0 deletions core/lib/protobuf_config/src/proto/config/general.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import "zksync/config/observability.proto";
import "zksync/config/snapshots_creator.proto";
import "zksync/config/utils.proto";
import "zksync/config/vm_runner.proto";
import "zksync/config/object_store.proto";

message GeneralConfig {
optional config.database.Postgres postgres = 1;
Expand All @@ -37,4 +38,5 @@ message GeneralConfig {
optional config.snapshot_creator.SnapshotsCreator snapshot_creator = 31;
optional config.observability.Observability observability = 32;
optional config.vm_runner.ProtectiveReadsWriter protective_reads_writer = 33;
optional config.object_store.ObjectStore core_object_store = 34;
}
133 changes: 67 additions & 66 deletions core/lib/protobuf_config/src/proto/config/prover.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,97 +5,98 @@ import "zksync/config/object_store.proto";
package zksync.config.prover;

message ProofCompressor {
optional uint32 compression_mode = 1; // required; u8
optional uint32 prometheus_listener_port = 2; // required; u16
optional string prometheus_pushgateway_url = 3; // required
optional uint64 prometheus_push_interval_ms = 4; // optional; ms
optional uint32 generation_timeout_in_secs = 5; // required; s
optional uint32 max_attempts = 6; // required
optional string universal_setup_path = 7; // required; fs path
optional string universal_setup_download_url = 8; // required
optional bool verify_wrapper_proof = 9; // required
optional uint32 compression_mode = 1; // required; u8
optional uint32 prometheus_listener_port = 2; // required; u16
optional string prometheus_pushgateway_url = 3; // required
optional uint64 prometheus_push_interval_ms = 4; // optional; ms
optional uint32 generation_timeout_in_secs = 5; // required; s
optional uint32 max_attempts = 6; // required
optional string universal_setup_path = 7; // required; fs path
optional string universal_setup_download_url = 8; // required
optional bool verify_wrapper_proof = 9; // required
}

enum SetupLoadMode {
FROM_DISK = 0;
FROM_MEMORY = 1;
FROM_DISK = 0;
FROM_MEMORY = 1;
}

message Prover {
optional string setup_data_path = 1; // required; fs path?
optional uint32 prometheus_port = 2; // required; u16
optional uint32 max_attempts = 3; // required
optional uint32 generation_timeout_in_secs = 4; // required; s
optional SetupLoadMode setup_load_mode = 7; // required
optional uint32 specialized_group_id = 8; // required; u8
optional uint64 queue_capacity = 10; // required
optional uint32 witness_vector_receiver_port = 11; // required; u16
optional string zone_read_url = 12; // required
optional uint32 availability_check_interval_in_secs = 21; // optional; s
optional bool shall_save_to_public_bucket = 13; // required
optional config.object_store.ObjectStore object_store = 20;
reserved 5, 6, 9; reserved "base_layer_circuit_ids_to_be_verified", "recursive_layer_circuit_ids_to_be_verified", "witness_vector_generator_thread_count";
optional string setup_data_path = 1; // required; fs path?
optional uint32 prometheus_port = 2; // required; u16
optional uint32 max_attempts = 3; // required
optional uint32 generation_timeout_in_secs = 4; // required; s
optional SetupLoadMode setup_load_mode = 7; // required
optional uint32 specialized_group_id = 8; // required; u8
optional uint64 queue_capacity = 10; // required
optional uint32 witness_vector_receiver_port = 11; // required; u16
optional string zone_read_url = 12; // required
optional uint32 availability_check_interval_in_secs = 21; // optional; s
optional bool shall_save_to_public_bucket = 13; // required
optional config.object_store.ObjectStore public_object_store = 22;
optional config.object_store.ObjectStore prover_object_store = 23;
reserved 5, 6, 9; reserved "base_layer_circuit_ids_to_be_verified", "recursive_layer_circuit_ids_to_be_verified", "witness_vector_generator_thread_count";
}


message CircuitIdRoundTuple {
optional uint32 circuit_id = 1; // required; u8
optional uint32 aggregation_round = 2; // required; u8
optional uint32 circuit_id = 1; // required; u8
optional uint32 aggregation_round = 2; // required; u8
}

message ProverGroup {
repeated CircuitIdRoundTuple group_0 = 1;
repeated CircuitIdRoundTuple group_1 = 2;
repeated CircuitIdRoundTuple group_2 = 3;
repeated CircuitIdRoundTuple group_3 = 4;
repeated CircuitIdRoundTuple group_4 = 5;
repeated CircuitIdRoundTuple group_5 = 6;
repeated CircuitIdRoundTuple group_6 = 7;
repeated CircuitIdRoundTuple group_7 = 8;
repeated CircuitIdRoundTuple group_8 = 9;
repeated CircuitIdRoundTuple group_9 = 10;
repeated CircuitIdRoundTuple group_10 = 11;
repeated CircuitIdRoundTuple group_11 = 12;
repeated CircuitIdRoundTuple group_12 = 13;
repeated CircuitIdRoundTuple group_13 = 14;
repeated CircuitIdRoundTuple group_14 = 15;
repeated CircuitIdRoundTuple group_0 = 1;
repeated CircuitIdRoundTuple group_1 = 2;
repeated CircuitIdRoundTuple group_2 = 3;
repeated CircuitIdRoundTuple group_3 = 4;
repeated CircuitIdRoundTuple group_4 = 5;
repeated CircuitIdRoundTuple group_5 = 6;
repeated CircuitIdRoundTuple group_6 = 7;
repeated CircuitIdRoundTuple group_7 = 8;
repeated CircuitIdRoundTuple group_8 = 9;
repeated CircuitIdRoundTuple group_9 = 10;
repeated CircuitIdRoundTuple group_10 = 11;
repeated CircuitIdRoundTuple group_11 = 12;
repeated CircuitIdRoundTuple group_12 = 13;
repeated CircuitIdRoundTuple group_13 = 14;
repeated CircuitIdRoundTuple group_14 = 15;
}

message ProverGateway {
optional string api_url = 1; // required
optional uint32 api_poll_duration_secs = 2; // required; s
optional uint32 prometheus_listener_port = 3; // required; u16
optional string prometheus_pushgateway_url = 4; // required
optional uint64 prometheus_push_interval_ms = 5; // optional; ms
optional string api_url = 1; // required
optional uint32 api_poll_duration_secs = 2; // required; s
optional uint32 prometheus_listener_port = 3; // required; u16
optional string prometheus_pushgateway_url = 4; // required
optional uint64 prometheus_push_interval_ms = 5; // optional; ms
}


message WitnessGenerator {
optional uint32 generation_timeout_in_secs = 1; // required;
optional uint32 max_attempts = 2; // required;
optional uint32 last_l1_batch_to_process = 5; // optional
optional bool shall_save_to_public_bucket = 7; // required
optional uint32 basic_generation_timeout_in_secs = 8; // optional;
optional uint32 leaf_generation_timeout_in_secs = 9; // optional;
optional uint32 node_generation_timeout_in_secs = 10; // optional;
optional uint32 scheduler_generation_timeout_in_secs = 11; // optional;
optional uint32 recursion_tip_timeout_in_secs = 12; // optional;
reserved 3, 4, 6;
reserved "dump_arguments_for_blocks", "force_process_block", "blocks_proving_percentage";
optional uint32 generation_timeout_in_secs = 1; // required;
optional uint32 max_attempts = 2; // required;
optional uint32 last_l1_batch_to_process = 5; // optional
optional bool shall_save_to_public_bucket = 7; // required
optional uint32 basic_generation_timeout_in_secs = 8; // optional;
optional uint32 leaf_generation_timeout_in_secs = 9; // optional;
optional uint32 node_generation_timeout_in_secs = 10; // optional;
optional uint32 scheduler_generation_timeout_in_secs = 11; // optional;
optional uint32 recursion_tip_timeout_in_secs = 12; // optional;
reserved 3, 4, 6;
reserved "dump_arguments_for_blocks", "force_process_block", "blocks_proving_percentage";
}

message WitnessVectorGenerator {
optional uint32 max_prover_reservation_duration_in_secs = 1; // required; s
optional uint32 prover_instance_wait_timeout_in_secs = 2; // required; s
optional uint32 prover_instance_poll_time_in_milli_secs = 3; // required; ms
optional uint32 prometheus_listener_port = 4; // required; u16
optional string prometheus_pushgateway_url = 5; // required
optional uint64 prometheus_push_interval_ms = 6; // optional; ms
optional uint32 specialized_group_id = 7; // required; u8
optional uint32 max_prover_reservation_duration_in_secs = 1; // required; s
optional uint32 prover_instance_wait_timeout_in_secs = 2; // required; s
optional uint32 prover_instance_poll_time_in_milli_secs = 3; // required; ms
optional uint32 prometheus_listener_port = 4; // required; u16
optional string prometheus_pushgateway_url = 5; // required
optional uint64 prometheus_push_interval_ms = 6; // optional; ms
optional uint32 specialized_group_id = 7; // required; u8
}


message ProofDataHandler {
optional uint32 http_port = 1; // required; u16
optional uint32 proof_generation_timeout_in_secs = 2; // required; s
optional uint32 http_port = 1; // required; u16
optional uint32 proof_generation_timeout_in_secs = 2; // required; s
}
13 changes: 10 additions & 3 deletions core/lib/protobuf_config/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,12 @@ impl proto::SetupLoadMode {
impl ProtoRepr for proto::Prover {
type Type = configs::FriProverConfig;
fn read(&self) -> anyhow::Result<Self::Type> {
let object_store = if let Some(object_store) = &self.object_store {
let public_object_store = if let Some(object_store) = &self.public_object_store {
Some(object_store.read()?)
} else {
None
};
let prover_object_store = if let Some(object_store) = &self.prover_object_store {
Some(object_store.read()?)
} else {
None
Expand Down Expand Up @@ -325,7 +330,8 @@ impl ProtoRepr for proto::Prover {
availability_check_interval_in_secs: self.availability_check_interval_in_secs,
shall_save_to_public_bucket: *required(&self.shall_save_to_public_bucket)
.context("shall_save_to_public_bucket")?,
object_store,
public_object_store,
prover_object_store,
})
}

Expand All @@ -342,7 +348,8 @@ impl ProtoRepr for proto::Prover {
zone_read_url: Some(this.zone_read_url.clone()),
availability_check_interval_in_secs: this.availability_check_interval_in_secs,
shall_save_to_public_bucket: Some(this.shall_save_to_public_bucket),
object_store: this.object_store.as_ref().map(ProtoRepr::build),
prover_object_store: this.prover_object_store.as_ref().map(ProtoRepr::build),
public_object_store: this.public_object_store.as_ref().map(ProtoRepr::build),
}
}
}
7 changes: 2 additions & 5 deletions core/lib/zksync_core_leftovers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,9 @@ pub async fn initialize_components(
}

let object_store_config = configs
.prover_config
.core_object_store
.clone()
.context("Prover")?
.object_store
.clone()
.context("object_store_config")?;
.context("core_object_store_config")?;
let store_factory = ObjectStoreFactory::new(object_store_config);

if components.contains(&Component::StateKeeper) {
Expand Down
3 changes: 2 additions & 1 deletion core/lib/zksync_core_leftovers/src/temp_config_store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ pub struct TempConfigStore {
pub eth_sender_config: Option<EthConfig>,
pub eth_watch_config: Option<EthWatchConfig>,
pub gas_adjuster_config: Option<GasAdjusterConfig>,
pub object_store_config: Option<ObjectStoreConfig>,
pub observability: Option<ObservabilityConfig>,
pub snapshot_creator: Option<SnapshotsCreatorConfig>,
pub protective_reads_writer_config: Option<ProtectiveReadsWriterConfig>,
pub core_object_store: Option<ObjectStoreConfig>,
}

impl TempConfigStore {
Expand All @@ -88,6 +88,7 @@ impl TempConfigStore {
snapshot_creator: self.snapshot_creator.clone(),
observability: self.observability.clone(),
protective_reads_writer_config: self.protective_reads_writer_config.clone(),
core_object_store: self.core_object_store.clone(),
}
}

Expand Down
6 changes: 5 additions & 1 deletion etc/env/file_based/general.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ snapshot_creator:


prover:
object_store:
prover_object_store:
file_backed:
file_backed_base_path: artifacts
max_retries: 10
public_object_store:
file_backed:
file_backed_base_path: artifacts
max_retries: 10
Expand Down
Loading
Loading