Skip to content

Commit

Permalink
Move object store
Browse files Browse the repository at this point in the history
Signed-off-by: Danil <[email protected]>
  • Loading branch information
Deniallugo committed Jun 7, 2024
1 parent c4b27d2 commit 1004cd4
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 23 deletions.
3 changes: 2 additions & 1 deletion core/bin/zksync_server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use zksync_config::{
ProtectiveReadsWriterConfig, Secrets,
},
ApiConfig, ContractVerifierConfig, DBConfig, EthConfig, EthWatchConfig, GasAdjusterConfig,
GenesisConfig, PostgresConfig, SnapshotsCreatorConfig,
GenesisConfig, ObjectStoreConfig, PostgresConfig, SnapshotsCreatorConfig,
};
use zksync_core_leftovers::{
genesis_init, initialize_components, is_genesis_needed, setup_sigint_handler,
Expand Down Expand Up @@ -307,5 +307,6 @@ fn load_env_config() -> anyhow::Result<TempConfigStore> {
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)
.core_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
1 change: 0 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,6 @@ 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 core_object_store: Option<ObjectStoreConfig>,
pub prover_object_store: Option<ObjectStoreConfig>,
pub public_object_store: Option<ObjectStoreConfig>,
}
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>,
}
1 change: 0 additions & 1 deletion core/lib/config/src/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,6 @@ 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),
core_object_store: self.sample(rng),
prover_object_store: self.sample(rng),
public_object_store: self.sample(rng),
}
Expand Down
3 changes: 1 addition & 2 deletions core/lib/env_config/src/fri_prover.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use zksync_config::{configs::FriProverConfig, ObjectStoreConfig};
use zksync_config::configs::FriProverConfig;

use crate::{
envy_load,
Expand All @@ -11,7 +11,6 @@ impl FromEnv for FriProverConfig {
let mut prover: FriProverConfig = envy_load("fri_prover", "FRI_PROVER_")?;
prover.prover_object_store = ProverObjectStoreConfig::from_env().map(|a| a.0).ok();
prover.public_object_store = PublicObjectStoreConfig::from_env().map(|a| a.0).ok();
prover.core_object_store = ObjectStoreConfig::from_env().ok();
Ok(prover)
}
}
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;
}
1 change: 0 additions & 1 deletion core/lib/protobuf_config/src/proto/config/prover.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ message Prover {
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;
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";
Expand Down
7 changes: 0 additions & 7 deletions core/lib/protobuf_config/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,6 @@ impl proto::SetupLoadMode {
impl ProtoRepr for proto::Prover {
type Type = configs::FriProverConfig;
fn read(&self) -> anyhow::Result<Self::Type> {
let core_object_store = if let Some(object_store) = &self.object_store {
Some(object_store.read()?)
} else {
None
};
let public_object_store = if let Some(object_store) = &self.public_object_store {
Some(object_store.read()?)
} else {
Expand Down Expand Up @@ -335,7 +330,6 @@ 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")?,
core_object_store,
public_object_store,
prover_object_store,
})
Expand All @@ -354,7 +348,6 @@ 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.core_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),
}
Expand Down
3 changes: 0 additions & 3 deletions core/lib/zksync_core_leftovers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,6 @@ pub async fn initialize_components(
}

let object_store_config = configs
.prover_config
.clone()
.context("Prover")?
.core_object_store
.clone()
.context("core_object_store_config")?;
Expand Down
4 changes: 3 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 @@ -13,7 +13,7 @@ use zksync_config::{
ObservabilityConfig, PrometheusConfig, ProofDataHandlerConfig, ProtectiveReadsWriterConfig,
},
ApiConfig, ContractVerifierConfig, DBConfig, EthConfig, EthWatchConfig, GasAdjusterConfig,
PostgresConfig, SnapshotsCreatorConfig,
ObjectStoreConfig, PostgresConfig, SnapshotsCreatorConfig,
};
use zksync_protobuf::{repr::ProtoRepr, ProtoFmt};

Expand Down Expand Up @@ -61,6 +61,7 @@ pub struct TempConfigStore {
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 @@ -87,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
4 changes: 3 additions & 1 deletion prover/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use zksync_config::{
house_keeper::HouseKeeperConfig,
DatabaseSecrets, FriProofCompressorConfig, FriProverConfig, FriProverGatewayConfig,
FriWitnessGeneratorConfig, FriWitnessVectorGeneratorConfig, GeneralConfig,
ObservabilityConfig, PrometheusConfig, ProofDataHandlerConfig, ProtectiveReadsWriterConfig,
ObjectStoreConfig, ObservabilityConfig, PrometheusConfig, ProofDataHandlerConfig,
ProtectiveReadsWriterConfig,
},
ApiConfig, ContractVerifierConfig, DBConfig, EthConfig, EthWatchConfig, GasAdjusterConfig,
PostgresConfig, SnapshotsCreatorConfig,
Expand Down Expand Up @@ -48,6 +49,7 @@ fn load_env_config() -> anyhow::Result<TempConfigStore> {
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(),
})
}

Expand Down

0 comments on commit 1004cd4

Please sign in to comment.