diff --git a/Cargo.lock b/Cargo.lock index cca27a7f55..e11020ad41 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7316,6 +7316,7 @@ dependencies = [ "thiserror", "tokio", "url", + "validator", ] [[package]] @@ -10726,6 +10727,7 @@ dependencies = [ "futures", "infra_utils", "mempool_test_utils", + "papyrus_base_layer", "papyrus_config", "papyrus_proc_macros", "papyrus_protobuf", diff --git a/config/sequencer/default_config.json b/config/sequencer/default_config.json index 0d3d8ef4d6..31c75a3d44 100644 --- a/config/sequencer/default_config.json +++ b/config/sequencer/default_config.json @@ -1,4 +1,14 @@ { + "base_layer_config.node_url": { + "description": "A required param! Ethereum node URL. A schema to match to Infura node: https://mainnet.infura.io/v3/, but any other node can be used.", + "param_type": "String", + "privacy": "Private" + }, + "base_layer_config.starknet_contract_address": { + "description": "Starknet contract address in ethereum.", + "privacy": "Public", + "value": "0xc662c410C0ECf747543f5bA90660f6ABeBD9C8c4" + }, "batcher_config.block_builder_config.bouncer_config.block_max_capacity.builtin_count.add_mod": { "description": "Max number of add mod builtin usage in a block.", "privacy": "Public", diff --git a/crates/papyrus_base_layer/Cargo.toml b/crates/papyrus_base_layer/Cargo.toml index 3fa0fae8bd..5390e7a576 100644 --- a/crates/papyrus_base_layer/Cargo.toml +++ b/crates/papyrus_base_layer/Cargo.toml @@ -32,6 +32,7 @@ tempfile = { workspace = true, optional = true } thiserror.workspace = true tokio = { workspace = true, features = ["full", "sync"] } url = { workspace = true, features = ["serde"] } +validator.workspace = true [dev-dependencies] ethers-core.workspace = true 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 107321a59e..96bcf04962 100644 --- a/crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs +++ b/crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs @@ -18,6 +18,7 @@ use starknet_api::block::{BlockHash, BlockHashAndNumber, BlockNumber}; use starknet_api::hash::StarkHash; use starknet_api::StarknetApiError; use url::Url; +use validator::Validate; use crate::{BaseLayerContract, L1Event}; @@ -117,7 +118,7 @@ pub enum EthereumBaseLayerError { FeeOutOfRange(alloy_primitives::ruint::FromUintError), } -#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Validate)] pub struct EthereumBaseLayerConfig { pub node_url: Url, pub starknet_contract_address: EthereumContractAddress, diff --git a/crates/starknet_sequencer_node/Cargo.toml b/crates/starknet_sequencer_node/Cargo.toml index 636b021f31..6b5c7f6df3 100644 --- a/crates/starknet_sequencer_node/Cargo.toml +++ b/crates/starknet_sequencer_node/Cargo.toml @@ -17,6 +17,7 @@ clap.workspace = true const_format.workspace = true futures.workspace = true infra_utils.workspace = true +papyrus_base_layer.workspace = true papyrus_config.workspace = true papyrus_proc_macros = { workspace = true, optional = true } papyrus_protobuf.workspace = true diff --git a/crates/starknet_sequencer_node/src/config/node_config.rs b/crates/starknet_sequencer_node/src/config/node_config.rs index d8a289ad80..c6ac538764 100644 --- a/crates/starknet_sequencer_node/src/config/node_config.rs +++ b/crates/starknet_sequencer_node/src/config/node_config.rs @@ -6,6 +6,7 @@ use std::vec::Vec; use clap::Command; use infra_utils::path::resolve_project_relative_path; +use papyrus_base_layer::ethereum_base_layer_contract::EthereumBaseLayerConfig; use papyrus_config::dumping::{ append_sub_config_name, generate_struct_pointer, @@ -116,6 +117,8 @@ pub struct SequencerNodeConfig { #[validate] pub consensus_manager_config: ConsensusManagerConfig, #[validate] + pub base_layer_config: EthereumBaseLayerConfig, + #[validate] pub gateway_config: GatewayConfig, #[validate] pub http_server_config: HttpServerConfig, @@ -144,6 +147,7 @@ impl SerializeConfig for SequencerNodeConfig { ), append_sub_config_name(self.gateway_config.dump(), "gateway_config"), append_sub_config_name(self.http_server_config.dump(), "http_server_config"), + append_sub_config_name(self.base_layer_config.dump(), "base_layer_config"), append_sub_config_name(self.rpc_state_reader_config.dump(), "rpc_state_reader_config"), append_sub_config_name(self.compiler_config.dump(), "compiler_config"), append_sub_config_name(self.mempool_p2p_config.dump(), "mempool_p2p_config"),