diff --git a/crates/apollo_batcher_config/src/config.rs b/crates/apollo_batcher_config/src/config.rs index 86672f7c3e7..338ad22e369 100644 --- a/crates/apollo_batcher_config/src/config.rs +++ b/crates/apollo_batcher_config/src/config.rs @@ -1,17 +1,9 @@ -use std::collections::BTreeMap; use std::time::Duration; use apollo_config::converters::{ deserialize_milliseconds_to_duration, serialize_duration_as_milliseconds, }; -use apollo_config::dumping::{ - prepend_sub_config_name, - ser_optional_sub_config, - ser_param, - SerializeConfig, -}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use apollo_storage::db::DbConfig; use apollo_storage::storage_reader_server::{ StorageReaderServerDynamicConfig, @@ -43,19 +35,6 @@ pub struct BlockBuilderConfig { pub versioned_constants_overrides: Option, } -impl SerializeConfig for BlockBuilderConfig { - fn dump(&self) -> BTreeMap { - let mut dump = prepend_sub_config_name(self.chain_info.dump(), "chain_info"); - dump.append(&mut prepend_sub_config_name(self.execute_config.dump(), "execute_config")); - dump.append(&mut prepend_sub_config_name(self.bouncer_config.dump(), "bouncer_config")); - dump.append(&mut ser_optional_sub_config( - &self.versioned_constants_overrides, - "versioned_constants_overrides", - )); - dump - } -} - #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct CommitmentManagerConfig { pub tasks_channel_size: usize, @@ -73,32 +52,6 @@ impl Default for CommitmentManagerConfig { } } -impl SerializeConfig for CommitmentManagerConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from([ - ser_param( - "tasks_channel_size", - &self.tasks_channel_size, - "The size of the channel for sending tasks to the commitment manager.", - ParamPrivacyInput::Public, - ), - ser_param( - "results_channel_size", - &self.results_channel_size, - "The size of the channel for receiving results from the commitment manager.", - ParamPrivacyInput::Public, - ), - ser_param( - "panic_if_task_channel_full", - &self.panic_if_task_channel_full, - "If the task channel is full: if true, will panic. If false, will wait for the \ - tasks channel to be available.", - ParamPrivacyInput::Public, - ), - ]) - } -} - /// Configuration for the preconfirmed block writer component of the batcher. #[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)] pub struct PreconfirmedBlockWriterConfig { @@ -112,26 +65,6 @@ impl Default for PreconfirmedBlockWriterConfig { } } -impl SerializeConfig for PreconfirmedBlockWriterConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "channel_buffer_capacity", - &self.channel_buffer_capacity, - "The capacity of the channel buffer for receiving pre-confirmed transactions.", - ParamPrivacyInput::Public, - ), - ser_param( - "write_block_interval_millis", - &self.write_block_interval_millis, - "Time interval (ms) between writing pre-confirmed blocks. Writes occur only when \ - block data changes.", - ParamPrivacyInput::Public, - ), - ]) - } -} - /// Configuration for the preconfirmed Cende client component of the batcher. #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct PreconfirmedCendeConfig { @@ -148,17 +81,6 @@ impl Default for PreconfirmedCendeConfig { } } -impl SerializeConfig for PreconfirmedCendeConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from([ser_param( - "recorder_url", - &self.recorder_url, - "The URL of the Pythonic cende_recorder", - ParamPrivacyInput::Public, - )]) - } -} - #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Default)] pub struct FirstBlockWithPartialBlockHash { pub block_number: BlockNumber, @@ -166,32 +88,6 @@ pub struct FirstBlockWithPartialBlockHash { pub parent_block_hash: BlockHash, } -impl SerializeConfig for FirstBlockWithPartialBlockHash { - fn dump(&self) -> BTreeMap { - BTreeMap::from([ - ser_param( - "block_number", - &self.block_number, - "The number of the first block with a partial block hash components.", - ParamPrivacyInput::Public, - ), - ser_param( - "block_hash", - &self.block_hash, - "The hash of the first block with a partial block hash components.", - ParamPrivacyInput::Public, - ), - ser_param( - "parent_block_hash", - &self.parent_block_hash, - "The hash of the parent block of the first block with a partial block hash \ - components.", - ParamPrivacyInput::Public, - ), - ]) - } -} - #[derive(Clone, Debug, Serialize, Deserialize, Validate, PartialEq)] pub struct BatcherStaticConfig { #[validate(nested)] @@ -214,76 +110,6 @@ pub struct BatcherStaticConfig { pub validation_only: bool, } -impl SerializeConfig for BatcherStaticConfig { - fn dump(&self) -> BTreeMap { - // TODO(yair): create nicer function to append sub configs. - let mut dump = BTreeMap::from([ - ser_param( - "outstream_content_buffer_size", - &self.outstream_content_buffer_size, - "The maximum number of items to include in a single get_proposal_content response.", - ParamPrivacyInput::Public, - ), - ser_param( - "input_stream_content_buffer_size", - &self.input_stream_content_buffer_size, - "Sets the buffer size for the input transaction channel. Adding more transactions \ - beyond this limit will block until space is available.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_l1_handler_txs_per_block_proposal", - &self.max_l1_handler_txs_per_block_proposal, - "The maximum number of L1 handler transactions to include in a block proposal.", - ParamPrivacyInput::Public, - ), - ser_param( - "propose_l1_txs_every", - &self.propose_l1_txs_every, - "Only propose L1 transactions every N proposals.", - ParamPrivacyInput::Public, - ), - ]); - dump.append(&mut prepend_sub_config_name(self.storage.dump(), "storage")); - dump.append(&mut prepend_sub_config_name( - self.block_builder_config.dump(), - "block_builder_config", - )); - dump.append(&mut prepend_sub_config_name( - self.pre_confirmed_block_writer_config.dump(), - "pre_confirmed_block_writer_config", - )); - dump.append(&mut prepend_sub_config_name( - self.contract_class_manager_config.dump(), - "contract_class_manager_config", - )); - dump.append(&mut prepend_sub_config_name( - self.commitment_manager_config.dump(), - "commitment_manager_config", - )); - dump.append(&mut prepend_sub_config_name( - self.pre_confirmed_cende_config.dump(), - "pre_confirmed_cende_config", - )); - dump.extend(ser_optional_sub_config( - &self.first_block_with_partial_block_hash, - "first_block_with_partial_block_hash", - )); - dump.append(&mut prepend_sub_config_name( - self.storage_reader_server_static_config.dump(), - "storage_reader_server_static_config", - )); - dump.append(&mut BTreeMap::from([ser_param( - "validation_only", - &self.validation_only, - "If true, the batcher only validates proposed blocks and cannot build proposals. Set \ - via the node-level validation_only config pointer.", - ParamPrivacyInput::Public, - )])); - dump - } -} - impl Default for BatcherStaticConfig { fn default() -> Self { Self { @@ -345,40 +171,6 @@ impl Default for BatcherDynamicConfig { } } -impl SerializeConfig for BatcherDynamicConfig { - fn dump(&self) -> BTreeMap { - let mut dump = BTreeMap::from([ - self.native_classes_whitelist.ser_param(), - ser_param( - "n_concurrent_txs", - &self.n_concurrent_txs, - "Number of transactions in each request from the tx_provider.", - ParamPrivacyInput::Public, - ), - ser_param( - "tx_polling_interval_millis", - &self.tx_polling_interval_millis, - "Time to wait (in milliseconds) between transaction requests when the previous \ - request returned no transactions.", - ParamPrivacyInput::Public, - ), - ser_param( - "proposer_idle_detection_delay_millis", - &self.proposer_idle_detection_delay_millis.as_millis(), - "Minimum time (in milliseconds) that must pass since block creation started \ - before checking for idle state. If this delay has passed AND no transactions are \ - currently being executed, the proposer will finish building the current block.", - ParamPrivacyInput::Public, - ), - ]); - dump.append(&mut prepend_sub_config_name( - self.storage_reader_server_dynamic_config.dump(), - "storage_reader_server_dynamic_config", - )); - dump - } -} - /// The batcher related configuration. #[derive(Clone, Debug, Default, Serialize, Deserialize, Validate, PartialEq)] #[validate(schema(function = "validate_batcher_config"))] @@ -389,15 +181,6 @@ pub struct BatcherConfig { pub dynamic_config: BatcherDynamicConfig, } -impl SerializeConfig for BatcherConfig { - fn dump(&self) -> BTreeMap { - let mut config = BTreeMap::new(); - config.extend(prepend_sub_config_name(self.static_config.dump(), "static_config")); - config.extend(prepend_sub_config_name(self.dynamic_config.dump(), "dynamic_config")); - config - } -} - fn validate_batcher_dynamic_config( dynamic_config: &BatcherDynamicConfig, ) -> Result<(), ValidationError> { diff --git a/crates/apollo_central_sync_config/src/config.rs b/crates/apollo_central_sync_config/src/config.rs index 7ed81e305c1..0148c39866a 100644 --- a/crates/apollo_central_sync_config/src/config.rs +++ b/crates/apollo_central_sync_config/src/config.rs @@ -1,4 +1,4 @@ -use std::collections::{BTreeMap, HashMap}; +use std::collections::HashMap; use std::time::Duration; use apollo_config::converters::{ @@ -7,13 +7,9 @@ use apollo_config::converters::{ deserialize_seconds_to_duration, serialize_duration_as_milliseconds, serialize_duration_as_seconds, - serialize_optional_map, }; -use apollo_config::dumping::{prepend_sub_config_name, ser_param, SerializeConfig}; use apollo_config::secrets::Sensitive; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use apollo_starknet_client::RetryConfig; -use itertools::chain; use serde::{Deserialize, Serialize}; use url::Url; use validator::Validate; @@ -52,58 +48,6 @@ impl Default for CentralSourceConfig { } } -impl SerializeConfig for CentralSourceConfig { - fn dump(&self) -> BTreeMap { - let self_params_dump = BTreeMap::from_iter([ - ser_param( - "concurrent_requests", - &self.concurrent_requests, - "Maximum number of concurrent requests to Starknet feeder-gateway for getting a \ - type of data (for example, blocks).", - ParamPrivacyInput::Public, - ), - ser_param( - "starknet_url", - &self.starknet_url, - "Starknet feeder-gateway URL. It should match chain_id.", - ParamPrivacyInput::Public, - ), - ser_param( - "http_headers", - &serialize_optional_map(&None), - "'k1:v1 k2:v2 ...' headers for SN-client.", - ParamPrivacyInput::Private, - ), - ser_param( - "max_state_updates_to_download", - &self.max_state_updates_to_download, - "Maximum number of state updates to download at a given time.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_state_updates_to_store_in_memory", - &self.max_state_updates_to_store_in_memory, - "Maximum number of state updates to store in memory at a given time.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_classes_to_download", - &self.max_classes_to_download, - "Maximum number of classes to download at a given time.", - ParamPrivacyInput::Public, - ), - ser_param( - "class_cache_size", - &self.class_cache_size, - "Size of class cache, must be a positive integer.", - ParamPrivacyInput::Public, - ), - ]); - chain!(self_params_dump, prepend_sub_config_name(self.retry_config.dump(), "retry_config")) - .collect() - } -} - #[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)] pub struct SyncConfig { #[serde( @@ -132,75 +76,6 @@ pub struct SyncConfig { pub blocks_before_tip_to_disable_batching: u64, } -impl SerializeConfig for SyncConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "latest_block_poll_interval_millis", - &self.latest_block_poll_interval_millis.as_millis(), - "Time in milliseconds between polling for the latest block while node is \ - synchronized.", - ParamPrivacyInput::Public, - ), - ser_param( - "base_layer_propagation_sleep_duration", - &self.base_layer_propagation_sleep_duration.as_secs(), - "Time in seconds to poll the base layer to get the latest proved block.", - ParamPrivacyInput::Public, - ), - ser_param( - "recoverable_error_sleep_duration", - &self.recoverable_error_sleep_duration.as_secs(), - "Waiting time in seconds before restarting synchronization after a recoverable \ - error.", - ParamPrivacyInput::Public, - ), - ser_param( - "blocks_max_stream_size", - &self.blocks_max_stream_size, - "Max amount of blocks to download in a stream.", - ParamPrivacyInput::Public, - ), - ser_param( - "state_updates_max_stream_size", - &self.state_updates_max_stream_size, - "Max amount of state updates to download in a stream.", - ParamPrivacyInput::Public, - ), - ser_param( - "verify_blocks", - &self.verify_blocks, - "Whether to verify incoming blocks.", - ParamPrivacyInput::Public, - ), - ser_param( - "collect_pending_data", - &self.collect_pending_data, - "Whether to collect data on pending blocks.", - ParamPrivacyInput::Public, - ), - ser_param( - "store_sierras_and_casms_block_threshold", - &self.store_sierras_and_casms_block_threshold, - "Block-number threshold for persisting **Sierra** and **CASM** to local storage \ - (for backward compatibility with the native blockifier). For blocks with \ - block_number < this value, Sierra and CASM are stored for all classes; for \ - block_number >= this value they are stored only for **legacy** classes (compiled \ - with a version < `STARKNET_VERSION_TO_COMPILE_FROM`). Use 0 to store for no \ - blocks, or a large value (e.g. u64::MAX) to store for all.", - ParamPrivacyInput::Public, - ), - ser_param( - "blocks_before_tip_to_disable_batching", - &self.blocks_before_tip_to_disable_batching, - "Batching is automatically disabled (batch_size=1) once the node is within this \ - many blocks of the chain tip, ensuring low-latency commits near the tip.", - ParamPrivacyInput::Public, - ), - ]) - } -} - impl Default for SyncConfig { fn default() -> Self { SyncConfig { diff --git a/crates/apollo_class_manager_config/src/config.rs b/crates/apollo_class_manager_config/src/config.rs index 7bda4efb6f0..5b9159e1764 100644 --- a/crates/apollo_class_manager_config/src/config.rs +++ b/crates/apollo_class_manager_config/src/config.rs @@ -1,8 +1,5 @@ -use std::collections::BTreeMap; use std::path::PathBuf; -use apollo_config::dumping::{prepend_sub_config_name, ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use apollo_storage::db::DbConfig; use apollo_storage::mmap_file::MmapFileConfig; use apollo_storage::storage_reader_server::{ @@ -28,25 +25,6 @@ impl Default for CachedClassStorageConfig { } } -impl SerializeConfig for CachedClassStorageConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from([ - ser_param( - "class_cache_size", - &self.class_cache_size, - "Contract classes cache size.", - ParamPrivacyInput::Public, - ), - ser_param( - "deprecated_class_cache_size", - &self.deprecated_class_cache_size, - "Deprecated contract classes cache size.", - ParamPrivacyInput::Public, - ), - ]) - } -} - /// Configuration for filesystem class storage. #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Validate)] pub struct FsClassStorageConfig { @@ -79,26 +57,6 @@ impl Default for FsClassStorageConfig { } } -impl SerializeConfig for FsClassStorageConfig { - fn dump(&self) -> BTreeMap { - let mut dump = BTreeMap::from([ser_param( - "persistent_root", - &self.persistent_root, - "Path to the node's class storage directory.", - ParamPrivacyInput::Public, - )]); - dump.append(&mut prepend_sub_config_name( - self.class_hash_storage_config.dump(), - "class_hash_storage_config", - )); - dump.append(&mut prepend_sub_config_name( - self.storage_reader_server_static_config.dump(), - "storage_reader_server_static_config", - )); - dump - } -} - /// Configuration for class manager. #[derive(Clone, Debug, Serialize, Deserialize, Validate, PartialEq)] pub struct ClassManagerConfig { @@ -116,22 +74,6 @@ impl Default for ClassManagerConfig { } } -impl SerializeConfig for ClassManagerConfig { - fn dump(&self) -> BTreeMap { - let mut dump = BTreeMap::from([ser_param( - "max_compiled_contract_class_object_size", - &self.max_compiled_contract_class_object_size, - "Limitation of compiled contract class object size.", - ParamPrivacyInput::Public, - )]); - dump.append(&mut prepend_sub_config_name( - self.cached_class_storage_config.dump(), - "cached_class_storage_config", - )); - dump - } -} - /// Dynamic configuration for class manager. #[derive(Clone, Debug, Default, Serialize, Deserialize, Validate, PartialEq)] pub struct ClassManagerDynamicConfig { @@ -139,15 +81,6 @@ pub struct ClassManagerDynamicConfig { pub storage_reader_server_dynamic_config: StorageReaderServerDynamicConfig, } -impl SerializeConfig for ClassManagerDynamicConfig { - fn dump(&self) -> BTreeMap { - prepend_sub_config_name( - self.storage_reader_server_dynamic_config.dump(), - "storage_reader_server_dynamic_config", - ) - } -} - /// Static configuration for filesystem-based class manager. #[derive(Clone, Debug, Default, Serialize, Deserialize, Validate, PartialEq)] pub struct ClassManagerStaticConfig { @@ -157,21 +90,6 @@ pub struct ClassManagerStaticConfig { pub class_storage_config: FsClassStorageConfig, } -impl SerializeConfig for ClassManagerStaticConfig { - fn dump(&self) -> BTreeMap { - let mut dump = BTreeMap::new(); - dump.append(&mut prepend_sub_config_name( - self.class_manager_config.dump(), - "class_manager_config", - )); - dump.append(&mut prepend_sub_config_name( - self.class_storage_config.dump(), - "class_storage_config", - )); - dump - } -} - /// Configuration for filesystem-based class manager. #[derive(Clone, Debug, Default, Serialize, Deserialize, Validate, PartialEq)] pub struct FsClassManagerConfig { @@ -180,12 +98,3 @@ pub struct FsClassManagerConfig { #[validate(nested)] pub dynamic_config: ClassManagerDynamicConfig, } - -impl SerializeConfig for FsClassManagerConfig { - fn dump(&self) -> BTreeMap { - let mut config = BTreeMap::new(); - config.extend(prepend_sub_config_name(self.static_config.dump(), "static_config")); - config.extend(prepend_sub_config_name(self.dynamic_config.dump(), "dynamic_config")); - config - } -} diff --git a/crates/apollo_committer_config/src/config.rs b/crates/apollo_committer_config/src/config.rs index f53e9ac77c0..50e28678a7a 100644 --- a/crates/apollo_committer_config/src/config.rs +++ b/crates/apollo_committer_config/src/config.rs @@ -1,8 +1,5 @@ -use std::collections::BTreeMap; use std::path::PathBuf; -use apollo_config::dumping::{prepend_sub_config_name, ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use starknet_committer::block_committer::input::ReaderConfig; use starknet_patricia_storage::map_storage::CachedStorage; @@ -22,28 +19,6 @@ pub struct CommitterConfig { pub verify_state_diff_hash: bool, } -impl SerializeConfig for CommitterConfig { - fn dump(&self) -> BTreeMap { - let mut dump = BTreeMap::from_iter([ - ser_param( - "verify_state_diff_hash", - &self.verify_state_diff_hash, - "If true, the committer will verify the state diff hash.", - ParamPrivacyInput::Public, - ), - ser_param( - "db_path", - &self.db_path, - "Path to the committer storage directory.", - ParamPrivacyInput::Public, - ), - ]); - dump.extend(prepend_sub_config_name(self.reader_config.dump(), "reader_config")); - dump.extend(prepend_sub_config_name(self.storage_config.dump(), "storage_config")); - dump - } -} - impl Default for CommitterConfig { fn default() -> Self { // TODO(Nimrod): Consider adding dynamic config and move `build_storage_tries_concurrently` diff --git a/crates/apollo_compile_to_native_types/src/lib.rs b/crates/apollo_compile_to_native_types/src/lib.rs index d37344f1038..3914309e67a 100644 --- a/crates/apollo_compile_to_native_types/src/lib.rs +++ b/crates/apollo_compile_to_native_types/src/lib.rs @@ -1,10 +1,7 @@ //! Types and configuration for Cairo native compilation. -use std::collections::BTreeMap; use std::path::PathBuf; -use apollo_config::dumping::{ser_optional_param, ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use validator::Validate; @@ -51,43 +48,3 @@ impl SierraCompilationConfig { } } } - -impl SerializeConfig for SierraCompilationConfig { - fn dump(&self) -> BTreeMap { - let mut dump = BTreeMap::from([ - ser_param( - "optimization_level", - &self.optimization_level, - "The level of optimization to apply during compilation.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_cpu_time", - &self.max_cpu_time, - "Limitation of compilation cpu time (seconds).", - ParamPrivacyInput::Public, - ), - ser_param( - "max_memory_usage", - &self.max_memory_usage, - "Limitation of compilation process's virtual memory (bytes).", - ParamPrivacyInput::Public, - ), - ]); - dump.extend(ser_optional_param( - &self.compiler_binary_path, - "".into(), - "compiler_binary_path", - "The path to the Sierra-to-Native compiler binary.", - ParamPrivacyInput::Public, - )); - dump.extend(ser_optional_param( - &self.max_file_size, - DEFAULT_MAX_FILE_SIZE, - "max_file_size", - "Limitation of compiled Cairo Native file size (bytes).", - ParamPrivacyInput::Public, - )); - dump - } -} diff --git a/crates/apollo_config/src/config_test.rs b/crates/apollo_config/src/config_test.rs index 1fc2ac2a4d1..a305e139171 100644 --- a/crates/apollo_config/src/config_test.rs +++ b/crates/apollo_config/src/config_test.rs @@ -1,4 +1,4 @@ -use std::collections::{BTreeMap, BTreeSet, HashSet}; +use std::collections::{BTreeMap, BTreeSet}; use std::time::Duration; use assert_matches::assert_matches; @@ -16,32 +16,9 @@ use crate::converters::{ serialize_optional_list_with_url_and_headers, UrlAndHeaders, }; -use crate::dumping::{ - combine_config_map_and_pointers, - generate_struct_pointer, - prepend_sub_config_name, - required_param_description, - ser_optional_param, - ser_optional_sub_config, - ser_param, - ser_pointer_target_param, - ser_pointer_target_required_param, - ser_required_param, - set_pointing_param_paths, - SerializeConfig, -}; use crate::loading::{load, load_and_process_config}; use crate::presentation::get_config_presentation; -use crate::{ - ConfigError, - ParamPath, - ParamPrivacy, - ParamPrivacyInput, - SerializationType, - SerializedContent, - SerializedParam, - CONFIG_FILE_ARG, -}; +use crate::{ConfigError, ParamPath, CONFIG_FILE_ARG}; #[derive(Clone, Copy, Default, Serialize, Deserialize, Debug, PartialEq, Validate)] struct InnerConfig { @@ -49,12 +26,6 @@ struct InnerConfig { o: usize, } -impl SerializeConfig for InnerConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from([ser_param("o", &self.o, "This is o.", ParamPrivacyInput::Public)]) - } -} - #[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Validate)] struct OuterConfig { opt_elem: Option, @@ -63,23 +34,6 @@ struct OuterConfig { inner_config: InnerConfig, } -impl SerializeConfig for OuterConfig { - fn dump(&self) -> BTreeMap { - chain!( - ser_optional_param( - &self.opt_elem, - 1, - "opt_elem", - "This is elem.", - ParamPrivacyInput::Public - ), - ser_optional_sub_config(&self.opt_config, "opt_config"), - prepend_sub_config_name(self.inner_config.dump(), "inner_config"), - ) - .collect() - } -} - #[test] fn test_validation() { let outer_config = @@ -98,36 +52,6 @@ struct TypicalConfig { f: f64, } -impl SerializeConfig for TypicalConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from([ - ser_param( - "a", - &self.a.as_millis(), - "This is a as milliseconds.", - ParamPrivacyInput::Public, - ), - ser_param("b", &self.b, "This is b.", ParamPrivacyInput::Public), - ser_param("c", &self.c, "This is c.", ParamPrivacyInput::Private), - ser_param("d", &self.d, "This is d.", ParamPrivacyInput::Public), - ser_param("e", &self.e, "This is e.", ParamPrivacyInput::Public), - ser_param("f", &self.f, "This is f.", ParamPrivacyInput::Public), - ]) - } -} - -/// Derives the set of `Private` param paths from a fixture's `dump()`. Mirrors the privacy registry -/// that production callers inject (e.g. `private_parameters()`), so the presentation tests stay -/// pinned to the fixtures' own privacy declarations. -fn private_paths_from_dump(config: &T) -> BTreeSet { - config - .dump() - .into_iter() - .filter(|(_, serialized_param)| serialized_param.privacy == ParamPrivacy::Private) - .map(|(param_path, _)| param_path) - .collect() -} - #[test] fn test_config_presentation() { let config = TypicalConfig { @@ -138,9 +62,9 @@ fn test_config_presentation() { e: 10, f: 0.5, }; - let private_paths = private_paths_from_dump(&config); - // `c` is the only `Private` param in this fixture. - assert_eq!(private_paths, BTreeSet::from(["c".to_owned()])); + // `c` is the secret param for this fixture; production callers inject the private path set + // (e.g. `private_parameters()`) rather than deriving it. + let private_paths = BTreeSet::from(["c".to_owned()]); let presentation = get_config_presentation(&config, true, &private_paths).unwrap(); let keys: Vec<_> = presentation.as_object().unwrap().keys().collect(); @@ -192,11 +116,10 @@ fn test_nested_config_presentation() { OuterConfig { opt_elem: Some(1), opt_config: None, inner_config: InnerConfig { o: 3 } }, ]; - for config in configs { - let private_paths = private_paths_from_dump(&config); - // This fixture declares no `Private` params, so nothing is redacted. - assert!(private_paths.is_empty()); + // This fixture declares no private params, so nothing is redacted. + let private_paths = BTreeSet::new(); + for config in configs { let presentation = get_config_presentation(&config, true, &private_paths).unwrap(); let keys: Vec<_> = presentation.as_object().unwrap().keys().collect(); assert_eq!(keys, vec!["inner_config", "opt_config", "opt_elem"]); @@ -206,209 +129,6 @@ fn test_nested_config_presentation() { } } -#[test] -fn test_required_pointers_flow() { - // Set up the config map and pointers. - const REQUIRED_PARAM_NAME: &str = "b"; - const REQUIRED_PARAM_DESCRIPTION: &str = "This is common required b."; - const POINTING_PARAM_DESCRIPTION: &str = "This is b."; - const PUBLIC_POINTING_PARAM_NAME: &str = "public_b.b"; - const PRIVATE_POINTING_PARAM_NAME: &str = "private_b.b"; - const WHITELISTED_POINTING_PARAM_NAME: &str = "non_pointing.b"; - const VALUE: usize = 6; - - let config_map = BTreeMap::from([ - ser_param( - PUBLIC_POINTING_PARAM_NAME, - &json!(VALUE), - POINTING_PARAM_DESCRIPTION, - ParamPrivacyInput::Public, - ), - ser_param( - PRIVATE_POINTING_PARAM_NAME, - &json!(VALUE), - POINTING_PARAM_DESCRIPTION, - ParamPrivacyInput::Private, - ), - ser_param( - WHITELISTED_POINTING_PARAM_NAME, - &json!(VALUE), - POINTING_PARAM_DESCRIPTION, - ParamPrivacyInput::Private, - ), - ]); - let pointers = vec![( - ser_pointer_target_required_param( - REQUIRED_PARAM_NAME, - SerializationType::PositiveInteger, - REQUIRED_PARAM_DESCRIPTION, - ), - HashSet::from([ - PUBLIC_POINTING_PARAM_NAME.to_string(), - PRIVATE_POINTING_PARAM_NAME.to_string(), - ]), - )]; - let non_pointer_params = HashSet::from([WHITELISTED_POINTING_PARAM_NAME.to_string()]); - let stored_map = - combine_config_map_and_pointers(config_map, &pointers, &non_pointer_params).unwrap(); - - // Assert the pointing parameters are correctly set. - assert_eq!( - stored_map[PUBLIC_POINTING_PARAM_NAME], - json!(SerializedParam { - description: POINTING_PARAM_DESCRIPTION.to_owned(), - content: SerializedContent::PointerTarget(REQUIRED_PARAM_NAME.to_owned()), - privacy: ParamPrivacy::Public, - }) - ); - assert_eq!( - stored_map[PRIVATE_POINTING_PARAM_NAME], - json!(SerializedParam { - description: POINTING_PARAM_DESCRIPTION.to_owned(), - content: SerializedContent::PointerTarget(REQUIRED_PARAM_NAME.to_owned()), - privacy: ParamPrivacy::Private, - }) - ); - - // Assert the whitelisted parameter is correctly set. - assert_eq!( - stored_map[WHITELISTED_POINTING_PARAM_NAME], - json!(SerializedParam { - description: POINTING_PARAM_DESCRIPTION.to_owned(), - content: SerializedContent::DefaultValue(json!(VALUE)), - privacy: ParamPrivacy::Private, - }) - ); - - // Assert the pointed parameter is correctly set as a required parameter. - assert_eq!( - stored_map[REQUIRED_PARAM_NAME], - json!(SerializedParam { - description: required_param_description(REQUIRED_PARAM_DESCRIPTION).to_owned(), - content: SerializedContent::ParamType(SerializationType::PositiveInteger), - privacy: ParamPrivacy::TemporaryValue, - }) - ); -} - -#[test] -#[should_panic( - expected = "The target param should_be_pointing.c should point to c, or to be whitelisted." -)] -fn test_missing_pointer_flow() { - const TARGET_PARAM_NAME: &str = "c"; - const TARGET_PARAM_DESCRIPTION: &str = "This is common c."; - const PARAM_DESCRIPTION: &str = "This is c."; - const NON_POINTING_PARAM_NAME: &str = "should_be_pointing.c"; - - // Define a non-pointing parameter and a target pointer such that the parameter name matches the - // target. - let config_map = BTreeMap::from([ser_param( - NON_POINTING_PARAM_NAME, - &json!(7), - PARAM_DESCRIPTION, - ParamPrivacyInput::Private, - )]); - let pointers = vec![( - ser_pointer_target_param(TARGET_PARAM_NAME, &json!(10), TARGET_PARAM_DESCRIPTION), - HashSet::new(), - )]; - // Do not whitelist the non-pointing parameter. - let non_pointer_params = HashSet::new(); - - // Attempt to combine the config map and pointers. This should panic. - combine_config_map_and_pointers(config_map, &pointers, &non_pointer_params).unwrap(); -} - -#[test] -fn test_struct_pointers() { - const TARGET_PREFIX: &str = "base"; - let target_value = - RequiredConfig { param_path: "Not a default param_path.".to_owned(), num: 10 }; - let config_map = StructPointersConfig::default().dump(); - - let pointers = generate_struct_pointer( - TARGET_PREFIX.to_owned(), - &target_value, - set_pointing_param_paths(&["a", "b"]), - ); - let stored_map = - combine_config_map_and_pointers(config_map, &pointers, &HashSet::default()).unwrap(); - - // Assert the pointing parameters are correctly set. - assert_eq!( - stored_map["a.param_path"], - json!(SerializedParam { - description: required_param_description(RequiredConfig::param_path_description()) - .to_owned(), - content: SerializedContent::PointerTarget( - format!("{TARGET_PREFIX}.param_path").to_owned() - ), - privacy: ParamPrivacy::Public, - }) - ); - assert_eq!( - stored_map["a.num"], - json!(SerializedParam { - description: RequiredConfig::num_description().to_owned(), - content: SerializedContent::PointerTarget(format!("{TARGET_PREFIX}.num").to_owned()), - privacy: ParamPrivacy::Public, - }) - ); - assert_eq!( - stored_map["b.param_path"], - json!(SerializedParam { - description: required_param_description(RequiredConfig::param_path_description()) - .to_owned(), - content: SerializedContent::PointerTarget( - format!("{TARGET_PREFIX}.param_path").to_owned() - ), - privacy: ParamPrivacy::Public, - }) - ); - assert_eq!( - stored_map["b.num"], - json!(SerializedParam { - description: RequiredConfig::num_description().to_owned(), - content: SerializedContent::PointerTarget(format!("{TARGET_PREFIX}.num").to_owned()), - privacy: ParamPrivacy::Public, - }) - ); - - // Assert the pointed parameter is correctly set. - assert_eq!( - stored_map[format!("{TARGET_PREFIX}.param_path").to_owned()], - json!(SerializedParam { - description: required_param_description(RequiredConfig::param_path_description()) - .to_owned(), - content: SerializedContent::ParamType(SerializationType::String), - privacy: ParamPrivacy::TemporaryValue, - }) - ); - assert_eq!( - stored_map[format!("{TARGET_PREFIX}.num").to_owned()], - json!(SerializedParam { - description: RequiredConfig::num_description().to_owned(), - content: SerializedContent::DefaultValue(json!(10)), - privacy: ParamPrivacy::TemporaryValue, - }) - ); -} - -#[derive(Clone, Default, Serialize, Deserialize, Debug, PartialEq)] -struct StructPointersConfig { - pub a: RequiredConfig, - pub b: RequiredConfig, -} -impl SerializeConfig for StructPointersConfig { - fn dump(&self) -> BTreeMap { - let mut dump = BTreeMap::new(); - dump.append(&mut prepend_sub_config_name(self.a.dump(), "a")); - dump.append(&mut prepend_sub_config_name(self.b.dump(), "b")); - dump - } -} - #[derive(Deserialize, Debug, PartialEq)] struct NativeInnerConfig { a: usize, @@ -638,52 +358,12 @@ fn serialization_precision() { assert_eq!(input, deserialized); } -#[derive(Clone, Default, Serialize, Deserialize, Debug, PartialEq)] -struct RequiredConfig { - param_path: String, - num: usize, -} - -impl RequiredConfig { - pub const fn param_path_description() -> &'static str { - "This is param_path." - } - pub const fn num_description() -> &'static str { - "This is num." - } -} - -impl SerializeConfig for RequiredConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from([ - ser_required_param( - "param_path", - SerializationType::String, - Self::param_path_description(), - ParamPrivacyInput::Public, - ), - ser_param("num", &self.num, Self::num_description(), ParamPrivacyInput::Public), - ]) - } -} - #[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Default)] struct TestConfigWithNestedJson { #[serde(deserialize_with = "deserialize_optional_list_with_url_and_headers")] list_of_maps: Option>, } -impl SerializeConfig for TestConfigWithNestedJson { - fn dump(&self) -> BTreeMap { - BTreeMap::from([ser_param( - "list_of_maps", - &serialize_optional_list_with_url_and_headers(&self.list_of_maps), - "A list of nested JSON values.", - ParamPrivacyInput::Public, - )]) - } -} - #[test] fn optional_list_nested_btreemaps() { let config = TestConfigWithNestedJson { @@ -712,15 +392,11 @@ fn optional_list_nested_btreemaps() { }, ]), }; - // Build the flat values map directly from the dump (a single serialized leaf), then load it. - let config_map: BTreeMap = config - .dump() - .into_iter() - .filter_map(|(param_path, serialized_param)| match serialized_param.content { - SerializedContent::DefaultValue(value) => Some((param_path, value)), - _ => None, - }) - .collect(); + // Build the flat single-leaf values map directly from the converter, then load it back. + let config_map: BTreeMap = BTreeMap::from([( + "list_of_maps".to_owned(), + json!(serialize_optional_list_with_url_and_headers(&config.list_of_maps)), + )]); let loaded_config = load::(&config_map).unwrap(); assert_eq!(loaded_config.list_of_maps, config.list_of_maps); let serialized = serde_json::to_string(&config_map).unwrap(); diff --git a/crates/apollo_config/src/dumping.rs b/crates/apollo_config/src/dumping.rs deleted file mode 100644 index 7209e9d2072..00000000000 --- a/crates/apollo_config/src/dumping.rs +++ /dev/null @@ -1,462 +0,0 @@ -//! Utils for serializing config objects into flatten map and json file. -//! The elements structure is: -//! -//! ```json -//! "conf1.conf2.conf3.param_name": { -//! "description": "Param description.", -//! "value": json_value -//! } -//! ``` -//! In addition, supports pointers in the map, with the structure: -//! -//! ```json -//! "conf1.conf2.conf3.param_name": { -//! "description": "Param description.", -//! "pointer_target": "target_param_path" -//! } -//! ``` -//! -//! Supports required params. A required param has no default value, but the type of value that the -//! user must set: -//! ```json -//! "conf1.conf2.conf3.param_name: { -//! "description": "Param description.", -//! "required_type": Number -//! } -//! ``` -//! -//! Supports flags for optional params and sub-configs. An optional param / sub-config has an -//! "#is_none" indicator that determines whether to take its value or to deserialize it to None: -//! ```json -//! "conf1.conf2.#is_none": { -//! "description": "Flag for an optional field.", -//! "value": true -//! } -//! ``` - -use std::collections::{BTreeMap, HashSet}; - -use apollo_infra_utils::dumping::serialize_to_file; -use itertools::chain; -use serde::Serialize; -use serde_json::{json, Value}; - -use crate::{ - ConfigError, - ParamPath, - ParamPrivacy, - ParamPrivacyInput, - SerializationType, - SerializedContent, - SerializedParam, - FIELD_SEPARATOR, - IS_NONE_MARK, -}; - -/// Type alias for a pointer parameter and its serialized representation. -type PointerTarget = (ParamPath, SerializedParam); - -/// Type alias for a set of pointing parameters. -pub type Pointers = HashSet; - -/// Detailing pointers in the config map. -pub type ConfigPointers = Vec<(PointerTarget, Pointers)>; - -/// Given a set of paths that are configuration of the same struct type, makes all the paths point -/// to the same target. -pub fn generate_struct_pointer( - target_prefix: ParamPath, - default_instance: &T, - pointer_prefixes: HashSet, -) -> ConfigPointers { - let mut res = ConfigPointers::new(); - for (param_path, serialized_param) in default_instance.dump() { - let pointer_target = serialized_param_to_pointer_target( - target_prefix.clone(), - ¶m_path, - &serialized_param, - ); - let pointers = pointer_prefixes - .iter() - .map(|pointer| chain_param_paths(&[pointer, ¶m_path])) - .collect(); - - res.push((pointer_target, pointers)); - } - res -} - -/// Generates pointers for an optional struct: -/// - All fields under `target_prefix` (using `default_instance` if provided, otherwise -/// `T::default()`), pointed to by each prefix in `pointer_prefixes`. -/// - The optional flag's default is derived from whether a default instance was provided: `true` if -/// `default_instance` is `None`, otherwise `false`. -pub fn generate_optional_struct_pointer( - target_prefix: ParamPath, - default_instance: Option<&T>, - pointer_prefixes: HashSet, -) -> ConfigPointers { - // Use provided instance if given; otherwise use a local default that lives for this call. - let default_instance_value = match default_instance { - Some(instance) => instance, - None => &T::default(), - }; - let mut res = generate_struct_pointer( - target_prefix.clone(), - default_instance_value, - pointer_prefixes.clone(), - ); - - // Optional flag default derives from whether an instance was provided. - let pointer_target = ser_is_param_none(target_prefix.as_str(), default_instance.is_none()); - let pointing_params: Pointers = pointer_prefixes - .into_iter() - .map(|prefix| format!("{prefix}{FIELD_SEPARATOR}{IS_NONE_MARK}")) - .collect(); - res.push((pointer_target, pointing_params)); - - res -} - -// Converts a serialized param to a pointer target. -fn serialized_param_to_pointer_target( - target_prefix: ParamPath, - param_path: &ParamPath, - serialized_param: &SerializedParam, -) -> PointerTarget { - let full_param_path = chain_param_paths(&[&target_prefix, param_path]); - if serialized_param.is_required() { - let description = serialized_param - .description - .strip_prefix(REQUIRED_PARAM_DESCRIPTION_PREFIX) - .unwrap_or(&serialized_param.description) - .trim_start(); - ser_pointer_target_required_param( - &full_param_path, - serialized_param.content.get_serialization_type().unwrap(), - description, - ) - } else { - let default_value = match &serialized_param.content { - SerializedContent::DefaultValue(value) => value, - SerializedContent::PointerTarget(_) => panic!("Pointers to pointer is not supported."), - // We already checked that the param is not required, so it must be a generated param. - SerializedContent::ParamType(_) => { - panic!("Generated pointer targets are not supported.") - } - }; - ser_pointer_target_param(&full_param_path, default_value, &serialized_param.description) - } -} - -fn chain_param_paths(param_paths: &[&str]) -> ParamPath { - param_paths.join(FIELD_SEPARATOR) -} - -/// Serialization for configs. -pub trait SerializeConfig { - /// Conversion of a configuration to a mapping of flattened parameters to their descriptions and - /// values. - /// Note, in the case of None sub configs, their elements will not be included in the flatten - /// map. - fn dump(&self) -> BTreeMap; - - /// Serialization of a configuration into a JSON file. - /// Takes a vector of {target pointer params, SerializedParam, and vector of pointing params}, - /// adds the target pointer params with the description and a value, and replaces the value of - /// the pointing params to contain only the name of the target they point to. - /// Fails if a param is not pointing to a same-named pointer target nor whitelisted. - /// - /// # Example - /// - /// ``` - /// # use std::collections::{BTreeMap, HashSet}; - /// - /// # use apollo_config::dumping::{ser_param, SerializeConfig}; - /// # use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; - /// # use serde::{Deserialize, Serialize}; - /// # use tempfile::TempDir; - /// - /// #[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] - /// struct ConfigExample { - /// key: usize, - /// } - /// - /// impl SerializeConfig for ConfigExample { - /// fn dump(&self) -> BTreeMap { - /// BTreeMap::from([ser_param( - /// "key", - /// &self.key, - /// "This is key description.", - /// ParamPrivacyInput::Public, - /// )]) - /// } - /// } - /// - /// let dir = TempDir::new().unwrap(); - /// let file_path = dir.path().join("config.json"); - /// ConfigExample { key: 42 }.dump_to_file(&vec![], &HashSet::new(), file_path.to_str().unwrap()); - /// ``` - /// Note, in the case of None sub configs, their elements will not be included in the file. - fn dump_to_file( - &self, - config_pointers: &ConfigPointers, - non_pointer_params: &Pointers, - file_path: &str, - ) -> Result<(), ConfigError> { - let combined_map = - combine_config_map_and_pointers(self.dump(), config_pointers, non_pointer_params)?; - serialize_to_file(&combined_map, file_path); - Ok(()) - } -} - -/// Prepends `sub_config_name` to the ParamPath for each entry in `sub_config_dump`. -/// In order to load from a dump properly, `sub_config_name` must match the field's name for the -/// struct this function is called from. -pub fn prepend_sub_config_name( - sub_config_dump: BTreeMap, - sub_config_name: &str, -) -> BTreeMap { - BTreeMap::from_iter( - sub_config_dump.into_iter().map(|(field_name, val)| { - (format!("{sub_config_name}{FIELD_SEPARATOR}{field_name}"), val) - }), - ) -} - -// Serializes a parameter of a config. -fn common_ser_param( - name: &str, - content: SerializedContent, - description: &str, - privacy: ParamPrivacy, -) -> (String, SerializedParam) { - (name.to_owned(), SerializedParam { description: description.to_owned(), content, privacy }) -} - -/// Serializes a single param of a config. -/// The returned pair is designed to be an input to a dumped config map. -pub fn ser_param( - name: &str, - value: &T, - description: &str, - privacy: ParamPrivacyInput, -) -> (String, SerializedParam) { - common_ser_param( - name, - SerializedContent::DefaultValue(json!(value)), - description, - privacy.into(), - ) -} - -/// Serializes expected type for a single required param of a config. -/// The returned pair is designed to be an input to a dumped config map. -pub fn ser_required_param( - name: &str, - serialization_type: SerializationType, - description: &str, - privacy: ParamPrivacyInput, -) -> (String, SerializedParam) { - common_ser_param( - name, - SerializedContent::ParamType(serialization_type), - required_param_description(description).as_str(), - privacy.into(), - ) -} - -/// Serializes expected type for a single param of a config that the system may generate. The -/// generation should be defined as serde default field attribute. -/// The returned pair is designed to be an input to a dumped config map. -pub fn ser_generated_param( - name: &str, - serialization_type: SerializationType, - description: &str, - privacy: ParamPrivacyInput, -) -> (String, SerializedParam) { - common_ser_param( - name, - SerializedContent::ParamType(serialization_type), - format!("{description} If no value is provided, the system will generate one.").as_str(), - privacy.into(), - ) -} - -/// Serializes optional sub-config fields (or default fields for None sub-config) and adds an -/// "#is_none" flag. -pub fn ser_optional_sub_config( - optional_config: &Option, - name: &str, -) -> BTreeMap { - chain!( - BTreeMap::from_iter([ser_is_param_none(name, optional_config.is_none())]), - prepend_sub_config_name( - match optional_config { - None => T::default().dump(), - Some(config) => config.dump(), - }, - name, - ), - ) - .collect() -} - -/// Serializes optional param value (or default value for None param) and adds an "#is_none" flag. -pub fn ser_optional_param( - optional_param: &Option, - default_value: T, - name: &str, - description: &str, - privacy: ParamPrivacyInput, -) -> BTreeMap { - BTreeMap::from([ - ser_is_param_none(name, optional_param.is_none()), - ser_param( - name, - match optional_param { - Some(param) => param, - None => &default_value, - }, - description, - privacy, - ), - ]) -} - -/// Serializes is_none flag for a param. -pub fn ser_is_param_none(name: &str, is_none: bool) -> (String, SerializedParam) { - common_ser_param( - format!("{name}{FIELD_SEPARATOR}{IS_NONE_MARK}").as_str(), - SerializedContent::DefaultValue(json!(is_none)), - "Flag for an optional field.", - ParamPrivacy::TemporaryValue, - ) -} - -/// Serializes a pointer target param of a config. -/// -/// # Example -/// Create config_pointers vector to be used in `dump_to_file`: -/// ``` -/// # use apollo_config::dumping::ser_pointer_target_param; -/// -/// let pointer_target_param = ser_pointer_target_param( -/// "shared_param", -/// &("param".to_string()), -/// "A string parameter description.", -/// ); -/// let pointer_param_paths = -/// vec!["conf1.conf2.same_param".to_owned(), "conf3.same_param".to_owned()]; -/// let config_pointers = vec![(pointer_target_param, pointer_param_paths)]; -/// ``` -pub fn ser_pointer_target_param( - name: &str, - value: &T, - description: &str, -) -> (String, SerializedParam) { - common_ser_param( - name, - SerializedContent::DefaultValue(json!(value)), - description, - ParamPrivacy::TemporaryValue, - ) -} - -/// Serializes a pointer target for a required param of a config. -pub fn ser_pointer_target_required_param( - name: &str, - serialization_type: SerializationType, - description: &str, -) -> (String, SerializedParam) { - common_ser_param( - name, - SerializedContent::ParamType(serialization_type), - required_param_description(description).as_str(), - ParamPrivacy::TemporaryValue, - ) -} - -/// Takes a config map and a vector of target parameters with their serialized representations. -/// Adds each target param to the config map. -/// Updates entries in the map to point to these targets, replacing values of entries that match -/// the target parameter paths to contain only the name of the target they point to. -/// Fails if a param is not pointing to a same-named pointer target nor whitelisted. -pub fn combine_config_map_and_pointers( - mut config_map: BTreeMap, - pointers: &ConfigPointers, - non_pointer_params: &Pointers, -) -> Result { - // Update config with target params. - for ((target_param, serialized_pointer), pointing_params_vec) in pointers { - // Insert target param. - config_map.insert(target_param.clone(), serialized_pointer.clone()); - - // Update pointing params to point at the target param. - for pointing_param in pointing_params_vec { - let pointing_serialized_param = - config_map.get(pointing_param).ok_or(ConfigError::PointerSourceNotFound { - pointing_param: pointing_param.to_owned(), - })?; - config_map.insert( - pointing_param.to_owned(), - SerializedParam { - description: pointing_serialized_param.description.clone(), - content: SerializedContent::PointerTarget(target_param.to_owned()), - privacy: pointing_serialized_param.privacy.clone(), - }, - ); - } - } - - verify_pointing_params_by_name(&config_map, pointers, non_pointer_params); - - Ok(json!(config_map)) -} - -/// Creates a set of pointing params, ensuring no duplications. -pub fn set_pointing_param_paths(param_path_list: &[&str]) -> Pointers { - let mut param_paths = HashSet::new(); - for ¶m_path in param_path_list { - assert!( - param_paths.insert(param_path.to_string()), - "Duplicate parameter path found: {param_path}" - ); - } - param_paths -} - -/// Prefix for required params description. -pub(crate) const REQUIRED_PARAM_DESCRIPTION_PREFIX: &str = "A required param!"; - -pub(crate) fn required_param_description(description: &str) -> String { - format!("{REQUIRED_PARAM_DESCRIPTION_PREFIX} {description}") -} - -/// Verifies that params whose name matches a pointer target either point at it, or are whitelisted. -fn verify_pointing_params_by_name( - config_map: &BTreeMap, - pointers: &ConfigPointers, - non_pointer_params: &Pointers, -) { - // Iterate over the config, check that all parameters whose name matches a pointer target either - // point at it or are in the whitelist. - config_map.iter().for_each(|(param_path, serialized_param)| { - for ((target_param, _), _) in pointers { - // Check if the param name matches a pointer target, and that it is not in the - // whitelist. - if param_path.ends_with(format!("{FIELD_SEPARATOR}{target_param}").as_str()) - && !non_pointer_params.contains(param_path) - { - // Check that the param points to the target param. - assert!( - serialized_param.content - == SerializedContent::PointerTarget(target_param.to_owned()), - "The target param {param_path} should point to {target_param}, or to be \ - whitelisted. You can use set_pointing_param_paths to point it to a value." - ); - }; - } - }); -} diff --git a/crates/apollo_config/src/lib.rs b/crates/apollo_config/src/lib.rs index 147f90bc96b..9fbee29d5d5 100644 --- a/crates/apollo_config/src/lib.rs +++ b/crates/apollo_config/src/lib.rs @@ -45,7 +45,6 @@ use clap::parser::MatchesError; use const_format::formatcp; -use dumping::REQUIRED_PARAM_DESCRIPTION_PREFIX; use serde::{Deserialize, Serialize}; use serde_json::Value; use strum::Display; @@ -59,15 +58,11 @@ pub const CONFIG_FILE_SHORT_ARG_NAME: char = 'f'; /// The config file arg name prepended with a double dash. pub const CONFIG_FILE_ARG: &str = formatcp!("--{}", CONFIG_FILE_ARG_NAME); -/// A config indicator for optional parameters. -pub const IS_NONE_MARK: &str = "#is_none"; /// A config indicator for a sub config. pub const FIELD_SEPARATOR: &str = "."; /// A nested path of a configuration parameter. pub type ParamPath = String; -/// A description of a configuration parameter. -pub type Description = String; /// Behavior mode configuration for the node. pub mod behavior_mode; @@ -75,105 +70,11 @@ mod command; #[cfg(test)] mod config_test; pub mod converters; -pub mod dumping; pub mod loading; pub mod presentation; pub mod secrets; -#[cfg(any(feature = "testing", test))] -/// Utilities for the produced configuration. -pub mod test_utils; pub mod validators; -/// The privacy level of a config parameter, that received as input from the configs. -#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] -pub enum ParamPrivacyInput { - /// The field is visible only by a secret. - Private, - /// The field is visible only to node's users. - Public, -} - -/// The privacy level of a config parameter. -#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] -enum ParamPrivacy { - /// The field is visible only by a secret. - Private, - /// The field is visible only to node's users. - Public, - /// The field is not a part of the final config. - TemporaryValue, -} - -impl From for ParamPrivacy { - fn from(user_param_privacy: ParamPrivacyInput) -> Self { - match user_param_privacy { - ParamPrivacyInput::Private => ParamPrivacy::Private, - ParamPrivacyInput::Public => ParamPrivacy::Public, - } - } -} - -/// A serialized content of a configuration parameter. -#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] -#[serde(rename_all = "snake_case")] -pub enum SerializedContent { - /// Serialized JSON default value. - #[serde(rename = "value")] - DefaultValue(Value), - /// The target from which to take the JSON value of a configuration parameter. - PointerTarget(ParamPath), - /// Type of a configuration parameter. - ParamType(SerializationType), -} - -impl SerializedContent { - fn get_serialization_type(&self) -> Option { - match self { - SerializedContent::DefaultValue(value) => match value { - // JSON "Number" is handled as PosInt(u64), NegInt(i64), or Float(f64). - Value::Number(num) => { - if num.is_f64() { - Some(SerializationType::Float) - } else if num.is_u64() { - Some(SerializationType::PositiveInteger) - } else { - Some(SerializationType::NegativeInteger) - } - } - Value::Bool(_) => Some(SerializationType::Boolean), - Value::String(_) => Some(SerializationType::String), - _ => None, - }, - SerializedContent::PointerTarget(_) => None, - SerializedContent::ParamType(ser_type) => Some(*ser_type), - } - } -} - -/// A description and serialized content of a configuration parameter. -#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] -pub struct SerializedParam { - /// The description of the parameter. - pub description: Description, - /// The content of the parameter. - #[serde(flatten)] - pub content: SerializedContent, - pub(crate) privacy: ParamPrivacy, -} - -impl SerializedParam { - /// Whether the parameter is required. - // TODO(yair): Find a better way to identify required params - maybe add to the dump. - pub fn is_required(&self) -> bool { - self.description.starts_with(REQUIRED_PARAM_DESCRIPTION_PREFIX) - } - - /// Whether the parameter is private. - pub fn is_private(&self) -> bool { - self.privacy == ParamPrivacy::Private - } -} - /// A serialized type of a configuration parameter. #[derive(Clone, Copy, Serialize, Deserialize, Debug, PartialEq, Display)] #[allow(missing_docs)] diff --git a/crates/apollo_config/src/secrets.rs b/crates/apollo_config/src/secrets.rs index 92642c1017c..7ab182d071d 100644 --- a/crates/apollo_config/src/secrets.rs +++ b/crates/apollo_config/src/secrets.rs @@ -18,7 +18,10 @@ use url::Url; #[path = "secrets_test.rs"] mod secrets_test; -const DEFAULT_REDACTION_OUTPUT: &str = "<>"; +/// The string a `Sensitive` with no custom redactor serializes/displays to. Exposed so callers +/// (e.g. the secrets-schema safety guard) can detect default-redacted fields in a serialized +/// config. +pub const DEFAULT_REDACTION_OUTPUT: &str = "<>"; type Redactor = Arc String + Send + Sync + 'static>; diff --git a/crates/apollo_config/src/test_utils.rs b/crates/apollo_config/src/test_utils.rs deleted file mode 100644 index 07aefa96fe8..00000000000 --- a/crates/apollo_config/src/test_utils.rs +++ /dev/null @@ -1,50 +0,0 @@ -use std::env; -use std::fs::File; - -use apollo_infra_utils::path::resolve_project_relative_path; -use apollo_infra_utils::test_utils::assert_json_eq; -use colored::Colorize; - -use crate::dumping::{ConfigPointers, Pointers, SerializeConfig}; - -/// Loads a config from file and asserts the result json equals to the default config. -pub fn assert_default_config_file_is_up_to_date( - config_binary_name: &str, - default_config_path: &str, - config_pointers: &ConfigPointers, - config_non_pointers_whitelist: &Pointers, -) { - let config_path = resolve_project_relative_path("").unwrap().join(default_config_path); - let from_default_config_file: serde_json::Value = - serde_json::from_reader(File::open(config_path).unwrap()).unwrap(); - - // Create a temporary file and dump the default config to it. - let mut tmp_file_path = env::temp_dir(); - tmp_file_path.push("cfg.json"); - T::default() - .dump_to_file( - config_pointers, - config_non_pointers_whitelist, - tmp_file_path.to_str().unwrap(), - ) - .unwrap(); - - // Read the dumped config from the file. - let from_code: serde_json::Value = - serde_json::from_reader(File::open(tmp_file_path).unwrap()).unwrap(); - - let update_instructions = format!( - "Default config file doesn't match the default {} implementation. Please update it using \ - the {} binary.", - std::any::type_name::(), - config_binary_name - ) - .purple() - .bold(); - let file_names_on_diff = format!( - "Diffs shown below (default config file <<>> dump of {}::default()).", - std::any::type_name::() - ); - let error_message = format!("{update_instructions}\n{file_names_on_diff}"); - assert_json_eq(&from_default_config_file, &from_code, error_message); -} diff --git a/crates/apollo_config_manager_config/src/config.rs b/crates/apollo_config_manager_config/src/config.rs index 2204ef2aca9..636b71e609f 100644 --- a/crates/apollo_config_manager_config/src/config.rs +++ b/crates/apollo_config_manager_config/src/config.rs @@ -1,7 +1,3 @@ -use std::collections::BTreeMap; - -use apollo_config::dumping::{ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use validator::Validate; @@ -11,25 +7,6 @@ pub struct ConfigManagerConfig { pub config_update_interval_secs: f64, } -impl SerializeConfig for ConfigManagerConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "enable_config_updates", - &self.enable_config_updates, - "Enables the resampling of the config every `config_update_interval_secs` seconds", - ParamPrivacyInput::Public, - ), - ser_param( - "config_update_interval_secs", - &self.config_update_interval_secs, - "Update interval in seconds for config updates", - ParamPrivacyInput::Public, - ), - ]) - } -} - impl Default for ConfigManagerConfig { fn default() -> Self { Self { enable_config_updates: false, config_update_interval_secs: 60.0 } diff --git a/crates/apollo_consensus_config/src/config.rs b/crates/apollo_consensus_config/src/config.rs index 8b245934c75..838063cbcd3 100644 --- a/crates/apollo_consensus_config/src/config.rs +++ b/crates/apollo_consensus_config/src/config.rs @@ -1,8 +1,7 @@ -//! This module contains the configuration for consensus, including the `ConsensusConfig` struct -//! and its implementation of the `SerializeConfig` trait. The configuration includes parameters -//! such as the validator ID, the network topic of the consensus, and the starting block height. +//! This module contains the configuration for consensus, including the `ConsensusConfig` struct. +//! The configuration includes parameters such as the validator ID, the network topic of the +//! consensus, and the starting block height. -use std::collections::BTreeMap; use std::time::Duration; use apollo_config::converters::{ @@ -11,13 +10,6 @@ use apollo_config::converters::{ serialize_duration_as_float_seconds, serialize_duration_as_seconds, }; -use apollo_config::dumping::{ - prepend_sub_config_name, - ser_optional_param, - ser_param, - SerializeConfig, -}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use apollo_protobuf::consensus::DEFAULT_VALIDATOR_ID; use apollo_storage::db::DbConfig; use apollo_storage::{StorageConfig, StorageScope}; @@ -73,72 +65,6 @@ pub struct ConsensusConfig { pub static_config: ConsensusStaticConfig, } -impl SerializeConfig for ConsensusDynamicConfig { - fn dump(&self) -> BTreeMap { - let mut config = BTreeMap::from_iter([ - ser_param( - "validator_id", - &self.validator_id, - "The validator id of the node.", - ParamPrivacyInput::Public, - ), - ser_param( - "sync_retry_interval", - &self.sync_retry_interval.as_secs_f64(), - "The duration (seconds) between sync attempts.", - ParamPrivacyInput::Public, - ), - ser_param( - "require_virtual_proposer_vote", - &self.require_virtual_proposer_vote, - "When true, require the virtual proposer to have voted in favor before reaching a \ - decision.", - ParamPrivacyInput::Public, - ), - ]); - config.extend(prepend_sub_config_name(self.timeouts.dump(), "timeouts")); - config.extend(prepend_sub_config_name(self.future_msg_limit.dump(), "future_msg_limit")); - config.extend(ser_optional_param( - &self.stop_at_height, - BlockNumber::default(), - "stop_at_height", - "If set, the node will stop participating in consensus after this height.", - ParamPrivacyInput::Public, - )); - config - } -} - -impl SerializeConfig for ConsensusStaticConfig { - fn dump(&self) -> BTreeMap { - let mut config = BTreeMap::from_iter([ - ser_param( - "startup_delay", - &self.startup_delay.as_secs(), - "Delay (seconds) before starting consensus to give time for network peering.", - ParamPrivacyInput::Public, - ), - ser_param( - "skip_last_voted_height_check", - &self.skip_last_voted_height_check, - "If true, skips check that we didn't vote on this height.", - ParamPrivacyInput::Public, - ), - ]); - config.extend(prepend_sub_config_name(self.storage_config.dump(), "storage_config")); - config - } -} - -impl SerializeConfig for ConsensusConfig { - fn dump(&self) -> BTreeMap { - let mut config = BTreeMap::new(); - config.extend(prepend_sub_config_name(self.dynamic_config.dump(), "dynamic_config")); - config.extend(prepend_sub_config_name(self.static_config.dump(), "static_config")); - config - } -} - impl Default for ConsensusDynamicConfig { fn default() -> Self { Self { @@ -226,31 +152,6 @@ impl Timeout { } } -impl SerializeConfig for Timeout { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "base", - &self.base.as_secs_f64(), - "The base timeout (seconds).", - ParamPrivacyInput::Public, - ), - ser_param( - "delta", - &self.delta.as_secs_f64(), - "The per-round timeout delta (seconds).", - ParamPrivacyInput::Public, - ), - ser_param( - "max", - &self.max.as_secs_f64(), - "The maximum timeout (seconds).", - ParamPrivacyInput::Public, - ), - ]) - } -} - /// Configuration for consensus timeouts. #[derive(Debug, Deserialize, Serialize, Clone, PartialEq)] pub struct TimeoutsConfig { @@ -284,16 +185,6 @@ impl Default for TimeoutsConfig { } } -impl SerializeConfig for TimeoutsConfig { - fn dump(&self) -> BTreeMap { - let mut config = BTreeMap::new(); - config.extend(prepend_sub_config_name(self.proposal.dump(), "proposal")); - config.extend(prepend_sub_config_name(self.prevote.dump(), "prevote")); - config.extend(prepend_sub_config_name(self.precommit.dump(), "precommit")); - config - } -} - impl TimeoutsConfig { pub fn new(proposal: Timeout, prevote: Timeout, precommit: Timeout) -> Self { Self { proposal, prevote, precommit } @@ -332,31 +223,6 @@ impl Default for FutureMsgLimitsConfig { } } -impl SerializeConfig for FutureMsgLimitsConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "future_height_limit", - &self.future_height_limit, - "How many heights in the future should we cache.", - ParamPrivacyInput::Public, - ), - ser_param( - "future_round_limit", - &self.future_round_limit, - "How many rounds in the future (for current height) should we cache.", - ParamPrivacyInput::Public, - ), - ser_param( - "future_height_round_limit", - &self.future_height_round_limit, - "How many rounds should we cache for future heights.", - ParamPrivacyInput::Public, - ), - ]) - } -} - /// Configuration for the `StreamHandler`. #[derive(Debug, Deserialize, Serialize, Clone, PartialEq)] pub struct StreamHandlerConfig { @@ -380,34 +246,3 @@ impl Default for StreamHandlerConfig { } } } - -impl SerializeConfig for StreamHandlerConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "channel_buffer_capacity", - &self.channel_buffer_capacity, - "The capacity of the channel buffer for stream messages.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_peers", - &self.max_peers, - "The maximum number of peers that can send inbound messages.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_streams", - &self.max_streams, - "The maximum number of streams that can be open at the same time, per peer.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_message_buffer_size", - &self.max_message_buffer_size, - "The maximum number of messages for each stream that can be buffered.", - ParamPrivacyInput::Public, - ), - ]) - } -} diff --git a/crates/apollo_consensus_manager_config/src/config.rs b/crates/apollo_consensus_manager_config/src/config.rs index a84a2f54ea4..87acdf5ba6d 100644 --- a/crates/apollo_consensus_manager_config/src/config.rs +++ b/crates/apollo_consensus_manager_config/src/config.rs @@ -1,7 +1,3 @@ -use std::collections::BTreeMap; - -use apollo_config::dumping::{prepend_sub_config_name, ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use apollo_consensus_config::config::{ConsensusConfig, StreamHandlerConfig}; use apollo_consensus_orchestrator_config::config::{CendeConfig, ContextConfig}; use apollo_network::NetworkConfig; @@ -29,55 +25,6 @@ pub struct ConsensusManagerConfig { pub assume_no_malicious_validators: bool, } -impl SerializeConfig for ConsensusManagerConfig { - fn dump(&self) -> BTreeMap { - let mut config = BTreeMap::from_iter([ - ser_param( - "votes_topic", - &self.votes_topic, - "The topic for consensus votes.", - ParamPrivacyInput::Public, - ), - ser_param( - "proposals_topic", - &self.proposals_topic, - "The topic for consensus proposals.", - ParamPrivacyInput::Public, - ), - ser_param( - "broadcast_buffer_size", - &self.broadcast_buffer_size, - "The buffer size for the broadcast channel.", - ParamPrivacyInput::Public, - ), - ser_param( - "assume_no_malicious_validators", - &self.assume_no_malicious_validators, - "Assumes all validators are honest. If true, uses 1/2 votes to get quorum. Use \ - with caution!", - ParamPrivacyInput::Public, - ), - ]); - config.extend(prepend_sub_config_name( - self.consensus_manager_config.dump(), - "consensus_manager_config", - )); - config.extend(prepend_sub_config_name(self.context_config.dump(), "context_config")); - config.extend(prepend_sub_config_name( - self.stream_handler_config.dump(), - "stream_handler_config", - )); - config.extend(prepend_sub_config_name(self.cende_config.dump(), "cende_config")); - config.extend(prepend_sub_config_name(self.network_config.dump(), "network_config")); - config.extend(prepend_sub_config_name(self.revert_config.dump(), "revert_config")); - config.extend(prepend_sub_config_name( - self.staking_manager_config.dump(), - "staking_manager_config", - )); - config - } -} - impl Default for ConsensusManagerConfig { fn default() -> Self { ConsensusManagerConfig { diff --git a/crates/apollo_consensus_orchestrator_config/src/config.rs b/crates/apollo_consensus_orchestrator_config/src/config.rs index b5d9da96a65..797df11acaa 100644 --- a/crates/apollo_consensus_orchestrator_config/src/config.rs +++ b/crates/apollo_consensus_orchestrator_config/src/config.rs @@ -1,4 +1,3 @@ -use std::collections::BTreeMap; use std::fmt::Debug; use std::time::Duration; @@ -9,13 +8,6 @@ use apollo_config::converters::{ serialize_duration_as_milliseconds, serialize_duration_as_seconds, }; -use apollo_config::dumping::{ - prepend_sub_config_name, - ser_optional_param, - ser_param, - SerializeConfig, -}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::de::{Deserializer, Error}; use serde::ser::Serializer; use serde::{Deserialize, Serialize}; @@ -58,37 +50,6 @@ impl Default for CendeConfig { } } -impl SerializeConfig for CendeConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "recorder_url", - &self.recorder_url, - "The URL of the Pythonic cende_recorder", - ParamPrivacyInput::Public, - ), - ser_param( - "max_retry_duration_secs", - &self.max_retry_duration_secs.as_secs(), - "The maximum duration (seconds) to retry the request to the recorder", - ParamPrivacyInput::Public, - ), - ser_param( - "min_retry_interval_ms", - &self.min_retry_interval_ms.as_millis(), - "The minimum waiting time (milliseconds) between retries", - ParamPrivacyInput::Public, - ), - ser_param( - "max_retry_interval_ms", - &self.max_retry_interval_ms.as_millis(), - "The maximum waiting time (milliseconds) between retries", - ParamPrivacyInput::Public, - ), - ]) - } -} - const GWEI_FACTOR: u128 = u128::pow(10, 9); const ETH_FACTOR: u128 = u128::pow(10, 18); @@ -151,15 +112,6 @@ pub struct ContextConfig { pub static_config: ContextStaticConfig, } -impl SerializeConfig for ContextConfig { - fn dump(&self) -> BTreeMap { - let mut config = BTreeMap::new(); - config.extend(prepend_sub_config_name(self.dynamic_config.dump(), "dynamic_config")); - config.extend(prepend_sub_config_name(self.static_config.dump(), "static_config")); - config - } -} - /// Static configuration for the Context struct. #[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Validate)] pub struct ContextStaticConfig { @@ -195,72 +147,6 @@ pub struct ContextStaticConfig { pub behavior_mode: BehaviorMode, } -impl SerializeConfig for ContextStaticConfig { - fn dump(&self) -> BTreeMap { - let mut dump = BTreeMap::from_iter([ - ser_param( - "proposal_buffer_size", - &self.proposal_buffer_size, - "The buffer size for streaming outbound proposals.", - ParamPrivacyInput::Public, - ), - ser_param( - "chain_id", - &self.chain_id, - "The chain id of the Starknet chain.", - ParamPrivacyInput::Public, - ), - ser_param( - "block_timestamp_window_seconds", - &self.block_timestamp_window_seconds, - "Maximum allowed deviation (seconds) of a proposed block's timestamp from the \ - current time.", - ParamPrivacyInput::Public, - ), - ser_param( - "l1_da_mode", - &self.l1_da_mode, - "The data availability mode, true: Blob, false: Calldata.", - ParamPrivacyInput::Public, - ), - ser_param( - "builder_address", - &self.builder_address, - "The address of the contract that builds the block.", - ParamPrivacyInput::Public, - ), - ser_param( - "validate_proposal_margin_millis", - &self.validate_proposal_margin_millis.as_millis(), - "Safety margin (in ms) to make sure that consensus determines when to timeout \ - validating a proposal.", - ParamPrivacyInput::Public, - ), - ser_param( - "build_proposal_time_ratio_for_retrospective_block_hash", - &self.build_proposal_time_ratio_for_retrospective_block_hash, - "The fraction (0.0 - 1.0) of the total build time allocated to waiting for the \ - retrospective block hash to be available. The remaining time is used to build \ - the proposal.", - ParamPrivacyInput::Public, - ), - ser_param( - "retrospective_block_hash_retry_interval_millis", - &self.retrospective_block_hash_retry_interval_millis.as_millis(), - "The interval between retrospective block hash retries.", - ParamPrivacyInput::Public, - ), - ]); - dump.extend([ser_param( - "behavior_mode", - &self.behavior_mode, - "Behavior mode: 'starknet' for production, 'echonet' for test/replay mode.", - ParamPrivacyInput::Public, - )]); - dump - } -} - impl Default for ContextStaticConfig { fn default() -> Self { Self { @@ -325,113 +211,6 @@ pub struct ContextDynamicConfig { pub compare_retrospective_block_hash: bool, } -impl SerializeConfig for ContextDynamicConfig { - fn dump(&self) -> BTreeMap { - let mut dump = BTreeMap::from_iter([ - ser_param( - "build_proposal_margin_millis", - &self.build_proposal_margin_millis.as_millis(), - "Safety margin (in ms) to make sure that the batcher completes building the \ - proposal with enough time for the Fin to be checked by validators.", - ParamPrivacyInput::Public, - ), - ser_param( - "min_l1_gas_price_wei", - &self.min_l1_gas_price_wei, - "The minimum L1 gas price in wei.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_l1_gas_price_wei", - &self.max_l1_gas_price_wei, - "The maximum L1 gas price in wei.", - ParamPrivacyInput::Public, - ), - ser_param( - "min_l1_data_gas_price_wei", - &self.min_l1_data_gas_price_wei, - "The minimum L1 data gas price in wei.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_l1_data_gas_price_wei", - &self.max_l1_data_gas_price_wei, - "The maximum L1 data gas price in wei.", - ParamPrivacyInput::Public, - ), - ser_param( - "l1_data_gas_price_multiplier_ppt", - &self.l1_data_gas_price_multiplier_ppt, - "Part per thousand of multiplicative factor to apply to the data gas price, to \ - enable fine-tuning of the price charged to end users.", - ParamPrivacyInput::Public, - ), - ser_param( - "l1_gas_tip_wei", - &self.l1_gas_tip_wei, - "This additional gas is added to the L1 gas price.", - ParamPrivacyInput::Public, - ), - ser_param( - "snip35_target_atto_usd_per_l2_gas", - &self.snip35_target_atto_usd_per_l2_gas, - "SNIP-35 target USD cost per L2 gas unit, in atto-USD ($0.88 per 1e9 L2 gas = \ - 880_000_000 atto-USD).", - ParamPrivacyInput::Public, - ), - ser_param( - "compare_retrospective_block_hash", - &self.compare_retrospective_block_hash, - "Whether to compare the retrospective block hash between the Batcher and the \ - State Sync.", - ParamPrivacyInput::Public, - ), - ]); - dump.extend(ser_optional_param( - &self.override_l2_gas_price_fri, - 0, - "override_l2_gas_price_fri", - "Replace the L2 gas price (fri) with this value.", - ParamPrivacyInput::Public, - )); - dump.extend(ser_optional_param( - &self.override_l1_gas_price_fri, - 0, - "override_l1_gas_price_fri", - "Replace the L1 gas price (fri) with this value.", - ParamPrivacyInput::Public, - )); - dump.extend(ser_optional_param( - &self.override_l1_data_gas_price_fri, - 0, - "override_l1_data_gas_price_fri", - "Replace the L1 data gas price (fri) with this value.", - ParamPrivacyInput::Public, - )); - dump.extend(ser_optional_param( - &self.override_eth_to_fri_rate, - 0, - "override_eth_to_fri_rate", - "Replace the Eth-to-Fri conversion rate with this value.", - ParamPrivacyInput::Public, - )); - - // Serialize as string format "h1:v1,h2:v2" using the same function as the Serialize impl - let serialized = serialize_price_per_height(&self.min_l2_gas_price_per_height); - let (key, value) = ser_param( - "min_l2_gas_price_per_height", - &serialized, - "List of minimum L2 gas prices per block height in format \ - 'height1:price1,height2:price2'. Each entry specifies a height and the minimum gas \ - price that applies from that height onwards.", - ParamPrivacyInput::Public, - ); - dump.insert(key, value); - - dump - } -} - impl Default for ContextDynamicConfig { fn default() -> Self { Self { diff --git a/crates/apollo_gateway_config/src/compiler_version.rs b/crates/apollo_gateway_config/src/compiler_version.rs index dba1973f309..af5d57a7552 100644 --- a/crates/apollo_gateway_config/src/compiler_version.rs +++ b/crates/apollo_gateway_config/src/compiler_version.rs @@ -1,8 +1,4 @@ -use std::collections::BTreeMap; - use apollo_compilation_utils::class_utils::sierra_program_as_felts_to_big_uint_as_hex; -use apollo_config::dumping::{ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use cairo_lang_starknet_classes::compiler_version::VersionId as CairoLangVersionId; use cairo_lang_starknet_classes::contract_class::version_id_from_serialized_sierra_program; use serde::{Deserialize, Serialize}; @@ -75,28 +71,3 @@ impl PartialOrd for VersionId { partial_cmp(&self.0, &other.0) } } - -impl SerializeConfig for VersionId { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "major", - &self.0.major, - "The major version of the configuration.", - ParamPrivacyInput::Public, - ), - ser_param( - "minor", - &self.0.minor, - "The minor version of the configuration.", - ParamPrivacyInput::Public, - ), - ser_param( - "patch", - &self.0.patch, - "The patch version of the configuration.", - ParamPrivacyInput::Public, - ), - ]) - } -} diff --git a/crates/apollo_gateway_config/src/config.rs b/crates/apollo_gateway_config/src/config.rs index beb22b8ada0..86a7a6cbfe3 100644 --- a/crates/apollo_gateway_config/src/config.rs +++ b/crates/apollo_gateway_config/src/config.rs @@ -1,18 +1,7 @@ -use std::collections::BTreeMap; - use apollo_config::converters::{ deserialize_comma_separated_str, - serialize_optional_comma_separated, serialize_optional_comma_separated_str, }; -use apollo_config::dumping::{ - prepend_sub_config_name, - ser_optional_param, - ser_optional_sub_config, - ser_param, - SerializeConfig, -}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use blockifier::blockifier::config::{ContractClassManagerConfig, NativeClassesWhitelist}; use blockifier::blockifier_versioned_constants::VersionedConstantsOverrides; use blockifier::context::ChainInfo; @@ -80,51 +69,6 @@ impl Default for GatewayStaticConfig { } } -impl SerializeConfig for GatewayStaticConfig { - fn dump(&self) -> BTreeMap { - let mut dump = BTreeMap::from_iter([ser_param( - "block_declare", - &self.block_declare, - "If true, the gateway will block declare transactions.", - ParamPrivacyInput::Public, - )]); - dump.extend(prepend_sub_config_name( - self.stateless_tx_validator_config.dump(), - "stateless_tx_validator_config", - )); - dump.extend(prepend_sub_config_name( - self.stateful_tx_validator_config.dump(), - "stateful_tx_validator_config", - )); - dump.extend(prepend_sub_config_name( - self.contract_class_manager_config.dump(), - "contract_class_manager_config", - )); - dump.extend(prepend_sub_config_name(self.chain_info.dump(), "chain_info")); - dump.extend(ser_optional_param( - &serialize_optional_comma_separated(&self.authorized_declarer_accounts), - "".to_string(), - "authorized_declarer_accounts", - "Authorized declarer accounts. If set, only these accounts can declare new contracts. \ - Addresses are in hex format and separated by a comma with no space.", - ParamPrivacyInput::Public, - )); - dump.extend([ser_param( - "max_concurrent_declare_compilations", - &self.max_concurrent_declare_compilations, - "Maximum number of Sierra-to-CASM compilations (triggered by declare transactions) \ - allowed to run concurrently. Declares arriving while this limit is reached are \ - rejected immediately.", - ParamPrivacyInput::Public, - )]); - dump.extend(prepend_sub_config_name( - self.proof_archive_writer_config.dump(), - "proof_archive_writer_config", - )); - dump - } -} - #[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize, Validate)] pub struct GatewayConfig { #[validate(nested)] @@ -133,15 +77,6 @@ pub struct GatewayConfig { pub static_config: GatewayStaticConfig, } -impl SerializeConfig for GatewayConfig { - fn dump(&self) -> BTreeMap { - let mut dump = BTreeMap::new(); - dump.extend(prepend_sub_config_name(self.dynamic_config.dump(), "dynamic_config")); - dump.extend(prepend_sub_config_name(self.static_config.dump(), "static_config")); - dump - } -} - impl GatewayConfig { pub fn is_authorized_declarer(&self, declarer_address: &ContractAddress) -> bool { match &self.static_config.authorized_declarer_accounts { @@ -162,12 +97,6 @@ impl Default for GatewayDynamicConfig { } } -impl SerializeConfig for GatewayDynamicConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([self.native_classes_whitelist.ser_param()]) - } -} - #[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Validate)] pub struct StatelessTransactionValidatorConfig { // If true, ensures that at least one resource bound (L1, L2, or L1 data) is greater than zero. @@ -208,76 +137,6 @@ impl Default for StatelessTransactionValidatorConfig { } } -impl SerializeConfig for StatelessTransactionValidatorConfig { - fn dump(&self) -> BTreeMap { - let members = BTreeMap::from_iter([ - ser_param( - "validate_resource_bounds", - &self.validate_resource_bounds, - "If true, ensures that at least one resource bound (L1, L2, or L1 data) is \ - greater than zero.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_signature_length", - &self.max_signature_length, - "Limitation of signature length.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_calldata_length", - &self.max_calldata_length, - "Limitation of calldata length.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_contract_bytecode_size", - &self.max_contract_bytecode_size, - "Limitation of contract class bytecode size.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_contract_class_object_size", - &self.max_contract_class_object_size, - "Limitation of contract class object size.", - ParamPrivacyInput::Public, - ), - ser_param( - "min_gas_price", - &self.min_gas_price, - "Minimum gas price for transactions.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_l2_gas_amount", - &self.max_l2_gas_amount, - "Maximum allowed L2 gas amount for transactions.", - ParamPrivacyInput::Public, - ), - ser_param( - "allow_client_side_proving", - &self.allow_client_side_proving, - "If true, allows transactions with non-empty proof_facts or proof fields.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_proof_size", - &self.max_proof_size, - "Limitation of proof size.", - ParamPrivacyInput::Public, - ), - ]); - vec![ - members, - prepend_sub_config_name(self.min_sierra_version.dump(), "min_sierra_version"), - prepend_sub_config_name(self.max_sierra_version.dump(), "max_sierra_version"), - ] - .into_iter() - .flatten() - .collect() - } -} - #[derive(Clone, Debug, Serialize, Deserialize, Validate, PartialEq)] pub struct StatefulTransactionValidatorConfig { // If true, ensures the max L2 gas price exceeds (a configurable percentage of) the base gas @@ -304,49 +163,6 @@ impl Default for StatefulTransactionValidatorConfig { } } -impl SerializeConfig for StatefulTransactionValidatorConfig { - fn dump(&self) -> BTreeMap { - let mut dump = BTreeMap::from_iter([ - ser_param( - "validate_resource_bounds", - &self.validate_resource_bounds, - "If true, ensures the max L2 gas price exceeds (a configurable percentage of) the \ - base gas price of the previous block.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_nonce_for_validation_skip", - &self.max_nonce_for_validation_skip, - "Maximum nonce for which the validation is skipped.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_allowed_nonce_gap", - &self.max_allowed_nonce_gap, - "The maximum allowed gap between the account nonce and the transaction nonce.", - ParamPrivacyInput::Public, - ), - ser_param( - "reject_future_declare_txs", - &self.reject_future_declare_txs, - "If true, rejects declare transactions with future nonces.", - ParamPrivacyInput::Public, - ), - ser_param( - "min_gas_price_percentage", - &self.min_gas_price_percentage, - "Minimum gas price as percentage of threshold to accept transactions.", - ParamPrivacyInput::Public, - ), - ]); - dump.append(&mut ser_optional_sub_config( - &self.versioned_constants_overrides, - "versioned_constants_overrides", - )); - dump - } -} - #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct ProofArchiveWriterConfig { pub bucket_name: String, @@ -365,15 +181,3 @@ impl ProofArchiveWriterConfig { Self { bucket_name: String::new() } } } - -impl SerializeConfig for ProofArchiveWriterConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ser_param( - "bucket_name", - &self.bucket_name, - "The name of the bucket to write proofs to. An empty string indicates a test \ - environment that does not connect to GCS.", - ParamPrivacyInput::Public, - )]) - } -} diff --git a/crates/apollo_http_server_config/src/config.rs b/crates/apollo_http_server_config/src/config.rs index a9d93986ce1..8ab0f363b38 100644 --- a/crates/apollo_http_server_config/src/config.rs +++ b/crates/apollo_http_server_config/src/config.rs @@ -1,4 +1,3 @@ -use std::collections::BTreeMap; use std::net::{IpAddr, Ipv4Addr}; use std::time::Duration; @@ -6,8 +5,6 @@ use apollo_config::converters::{ deserialize_milliseconds_to_duration, serialize_duration_as_milliseconds, }; -use apollo_config::dumping::{prepend_sub_config_name, ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use validator::{Validate, ValidationError}; @@ -26,15 +23,6 @@ pub struct HttpServerConfig { pub static_config: HttpServerStaticConfig, } -impl SerializeConfig for HttpServerConfig { - fn dump(&self) -> BTreeMap { - let mut config = BTreeMap::new(); - config.extend(prepend_sub_config_name(self.dynamic_config.dump(), "dynamic_config")); - config.extend(prepend_sub_config_name(self.static_config.dump(), "static_config")); - config - } -} - impl HttpServerConfig { pub fn new(ip: IpAddr, port: u16, max_sierra_program_size: usize) -> Self { Self { @@ -63,27 +51,6 @@ pub struct HttpServerStaticConfig { pub dynamic_config_poll_interval: Duration, } -impl SerializeConfig for HttpServerStaticConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param("ip", &self.ip.to_string(), "The http server ip.", ParamPrivacyInput::Public), - ser_param("port", &self.port, "The http server port.", ParamPrivacyInput::Public), - ser_param( - "max_request_body_size", - &self.max_request_body_size, - "Max request body size in bytes.", - ParamPrivacyInput::Public, - ), - ser_param( - "dynamic_config_poll_interval", - &self.dynamic_config_poll_interval.as_millis(), - "Polling interval (in milliseconds) for dynamic config.", - ParamPrivacyInput::Public, - ), - ]) - } -} - impl Default for HttpServerStaticConfig { fn default() -> Self { Self { @@ -103,25 +70,6 @@ pub struct HttpServerDynamicConfig { pub max_sierra_program_size: usize, } -impl SerializeConfig for HttpServerDynamicConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "accept_new_txs", - &self.accept_new_txs, - "Enables accepting new txs.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_sierra_program_size", - &self.max_sierra_program_size, - "The maximum size of a sierra program in bytes.", - ParamPrivacyInput::Public, - ), - ]) - } -} - impl Default for HttpServerDynamicConfig { fn default() -> Self { Self { accept_new_txs: true, max_sierra_program_size: DEFAULT_MAX_SIERRA_PROGRAM_SIZE } diff --git a/crates/apollo_infra/src/component_client/remote_component_client.rs b/crates/apollo_infra/src/component_client/remote_component_client.rs index 6c8b392b901..836a50fd962 100644 --- a/crates/apollo_infra/src/component_client/remote_component_client.rs +++ b/crates/apollo_infra/src/component_client/remote_component_client.rs @@ -1,11 +1,8 @@ -use std::collections::BTreeMap; use std::fmt::Debug; use std::marker::PhantomData; use std::time::Duration; -use apollo_config::dumping::{ser_param, SerializeConfig}; use apollo_config::validators::create_validation_error; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use async_trait::async_trait; use bytes::Bytes; use http::header::CONTENT_TYPE; @@ -138,76 +135,6 @@ pub(crate) fn validate_keepalive_timeout_ms( Ok(()) } -impl SerializeConfig for RemoteClientConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "retries", - &self.retries, - "The max number of retries for sending a message.", - ParamPrivacyInput::Public, - ), - ser_param( - "idle_connections", - &self.idle_connections, - "The maximum number of idle connections to keep alive.", - ParamPrivacyInput::Public, - ), - ser_param( - "keepalive_timeout_ms", - &self.keepalive_timeout_ms, - "The duration in milliseconds to keep an idle connection open before closing.", - ParamPrivacyInput::Public, - ), - ser_param( - "initial_retry_delay_ms", - &self.initial_retry_delay_ms, - "Initial delay before first retry in milliseconds.", - ParamPrivacyInput::Public, - ), - ser_param( - "attempts_per_log", - &self.attempts_per_log, - "Number of attempts between failure log messages.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_retry_interval_ms", - &self.max_retry_interval_ms, - "The maximal duration in milliseconds to wait between remote connection retries.", - ParamPrivacyInput::Public, - ), - ser_param( - "connection_timeout_ms", - &self.connection_timeout_ms, - "The maximal duration in milliseconds before a client forgoes remote connection \ - creation attempt.", - ParamPrivacyInput::Public, - ), - ser_param( - "request_timeout_ms", - &self.request_timeout_ms, - "The maximal duration in milliseconds for the full request-response cycle; \ - connection establishment is separate.", - ParamPrivacyInput::Public, - ), - ser_param( - "set_tcp_nodelay", - &self.set_tcp_nodelay, - "Whether to set TCP_NODELAY on the client requests.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_response_body_bytes", - &self.max_response_body_bytes, - "Maximum allowed size in bytes for an incoming response body. Responses exceeding \ - this limit are treated as a communication failure.", - ParamPrivacyInput::Public, - ), - ]) - } -} - /// The `RemoteComponentClient` struct is a generic client for sending component requests and /// receiving responses asynchronously through HTTP connection. pub struct RemoteComponentClient diff --git a/crates/apollo_infra/src/component_server/local_component_server.rs b/crates/apollo_infra/src/component_server/local_component_server.rs index ddb1527033a..d13faebb53d 100644 --- a/crates/apollo_infra/src/component_server/local_component_server.rs +++ b/crates/apollo_infra/src/component_server/local_component_server.rs @@ -1,10 +1,7 @@ -use std::collections::BTreeMap; use std::fmt::Debug; use std::sync::Arc; -use apollo_config::dumping::{ser_param, SerializeConfig}; use apollo_config::validators::validate_positive; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use apollo_infra_utils::type_name::short_type_name; use async_trait::async_trait; use serde::{Deserialize, Serialize}; @@ -46,43 +43,6 @@ pub struct LocalServerConfig { pub max_concurrency: usize, } -impl SerializeConfig for LocalServerConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "inbound_requests_channel_capacity", - &self.inbound_requests_channel_capacity, - "The inbound requests channel capacity.", - ParamPrivacyInput::Public, - ), - ser_param( - "high_priority_requests_channel_capacity", - &self.high_priority_requests_channel_capacity, - "The high priority requests channel capacity.", - ParamPrivacyInput::Public, - ), - ser_param( - "normal_priority_requests_channel_capacity", - &self.normal_priority_requests_channel_capacity, - "The normal priority requests channel capacity.", - ParamPrivacyInput::Public, - ), - ser_param( - "processing_time_warning_threshold_ms", - &self.processing_time_warning_threshold_ms, - "Request processing threshold time in ms after which a warning message is logged.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_concurrency", - &self.max_concurrency, - "The maximum number of concurrent requests handling.", - ParamPrivacyInput::Public, - ), - ]) - } -} - impl Default for LocalServerConfig { fn default() -> Self { Self { diff --git a/crates/apollo_infra/src/component_server/remote_component_server.rs b/crates/apollo_infra/src/component_server/remote_component_server.rs index fe65650b2f9..e9ff3786df3 100644 --- a/crates/apollo_infra/src/component_server/remote_component_server.rs +++ b/crates/apollo_infra/src/component_server/remote_component_server.rs @@ -1,12 +1,9 @@ -use std::collections::BTreeMap; use std::fmt::Debug; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::sync::Arc; use std::time::Duration; -use apollo_config::dumping::{ser_param, SerializeConfig}; use apollo_config::validators::validate_positive; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use apollo_infra_utils::type_name::short_type_name; use async_trait::async_trait; use bytes::Bytes; @@ -90,57 +87,6 @@ pub struct RemoteServerConfig { pub keepalive_timeout_ms: u64, } -impl SerializeConfig for RemoteServerConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "bind_ip", - &self.bind_ip.to_string(), - "Binding address of the remote component server.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_streams_per_connection", - &self.max_streams_per_connection, - "Maximal number of streams per HTTP connection.", - ParamPrivacyInput::Public, - ), - ser_param( - "set_tcp_nodelay", - &self.set_tcp_nodelay, - "Whether to set TCP_NODELAY on the server responses.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_concurrency", - &self.max_concurrency, - "The maximum number of concurrent requests handling.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_request_body_bytes", - &self.max_request_body_bytes, - "Maximum allowed size in bytes for an incoming request body. Requests exceeding \ - this limit are rejected with 413 Payload Too Large.", - ParamPrivacyInput::Public, - ), - ser_param( - "keepalive_interval_ms", - &self.keepalive_interval_ms, - "Interval in milliseconds between HTTP/2 keepalive pings sent to the client.", - ParamPrivacyInput::Public, - ), - ser_param( - "keepalive_timeout_ms", - &self.keepalive_timeout_ms, - "Timeout in milliseconds to wait for a keepalive ping response before closing the \ - connection.", - ParamPrivacyInput::Public, - ), - ]) - } -} - impl Default for RemoteServerConfig { fn default() -> Self { Self { diff --git a/crates/apollo_l1_events_config/src/config.rs b/crates/apollo_l1_events_config/src/config.rs index d4e77949349..bdd4f323989 100644 --- a/crates/apollo_l1_events_config/src/config.rs +++ b/crates/apollo_l1_events_config/src/config.rs @@ -1,13 +1,10 @@ -use std::collections::BTreeMap; use std::time::Duration; use apollo_config::converters::{ deserialize_float_seconds_to_duration, serialize_duration_as_float_seconds, }; -use apollo_config::dumping::{ser_param, SerializeConfig}; use apollo_config::validators::validate_ascii; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use starknet_api::core::ChainId; use validator::Validate; @@ -50,47 +47,6 @@ impl Default for L1EventsProviderConfig { } } -impl SerializeConfig for L1EventsProviderConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from([ - ser_param( - "startup_sync_sleep_retry_interval_seconds", - &self.startup_sync_sleep_retry_interval_seconds.as_secs(), - "Interval in seconds between each retry of syncing with L2 during startup.", - ParamPrivacyInput::Public, - ), - ser_param( - "l1_handler_cancellation_timelock_seconds", - &self.l1_handler_cancellation_timelock_seconds.as_secs(), - "How long to allow a transaction requested for cancellation to be validated \ - against (proposals are banned upon receiving a cancellation request).", - ParamPrivacyInput::Public, - ), - ser_param( - "l1_handler_consumption_timelock_seconds", - &self.l1_handler_consumption_timelock_seconds.as_secs_f64(), - "How long to wait after a transaction is consumed on L1 before it can be cleared \ - from the transaction manager.", - ParamPrivacyInput::Public, - ), - ser_param( - "l1_handler_proposal_cooldown_seconds", - &self.l1_handler_proposal_cooldown_seconds.as_secs(), - "How long to wait before allowing new L1 handler transactions to be proposed \ - (validation is available immediately), from the moment they are scraped.", - ParamPrivacyInput::Public, - ), - ser_param( - "dummy_mode", - &self.dummy_mode, - "When true, the L1 provider operates in dummy mode, always responding with \ - trivial truthy responses without connecting to actual L1.", - ParamPrivacyInput::Public, - ), - ]) - } -} - #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct TransactionManagerConfig { // How long to wait before allowing new L1 handler transactions to be proposed (validation is @@ -153,47 +109,3 @@ impl Default for L1EventsScraperConfig { } } } - -impl SerializeConfig for L1EventsScraperConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from([ - ser_param( - "startup_rewind_time_seconds", - &self.startup_rewind_time_seconds.as_secs(), - "Duration in seconds to rewind from latest L1 block when starting scraping.", - ParamPrivacyInput::Public, - ), - ser_param( - "finality", - &self.finality, - "Number of blocks to wait for finality", - ParamPrivacyInput::Public, - ), - ser_param( - "polling_interval_seconds", - &self.polling_interval_seconds.as_secs(), - "Interval in Seconds between each scraping attempt of L1.", - ParamPrivacyInput::Public, - ), - ser_param( - "chain_id", - &self.chain_id, - "The chain to follow. For more details see https://docs.starknet.io/learn/cheatsheets/transactions-reference#chain-id.", - ParamPrivacyInput::Public, - ), - ser_param( - "set_provider_historic_height_to_l2_genesis", - &self.set_provider_historic_height_to_l2_genesis, - "When true, the scraper will send the provider an historic height set to the L2 genesis (height zero). \ - This is useful on new chains (or in tests) where there have not been any state updates to the Starknet contract.", - ParamPrivacyInput::Public, - ), - ser_param( - "l1_block_time_seconds", - &self.l1_block_time_seconds.as_secs(), - "The time it takes for a new L1 block to be created.", - ParamPrivacyInput::Public, - ), - ]) - } -} diff --git a/crates/apollo_l1_gas_price_config/src/config.rs b/crates/apollo_l1_gas_price_config/src/config.rs index beeadbedb81..331ec51b7be 100644 --- a/crates/apollo_l1_gas_price_config/src/config.rs +++ b/crates/apollo_l1_gas_price_config/src/config.rs @@ -5,18 +5,10 @@ use apollo_config::converters::{ deserialize_float_seconds_to_duration, deserialize_optional_sensitive_list_with_url_and_headers, serialize_duration_as_float_seconds, - serialize_optional_list_with_url_and_headers, UrlAndHeaders, }; -use apollo_config::dumping::{ - prepend_sub_config_name, - ser_optional_param, - ser_param, - SerializeConfig, -}; use apollo_config::secrets::Sensitive; use apollo_config::validators::validate_ascii; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use starknet_api::core::ChainId; use url::Url; @@ -35,49 +27,6 @@ pub struct ExchangeRateOracleConfig { pub query_timeout_sec: u64, } -impl SerializeConfig for ExchangeRateOracleConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "url_header_list", - &serialize_optional_list_with_url_and_headers( - &self.url_header_list.as_ref().map(|list| { - list.iter().map(|s| s.peek_secret()).cloned().collect() - }), - ), - "A list of Url+HTTP headers for the exchange rate oracle. \ - The url is followed by a comma and then headers as key^value pairs, separated by commas. \ - For example: `https://api.example.com/api,key1^value1,key2^value2`. \ - Each URL+headers is separated by a pipe `|` character. \ - The `timestamp` parameter is appended dynamically when making requests, in order \ - to have a stable mapping from block timestamp to conversion rate. ", - ParamPrivacyInput::Private, - ), - ser_param( - "lag_interval_seconds", - &self.lag_interval_seconds, - "The size of the interval (seconds) that the exchange rate is taken on. The \ - lag refers to the fact that the interval `[T, T+k)` contains the conversion rate \ - for queries in the interval `[T+k, T+2k)`. Should be configured in alignment \ - with relevant query parameters in `url_header_list`, if required.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_cache_size", - &self.max_cache_size, - "The maximum number of cached conversion rates.", - ParamPrivacyInput::Public, - ), - ser_param( - "query_timeout_sec", - &self.query_timeout_sec, - "The timeout (seconds) for the query to the exchange rate oracle.", - ParamPrivacyInput::Public, - ), - ]) - } -} - impl Default for ExchangeRateOracleConfig { fn default() -> Self { Self { @@ -132,48 +81,6 @@ impl Default for L1GasPriceProviderConfig { } } -impl SerializeConfig for L1GasPriceProviderConfig { - fn dump(&self) -> BTreeMap { - let mut config = BTreeMap::from([ - ser_param( - "number_of_blocks_for_mean", - &self.number_of_blocks_for_mean, - "Number of blocks to use for the mean gas price calculation", - ParamPrivacyInput::Public, - ), - ser_param( - "lag_margin_seconds", - &self.lag_margin_seconds.as_secs(), - "Difference between the time of the block from L1 used to calculate the gas price \ - and the time of the L2 block this price is used in", - ParamPrivacyInput::Public, - ), - ser_param( - "storage_limit", - &self.storage_limit, - "Maximum number of L1 blocks to keep cached", - ParamPrivacyInput::Public, - ), - ser_param( - "max_time_gap_seconds", - &self.max_time_gap_seconds, - "Maximum valid time gap between the requested timestamp and the last price sample \ - in seconds", - ParamPrivacyInput::Public, - ), - ]); - config.extend(prepend_sub_config_name( - self.eth_to_strk_oracle_config.dump(), - "eth_to_strk_oracle_config", - )); - config.extend(prepend_sub_config_name( - self.strk_to_usd_oracle_config.dump(), - "strk_to_usd_oracle_config", - )); - config - } -} - // TODO(guyn): find a way to synchronize the value of number_of_blocks_for_mean // with the one in L1GasPriceProviderConfig. In the end they should both be loaded // from VersionedConstants. @@ -210,48 +117,3 @@ impl Default for L1GasPriceScraperConfig { } } } - -impl SerializeConfig for L1GasPriceScraperConfig { - fn dump(&self) -> BTreeMap { - let mut config = BTreeMap::from([ - ser_param( - "chain_id", - &self.chain_id, - "The chain to follow. For more details see https://docs.starknet.io/learn/cheatsheets/transactions-reference#chain-id", - ParamPrivacyInput::Public, - ), - ser_param( - "finality", - &self.finality, - "Number of blocks to wait for finality in L1", - ParamPrivacyInput::Public, - ), - ser_param( - "polling_interval", - &self.polling_interval.as_secs(), - "The duration (seconds) between each scraping attempt of L1", - ParamPrivacyInput::Public, - ), - ser_param( - "number_of_blocks_for_mean", - &self.number_of_blocks_for_mean, - "Number of blocks to use for the mean gas price calculation", - ParamPrivacyInput::Public, - ), - ser_param( - "startup_num_blocks_multiplier", - &self.startup_num_blocks_multiplier, - "How many sets of config.num_blocks_for_mean blocks to go back on the chain when starting to scrape.", - ParamPrivacyInput::Public, - ), - ]); - config.extend(ser_optional_param( - &self.starting_block, - 0, // This value is never used, since #is_none turns it to a None. - "starting_block", - "Starting block to scrape from", - ParamPrivacyInput::Public, - )); - config - } -} diff --git a/crates/apollo_mempool_config/src/config.rs b/crates/apollo_mempool_config/src/config.rs index 95f04844844..c13ec9d8f27 100644 --- a/crates/apollo_mempool_config/src/config.rs +++ b/crates/apollo_mempool_config/src/config.rs @@ -1,10 +1,7 @@ -use std::collections::BTreeMap; use std::time::Duration; use apollo_config::behavior_mode::BehaviorMode; use apollo_config::converters::{deserialize_seconds_to_duration, serialize_duration_as_seconds}; -use apollo_config::dumping::{prepend_sub_config_name, ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use url::Url; use validator::Validate; @@ -18,15 +15,6 @@ pub struct MempoolConfig { pub static_config: MempoolStaticConfig, } -impl SerializeConfig for MempoolConfig { - fn dump(&self) -> BTreeMap { - let mut config = BTreeMap::new(); - config.extend(prepend_sub_config_name(self.dynamic_config.dump(), "dynamic_config")); - config.extend(prepend_sub_config_name(self.static_config.dump(), "static_config")); - config - } -} - #[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Validate)] pub struct MempoolDynamicConfig { // Time-to-live for transactions in the mempool, in seconds. @@ -46,17 +34,6 @@ impl Default for MempoolDynamicConfig { } } -impl SerializeConfig for MempoolDynamicConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ser_param( - "transaction_ttl", - &self.transaction_ttl.as_secs(), - "Time-to-live for transactions in the mempool, in seconds.", - ParamPrivacyInput::Public, - )]) - } -} - #[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Validate)] pub struct MempoolStaticConfig { pub enable_fee_escalation: bool, @@ -100,61 +77,3 @@ impl Default for MempoolStaticConfig { } } } - -impl SerializeConfig for MempoolStaticConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "enable_fee_escalation", - &self.enable_fee_escalation, - "If true, transactions can be replaced with higher fee transactions.", - ParamPrivacyInput::Public, - ), - ser_param( - "validate_resource_bounds", - &self.validate_resource_bounds, - "If true, only transactions with max L2 gas price per unit bound that are above \ - the threshold are inserted into the priority queue. If false, all transactions \ - are inserted into the priority queue.", - ParamPrivacyInput::Public, - ), - ser_param( - "fee_escalation_percentage", - &self.fee_escalation_percentage, - "Percentage increase for tip and max gas price to enable transaction replacement.", - ParamPrivacyInput::Public, - ), - ser_param( - "declare_delay", - &self.declare_delay.as_secs(), - "Time to wait before allowing a Declare transaction to be returned, in seconds.", - ParamPrivacyInput::Public, - ), - ser_param( - "committed_nonce_retention_block_count", - &self.committed_nonce_retention_block_count, - "Number of latest committed blocks for which committed account nonces are \ - retained.", - ParamPrivacyInput::Public, - ), - ser_param( - "capacity_in_bytes", - &self.capacity_in_bytes, - "Maximum size of the mempool, in bytes.", - ParamPrivacyInput::Public, - ), - ser_param( - "behavior_mode", - &self.behavior_mode, - "Behavior mode: 'starknet' for production, 'echonet' for test/replay mode.", - ParamPrivacyInput::Public, - ), - ser_param( - "recorder_url", - &self.recorder_url, - "The URL of the recorder service (used for FIFO queue timestamp fetching).", - ParamPrivacyInput::Public, - ), - ]) - } -} diff --git a/crates/apollo_mempool_p2p_config/src/config.rs b/crates/apollo_mempool_p2p_config/src/config.rs index 6dfdefa96fc..7376c4cd679 100644 --- a/crates/apollo_mempool_p2p_config/src/config.rs +++ b/crates/apollo_mempool_p2p_config/src/config.rs @@ -1,12 +1,9 @@ -use std::collections::BTreeMap; use std::time::Duration; use apollo_config::converters::{ deserialize_milliseconds_to_duration, serialize_duration_as_milliseconds, }; -use apollo_config::dumping::{prepend_sub_config_name, ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use apollo_network::NetworkConfig; use serde::{Deserialize, Serialize}; use validator::Validate; @@ -39,42 +36,3 @@ impl Default for MempoolP2pConfig { } } } - -impl SerializeConfig for MempoolP2pConfig { - fn dump(&self) -> BTreeMap { - vec![ - BTreeMap::from_iter([ - ser_param( - "network_buffer_size", - &self.network_buffer_size, - "Network buffer size.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_transaction_batch_size", - &self.max_transaction_batch_size, - "Maximum number of transactions in each batch.", - ParamPrivacyInput::Public, - ), - ser_param( - "transaction_batch_rate_millis", - &self.transaction_batch_rate_millis.as_millis(), - "Maximum time until a transaction batch is closed and propagated in \ - milliseconds.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_concurrent_gateway_requests", - &self.max_concurrent_gateway_requests, - "Maximum number of concurrent gateway requests before rejecting new \ - transactions.", - ParamPrivacyInput::Public, - ), - ]), - prepend_sub_config_name(self.network_config.dump(), "network_config"), - ] - .into_iter() - .flatten() - .collect() - } -} diff --git a/crates/apollo_monitoring_endpoint_config/src/config.rs b/crates/apollo_monitoring_endpoint_config/src/config.rs index 531bb11f8cb..4a5a0e875bb 100644 --- a/crates/apollo_monitoring_endpoint_config/src/config.rs +++ b/crates/apollo_monitoring_endpoint_config/src/config.rs @@ -1,9 +1,6 @@ -use std::collections::BTreeMap; use std::fmt::{Display, Formatter, Result}; use std::net::{IpAddr, Ipv4Addr}; -use apollo_config::dumping::{ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use validator::Validate; @@ -35,32 +32,6 @@ impl Default for MonitoringEndpointConfig { } } -impl SerializeConfig for MonitoringEndpointConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "ip", - &self.ip.to_string(), - "The monitoring endpoint ip address.", - ParamPrivacyInput::Public, - ), - ser_param( - "port", - &self.port, - "The monitoring endpoint port.", - ParamPrivacyInput::Public, - ), - ser_param( - "snapshot_timeout_millis", - &self.snapshot_timeout_millis, - "Timeout in milliseconds for snapshot requests to internal services (mempool, L1 \ - provider). Returns 504 if the service does not respond within this deadline.", - ParamPrivacyInput::Public, - ), - ]) - } -} - impl Display for MonitoringEndpointConfig { #[cfg_attr(coverage_nightly, coverage_attribute)] fn fmt(&self, f: &mut Formatter<'_>) -> Result { diff --git a/crates/apollo_network/src/discovery/mod.rs b/crates/apollo_network/src/discovery/mod.rs index c08f76f06dd..97fc3154de9 100644 --- a/crates/apollo_network/src/discovery/mod.rs +++ b/crates/apollo_network/src/discovery/mod.rs @@ -29,7 +29,6 @@ pub mod kad_impl; #[cfg(test)] mod testing_utils; -use std::collections::BTreeMap; use std::time::Duration; use apollo_config::converters::{ @@ -38,8 +37,6 @@ use apollo_config::converters::{ serialize_duration_as_milliseconds, serialize_duration_as_seconds, }; -use apollo_config::dumping::{prepend_sub_config_name, ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use behaviours::bootstrapping::BootstrappingBehaviour; use behaviours::dialing::DialingBehaviour; use behaviours::kad_requesting::KadRequestingBehaviour; @@ -147,22 +144,6 @@ impl Default for DiscoveryConfig { } } -impl SerializeConfig for DiscoveryConfig { - fn dump(&self) -> BTreeMap { - let mut dump = BTreeMap::from([ser_param( - "heartbeat_interval", - &self.heartbeat_interval.as_millis(), - "The interval between each discovery (Kademlia) query in milliseconds.", - ParamPrivacyInput::Public, - )]); - dump.append(&mut prepend_sub_config_name( - self.bootstrap_dial_retry_config.dump(), - "bootstrap_dial_retry_config", - )); - dump - } -} - /// Configuration for exponential backoff retry logic. /// /// This struct defines the parameters for the exponential backoff strategy @@ -233,37 +214,6 @@ impl Default for RetryConfig { } } -impl SerializeConfig for RetryConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from([ - ser_param( - "base_delay_millis", - &self.base_delay_millis, - "The base delay in milliseconds for the exponential backoff strategy.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_delay_seconds", - &self.max_delay_seconds.as_secs(), - "The maximum delay in seconds for the exponential backoff strategy.", - ParamPrivacyInput::Public, - ), - ser_param( - "factor", - &self.factor, - "The factor for the exponential backoff strategy.", - ParamPrivacyInput::Public, - ), - ser_param( - "new_connection_stabilization_millis", - &self.new_connection_stabilization_millis.as_millis(), - "Milliseconds to wait on a new connection before treating it as stable.", - ParamPrivacyInput::Public, - ), - ]) - } -} - impl RetryConfig { pub fn strategy(&self) -> ExponentialBackoff { ExponentialBackoff::from_millis(self.base_delay_millis) diff --git a/crates/apollo_network/src/lib.rs b/crates/apollo_network/src/lib.rs index 4dc9234034b..a6d50f20ed1 100644 --- a/crates/apollo_network/src/lib.rs +++ b/crates/apollo_network/src/lib.rs @@ -219,7 +219,7 @@ pub mod sqmr; mod test_utils; pub mod utils; -use std::collections::{BTreeMap, HashSet}; +use std::collections::HashSet; use std::time::Duration; use apollo_config::converters::{ @@ -227,19 +227,10 @@ use apollo_config::converters::{ deserialize_optional_sensitive_vec_u8, deserialize_seconds_to_duration, serialize_duration_as_seconds, - serialize_optional_comma_separated, serialize_optional_comma_separated_str, - serialize_optional_vec_u8, -}; -use apollo_config::dumping::{ - prepend_sub_config_name, - ser_optional_param, - ser_param, - SerializeConfig, }; use apollo_config::secrets::Sensitive; use apollo_config::validators::validate_optional_sensitive_vec_u256; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use discovery::DiscoveryConfig; use libp2p::identity::Keypair; use libp2p::swarm::dial_opts::DialOpts; @@ -374,93 +365,6 @@ pub struct NetworkConfig { pub prune_dead_connections_ping_timeout: Duration, } -impl SerializeConfig for NetworkConfig { - fn dump(&self) -> BTreeMap { - let mut config = BTreeMap::from_iter([ - ser_param( - "port", - &self.port, - "The port that the node listens on for incoming connections.", - ParamPrivacyInput::Public, - ), - ser_param( - "session_timeout", - &self.session_timeout.as_secs(), - "Maximal time in seconds that each session can take before failing on timeout.", - ParamPrivacyInput::Public, - ), - ser_param( - "idle_connection_timeout", - &self.idle_connection_timeout.as_secs(), - "Amount of time in seconds that a connection with no active sessions will stay \ - alive.", - ParamPrivacyInput::Public, - ), - ser_param( - "chain_id", - &self.chain_id, - "The chain to follow. For more details see https://docs.starknet.io/learn/cheatsheets/transactions-reference#chain-id.", - ParamPrivacyInput::Public, - ), - ser_param( - "broadcasted_message_metadata_buffer_size", - &self.broadcasted_message_metadata_buffer_size, - "The size of the buffer that holds the metadata of the broadcasted messages.", - ParamPrivacyInput::Public, - ), - ser_param( - "reported_peer_ids_buffer_size", - &self.reported_peer_ids_buffer_size, - "The size of the buffer that holds the reported peer ids.", - ParamPrivacyInput::Public, - ), - ser_param( - "prune_dead_connections_ping_interval", - &self.prune_dead_connections_ping_interval.as_secs(), - "The interval in seconds between each prune dead connections ping check.", - ParamPrivacyInput::Public, - ), - ser_param( - "prune_dead_connections_ping_timeout", - &self.prune_dead_connections_ping_timeout.as_secs(), - "The timeout in seconds for a ping to be considered failed.", - ParamPrivacyInput::Public, - ), - ser_param( - "secret_key", - &serialize_optional_vec_u8( - &self.secret_key.as_ref().map(|s| s.clone().expose_secret()), - ), - "The secret key used for building the peer id. If it's an empty string a random one \ - will be used.", - ParamPrivacyInput::Private, - ), - ]); - config.extend(ser_optional_param( - &serialize_optional_comma_separated(&self.bootstrap_peer_multiaddr), - String::from(""), - "bootstrap_peer_multiaddr", - "The multiaddress of the peer node. It should include the peer's id. For more info: https://docs.libp2p.io/concepts/fundamentals/peers/", - ParamPrivacyInput::Public, - )); - config.extend(ser_optional_param( - &self.advertised_multiaddr, - Multiaddr::empty(), - "advertised_multiaddr", - "The external address other peers see this node. If this is set, the node will not \ - try to find out which addresses it has and will write this address as external \ - instead", - ParamPrivacyInput::Public, - )); - config.extend(prepend_sub_config_name(self.discovery_config.dump(), "discovery_config")); - config.extend(prepend_sub_config_name( - self.peer_manager_config.dump(), - "peer_manager_config", - )); - config - } -} - impl Default for NetworkConfig { fn default() -> Self { Self { diff --git a/crates/apollo_network/src/peer_manager/mod.rs b/crates/apollo_network/src/peer_manager/mod.rs index 158a3da4535..73d338ea4ad 100644 --- a/crates/apollo_network/src/peer_manager/mod.rs +++ b/crates/apollo_network/src/peer_manager/mod.rs @@ -1,4 +1,4 @@ -use std::collections::{BTreeMap, HashMap}; +use std::collections::HashMap; use std::time::Duration; use apollo_config::converters::{ @@ -7,8 +7,6 @@ use apollo_config::converters::{ serialize_duration_as_milliseconds, serialize_duration_as_seconds, }; -use apollo_config::dumping::{ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use futures::future::BoxFuture; use futures::FutureExt; use libp2p::swarm::dial_opts::DialOpts; @@ -86,25 +84,6 @@ impl Default for PeerManagerConfig { } } -impl SerializeConfig for PeerManagerConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from([ - ser_param( - "malicious_timeout_seconds", - &self.malicious_timeout_seconds.as_secs(), - "The duration in seconds a peer is blacklisted after being marked as malicious.", - ParamPrivacyInput::Public, - ), - ser_param( - "unstable_timeout_millis", - &self.unstable_timeout_millis.as_millis(), - "The duration in milliseconds a peer blacklisted after being reported as unstable.", - ParamPrivacyInput::Public, - ), - ]) - } -} - #[allow(dead_code)] impl PeerManager { pub(crate) fn new(config: PeerManagerConfig) -> Self { diff --git a/crates/apollo_node/src/bin/update_apollo_node_config_schema.rs b/crates/apollo_node/src/bin/update_apollo_node_config_schema.rs deleted file mode 100644 index 4cb55cf698f..00000000000 --- a/crates/apollo_node/src/bin/update_apollo_node_config_schema.rs +++ /dev/null @@ -1,24 +0,0 @@ -use std::collections::BTreeSet; - -use apollo_config::dumping::SerializeConfig; -use apollo_config::ParamPath; -use apollo_infra_utils::dumping::serialize_to_file; -use apollo_node_config::node_config::{SequencerNodeConfig, CONFIG_SECRETS_SCHEMA_PATH}; - -/// Derives the private-parameter set from the config dump: every private parameter. This is the -/// source of truth the committed secrets schema is generated from; `private_parameters()` reads -/// back the committed file. -fn private_parameters_from_config_dump() -> BTreeSet { - SequencerNodeConfig::default() - .dump() - .into_iter() - .filter(|(_param_path, ser_param)| ser_param.is_private()) - .map(|(param_path, _ser_param)| param_path) - .collect() -} - -/// Updates the committed apollo node secrets schema (`CONFIG_SECRETS_SCHEMA_PATH`), which is the -/// serialized private-parameter set derived from the config. -fn main() { - serialize_to_file(&private_parameters_from_config_dump(), CONFIG_SECRETS_SCHEMA_PATH); -} diff --git a/crates/apollo_node_config/src/component_config.rs b/crates/apollo_node_config/src/component_config.rs index a0a74d7ede2..dd2b396a925 100644 --- a/crates/apollo_node_config/src/component_config.rs +++ b/crates/apollo_node_config/src/component_config.rs @@ -1,7 +1,4 @@ -use std::collections::BTreeMap; - -use apollo_config::dumping::{prepend_sub_config_name, SerializeConfig}; -use apollo_config::{ConfigError, ParamPath, SerializedParam}; +use apollo_config::ConfigError; use serde::{Deserialize, Serialize}; use validator::Validate; @@ -64,33 +61,6 @@ pub struct ComponentConfig { pub monitoring_endpoint: ActiveComponentExecutionConfig, } -impl SerializeConfig for ComponentConfig { - fn dump(&self) -> BTreeMap { - let sub_configs = vec![ - prepend_sub_config_name(self.batcher.dump(), "batcher"), - prepend_sub_config_name(self.class_manager.dump(), "class_manager"), - prepend_sub_config_name(self.committer.dump(), "committer"), - prepend_sub_config_name(self.config_manager.dump(), "config_manager"), - prepend_sub_config_name(self.consensus_manager.dump(), "consensus_manager"), - prepend_sub_config_name(self.gateway.dump(), "gateway"), - prepend_sub_config_name(self.http_server.dump(), "http_server"), - prepend_sub_config_name(self.l1_events_provider.dump(), "l1_events_provider"), - prepend_sub_config_name(self.l1_gas_price_provider.dump(), "l1_gas_price_provider"), - prepend_sub_config_name(self.l1_events_scraper.dump(), "l1_events_scraper"), - prepend_sub_config_name(self.l1_gas_price_scraper.dump(), "l1_gas_price_scraper"), - prepend_sub_config_name(self.mempool.dump(), "mempool"), - prepend_sub_config_name(self.mempool_p2p.dump(), "mempool_p2p"), - prepend_sub_config_name(self.monitoring_endpoint.dump(), "monitoring_endpoint"), - prepend_sub_config_name(self.proof_manager.dump(), "proof_manager"), - prepend_sub_config_name(self.sierra_compiler.dump(), "sierra_compiler"), - prepend_sub_config_name(self.signature_manager.dump(), "signature_manager"), - prepend_sub_config_name(self.state_sync.dump(), "state_sync"), - ]; - - sub_configs.into_iter().flatten().collect() - } -} - impl ComponentConfig { pub fn disabled() -> ComponentConfig { ComponentConfig { diff --git a/crates/apollo_node_config/src/component_execution_config.rs b/crates/apollo_node_config/src/component_execution_config.rs index 1e8cfe691d2..3bafa0bb758 100644 --- a/crates/apollo_node_config/src/component_execution_config.rs +++ b/crates/apollo_node_config/src/component_execution_config.rs @@ -1,9 +1,6 @@ -use std::collections::BTreeMap; use std::net::ToSocketAddrs; -use apollo_config::dumping::{ser_optional_sub_config, ser_param, SerializeConfig}; use apollo_config::validators::create_validation_error; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use apollo_infra::component_client::RemoteClientConfig; use apollo_infra::component_server::{LocalServerConfig, RemoteServerConfig}; use serde::{Deserialize, Serialize}; @@ -79,40 +76,6 @@ pub struct ReactiveComponentExecutionConfig { pub port: u16, } -impl SerializeConfig for ReactiveComponentExecutionConfig { - fn dump(&self) -> BTreeMap { - let members = BTreeMap::from_iter([ - ser_param( - "execution_mode", - &self.execution_mode, - "The component execution mode.", - ParamPrivacyInput::Public, - ), - ser_param( - "url", - &self.url, - "URL of the remote component server.", - ParamPrivacyInput::Public, - ), - ser_param( - "port", - &self.port, - "Listening port of the remote component server.", - ParamPrivacyInput::Public, - ), - ]); - vec![ - members, - ser_optional_sub_config(&self.local_server_config, "local_server_config"), - ser_optional_sub_config(&self.remote_server_config, "remote_server_config"), - ser_optional_sub_config(&self.remote_client_config, "remote_client_config"), - ] - .into_iter() - .flatten() - .collect() - } -} - impl Default for ReactiveComponentExecutionConfig { fn default() -> Self { Self::local_with_remote_disabled() @@ -207,17 +170,6 @@ pub struct ActiveComponentExecutionConfig { pub execution_mode: ActiveComponentExecutionMode, } -impl SerializeConfig for ActiveComponentExecutionConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ser_param( - "execution_mode", - &self.execution_mode, - "The component execution mode.", - ParamPrivacyInput::Public, - )]) - } -} - impl Default for ActiveComponentExecutionConfig { fn default() -> Self { ActiveComponentExecutionConfig::enabled() diff --git a/crates/apollo_node_config/src/config_test.rs b/crates/apollo_node_config/src/config_test.rs index 0c26ebc6254..66549abcb8f 100644 --- a/crates/apollo_node_config/src/config_test.rs +++ b/crates/apollo_node_config/src/config_test.rs @@ -1,12 +1,13 @@ -use apollo_config::behavior_mode::BehaviorMode; +use std::collections::BTreeSet; + +use apollo_config::secrets::DEFAULT_REDACTION_OUTPUT; +use apollo_config::{ParamPath, FIELD_SEPARATOR}; use apollo_infra::component_client::RemoteClientConfig; use apollo_infra::component_server::{LocalServerConfig, RemoteServerConfig}; -use apollo_infra_utils::dumping::serialize_to_file_test; -use apollo_reverts::RevertConfig; use apollo_state_sync_config::config::{StateSyncConfig, StateSyncStaticConfig}; use apollo_storage::{StorageConfig, StorageScope}; -use blockifier::blockifier::config::NativeClassesWhitelist; use rstest::rstest; +use serde_json::Value; use starknet_api::contract_address; use starknet_api::core::ChainId; use validator::Validate; @@ -21,8 +22,6 @@ use crate::config_utils::{normalize_pointer_groups, private_parameters}; use crate::monitoring::MonitoringConfig; use crate::node_config::{SequencerNodeConfig, CONFIG_SECRETS_SCHEMA_PATH}; -const FIX_BINARY_NAME: &str = "update_apollo_node_config_schema"; - const LOCAL_EXECUTION_MODE: ReactiveComponentExecutionMode = ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled; const ENABLE_REMOTE_CONNECTION_MODE: ReactiveComponentExecutionMode = @@ -78,11 +77,75 @@ fn valid_component_execution_config( assert_eq!(component_exe_config.validate(), Ok(())); } -/// Test that the committed secrets schema file is up to date. To update it, run -/// `cargo run --bin `. +/// Collects the dotted paths of every leaf in `value` whose serialized form is the +/// `Sensitive` default-redaction sentinel. These are the secret fields the type system can +/// detect automatically. Paths use [`FIELD_SEPARATOR`] to match the secrets-schema convention. +fn default_redacted_paths(value: &Value, prefix: &str, paths: &mut BTreeSet) { + match value { + Value::String(string_value) if string_value == DEFAULT_REDACTION_OUTPUT => { + paths.insert(prefix.to_owned()); + } + Value::Object(map) => { + for (key, child) in map { + let child_prefix = if prefix.is_empty() { + key.clone() + } else { + format!("{prefix}{FIELD_SEPARATOR}{key}") + }; + default_redacted_paths(child, &child_prefix, paths); + } + } + // A `Vec>`/`Option>>` secret (e.g. + // `ordered_l1_endpoint_urls`, `url_header_list`) serializes to an array of + // redaction sentinels. The whole field is one schema entry, so recurse into each + // element with the SAME prefix (no per-element index): any redacted element marks + // the field's own path. + Value::Array(items) => { + for item in items { + default_redacted_paths(item, prefix, paths); + } + } + _ => {} + } +} + +/// Safety guard for the hand-maintained secrets schema (`CONFIG_SECRETS_SCHEMA_PATH`). +/// +/// Walks the serialized default config for `Sensitive` default-redaction sentinels and asserts +/// every such field is declared in the committed schema. This catches a newly added secret field +/// (with the default redactor) that wasn't added to the schema. +/// +/// Best-effort by design: the schema is now hand-maintained (the generator binary was retired), so +/// this guard only enforces the subset direction. Gaps it cannot cover: +/// - `Sensitive` fields that attach a custom redactor serialize to that custom string, not the +/// default sentinel, so they are not detected here. +/// - Secret fields enforced only via `#[serde(deserialize_with = ...)]` (no `Sensitive` type) +/// have no serialized marker at all. +/// Such fields, and any unset (`None`) optional secrets, must be kept in the schema by hand. #[test] -fn default_config_file_is_up_to_date() { - serialize_to_file_test(&private_parameters(), CONFIG_SECRETS_SCHEMA_PATH, FIX_BINARY_NAME); +fn secrets_schema_contains_all_default_redacted_fields() { + let default_config_value = serde_json::to_value(SequencerNodeConfig::default()) + .expect("Should be able to serialize the default config to a JSON value"); + let mut detected_secret_paths = BTreeSet::new(); + default_redacted_paths(&default_config_value, "", &mut detected_secret_paths); + + // Guard against the detector silently regressing to vacuous (e.g. a serialized shape that stops + // hitting any arm, like the missing array arm this once had). At least the known array-typed L1 + // endpoint secret must be detected; otherwise the subset check below is meaningless. + assert!( + detected_secret_paths.contains("base_layer_config.ordered_l1_endpoint_urls"), + "secret detector found no default-redacted array fields — the recursion is likely not \ + descending into arrays; detected: {detected_secret_paths:?}" + ); + + let committed_secret_paths = private_parameters(); + let missing_paths: Vec<&ParamPath> = + detected_secret_paths.difference(&committed_secret_paths).collect(); + assert!( + missing_paths.is_empty(), + "The following default-redacted secret fields are missing from the committed secrets \ + schema ({CONFIG_SECRETS_SCHEMA_PATH}). Add them by hand: {missing_paths:?}" + ); } #[test] diff --git a/crates/apollo_node_config/src/config_utils.rs b/crates/apollo_node_config/src/config_utils.rs index 1764f74fc8d..5c21795cea6 100644 --- a/crates/apollo_node_config/src/config_utils.rs +++ b/crates/apollo_node_config/src/config_utils.rs @@ -1,12 +1,12 @@ -use std::collections::{BTreeSet, HashSet}; +use std::collections::BTreeSet; use std::fs::File; use std::path::Path; use apollo_config::presentation::get_config_presentation; -use apollo_config::{ConfigError, ParamPath, FIELD_SEPARATOR, IS_NONE_MARK}; +use apollo_config::{ConfigError, ParamPath}; use apollo_infra_utils::dumping::serialize_to_file; use apollo_infra_utils::path::resolve_project_relative_path; -use serde_json::{Map, Value}; +use serde_json::Value; use tracing::{error, info}; use crate::node_config::{SequencerNodeConfig, CONFIG_SECRETS_SCHEMA_PATH}; @@ -14,83 +14,14 @@ use crate::node_config::{SequencerNodeConfig, CONFIG_SECRETS_SCHEMA_PATH}; /// Returns the set of all non-pointer private parameters and all pointer target parameters pointed /// by private parameters, as committed in the secrets schema file (`CONFIG_SECRETS_SCHEMA_PATH`). /// -/// The committed file is exactly this set serialized; the `default_config_file_is_up_to_date` test -/// guards that it stays in sync with the config derivation. +/// The committed file is hand-maintained. The `secrets_schema_contains_all_default_redacted_fields` +/// test guards (best-effort) that every default-redacted `Sensitive` field is present in it. pub fn private_parameters() -> BTreeSet { let secrets_schema_path = &resolve_project_relative_path(CONFIG_SECRETS_SCHEMA_PATH).unwrap(); let secrets_schema_file = File::open(secrets_schema_path).unwrap(); serde_json::from_reader(secrets_schema_file).unwrap() } -/// Transforms a nested JSON dictionary object into a simplified JSON dictionary object by -/// extracting specific values from the inner dictionaries. -/// -/// # Parameters -/// - `config_map`: A reference to a `serde_json::Value` that must be a JSON dictionary object. Each -/// key in the object maps to another JSON dictionary object. -/// -/// # Returns -/// - A `serde_json::Value` dictionary object where: -/// - Each key is preserved from the top-level dictionary. -/// - Each value corresponds to the `"value"` field of the nested JSON dictionary under the -/// original key. -/// -/// # Panics -/// This function panics if the provided `config_map` is not a JSON dictionary object. -pub fn config_to_preset(config_map: &Value) -> Value { - // Ensure the config_map is a JSON object. - if let Value::Object(map) = config_map { - let mut result = Map::new(); - - for (key, value) in map { - if let Value::Object(inner_map) = value { - // Extract the value. - if let Some(inner_value) = inner_map.get("value") { - // Add it to the result map - result.insert(key.clone(), inner_value.clone()); - } - } - } - - // Return the transformed result as a JSON object. - Value::Object(result) - } else { - panic!("Config map is not a JSON object: {config_map:?}"); - } -} - -/// Keep "{prefix}.#is_none": true, remove all other keys that begin with "{prefix}" (including -/// the bare prefix). -pub fn prune_by_is_none(mut v: Value) -> Value { - let obj: &mut Map = - v.as_object_mut().expect("prune_by_is_none: expected a JSON object"); - - // Find optional parameter paths which are unset - let is_none_suffix = format!("{FIELD_SEPARATOR}{IS_NONE_MARK}"); - let mut unset_optional_param_paths: HashSet = HashSet::new(); - - for (k, val) in obj.iter() { - if let Some(prefix) = k.strip_suffix(&is_none_suffix) { - if val.as_bool() == Some(true) { - unset_optional_param_paths.insert(prefix.to_string()); - } - } - } - - // Remove keys that begin with any such prefix (including the bare prefix), except the - // "#is_none" flag itself - obj.retain(|k, _| { - if let Some(p) = unset_optional_param_paths.iter().find(|p| k.starts_with(&***p)) { - // keep only the "{prefix}.#is_none" key - k == &format!("{p}{FIELD_SEPARATOR}{IS_NONE_MARK}") - } else { - true - } - }); - - v -} - // TODO(Nadin/Tsabary): `DeploymentBaseAppConfig` is only used in tests, and should be marked as // such. #[derive(Debug, Clone, Default)] diff --git a/crates/apollo_node_config/src/monitoring.rs b/crates/apollo_node_config/src/monitoring.rs index 01ec3d5c744..7c4052454c7 100644 --- a/crates/apollo_node_config/src/monitoring.rs +++ b/crates/apollo_node_config/src/monitoring.rs @@ -1,8 +1,4 @@ -use std::collections::BTreeMap; - -use apollo_config::dumping::{ser_param, SerializeConfig}; use apollo_config::validators::create_validation_error; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use validator::{Validate, ValidationError}; @@ -13,25 +9,6 @@ pub struct MonitoringConfig { pub collect_profiling_metrics: bool, } -impl SerializeConfig for MonitoringConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "collect_metrics", - &self.collect_metrics, - "Indicating if metrics should be recorded.", - ParamPrivacyInput::Public, - ), - ser_param( - "collect_profiling_metrics", - &self.collect_profiling_metrics, - "Indicating if profiling metrics should be collected.", - ParamPrivacyInput::Public, - ), - ]) - } -} - impl Default for MonitoringConfig { fn default() -> Self { Self { collect_metrics: true, collect_profiling_metrics: true } diff --git a/crates/apollo_node_config/src/node_config.rs b/crates/apollo_node_config/src/node_config.rs index c4558ee94e3..ccdae31484f 100644 --- a/crates/apollo_node_config/src/node_config.rs +++ b/crates/apollo_node_config/src/node_config.rs @@ -1,18 +1,11 @@ -use std::collections::BTreeMap; use std::vec::Vec; use apollo_batcher_config::config::{BatcherConfig, BatcherDynamicConfig}; use apollo_class_manager_config::config::{ClassManagerDynamicConfig, FsClassManagerConfig}; use apollo_committer_config::config::ApolloCommitterConfig; -use apollo_config::dumping::{ - prepend_sub_config_name, - ser_optional_sub_config, - ser_param, - SerializeConfig, -}; use apollo_config::loading::load_and_process_config; use apollo_config::validators::config_validate; -use apollo_config::{ConfigError, ParamPath, ParamPrivacyInput, SerializedParam}; +use apollo_config::ConfigError; use apollo_config_manager_config::config::ConfigManagerConfig; use apollo_consensus_config::config::ConsensusDynamicConfig; use apollo_consensus_manager_config::config::ConsensusManagerConfig; @@ -96,51 +89,6 @@ pub struct SequencerNodeConfig { pub state_sync_config: Option, } -impl SerializeConfig for SequencerNodeConfig { - fn dump(&self) -> BTreeMap { - let mut dump = BTreeMap::from([ser_param( - "validation_only", - &self.validation_only, - "If true, the node validates proposed blocks but does not build proposals. Requires \ - gateway, http_server, and mempool to be disabled.", - ParamPrivacyInput::Public, - )]); - let sub_configs = vec![ - // Infra related configs. - prepend_sub_config_name(self.components.dump(), "components"), - ser_optional_sub_config(&self.config_manager_config, "config_manager_config"), - prepend_sub_config_name(self.monitoring_config.dump(), "monitoring_config"), - // Business-logic component configs. - ser_optional_sub_config(&self.base_layer_config, "base_layer_config"), - ser_optional_sub_config(&self.batcher_config, "batcher_config"), - ser_optional_sub_config(&self.class_manager_config, "class_manager_config"), - ser_optional_sub_config(&self.committer_config, "committer_config"), - ser_optional_sub_config(&self.consensus_manager_config, "consensus_manager_config"), - ser_optional_sub_config(&self.gateway_config, "gateway_config"), - ser_optional_sub_config(&self.http_server_config, "http_server_config"), - ser_optional_sub_config(&self.mempool_config, "mempool_config"), - ser_optional_sub_config(&self.mempool_p2p_config, "mempool_p2p_config"), - ser_optional_sub_config(&self.monitoring_endpoint_config, "monitoring_endpoint_config"), - ser_optional_sub_config( - &self.l1_gas_price_provider_config, - "l1_gas_price_provider_config", - ), - ser_optional_sub_config( - &self.l1_gas_price_scraper_config, - "l1_gas_price_scraper_config", - ), - ser_optional_sub_config(&self.l1_events_provider_config, "l1_events_provider_config"), - ser_optional_sub_config(&self.l1_events_scraper_config, "l1_events_scraper_config"), - ser_optional_sub_config(&self.proof_manager_config, "proof_manager_config"), - ser_optional_sub_config(&self.sierra_compiler_config, "sierra_compiler_config"), - ser_optional_sub_config(&self.state_sync_config, "state_sync_config"), - ]; - - dump.extend(sub_configs.into_iter().flatten()); - dump - } -} - impl Default for SequencerNodeConfig { fn default() -> Self { Self { @@ -194,29 +142,6 @@ pub struct NodeDynamicConfig { pub state_sync_dynamic_config: Option, } -impl SerializeConfig for NodeDynamicConfig { - fn dump(&self) -> BTreeMap { - let sub_configs = [ - ser_optional_sub_config(&self.batcher_dynamic_config, "batcher_dynamic_config"), - ser_optional_sub_config( - &self.class_manager_dynamic_config, - "class_manager_dynamic_config", - ), - ser_optional_sub_config(&self.consensus_dynamic_config, "consensus_dynamic_config"), - ser_optional_sub_config(&self.context_dynamic_config, "context_dynamic_config"), - ser_optional_sub_config(&self.gateway_dynamic_config, "gateway_dynamic_config"), - ser_optional_sub_config(&self.http_server_dynamic_config, "http_server_dynamic_config"), - ser_optional_sub_config(&self.mempool_dynamic_config, "mempool_dynamic_config"), - ser_optional_sub_config( - &self.staking_manager_dynamic_config, - "staking_manager_dynamic_config", - ), - ser_optional_sub_config(&self.state_sync_dynamic_config, "state_sync_dynamic_config"), - ]; - sub_configs.into_iter().flatten().collect() - } -} - impl From<&SequencerNodeConfig> for NodeDynamicConfig { fn from(sequencer_node_config: &SequencerNodeConfig) -> Self { // TODO(Nadin/Tsabary): consider creating a macro for this. diff --git a/crates/apollo_p2p_sync_config/src/config.rs b/crates/apollo_p2p_sync_config/src/config.rs index bd2679b6e82..5e030f9dcf1 100644 --- a/crates/apollo_p2p_sync_config/src/config.rs +++ b/crates/apollo_p2p_sync_config/src/config.rs @@ -1,12 +1,9 @@ -use std::collections::BTreeMap; use std::time::Duration; use apollo_config::converters::{ deserialize_milliseconds_to_duration, serialize_duration_as_milliseconds, }; -use apollo_config::dumping::{ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use validator::Validate; @@ -29,58 +26,6 @@ pub struct P2pSyncClientConfig { pub buffer_size: usize, } -impl SerializeConfig for P2pSyncClientConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "num_headers_per_query", - &self.num_headers_per_query, - "The maximum amount of headers to ask from peers in each iteration.", - ParamPrivacyInput::Public, - ), - ser_param( - "num_block_state_diffs_per_query", - &self.num_block_state_diffs_per_query, - "The maximum amount of block's state diffs to ask from peers in each iteration.", - ParamPrivacyInput::Public, - ), - ser_param( - "num_block_transactions_per_query", - &self.num_block_transactions_per_query, - "The maximum amount of blocks to ask their transactions from peers in each \ - iteration.", - ParamPrivacyInput::Public, - ), - ser_param( - "num_block_classes_per_query", - &self.num_block_classes_per_query, - "The maximum amount of block's classes to ask from peers in each iteration.", - ParamPrivacyInput::Public, - ), - ser_param( - "wait_period_for_new_data", - &self.wait_period_for_new_data.as_millis(), - "Time in milliseconds to wait when a query returned with partial data before \ - sending a new query", - ParamPrivacyInput::Public, - ), - ser_param( - "wait_period_for_other_protocol", - &self.wait_period_for_other_protocol.as_millis(), - "Time in milliseconds to wait for a dependency protocol to advance (e.g.state \ - diff sync depends on header sync)", - ParamPrivacyInput::Public, - ), - ser_param( - "buffer_size", - &self.buffer_size, - "Size of the buffer for read from the storage and for incoming responses.", - ParamPrivacyInput::Public, - ), - ]) - } -} - impl Default for P2pSyncClientConfig { fn default() -> Self { P2pSyncClientConfig { diff --git a/crates/apollo_proof_manager_config/src/config.rs b/crates/apollo_proof_manager_config/src/config.rs index 699b3c79592..7bd364fafd4 100644 --- a/crates/apollo_proof_manager_config/src/config.rs +++ b/crates/apollo_proof_manager_config/src/config.rs @@ -1,9 +1,6 @@ -use std::collections::BTreeMap; use std::num::NonZeroUsize; use std::path::PathBuf; -use apollo_config::dumping::{ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use validator::Validate; @@ -26,22 +23,3 @@ impl Default for ProofManagerConfig { } } } - -impl SerializeConfig for ProofManagerConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from([ - ser_param( - "persistent_root", - &self.persistent_root, - "Persistent root for proof storage.", - ParamPrivacyInput::Public, - ), - ser_param( - "cache_size", - &self.cache_size, - "Number of proofs to cache in memory.", - ParamPrivacyInput::Public, - ), - ]) - } -} diff --git a/crates/apollo_reverts/src/lib.rs b/crates/apollo_reverts/src/lib.rs index 87d7c10ea9f..d0c6c1127c8 100644 --- a/crates/apollo_reverts/src/lib.rs +++ b/crates/apollo_reverts/src/lib.rs @@ -1,8 +1,5 @@ -use std::collections::BTreeMap; use std::future::Future; -use apollo_config::dumping::{ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use apollo_metrics::metrics::MetricGauge; #[cfg(feature = "os_input")] use apollo_storage::accessed_keys::AccessedKeysStorageWriter; @@ -94,27 +91,6 @@ impl Default for RevertConfig { } } -impl SerializeConfig for RevertConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "revert_up_to_and_including", - &self.revert_up_to_and_including, - "The component will revert blocks up to this block number (including).", - // Use this configuration carefully to prevent significant revert operations and - // data loss - ParamPrivacyInput::Public, - ), - ser_param( - "should_revert", - &self.should_revert, - "If set true, the component would revert blocks and do nothing else.", - ParamPrivacyInput::Public, - ), - ]) - } -} - pub struct RevertComponentData { pub name: &'static str, pub revert_metric: MetricGauge, diff --git a/crates/apollo_rpc/src/lib.rs b/crates/apollo_rpc/src/lib.rs index d15a48ed67d..e349bb79535 100644 --- a/crates/apollo_rpc/src/lib.rs +++ b/crates/apollo_rpc/src/lib.rs @@ -14,14 +14,11 @@ mod test_utils; mod v0_8; mod version_config; -use std::collections::BTreeMap; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::sync::Arc; use apollo_class_manager_types::SharedClassManagerClient; -use apollo_config::dumping::{prepend_sub_config_name, ser_param, SerializeConfig}; use apollo_config::validators::validate_ascii; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use apollo_rpc_execution::ExecutionConfig; use apollo_starknet_client::reader::PendingData; use apollo_starknet_client::writer::StarknetGatewayClient; @@ -101,70 +98,6 @@ impl Default for RpcConfig { } } -impl SerializeConfig for RpcConfig { - fn dump(&self) -> BTreeMap { - let mut self_params_dump = BTreeMap::from_iter([ - ser_param( - "chain_id", - &self.chain_id, - "The chain to follow. For more details see https://docs.starknet.io/learn/cheatsheets/transactions-reference#chain-id.", - ParamPrivacyInput::Public, - ), - ser_param( - "ip", - &self.ip.to_string(), "The JSON RPC server ip.", - ParamPrivacyInput::Public - ), - ser_param( - "port", - &self.port, - "The JSON RPC server port.", - ParamPrivacyInput::Public - ), - ser_param( - "max_events_chunk_size", - &self.max_events_chunk_size, - "Maximum chunk size supported by the node in get_events requests.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_events_keys", - &self.max_events_keys, - "Maximum number of keys supported by the node in get_events requests.", - ParamPrivacyInput::Public, - ), - ser_param( - "collect_metrics", - &self.collect_metrics, - "If true, collect metrics for the rpc.", - ParamPrivacyInput::Public, - ), - ser_param( - "starknet_url", - &self.starknet_url, - "URL for communicating with Starknet in write_api methods.", - ParamPrivacyInput::Public, - ), - ]); - - self_params_dump - .append(&mut prepend_sub_config_name(self.execution_config.dump(), "execution_config")); - let mut retry_config_dump = prepend_sub_config_name( - self.apollo_gateway_retry_config.dump(), - "apollo_gateway_retry_config", - ); - for param in retry_config_dump.values_mut() { - param.description = format!( - "For communicating with Starknet gateway, {}{}", - param.description[0..1].to_lowercase(), - ¶m.description[1..] - ); - } - self_params_dump.append(&mut retry_config_dump); - self_params_dump - } -} - fn internal_server_error(err: impl std::fmt::Display) -> ErrorObjectOwned { error!("{}: {}", INTERNAL_ERROR_MSG, err); ErrorObjectOwned::owned(InternalError.code(), INTERNAL_ERROR_MSG, None::<()>) diff --git a/crates/apollo_rpc_execution/src/lib.rs b/crates/apollo_rpc_execution/src/lib.rs index 6dc9052b612..5c7594fc892 100644 --- a/crates/apollo_rpc_execution/src/lib.rs +++ b/crates/apollo_rpc_execution/src/lib.rs @@ -19,12 +19,9 @@ pub mod testing_instances; pub mod objects; use std::cell::Cell; -use std::collections::BTreeMap; use std::sync::{Arc, LazyLock}; use apollo_class_manager_types::SharedClassManagerClient; -use apollo_config::dumping::{ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use apollo_storage::header::HeaderStorageReader; use apollo_storage::{StorageError, StorageReader}; use blockifier::blockifier::block::pre_process_block; @@ -141,31 +138,6 @@ impl Default for ExecutionConfig { } } -impl SerializeConfig for ExecutionConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "strk_fee_contract_address", - &self.strk_fee_contract_address, - "The strk fee token address to receive fees", - ParamPrivacyInput::Public, - ), - ser_param( - "eth_fee_contract_address", - &self.eth_fee_contract_address, - "The eth fee token address to receive fees", - ParamPrivacyInput::Public, - ), - ser_param( - "default_initial_gas_cost", - &self.default_initial_gas_cost, - "The initial gas cost for a transaction", - ParamPrivacyInput::Public, - ), - ]) - } -} - #[allow(missing_docs)] /// The error type for the execution module. #[derive(thiserror::Error, Debug)] diff --git a/crates/apollo_sierra_compilation_config/src/config.rs b/crates/apollo_sierra_compilation_config/src/config.rs index b58a82965b6..08d088405fc 100644 --- a/crates/apollo_sierra_compilation_config/src/config.rs +++ b/crates/apollo_sierra_compilation_config/src/config.rs @@ -1,7 +1,3 @@ -use std::collections::BTreeMap; - -use apollo_config::dumping::{ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use validator::Validate; @@ -33,34 +29,3 @@ impl Default for SierraCompilationConfig { } } } - -impl SerializeConfig for SierraCompilationConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from([ - ser_param( - "max_bytecode_size", - &self.max_bytecode_size, - "Limitation of compiled CASM bytecode size (felts).", - ParamPrivacyInput::Public, - ), - ser_param( - "max_cpu_time", - &self.max_cpu_time, - "Limitation of compilation cpu time (seconds).", - ParamPrivacyInput::Public, - ), - ser_param( - "audited_libfuncs_only", - &self.audited_libfuncs_only, - "If true, restrict to audited libfuncs. Otherwise allow all.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_memory_usage", - &self.max_memory_usage, - "Limitation of compilation process's virtual memory (bytes).", - ParamPrivacyInput::Public, - ), - ]) - } -} diff --git a/crates/apollo_staking_config/src/config.rs b/crates/apollo_staking_config/src/config.rs index 8bd88fca58b..d3bb9207840 100644 --- a/crates/apollo_staking_config/src/config.rs +++ b/crates/apollo_staking_config/src/config.rs @@ -1,12 +1,3 @@ -use std::collections::BTreeMap; - -use apollo_config::dumping::{ - prepend_sub_config_name, - ser_optional_param, - ser_param, - SerializeConfig, -}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::de::Error as DeError; use serde::ser::Error as SerError; use serde::{Deserialize, Deserializer, Serialize, Serializer}; @@ -166,15 +157,6 @@ pub struct StakingManagerConfig { pub static_config: StakingManagerStaticConfig, } -impl SerializeConfig for StakingManagerConfig { - fn dump(&self) -> BTreeMap { - let mut config = BTreeMap::new(); - config.extend(prepend_sub_config_name(self.dynamic_config.dump(), "dynamic_config")); - config.extend(prepend_sub_config_name(self.static_config.dump(), "static_config")); - config - } -} - #[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Validate)] pub struct StakingManagerDynamicConfig { // Defines the default committee configuration (size and stakers) that applies to all epochs. @@ -203,25 +185,6 @@ impl Default for StakingManagerDynamicConfig { } } -impl SerializeConfig for StakingManagerDynamicConfig { - fn dump(&self) -> BTreeMap { - let mut config = BTreeMap::from_iter([ser_param( - "default_committee", - &self.default_committee, - "Defines the default committee configuration (size and stakers) for all epochs.", - ParamPrivacyInput::Public, - )]); - config.extend(ser_optional_param( - &self.override_committee, - self.default_committee.clone(), - "override_committee", - "Optional override configuration that takes precedence over default_committee.", - ParamPrivacyInput::Public, - )); - config - } -} - #[derive(Debug, Deserialize, Serialize, Clone, PartialEq)] pub struct StakingManagerStaticConfig { pub max_cached_epochs: usize, @@ -233,23 +196,3 @@ impl Default for StakingManagerStaticConfig { Self { max_cached_epochs: 10, use_only_actual_proposer_selection: false } } } - -impl SerializeConfig for StakingManagerStaticConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "max_cached_epochs", - &self.max_cached_epochs, - "The maximum number of epochs to cache.", - ParamPrivacyInput::Public, - ), - ser_param( - "use_only_actual_proposer_selection", - &self.use_only_actual_proposer_selection, - "If true, get_proposer will use the same deterministic round-robin selection as \ - get_actual_proposer.", - ParamPrivacyInput::Public, - ), - ]) - } -} diff --git a/crates/apollo_starknet_client/src/retry.rs b/crates/apollo_starknet_client/src/retry.rs index 003a091cc59..509a07828f9 100644 --- a/crates/apollo_starknet_client/src/retry.rs +++ b/crates/apollo_starknet_client/src/retry.rs @@ -2,13 +2,10 @@ #[path = "retry_test.rs"] mod retry_test; -use std::collections::BTreeMap; use std::fmt::Debug; use std::iter::Take; use std::time::Duration; -use apollo_config::dumping::{ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use tokio_retry::strategy::ExponentialBackoff; use tokio_retry::{Action, Condition, RetryIf}; @@ -25,32 +22,6 @@ pub struct RetryConfig { pub max_retries: usize, } -impl SerializeConfig for RetryConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "retry_base_millis", - &self.retry_base_millis, - "Base waiting time after a failed request. After that, the time increases \ - exponentially.", - ParamPrivacyInput::Public, - ), - ser_param( - "retry_max_delay_millis", - &self.retry_max_delay_millis, - "Max waiting time after a failed request.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_retries", - &self.max_retries, - "Maximum number of retries before the node stops retrying.", - ParamPrivacyInput::Public, - ), - ]) - } -} - /// A utility for retrying actions with a configurable backoff and error filter. Uses an /// [`ExponentialBackoff`] strategy. pub struct Retry { diff --git a/crates/apollo_state_sync_config/src/config.rs b/crates/apollo_state_sync_config/src/config.rs index 2dd4694cb70..d8c7471b4ad 100644 --- a/crates/apollo_state_sync_config/src/config.rs +++ b/crates/apollo_state_sync_config/src/config.rs @@ -1,10 +1,7 @@ -use std::collections::BTreeMap; use std::path::PathBuf; use std::result; use apollo_central_sync_config::config::{CentralSourceConfig, SyncConfig}; -use apollo_config::dumping::{prepend_sub_config_name, ser_optional_sub_config, SerializeConfig}; -use apollo_config::{ParamPath, SerializedParam}; use apollo_network::NetworkConfig; use apollo_p2p_sync_config::config::P2pSyncClientConfig; use apollo_reverts::RevertConfig; @@ -40,29 +37,6 @@ pub struct StateSyncStaticConfig { pub storage_reader_server_static_config: StorageReaderServerStaticConfig, } -impl SerializeConfig for StateSyncStaticConfig { - fn dump(&self) -> BTreeMap { - let mut config = BTreeMap::new(); - config.extend(prepend_sub_config_name(self.storage_config.dump(), "storage_config")); - config.extend(ser_optional_sub_config(&self.network_config, "network_config")); - config.extend(prepend_sub_config_name(self.revert_config.dump(), "revert_config")); - config.extend(prepend_sub_config_name(self.rpc_config.dump(), "rpc_config")); - config.extend(prepend_sub_config_name( - self.storage_reader_server_static_config.dump(), - "storage_reader_server_static_config", - )); - config.extend(ser_optional_sub_config( - &self.p2p_sync_client_config, - "p2p_sync_client_config", - )); - config.extend(ser_optional_sub_config( - &self.central_sync_client_config, - "central_sync_client_config", - )); - config - } -} - impl Default for StateSyncStaticConfig { fn default() -> Self { Self { @@ -88,15 +62,6 @@ pub struct StateSyncDynamicConfig { pub storage_reader_server_dynamic_config: StorageReaderServerDynamicConfig, } -impl SerializeConfig for StateSyncDynamicConfig { - fn dump(&self) -> BTreeMap { - prepend_sub_config_name( - self.storage_reader_server_dynamic_config.dump(), - "storage_reader_server_dynamic_config", - ) - } -} - #[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Validate)] pub struct StateSyncConfig { #[validate(nested)] @@ -105,15 +70,6 @@ pub struct StateSyncConfig { pub dynamic_config: StateSyncDynamicConfig, } -impl SerializeConfig for StateSyncConfig { - fn dump(&self) -> BTreeMap { - let mut config = BTreeMap::new(); - config.extend(prepend_sub_config_name(self.static_config.dump(), "static_config")); - config.extend(prepend_sub_config_name(self.dynamic_config.dump(), "dynamic_config")); - config - } -} - fn validate_state_sync_static_config( config: &StateSyncStaticConfig, ) -> result::Result<(), ValidationError> { @@ -133,15 +89,3 @@ pub struct CentralSyncClientConfig { pub sync_config: SyncConfig, pub central_source_config: CentralSourceConfig, } - -impl SerializeConfig for CentralSyncClientConfig { - fn dump(&self) -> BTreeMap { - vec![ - prepend_sub_config_name(self.sync_config.dump(), "sync_config"), - prepend_sub_config_name(self.central_source_config.dump(), "central_source_config"), - ] - .into_iter() - .flatten() - .collect() - } -} diff --git a/crates/apollo_storage/src/db/mod.rs b/crates/apollo_storage/src/db/mod.rs index 2fb62dbbf23..1daccd358b3 100644 --- a/crates/apollo_storage/src/db/mod.rs +++ b/crates/apollo_storage/src/db/mod.rs @@ -22,16 +22,13 @@ pub mod serialization; pub(crate) mod table_types; use std::borrow::Cow; -use std::collections::BTreeMap; use std::fmt::Debug; use std::marker::PhantomData; use std::path::PathBuf; use std::result; use std::sync::Arc; -use apollo_config::dumping::{ser_param, SerializeConfig}; use apollo_config::validators::validate_ascii; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use apollo_proc_macros::latency_histogram; use libmdbx::{DatabaseOptions, Mode, PageSize, ReadWriteOptions, WriteMap}; use serde::{Deserialize, Serialize}; @@ -93,58 +90,6 @@ impl Default for DbConfig { } } -impl SerializeConfig for DbConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "path_prefix", - &self.path_prefix, - "Prefix of the path of the node's storage directory, the storage file path \ - will be /. The path is not created automatically.", - ParamPrivacyInput::Public, - ), - ser_param( - "chain_id", - &self.chain_id, - "The chain to follow. For more details see https://docs.starknet.io/learn/cheatsheets/transactions-reference#chain-id.", - ParamPrivacyInput::Public, - ), - ser_param( - "enforce_file_exists", - &self.enforce_file_exists, - "Whether to enforce that the path exists. If true, `open_env` fails when the \ - mdbx.dat file does not exist.", - ParamPrivacyInput::Public, - ), - ser_param( - "min_size", - &self.min_size, - "The minimum size of the node's storage in bytes.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_size", - &self.max_size, - "The maximum size of the node's storage in bytes.", - ParamPrivacyInput::Public, - ), - ser_param( - "growth_step", - &self.growth_step, - "The growth step in bytes, must be greater than zero to allow the database to \ - grow.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_readers", - &self.max_readers, - "The maximum number of readers used by the database.", - ParamPrivacyInput::Public, - ), - ]) - } -} - impl DbConfig { /// Returns the path of the database (path prefix, followed by the chain id). pub fn path(&self) -> PathBuf { diff --git a/crates/apollo_storage/src/lib.rs b/crates/apollo_storage/src/lib.rs index b1453bc7ef3..19fbe03a684 100644 --- a/crates/apollo_storage/src/lib.rs +++ b/crates/apollo_storage/src/lib.rs @@ -128,8 +128,6 @@ use std::fs; use std::num::NonZeroUsize; use std::sync::{Arc, Mutex, MutexGuard}; -use apollo_config::dumping::{prepend_sub_config_name, ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use apollo_metrics::metrics::MetricGauge; use apollo_proc_macros::{latency_histogram, sequencer_latency_histogram}; use body::events::EventIndex; @@ -547,25 +545,6 @@ impl Default for BatchConfig { } } -impl SerializeConfig for BatchConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "enabled", - &self.enabled, - "Whether transaction batching is enabled.", - ParamPrivacyInput::Public, - ), - ser_param( - "batch_size", - &self.batch_size, - "Number of logical commits before actual MDBX commit.", - ParamPrivacyInput::Public, - ), - ]) - } -} - impl StorageReader { /// Takes a snapshot of the current state of the storage and returns a [`StorageTxn`] for /// reading data from the storage. @@ -1100,22 +1079,6 @@ pub struct StorageConfig { pub batch_config: BatchConfig, } -impl SerializeConfig for StorageConfig { - fn dump(&self) -> BTreeMap { - let mut dumped_config = BTreeMap::from_iter([ser_param( - "scope", - &self.scope, - "The categories of data saved in storage.", - ParamPrivacyInput::Public, - )]); - dumped_config - .extend(prepend_sub_config_name(self.mmap_file_config.dump(), "mmap_file_config")); - dumped_config.extend(prepend_sub_config_name(self.db_config.dump(), "db_config")); - dumped_config.extend(prepend_sub_config_name(self.batch_config.dump(), "batch_config")); - dumped_config - } -} - /// A struct for the statistics of the tables in the database. #[derive(Serialize, Deserialize, Debug)] pub struct DbStats { diff --git a/crates/apollo_storage/src/mmap_file/mod.rs b/crates/apollo_storage/src/mmap_file/mod.rs index 04d6d49e547..9f4b238b86f 100644 --- a/crates/apollo_storage/src/mmap_file/mod.rs +++ b/crates/apollo_storage/src/mmap_file/mod.rs @@ -7,7 +7,6 @@ #[cfg(test)] mod mmap_file_test; -use std::collections::BTreeMap; use std::fmt::Debug; use std::fs::{File, OpenOptions}; use std::marker::PhantomData; @@ -15,8 +14,6 @@ use std::path::PathBuf; use std::result; use std::sync::{Arc, Mutex}; -use apollo_config::dumping::{ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; #[cfg(test)] use apollo_test_utils::GetTestInstance; use memmap2::{MmapMut, MmapOptions}; @@ -44,32 +41,6 @@ pub struct MmapFileConfig { pub max_object_size: usize, } -impl SerializeConfig for MmapFileConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "max_size", - &self.max_size, - "The maximum size of a memory mapped file in bytes. Must be greater than \ - growth_step.", - ParamPrivacyInput::Public, - ), - ser_param( - "growth_step", - &self.growth_step, - "The growth step in bytes, must be greater than max_object_size.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_object_size", - &self.max_object_size, - "The maximum size of a single object in the file in bytes", - ParamPrivacyInput::Public, - ), - ]) - } -} - impl Default for MmapFileConfig { fn default() -> Self { Self { diff --git a/crates/apollo_storage/src/storage_reader_server.rs b/crates/apollo_storage/src/storage_reader_server.rs index fc960cad0fd..f2815c7d778 100644 --- a/crates/apollo_storage/src/storage_reader_server.rs +++ b/crates/apollo_storage/src/storage_reader_server.rs @@ -1,4 +1,3 @@ -use std::collections::BTreeMap; use std::error::Error; use std::fmt::{Display, Formatter, Result as FmtResult}; use std::io; @@ -6,8 +5,6 @@ use std::marker::PhantomData; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::sync::Arc; -use apollo_config::dumping::{prepend_sub_config_name, ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use async_trait::async_trait; use axum::extract::State; use axum::response::{IntoResponse, Response}; @@ -42,25 +39,6 @@ impl Default for StorageReaderServerStaticConfig { } } -impl SerializeConfig for StorageReaderServerStaticConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "ip", - &self.ip.to_string(), - "The IP address for the storage reader HTTP server.", - ParamPrivacyInput::Public, - ), - ser_param( - "port", - &self.port, - "The port for the storage reader HTTP server.", - ParamPrivacyInput::Public, - ), - ]) - } -} - /// Dynamic configuration for the storage reader server. #[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Validate)] pub struct StorageReaderServerDynamicConfig { @@ -68,17 +46,6 @@ pub struct StorageReaderServerDynamicConfig { pub enable: bool, } -impl SerializeConfig for StorageReaderServerDynamicConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ser_param( - "enable", - &self.enable, - "Whether to enable the storage reader HTTP server.", - ParamPrivacyInput::Public, - )]) - } -} - /// Error returned by [`DynamicConfigProvider`] implementations. #[derive(Debug)] pub struct DynamicConfigError(pub String); @@ -139,14 +106,6 @@ impl ServerConfig { } } -impl SerializeConfig for ServerConfig { - fn dump(&self) -> BTreeMap { - let mut dump = prepend_sub_config_name(self.static_config.dump(), "static_config"); - dump.append(&mut prepend_sub_config_name(self.dynamic_config.dump(), "dynamic_config")); - dump - } -} - #[async_trait] /// Handler trait for processing storage reader requests. pub trait StorageReaderServerHandler { diff --git a/crates/blockifier/src/blockifier/config.rs b/crates/blockifier/src/blockifier/config.rs index 7e941bccac6..d30092f3b54 100644 --- a/crates/blockifier/src/blockifier/config.rs +++ b/crates/blockifier/src/blockifier/config.rs @@ -1,8 +1,4 @@ -use std::collections::BTreeMap; - use apollo_compile_to_native_types::SierraCompilationConfig; -use apollo_config::dumping::{prepend_sub_config_name, ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::de::{self, Deserializer}; use serde::ser::Serializer; use serde::{Deserialize, Serialize}; @@ -45,20 +41,6 @@ impl Default for TransactionExecutorConfig { } } -impl SerializeConfig for TransactionExecutorConfig { - fn dump(&self) -> BTreeMap { - let mut dump = - prepend_sub_config_name(self.concurrency_config.dump(), "concurrency_config"); - dump.append(&mut BTreeMap::from([ser_param( - "stack_size", - &self.stack_size, - "The thread stack size (proportional to the maximal gas of a transaction).", - ParamPrivacyInput::Public, - )])); - dump - } -} - #[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)] pub struct ConcurrencyConfig { pub enabled: bool, @@ -75,31 +57,6 @@ impl ConcurrencyConfig { } } -impl SerializeConfig for ConcurrencyConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "enabled", - &self.enabled, - "Enables concurrency of transaction execution.", - ParamPrivacyInput::Public, - ), - ser_param( - "n_workers", - &self.n_workers, - "Number of parallel transaction execution workers.", - ParamPrivacyInput::Public, - ), - ser_param( - "chunk_size", - &self.chunk_size, - "The size of the transaction chunk executed in parallel.", - ParamPrivacyInput::Public, - ), - ]) - } -} - #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct WorkerPoolConfig { pub n_workers: usize, @@ -118,25 +75,6 @@ impl Default for WorkerPoolConfig { } } -impl SerializeConfig for WorkerPoolConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "n_workers", - &self.n_workers, - "Number of parallel transaction execution workers.", - ParamPrivacyInput::Public, - ), - ser_param( - "stack_size", - &self.stack_size, - "The thread stack size (proportional to the maximal gas of a transaction).", - ParamPrivacyInput::Public, - ), - ]) - } -} - #[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Validate)] pub struct ContractClassManagerConfig { pub cairo_native_run_config: CairoNativeRunConfig, @@ -165,47 +103,12 @@ impl ContractClassManagerConfig { } } -impl SerializeConfig for ContractClassManagerConfig { - fn dump(&self) -> BTreeMap { - let mut dump = BTreeMap::from_iter([ser_param( - "contract_cache_size", - &self.contract_cache_size, - "The size of the global contract cache.", - ParamPrivacyInput::Public, - )]); - dump.append(&mut prepend_sub_config_name( - self.cairo_native_run_config.dump(), - "cairo_native_run_config", - )); - dump.append(&mut prepend_sub_config_name( - self.native_compiler_config.dump(), - "native_compiler_config", - )); - dump - } -} - #[derive(Clone, Debug, PartialEq)] pub enum NativeClassesWhitelist { All, Limited(Vec), } -impl NativeClassesWhitelist { - pub const SER_PARAM_DESCRIPTION: &str = "Specifies whether to execute all class hashes or \ - only specific ones using Cairo native. If limited, a \ - specific list of class hashes is provided."; - - pub fn ser_param(&self) -> (String, SerializedParam) { - ser_param( - "native_classes_whitelist", - &self, - Self::SER_PARAM_DESCRIPTION, - ParamPrivacyInput::Public, - ) - } -} - impl<'de> Deserialize<'de> for NativeClassesWhitelist { fn deserialize(deserializer: D) -> Result where @@ -284,33 +187,6 @@ impl CairoNativeRunConfig { } } -impl SerializeConfig for CairoNativeRunConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "cairo_native_mode", - &self.cairo_native_mode, - "Cairo native execution mode. 'off' disables native execution, \ - 'wait_on_compilation' compiles synchronously, and 'lazy_compilation' compiles \ - asynchronously.", - ParamPrivacyInput::Public, - ), - ser_param( - "channel_size", - &self.channel_size, - "The size of the compilation request channel.", - ParamPrivacyInput::Public, - ), - ser_param( - "panic_on_compilation_failure", - &self.panic_on_compilation_failure, - "Whether to panic on compilation failure.", - ParamPrivacyInput::Public, - ), - ]) - } -} - #[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)] #[serde(rename_all = "snake_case")] pub enum CairoNativeMode { diff --git a/crates/blockifier/src/blockifier_versioned_constants.rs b/crates/blockifier/src/blockifier_versioned_constants.rs index c49305b48dc..e6f12f0a660 100644 --- a/crates/blockifier/src/blockifier_versioned_constants.rs +++ b/crates/blockifier/src/blockifier_versioned_constants.rs @@ -3,8 +3,6 @@ use std::io; use std::path::Path; use std::sync::Arc; -use apollo_config::dumping::{ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use cairo_vm::types::builtin_name::BuiltinName; use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use num_rational::Ratio; @@ -1500,34 +1498,3 @@ impl Default for VersionedConstantsOverrides { } } } - -impl SerializeConfig for VersionedConstantsOverrides { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "validate_max_n_steps", - &self.validate_max_n_steps, - "Maximum number of steps the validation function is allowed to run.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_recursion_depth", - &self.max_recursion_depth, - "Maximum recursion depth for nested calls during blockifier validation.", - ParamPrivacyInput::Public, - ), - ser_param( - "invoke_tx_max_n_steps", - &self.invoke_tx_max_n_steps, - "Maximum number of steps the invoke function is allowed to run.", - ParamPrivacyInput::Public, - ), - ser_param( - "max_n_events", - &self.max_n_events, - "Maximum number of events that can be emitted from the transaction.", - ParamPrivacyInput::Public, - ), - ]) - } -} diff --git a/crates/blockifier/src/bouncer.rs b/crates/blockifier/src/bouncer.rs index be1feed7865..eac586ee36d 100644 --- a/crates/blockifier/src/bouncer.rs +++ b/crates/blockifier/src/bouncer.rs @@ -1,8 +1,6 @@ use std::collections::{BTreeMap, HashMap, HashSet}; use std::num::NonZeroU64; -use apollo_config::dumping::{prepend_sub_config_name, ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use cairo_vm::types::builtin_name::BuiltinName; use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use serde::{Deserialize, Serialize}; @@ -137,18 +135,6 @@ impl BouncerConfig { } } -impl SerializeConfig for BouncerConfig { - fn dump(&self) -> BTreeMap { - let mut dump = - prepend_sub_config_name(self.block_max_capacity.dump(), "block_max_capacity"); - dump.append(&mut prepend_sub_config_name( - self.builtin_instance_limits.dump(), - "builtin_instance_limits", - )); - dump - } -} - #[cfg_attr(any(test, feature = "testing"), derive(derive_more::Add, derive_more::AddAssign))] #[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] /// Represents the execution resources counted throughout block creation. @@ -230,61 +216,6 @@ impl Default for BouncerWeights { } } -impl SerializeConfig for BouncerWeights { - fn dump(&self) -> BTreeMap { - let mut dump = BTreeMap::from([ser_param( - "l1_gas", - &self.l1_gas, - "An upper bound on the total l1_gas used in a block.", - ParamPrivacyInput::Public, - )]); - dump.append(&mut BTreeMap::from([ser_param( - "message_segment_length", - &self.message_segment_length, - "An upper bound on the message segment length in a block.", - ParamPrivacyInput::Public, - )])); - dump.append(&mut BTreeMap::from([ser_param( - "n_events", - &self.n_events, - "An upper bound on the total number of events generated in a block.", - ParamPrivacyInput::Public, - )])); - dump.append(&mut BTreeMap::from([ser_param( - "state_diff_size", - &self.state_diff_size, - "An upper bound on the total state diff size in a block.", - ParamPrivacyInput::Public, - )])); - dump.append(&mut BTreeMap::from([ser_param( - "sierra_gas", - &self.sierra_gas, - "An upper bound on the total sierra_gas used in a block.", - ParamPrivacyInput::Public, - )])); - dump.append(&mut BTreeMap::from([ser_param( - "n_txs", - &self.n_txs, - "An upper bound on the total number of transactions in a block.", - ParamPrivacyInput::Public, - )])); - dump.append(&mut BTreeMap::from([ser_param( - "proving_gas", - &self.proving_gas, - "An upper bound on the total builtins and steps gas usage used in a block.", - ParamPrivacyInput::Public, - )])); - dump.append(&mut BTreeMap::from([ser_param( - "receipt_l2_gas", - &self.receipt_l2_gas, - "An upper bound on the total receipt-based L2 gas in a block. Includes execution gas \ - plus state allocation costs. Should equal max_block_size.", - ParamPrivacyInput::Public, - )])); - dump - } -} - impl std::fmt::Display for BouncerWeights { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( @@ -490,79 +421,6 @@ impl Default for BuiltinInstanceLimits { } } -impl SerializeConfig for BuiltinInstanceLimits { - fn dump(&self) -> BTreeMap { - let mut dump = BTreeMap::from([ser_param( - "pedersen", - &self.pedersen, - "Instance limit for the pedersen builtin.", - ParamPrivacyInput::Public, - )]); - dump.append(&mut BTreeMap::from([ser_param( - "range_check", - &self.range_check, - "Instance limit for the range_check builtin.", - ParamPrivacyInput::Public, - )])); - dump.append(&mut BTreeMap::from([ser_param( - "range_check96", - &self.range_check96, - "Instance limit for the range_check96 builtin.", - ParamPrivacyInput::Public, - )])); - dump.append(&mut BTreeMap::from([ser_param( - "poseidon", - &self.poseidon, - "Instance limit for the poseidon builtin.", - ParamPrivacyInput::Public, - )])); - dump.append(&mut BTreeMap::from([ser_param( - "ecdsa", - &self.ecdsa, - "Instance limit for the ecdsa builtin.", - ParamPrivacyInput::Public, - )])); - dump.append(&mut BTreeMap::from([ser_param( - "ecop", - &self.ecop, - "Instance limit for the ec_op builtin.", - ParamPrivacyInput::Public, - )])); - dump.append(&mut BTreeMap::from([ser_param( - "add_mod", - &self.add_mod, - "Instance limit for the add_mod builtin.", - ParamPrivacyInput::Public, - )])); - dump.append(&mut BTreeMap::from([ser_param( - "mul_mod", - &self.mul_mod, - "Instance limit for the mul_mod builtin.", - ParamPrivacyInput::Public, - )])); - dump.append(&mut BTreeMap::from([ser_param( - "keccak", - &self.keccak, - "Instance limit for the keccak builtin.", - ParamPrivacyInput::Public, - )])); - dump.append(&mut BTreeMap::from([ser_param( - "bitwise", - &self.bitwise, - "Instance limit for the bitwise builtin.", - ParamPrivacyInput::Public, - )])); - dump.append(&mut BTreeMap::from([ser_param( - "blake", - &self.blake, - "Instance limit for the blake opcode.", - ParamPrivacyInput::Public, - )])); - - dump - } -} - #[derive(Debug, PartialEq)] #[cfg_attr(test, derive(Clone))] pub struct Bouncer { diff --git a/crates/blockifier/src/context.rs b/crates/blockifier/src/context.rs index 154d76b6d17..2b1f2c5de18 100644 --- a/crates/blockifier/src/context.rs +++ b/crates/blockifier/src/context.rs @@ -1,8 +1,5 @@ -use std::collections::BTreeMap; use std::sync::{Arc, OnceLock}; -use apollo_config::dumping::{prepend_sub_config_name, ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use starknet_api::block::{BlockInfo, BlockNumber, BlockTimestamp, FeeType, GasPriceVector}; use starknet_api::core::{ChainId, ContractAddress, OsChainInfo}; @@ -265,25 +262,6 @@ impl Default for ChainInfo { } } -impl SerializeConfig for ChainInfo { - fn dump(&self) -> BTreeMap { - let members = BTreeMap::from_iter([ser_param( - "chain_id", - &self.chain_id, - "The chain ID of the StarkNet chain.", - ParamPrivacyInput::Public, - )]); - - vec![ - members, - prepend_sub_config_name(self.fee_token_addresses.dump(), "fee_token_addresses"), - ] - .into_iter() - .flatten() - .collect() - } -} - #[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)] pub struct FeeTokenAddresses { pub strk_fee_token_address: ContractAddress, @@ -298,22 +276,3 @@ impl FeeTokenAddresses { } } } - -impl SerializeConfig for FeeTokenAddresses { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "strk_fee_token_address", - &self.strk_fee_token_address, - "Address of the STRK fee token.", - ParamPrivacyInput::Public, - ), - ser_param( - "eth_fee_token_address", - &self.eth_fee_token_address, - "Address of the ETH fee token.", - ParamPrivacyInput::Public, - ), - ]) - } -} diff --git a/crates/blockifier_reexecution/src/state_reader/config.rs b/crates/blockifier_reexecution/src/state_reader/config.rs index 16297084f35..6499f46ff11 100644 --- a/crates/blockifier_reexecution/src/state_reader/config.rs +++ b/crates/blockifier_reexecution/src/state_reader/config.rs @@ -1,7 +1,3 @@ -use std::collections::BTreeMap; - -use apollo_config::dumping::{ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use validator::Validate; @@ -31,17 +27,3 @@ impl RpcStateReaderConfig { Self::from_url("http://localhost:8080".to_string()) } } - -impl SerializeConfig for RpcStateReaderConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param("url", &self.url, "The url of the rpc server.", ParamPrivacyInput::Public), - ser_param( - "json_rpc_version", - &self.json_rpc_version, - "The json rpc version.", - ParamPrivacyInput::Public, - ), - ]) - } -} diff --git a/crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs b/crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs index fda31796470..66542606e13 100644 --- a/crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs +++ b/crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs @@ -1,4 +1,3 @@ -use std::collections::BTreeMap; use std::future::IntoFuture; use std::ops::RangeInclusive; use std::time::Duration; @@ -19,11 +18,8 @@ use apollo_config::converters::{ deserialize_vec, serialize_duration_as_milliseconds, serialize_duration_as_seconds, - serialize_slice, }; -use apollo_config::dumping::{ser_param, SerializeConfig}; use apollo_config::secrets::Sensitive; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use async_trait::async_trait; use serde::{Deserialize, Serialize}; use starknet_api::block::{BlockHash, BlockHashAndNumber, BlockNumber}; @@ -465,64 +461,6 @@ impl Validate for EthereumBaseLayerConfig { } } -impl SerializeConfig for EthereumBaseLayerConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "ordered_l1_endpoint_urls", - &serialize_slice( - &self - .ordered_l1_endpoint_urls - .iter() - .map(|url| url.peek_secret().clone()) - .collect::>(), - ), - "An ordered list of URLs for communicating with Ethereum. The list is used in \ - order, cyclically, switching if the current one is non-operational.", - ParamPrivacyInput::Private, - ), - ser_param( - "starknet_contract_address", - &self.starknet_contract_address.to_string(), - "Starknet contract address in ethereum.", - ParamPrivacyInput::Public, - ), - ser_param( - "fusaka_no_bpo_start_block_number", - &self.fusaka_no_bpo_start_block_number, - "The block number at which the Fusaka upgrade was deployed (not including any BPO \ - updates).", - ParamPrivacyInput::Public, - ), - ser_param( - "bpo1_start_block_number", - &self.bpo1_start_block_number, - "The block number at which BPO1 update was deployed.", - ParamPrivacyInput::Public, - ), - ser_param( - "bpo2_start_block_number", - &self.bpo2_start_block_number, - "The block number at which BPO2 update was deployed.", - ParamPrivacyInput::Public, - ), - ser_param( - "timeout_millis", - &self.timeout_millis.as_millis(), - "The timeout (milliseconds) for a query of the L1 base layer", - ParamPrivacyInput::Public, - ), - ser_param( - "retry_primary_interval_seconds", - &self.retry_primary_interval_seconds.as_secs(), - "The interval (seconds) after which the next base-layer access retries the \ - primary (first) endpoint.", - ParamPrivacyInput::Public, - ), - ]) - } -} - impl Default for EthereumBaseLayerConfig { fn default() -> Self { let starknet_contract_address = diff --git a/crates/starknet_committer/src/block_committer/input.rs b/crates/starknet_committer/src/block_committer/input.rs index 272bd30e22a..5af98dcefb8 100644 --- a/crates/starknet_committer/src/block_committer/input.rs +++ b/crates/starknet_committer/src/block_committer/input.rs @@ -1,8 +1,6 @@ -use std::collections::{BTreeMap, HashMap, HashSet}; +use std::collections::{HashMap, HashSet}; use std::fmt::Debug; -use apollo_config::dumping::{ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use starknet_api::core::{ClassHash, ContractAddress, Nonce, PatriciaKey}; use starknet_api::state::{StorageKey, ThinStateDiff}; @@ -181,25 +179,6 @@ impl ReaderConfig { } } -impl SerializeConfig for ReaderConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ - ser_param( - "warn_on_trivial_modifications", - &self.warn_on_trivial_modifications, - "Whether to warn on trivial state update.", - ParamPrivacyInput::Public, - ), - ser_param( - "build_storage_tries_concurrently", - &self.build_storage_tries_concurrently, - "Whether to build the storage tries concurrently or sequentially.", - ParamPrivacyInput::Public, - ), - ]) - } -} - /// Defines the context type for the input of the committer. pub trait InputContext: Clone {} diff --git a/crates/starknet_patricia_storage/src/map_storage.rs b/crates/starknet_patricia_storage/src/map_storage.rs index e5e5ca374f7..295fbd4e7b0 100644 --- a/crates/starknet_patricia_storage/src/map_storage.rs +++ b/crates/starknet_patricia_storage/src/map_storage.rs @@ -1,10 +1,7 @@ -use std::collections::BTreeMap; use std::fmt::Display; use std::num::NonZeroUsize; use std::sync::atomic::{AtomicU64, Ordering}; -use apollo_config::dumping::{prepend_sub_config_name, ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use async_trait::async_trait; use lru::LruCache; use serde::{Deserialize, Serialize}; @@ -149,34 +146,6 @@ impl Validate for CachedStorageConfig SerializeConfig - for CachedStorageConfig -{ - fn dump(&self) -> BTreeMap { - let mut cached_storage_config = BTreeMap::from([ - ser_param( - "cache_size", - &self.cache_size, - "Max number of entries in the cache", - ParamPrivacyInput::Public, - ), - ser_param( - "include_inner_stats", - &self.include_inner_stats, - "If true, the inner stats are included when collecting statistics", - ParamPrivacyInput::Public, - ), - ]); - - cached_storage_config.extend(prepend_sub_config_name( - self.inner_storage_config.dump(), - "inner_storage_config", - )); - - cached_storage_config - } -} - impl StorageConfigTrait for CachedStorageConfig { diff --git a/crates/starknet_patricia_storage/src/rocksdb_storage.rs b/crates/starknet_patricia_storage/src/rocksdb_storage.rs index b794804059e..661a83b4a38 100644 --- a/crates/starknet_patricia_storage/src/rocksdb_storage.rs +++ b/crates/starknet_patricia_storage/src/rocksdb_storage.rs @@ -1,10 +1,7 @@ use core::fmt; -use std::collections::BTreeMap; use std::path::Path; use std::sync::Arc; -use apollo_config::dumping::{ser_param, SerializeConfig}; -use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use rust_rocksdb::statistics::StatsLevel; use rust_rocksdb::{ BlockBasedIndexType, @@ -186,79 +183,6 @@ impl Validate for RocksDbStorageConfig { } } -impl SerializeConfig for RocksDbStorageConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::from([ - ser_param( - "num_threads", - &self.num_threads, - "Number of threads for parallelism", - ParamPrivacyInput::Public, - ), - ser_param( - "max_background_jobs", - &self.max_background_jobs, - "Maximum number of background compaction and flush jobs", - ParamPrivacyInput::Public, - ), - ser_param( - "bytes_per_sync", - &self.bytes_per_sync, - "Bytes to sync to disk incrementally during writes", - ParamPrivacyInput::Public, - ), - ser_param( - "write_buffer_size", - &self.write_buffer_size, - "Amount of data to build up in memory before writing to disk", - ParamPrivacyInput::Public, - ), - ser_param( - "max_write_buffers", - &self.max_write_buffers, - "Maximum number of write buffers (memtables)", - ParamPrivacyInput::Public, - ), - ser_param( - "max_subcompactions", - &self.max_subcompactions, - "Maximum number of subcompactions for parallel compaction", - ParamPrivacyInput::Public, - ), - ser_param( - "cache_size", - &self.cache_size, - "Size of the block cache in bytes", - ParamPrivacyInput::Public, - ), - ser_param( - "bloom_filter_bits", - &self.bloom_filter_bits, - "Number of bits in the bloom filter per key", - ParamPrivacyInput::Public, - ), - ser_param( - "enable_statistics", - &self.enable_statistics, - "Flag that determines whether to enable RocksDB statistics collection", - ParamPrivacyInput::Public, - ), - ser_param( - "use_mmap_reads", - &self.use_mmap_reads, - "Whether to use mmap for reading SST files", - ParamPrivacyInput::Public, - ), - ser_param( - "spawn_blocking_reads", - &self.spawn_blocking_reads, - "Whether to spawn blocking tasks for read operations", - ParamPrivacyInput::Public, - ), - ]) - } -} - impl StorageConfigTrait for RocksDbStorageConfig {} impl RocksDbStorage { diff --git a/crates/starknet_patricia_storage/src/storage_trait.rs b/crates/starknet_patricia_storage/src/storage_trait.rs index c661ed11347..31377905c62 100644 --- a/crates/starknet_patricia_storage/src/storage_trait.rs +++ b/crates/starknet_patricia_storage/src/storage_trait.rs @@ -1,10 +1,8 @@ use std::borrow::Cow; -use std::collections::{BTreeMap, HashMap}; +use std::collections::HashMap; use std::fmt::{Debug, Display}; use std::future::Future; -use apollo_config::dumping::SerializeConfig; -use apollo_config::{ParamPath, SerializedParam}; use async_trait::async_trait; use futures::future::join_all; use serde::{Deserialize, Serialize, Serializer}; @@ -102,7 +100,7 @@ impl Display for NoStats { /// All configuration structs of storage implementations that can be used in apollo must implement /// this trait. pub trait StorageConfigTrait: - Clone + Debug + Serialize + PartialEq + Validate + SerializeConfig + Default + Send + Sync + Clone + Debug + Serialize + PartialEq + Validate + Default + Send + Sync { } @@ -269,12 +267,6 @@ impl Validate for EmptyStorageConfig { } } -impl SerializeConfig for EmptyStorageConfig { - fn dump(&self) -> BTreeMap { - BTreeMap::new() - } -} - impl StorageConfigTrait for EmptyStorageConfig {} /// Dummy storage that does nothing.