Skip to content

Commit

Permalink
ugly hacks for required sub config
Browse files Browse the repository at this point in the history
  • Loading branch information
Itay-Tsabary-Starkware committed Dec 25, 2024
1 parent 5c4e745 commit 73f8297
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion crates/papyrus_proc_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>();
let field_names = field_idents
.iter()
.map(|ident| ident.to_string().replace("_fieldseperator_", "."))
.collect::<Vec<_>>();

// Generate the field_names method
let gen = quote! {
Expand Down
1 change: 1 addition & 0 deletions crates/starknet_integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion crates/starknet_integration_tests/src/config_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand All @@ -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
),+
})
};
Expand All @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions crates/starknet_integration_tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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(),
},
)
}
Expand Down
2 changes: 2 additions & 0 deletions crates/starknet_sequencer_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions crates/starknet_sequencer_node/src/config/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 {
Expand All @@ -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(),
}
}
}
Expand Down

0 comments on commit 73f8297

Please sign in to comment.