From 94ce4e7ddc3b01b3656bf0b16a1b38c3d9bacf15 Mon Sep 17 00:00:00 2001 From: Gilad Chase Date: Fri, 20 Dec 2024 19:39:27 +0200 Subject: [PATCH] chore(papyrus_base_layer): add eth base layer config to node infra --- Cargo.lock | 2 ++ config/sequencer/default_config.json | 10 ++++++++++ crates/papyrus_base_layer/Cargo.toml | 1 + .../src/ethereum_base_layer_contract.rs | 3 ++- crates/starknet_sequencer_node/Cargo.toml | 1 + .../starknet_sequencer_node/src/config/node_config.rs | 4 ++++ 6 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index ed3bf5b5cf..ed78ca723a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7318,6 +7318,7 @@ dependencies = [ "thiserror", "tokio", "url", + "validator", ] [[package]] @@ -10738,6 +10739,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 23b2a2ff3b..6086021cef 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 ab16b48e40..20611f3306 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}; @@ -116,7 +117,7 @@ pub enum EthereumBaseLayerError { UnhandledL1Event(alloy_primitives::Log), } -#[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 59d82c0cd8..28f9eed723 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 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 f7d67e837a..6e938648ef 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, @@ -124,6 +125,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, @@ -152,6 +155,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"),