Skip to content

Commit

Permalink
chore(starknet_sequencer_node): add base layer config to node config …
Browse files Browse the repository at this point in the history
…and required params (#3063)

commit-id:886f2b3e
  • Loading branch information
Itay-Tsabary-Starkware authored Jan 5, 2025
1 parent b26ca3b commit 030cba2
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions config/sequencer/default_config.json
Original file line number Diff line number Diff line change
@@ -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/<your_api_key>, 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",
Expand Down
10 changes: 8 additions & 2 deletions crates/starknet_integration_tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ use starknet_monitoring_endpoint::config::MonitoringEndpointConfig;
use starknet_sequencer_infra::test_utils::AvailablePorts;
use starknet_sequencer_node::config::component_config::ComponentConfig;
use starknet_sequencer_node::config::node_config::SequencerNodeConfig;
use starknet_sequencer_node::config::test_utils::RequiredParams;
use starknet_sequencer_node::config::test_utils::{
EthereumBaseLayerConfigRequiredParams,
RequiredParams,
};
use starknet_state_sync::config::StateSyncConfig;
use starknet_types_core::felt::Felt;
use url::Url;
Expand Down Expand Up @@ -89,7 +92,10 @@ pub async fn create_node_config(
strk_fee_token_address: fee_token_addresses.strk_fee_token_address,
validator_id,
// TODO(dvir): change this to real value when add recorder to integration tests.
recorder_url: Url::parse("https://recorder_url").expect("The URL is valid"),
recorder_url: Url::parse("https://recorder_url").expect("Should be a valid URL"),
base_layer_config: EthereumBaseLayerConfigRequiredParams {
node_url: Url::parse("https://node_url").expect("Should be a valid URL"),
},
},
)
}
Expand Down
1 change: 1 addition & 0 deletions crates/starknet_sequencer_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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_protobuf.workspace = true
rstest.workspace = true
Expand Down
4 changes: 4 additions & 0 deletions crates/starknet_sequencer_node/src/config/node_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -120,6 +121,8 @@ pub struct SequencerNodeConfig {
#[validate]
pub components: ComponentConfig,
#[validate]
pub base_layer_config: EthereumBaseLayerConfig,
#[validate]
pub batcher_config: BatcherConfig,
#[validate]
pub consensus_manager_config: ConsensusManagerConfig,
Expand All @@ -143,6 +146,7 @@ impl SerializeConfig for SequencerNodeConfig {
fn dump(&self) -> BTreeMap<ParamPath, SerializedParam> {
let sub_configs = vec![
append_sub_config_name(self.components.dump(), "components"),
append_sub_config_name(self.base_layer_config.dump(), "base_layer_config"),
append_sub_config_name(self.batcher_config.dump(), "batcher_config"),
append_sub_config_name(
self.consensus_manager_config.dump(),
Expand Down
34 changes: 31 additions & 3 deletions crates/starknet_sequencer_node/src/config/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
use std::collections::{BTreeMap, HashSet};

use papyrus_config::dumping::{combine_config_map_and_pointers, ser_param, SerializeConfig};
use papyrus_config::dumping::{
append_sub_config_name,
combine_config_map_and_pointers,
ser_param,
SerializeConfig,
};
use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam};
use papyrus_protobuf::consensus::DEFAULT_VALIDATOR_ID;
use serde::Serialize;
Expand All @@ -18,6 +23,7 @@ pub struct RequiredParams {
pub strk_fee_token_address: ContractAddress,
pub validator_id: ContractAddress,
pub recorder_url: Url,
pub base_layer_config: EthereumBaseLayerConfigRequiredParams,
}

impl SerializeConfig for RequiredParams {
Expand Down Expand Up @@ -49,7 +55,10 @@ impl SerializeConfig for RequiredParams {
ParamPrivacyInput::Public,
),
]);
vec![members].into_iter().flatten().collect()
vec![members, append_sub_config_name(self.base_layer_config.dump(), "base_layer_config")]
.into_iter()
.flatten()
.collect()
}
}

Expand All @@ -60,7 +69,10 @@ impl RequiredParams {
eth_fee_token_address: ContractAddress::from(2_u128),
strk_fee_token_address: ContractAddress::from(3_u128),
validator_id: ContractAddress::from(DEFAULT_VALIDATOR_ID),
recorder_url: Url::parse("https://recorder_url").expect("The URL is valid"),
recorder_url: Url::parse("https://recorder_url").expect("Should be a valid URL"),
base_layer_config: EthereumBaseLayerConfigRequiredParams {
node_url: Url::parse("https://node_url").expect("Should be a valid URL"),
},
}
}

Expand Down Expand Up @@ -101,6 +113,22 @@ pub fn create_test_config_load_args(required_params: RequiredParams) -> Vec<Stri
cli_args
}

#[derive(Serialize)]
pub struct EthereumBaseLayerConfigRequiredParams {
pub node_url: Url,
}

impl SerializeConfig for EthereumBaseLayerConfigRequiredParams {
fn dump(&self) -> BTreeMap<ParamPath, SerializedParam> {
BTreeMap::from_iter([ser_param(
"node_url",
&self.node_url,
"Placeholder.",
ParamPrivacyInput::Public,
)])
}
}

/// Transforms a nested JSON dictionary object into a simplified JSON dictionary object by
/// extracting specific values from the inner dictionaries.
///
Expand Down

0 comments on commit 030cba2

Please sign in to comment.