From 73f829756d6be11ecd9e96787a22a9b0f62033cd Mon Sep 17 00:00:00 2001 From: Itay Tsabary Date: Wed, 25 Dec 2024 08:23:27 +0200 Subject: [PATCH] ugly hacks for required sub config --- Cargo.lock | 2 ++ crates/papyrus_proc_macros/src/lib.rs | 5 ++++- crates/starknet_integration_tests/Cargo.toml | 1 + crates/starknet_integration_tests/src/config_utils.rs | 7 ++++++- crates/starknet_integration_tests/src/utils.rs | 2 ++ crates/starknet_sequencer_node/Cargo.toml | 2 ++ crates/starknet_sequencer_node/src/config/test_utils.rs | 3 +++ 7 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cf9619353c..8eb607678e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10543,6 +10543,7 @@ dependencies = [ "tempfile", "tokio", "tracing", + "url", ] [[package]] @@ -10761,6 +10762,7 @@ dependencies = [ "starknet_state_sync_types", "tokio", "tracing", + "url", "validator", ] diff --git a/crates/papyrus_proc_macros/src/lib.rs b/crates/papyrus_proc_macros/src/lib.rs index 69c0fe3e1a..613fb7ff50 100644 --- a/crates/papyrus_proc_macros/src/lib.rs +++ b/crates/papyrus_proc_macros/src/lib.rs @@ -292,7 +292,10 @@ pub fn gen_field_names_and_cli_args_fn(_attr: TokenStream, item: TokenStream) -> }; // Collect the names of the struct's fields as string literals - let field_names = field_idents.iter().map(|ident| ident.to_string()).collect::>(); + let field_names = field_idents + .iter() + .map(|ident| ident.to_string().replace("_fieldseperator_", ".")) + .collect::>(); // Generate the field_names method let gen = quote! { diff --git a/crates/starknet_integration_tests/Cargo.toml b/crates/starknet_integration_tests/Cargo.toml index 7743194f5d..a51b86aa23 100644 --- a/crates/starknet_integration_tests/Cargo.toml +++ b/crates/starknet_integration_tests/Cargo.toml @@ -42,6 +42,7 @@ strum.workspace = true tempfile.workspace = true tokio.workspace = true tracing.workspace = true +url = { workspace = true, features = ["serde"] } [dev-dependencies] futures.workspace = true diff --git a/crates/starknet_integration_tests/src/config_utils.rs b/crates/starknet_integration_tests/src/config_utils.rs index 82dcd36700..e239858ea4 100644 --- a/crates/starknet_integration_tests/src/config_utils.rs +++ b/crates/starknet_integration_tests/src/config_utils.rs @@ -16,6 +16,10 @@ use tracing::info; const NODE_CONFIG_CHANGES_FILE_PATH: &str = "node_integration_test_config_changes.json"; +fn replace_field_separator(s: &str) -> String { + s.replace("_fieldseperator_", ".") +} + /// A utility macro that takes a list of config fields and returns a json dictionary with "field /// name : field value" entries, where prefixed "config." name is removed from the entry key. /// @@ -34,7 +38,7 @@ macro_rules! config_fields_to_json { ( $( $expr:expr ),+ , ) => { json!({ $( - strip_config_prefix(stringify!($expr)): $expr + replace_field_separator(strip_config_prefix(stringify!($expr))): $expr ),+ }) }; @@ -53,6 +57,7 @@ pub(crate) fn dump_config_file_changes( required_params.eth_fee_token_address, required_params.strk_fee_token_address, required_params.validator_id, + required_params.base_layer_config_fieldseperator_node_url, ); // Create the entire mapping of the config and the pointers, without the required params. diff --git a/crates/starknet_integration_tests/src/utils.rs b/crates/starknet_integration_tests/src/utils.rs index f05a6793e3..1240878604 100644 --- a/crates/starknet_integration_tests/src/utils.rs +++ b/crates/starknet_integration_tests/src/utils.rs @@ -37,6 +37,7 @@ use starknet_sequencer_node::config::node_config::SequencerNodeConfig; use starknet_sequencer_node::config::test_utils::RequiredParams; use starknet_state_sync::config::StateSyncConfig; use starknet_types_core::felt::Felt; +use url::Url; pub fn create_chain_info() -> ChainInfo { let mut chain_info = ChainInfo::create_for_testing(); @@ -89,6 +90,7 @@ pub async fn create_config( eth_fee_token_address: fee_token_addresses.eth_fee_token_address, strk_fee_token_address: fee_token_addresses.strk_fee_token_address, validator_id, + base_layer_config_fieldseperator_node_url: Url::parse("http://localhost:8545").unwrap(), }, ) } diff --git a/crates/starknet_sequencer_node/Cargo.toml b/crates/starknet_sequencer_node/Cargo.toml index 6b5c7f6df3..143a7fbf09 100644 --- a/crates/starknet_sequencer_node/Cargo.toml +++ b/crates/starknet_sequencer_node/Cargo.toml @@ -43,8 +43,10 @@ starknet_state_sync.workspace = true starknet_state_sync_types.workspace = true tokio.workspace = true tracing.workspace = true +url = { workspace = true, features = ["serde"] } validator.workspace = true + [dev-dependencies] assert-json-diff.workspace = true assert_matches.workspace = true diff --git a/crates/starknet_sequencer_node/src/config/test_utils.rs b/crates/starknet_sequencer_node/src/config/test_utils.rs index e25a95a6cf..6f81be77fe 100644 --- a/crates/starknet_sequencer_node/src/config/test_utils.rs +++ b/crates/starknet_sequencer_node/src/config/test_utils.rs @@ -3,6 +3,7 @@ use std::vec::Vec; // Used by #[gen_field_names_fn]. use papyrus_proc_macros::gen_field_names_and_cli_args_fn; use papyrus_protobuf::consensus::DEFAULT_VALIDATOR_ID; use starknet_api::core::{ChainId, ContractAddress}; +use url::Url; use crate::config::node_config::node_command; @@ -13,6 +14,7 @@ pub struct RequiredParams { pub eth_fee_token_address: ContractAddress, pub strk_fee_token_address: ContractAddress, pub validator_id: ContractAddress, + pub base_layer_config_fieldseperator_node_url: Url, } impl RequiredParams { @@ -22,6 +24,7 @@ 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), + base_layer_config_fieldseperator_node_url: Url::parse("http://localhost:8545").unwrap(), } } }