diff --git a/core/lib/config/src/configs/proof_data_handler.rs b/core/lib/config/src/configs/proof_data_handler.rs index 9ce89421b34b..bbe9e881d5d6 100644 --- a/core/lib/config/src/configs/proof_data_handler.rs +++ b/core/lib/config/src/configs/proof_data_handler.rs @@ -1,23 +1,32 @@ -use std::{fmt, fmt::Display, marker::PhantomData, str::FromStr, time::Duration}; +use std::time::Duration; -use serde::{de, Deserialize}; +use serde::Deserialize; use zksync_basic_types::L1BatchNumber; #[derive(Debug, Deserialize, Clone, PartialEq)] pub struct TeeConfig { /// If true, the TEE support is enabled. - #[serde(deserialize_with = "deserialize_stringified_any")] pub tee_support: bool, /// All batches before this one are considered to be processed. - #[serde(deserialize_with = "deserialize_stringified_any", default)] pub first_tee_processed_batch: L1BatchNumber, } +impl Default for TeeConfig { + fn default() -> Self { + TeeConfig { + tee_support: false, + first_tee_processed_batch: L1BatchNumber(0), + } + } +} + #[derive(Debug, Deserialize, Clone, PartialEq)] pub struct ProofDataHandlerConfig { pub http_port: u16, pub proof_generation_timeout_in_secs: u16, - #[serde(flatten)] + #[serde(skip)] + // ^ Filled in separately in `Self::from_env()`. We cannot use `serde(flatten)` because it + // doesn't work with `envy`: https://github.com/softprops/envy/issues/26 pub tee_config: TeeConfig, } @@ -26,35 +35,3 @@ impl ProofDataHandlerConfig { Duration::from_secs(self.proof_generation_timeout_in_secs as u64) } } - -// Boilerplate to workaround https://github.com/softprops/envy/issues/26 - -pub fn deserialize_stringified_any<'de, D, T>(deserializer: D) -> Result -where - D: de::Deserializer<'de>, - T: FromStr, - T::Err: Display, -{ - deserializer.deserialize_any(StringifiedAnyVisitor(PhantomData)) -} - -pub struct StringifiedAnyVisitor(PhantomData); - -impl<'de, T> de::Visitor<'de> for StringifiedAnyVisitor -where - T: FromStr, - T::Err: Display, -{ - type Value = T; - - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("a string containing json data") - } - - fn visit_str(self, v: &str) -> Result - where - E: de::Error, - { - Self::Value::from_str(v).map_err(E::custom) - } -} diff --git a/core/lib/protobuf_config/src/proto/config/prover.proto b/core/lib/protobuf_config/src/proto/config/prover.proto index ae8a636f52af..5ce173d91dd9 100644 --- a/core/lib/protobuf_config/src/proto/config/prover.proto +++ b/core/lib/protobuf_config/src/proto/config/prover.proto @@ -108,5 +108,5 @@ message ProofDataHandler { optional uint32 http_port = 1; // required; u16 optional uint32 proof_generation_timeout_in_secs = 2; // required; s optional bool tee_support = 3; // required - optional uint64 first_tee_processed_batch = 4; // required + optional uint64 first_tee_processed_batch = 4; // optional }