From 6e7b1385eb359bd714264a5483095143cb3615f8 Mon Sep 17 00:00:00 2001 From: Lev Roitman Date: Wed, 14 Aug 2024 15:02:14 +0300 Subject: [PATCH] feat: add config template to consensus manager commit-id:13a987cd --- Cargo.lock | 3 +++ crates/consensus_manager/Cargo.toml | 3 +++ crates/consensus_manager/src/config.rs | 30 ++++++++++++++++++++++++++ crates/consensus_manager/src/lib.rs | 1 + 4 files changed, 37 insertions(+) create mode 100644 crates/consensus_manager/src/config.rs diff --git a/Cargo.lock b/Cargo.lock index 5dec8d9a29..e2d260c3aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8870,9 +8870,12 @@ name = "starknet_consensus_manager" version = "0.0.0" dependencies = [ "async-trait", + "papyrus_config", + "serde", "starknet_consensus_manager_types", "starknet_mempool_infra", "tokio", + "validator", ] [[package]] diff --git a/crates/consensus_manager/Cargo.toml b/crates/consensus_manager/Cargo.toml index 7fa57cf38a..2dbaf84219 100644 --- a/crates/consensus_manager/Cargo.toml +++ b/crates/consensus_manager/Cargo.toml @@ -11,6 +11,9 @@ workspace = true [dependencies] async-trait.workspace = true +papyrus_config.workspace = true +serde.workspace = true starknet_consensus_manager_types.workspace = true starknet_mempool_infra.workspace = true tokio.workspace = true +validator.workspace = true diff --git a/crates/consensus_manager/src/config.rs b/crates/consensus_manager/src/config.rs new file mode 100644 index 0000000000..8c05aaf123 --- /dev/null +++ b/crates/consensus_manager/src/config.rs @@ -0,0 +1,30 @@ +use std::collections::BTreeMap; + +use papyrus_config::dumping::{ser_param, SerializeConfig}; +use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; +use serde::{Deserialize, Serialize}; +use validator::Validate; + +/// The consensus manager related configuration. +/// TODO(Lev/Tsabary/Matan): Define actual configuration. +#[derive(Clone, Debug, Serialize, Deserialize, Validate, PartialEq)] +pub struct ConsensusManagerConfig { + pub consensus_config_param_1: usize, +} + +impl SerializeConfig for ConsensusManagerConfig { + fn dump(&self) -> BTreeMap { + BTreeMap::from_iter([ser_param( + "consensus_config_param_1", + &self.consensus_config_param_1, + "The first consensus manager configuration parameter", + ParamPrivacyInput::Public, + )]) + } +} + +impl Default for ConsensusManagerConfig { + fn default() -> Self { + Self { consensus_config_param_1: 1 } + } +} diff --git a/crates/consensus_manager/src/lib.rs b/crates/consensus_manager/src/lib.rs index b2febad068..eac2096a6e 100644 --- a/crates/consensus_manager/src/lib.rs +++ b/crates/consensus_manager/src/lib.rs @@ -1,2 +1,3 @@ pub mod communication; +pub mod config; pub mod consensus_manager;