Skip to content

refactor(starknet_sequencer_node): move dump_config_file to sequencer node #5021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

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

1 change: 0 additions & 1 deletion crates/starknet_integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ indexmap.workspace = true
itertools.workspace = true
mempool_test_utils.workspace = true
papyrus_base_layer = { workspace = true, features = ["testing"] }
papyrus_config.workspace = true
papyrus_network = { workspace = true, features = ["testing"] }
papyrus_protobuf.workspace = true
papyrus_storage = { workspace = true, features = ["testing"] }
Expand Down
21 changes: 4 additions & 17 deletions crates/starknet_integration_tests/src/executable_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::path::{Path, PathBuf};
use blockifier::context::ChainInfo;
use mempool_test_utils::starknet_api_test_utils::AccountTransactionGenerator;
use papyrus_base_layer::ethereum_base_layer_contract::EthereumBaseLayerConfig;
use papyrus_config::dumping::{combine_config_map_and_pointers, SerializeConfig};
use papyrus_storage::StorageConfig;
use starknet_api::execution_resources::GasAmount;
use starknet_api::rpc_transaction::RpcTransaction;
Expand All @@ -18,7 +17,7 @@ use starknet_mempool_p2p::config::MempoolP2pConfig;
use starknet_monitoring_endpoint::config::MonitoringEndpointConfig;
use starknet_monitoring_endpoint::test_utils::MonitoringClient;
use starknet_sequencer_node::config::component_config::ComponentConfig;
use starknet_sequencer_node::config::config_utils::{config_to_preset, dump_json_data};
use starknet_sequencer_node::config::config_utils::dump_config_file;
use starknet_sequencer_node::config::definitions::ConfigPointersMap;
use starknet_sequencer_node::config::node_config::{
SequencerNodeConfig,
Expand Down Expand Up @@ -236,23 +235,11 @@ impl ExecutableSetup {

/// Creates a config file for the sequencer node for an integration test.
pub fn dump_config_file_changes(&self) {
// Create the entire mapping of the config and the pointers, without the required params.
let config_as_map = combine_config_map_and_pointers(
self.config.dump(),
dump_config_file(
self.config.clone(),
&self.config_pointers_map.clone().into(),
&CONFIG_NON_POINTERS_WHITELIST,
)
.unwrap();

// Extract only the required fields from the config map.
let preset = config_to_preset(&config_as_map);

// Dump the preset to a file, return its path.
dump_json_data(preset, &self.node_config_path);
assert!(
&self.node_config_path.exists(),
"File does not exist: {:?}",
&self.node_config_path
&self.node_config_path,
);
}
}
26 changes: 26 additions & 0 deletions crates/starknet_sequencer_node/src/config/config_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ use std::fs::File;
use std::io::Write;
use std::path::PathBuf;

use papyrus_config::dumping::{
combine_config_map_and_pointers,
ConfigPointers,
Pointers,
SerializeConfig,
};
use serde_json::{Map, Value};
use tracing::{error, info};
use validator::ValidationError;

use super::node_config::SequencerNodeConfig;

pub(crate) fn create_validation_error(
error_msg: String,
validate_code: &'static str,
Expand Down Expand Up @@ -69,3 +77,21 @@ pub fn dump_json_data(json_data: Value, file_path: &PathBuf) {

info!("Writing required config changes to: {:?}", file_path);
}

pub fn dump_config_file(
config: SequencerNodeConfig,
pointers: &ConfigPointers,
non_pointer_params: &Pointers,
config_path: &PathBuf,
) {
// Create the entire mapping of the config and the pointers, without the required params.
let config_as_map =
combine_config_map_and_pointers(config.dump(), pointers, non_pointer_params).unwrap();

// Extract only the required fields from the config map.
let preset = config_to_preset(&config_as_map);

// Dump the preset to a file, return its path.
dump_json_data(preset, config_path);
assert!(config_path.exists(), "File does not exist: {:?}", config_path);
}
Loading