From 5c4e7451a49edfe6bd99f4b79a0a029a79d50f70 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 `ser_required_param` seems to be unsupported by the current infra tests and unused elsewhere, using regular `ser_param` instead. --- 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 bec5955457..cf9619353c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7318,6 +7318,7 @@ dependencies = [ "thiserror", "tokio", "url", + "validator", ] [[package]] @@ -10731,6 +10732,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 5c3ad7ccb7..a10028bc4d 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}; @@ -122,7 +123,7 @@ pub enum EthereumBaseLayerError { FeeOutOfRange(alloy_primitives::ruint::FromUintError), } -#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)] +#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, 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"),