1- use std:: collections:: { BTreeMap , HashSet } ;
2- use std:: sync:: LazyLock ;
1+ use std:: collections:: BTreeMap ;
32use std:: vec:: Vec ;
43
54use apollo_batcher_config:: config:: { BatcherConfig , BatcherDynamicConfig } ;
65use apollo_class_manager_config:: config:: { ClassManagerDynamicConfig , FsClassManagerConfig } ;
76use apollo_committer_config:: config:: ApolloCommitterConfig ;
8- use apollo_config:: behavior_mode:: BehaviorMode ;
97use apollo_config:: dumping:: {
10- generate_optional_struct_pointer,
11- generate_struct_pointer,
128 prepend_sub_config_name,
139 ser_optional_sub_config,
1410 ser_param,
15- ser_pointer_target_param,
16- set_pointing_param_paths,
17- ConfigPointers ,
18- Pointers ,
1911 SerializeConfig ,
2012} ;
2113use apollo_config:: loading:: load_and_process_config;
@@ -33,12 +25,9 @@ use apollo_mempool_config::config::{MempoolConfig, MempoolDynamicConfig};
3325use apollo_mempool_p2p_config:: config:: MempoolP2pConfig ;
3426use apollo_monitoring_endpoint_config:: config:: MonitoringEndpointConfig ;
3527use apollo_proof_manager_config:: config:: ProofManagerConfig ;
36- use apollo_reverts:: RevertConfig ;
3728use apollo_sierra_compilation_config:: config:: SierraCompilationConfig ;
3829use apollo_staking_config:: config:: StakingManagerDynamicConfig ;
3930use apollo_state_sync_config:: config:: { StateSyncConfig , StateSyncDynamicConfig } ;
40- use blockifier:: blockifier:: config:: NativeClassesWhitelist ;
41- use blockifier:: blockifier_versioned_constants:: VersionedConstantsOverrides ;
4231use clap:: Command ;
4332use papyrus_base_layer:: ethereum_base_layer_contract:: EthereumBaseLayerConfig ;
4433use serde:: { Deserialize , Serialize } ;
@@ -53,181 +42,10 @@ use crate::version::VERSION_FULL;
5342// the crate.
5443pub const CONFIG_SECRETS_SCHEMA_PATH : & str =
5544 "crates/apollo_node/resources/config_secrets_schema.json" ;
56- pub const POINTER_TARGET_VALUE : & str = "PointerTarget" ;
5745
5846// TODO(Tsabary): move metrics recorder to the node level, like tracing, instead of being
5947// initialized as part of the endpoint.
6048
61- // Configuration parameters that share the same value across multiple components.
62- pub static CONFIG_POINTERS : LazyLock < ConfigPointers > = LazyLock :: new ( || {
63- let mut pointers = vec ! [
64- (
65- ser_pointer_target_param(
66- "chain_id" ,
67- & POINTER_TARGET_VALUE . to_string( ) ,
68- "The chain to follow. For more details see https://docs.starknet.io/learn/cheatsheets/transactions-reference#chain-id." ,
69- ) ,
70- set_pointing_param_paths( & [
71- "batcher_config.static_config.block_builder_config.chain_info.chain_id" ,
72- "batcher_config.static_config.storage.db_config.chain_id" ,
73- "class_manager_config.static_config.class_storage_config.class_hash_storage_config.db_config.chain_id" ,
74- "consensus_manager_config.consensus_manager_config.static_config.storage_config.db_config.chain_id" ,
75- "consensus_manager_config.context_config.static_config.chain_id" ,
76- "consensus_manager_config.network_config.chain_id" ,
77- "gateway_config.static_config.chain_info.chain_id" ,
78- "l1_events_scraper_config.chain_id" ,
79- "l1_gas_price_scraper_config.chain_id" ,
80- "mempool_p2p_config.network_config.chain_id" ,
81- "state_sync_config.static_config.storage_config.db_config.chain_id" ,
82- "state_sync_config.static_config.network_config.chain_id" ,
83- "state_sync_config.static_config.rpc_config.chain_id" ,
84- ] ) ,
85- ) ,
86- (
87- ser_pointer_target_param(
88- "eth_fee_token_address" ,
89- & POINTER_TARGET_VALUE . to_string( ) ,
90- "Address of the ETH fee token." ,
91- ) ,
92- set_pointing_param_paths( & [
93- "batcher_config.static_config.block_builder_config.chain_info.fee_token_addresses.\
94- eth_fee_token_address",
95- "gateway_config.static_config.chain_info.fee_token_addresses.eth_fee_token_address" ,
96- "state_sync_config.static_config.rpc_config.execution_config.eth_fee_contract_address" ,
97- ] ) ,
98- ) ,
99- (
100- ser_pointer_target_param(
101- "native_classes_whitelist" ,
102- & "[]" . to_string( ) ,
103- NativeClassesWhitelist :: SER_PARAM_DESCRIPTION ,
104- ) ,
105- set_pointing_param_paths( & [
106- "batcher_config.dynamic_config.native_classes_whitelist" ,
107- "gateway_config.dynamic_config.native_classes_whitelist" ,
108- ] ) ,
109- ) ,
110- (
111- ser_pointer_target_param(
112- "starknet_url" ,
113- & POINTER_TARGET_VALUE . to_string( ) ,
114- "URL for communicating with Starknet." ,
115- ) ,
116- set_pointing_param_paths( & [
117- "state_sync_config.static_config.central_sync_client_config.central_source_config.starknet_url" ,
118- "state_sync_config.static_config.rpc_config.starknet_url" ,
119- ] ) ,
120- ) ,
121- (
122- ser_pointer_target_param(
123- "strk_fee_token_address" ,
124- & POINTER_TARGET_VALUE . to_string( ) ,
125- "Address of the STRK fee token." ,
126- ) ,
127- set_pointing_param_paths( & [
128- "batcher_config.static_config.block_builder_config.chain_info.fee_token_addresses.\
129- strk_fee_token_address",
130- "gateway_config.static_config.chain_info.fee_token_addresses.strk_fee_token_address" ,
131- "state_sync_config.static_config.rpc_config.execution_config.strk_fee_contract_address" ,
132- ] ) ,
133- ) ,
134- (
135- ser_pointer_target_param(
136- "validator_id" ,
137- & POINTER_TARGET_VALUE . to_string( ) ,
138- "The ID of the validator. \
139- Also the address of this validator as a starknet contract.",
140- ) ,
141- set_pointing_param_paths( & [ "consensus_manager_config.consensus_manager_config.dynamic_config.validator_id" ] ) ,
142- ) ,
143- (
144- ser_pointer_target_param(
145- "recorder_url" ,
146- & POINTER_TARGET_VALUE . to_string( ) ,
147- "The URL of the Pythonic cende_recorder" ,
148- ) ,
149- set_pointing_param_paths( & [
150- "consensus_manager_config.cende_config.recorder_url" ,
151- "batcher_config.static_config.pre_confirmed_cende_config.recorder_url" ,
152- "mempool_config.static_config.recorder_url" ,
153- ] ) ,
154- ) ,
155- (
156- ser_pointer_target_param(
157- "validate_resource_bounds" ,
158- & true ,
159- "Indicates that validations related to resource bounds are applied. \
160- It should be set to false during a system bootstrap.",
161- ) ,
162- set_pointing_param_paths( & [
163- "gateway_config.static_config.stateful_tx_validator_config.validate_resource_bounds" ,
164- "gateway_config.static_config.stateless_tx_validator_config.validate_resource_bounds" ,
165- "mempool_config.static_config.validate_resource_bounds" ,
166- ] ) ,
167- ) ,
168- (
169- ser_pointer_target_param(
170- "max_cpu_time" ,
171- & 600u64 ,
172- "Limitation of compilation cpu time (seconds)." ,
173- ) ,
174- set_pointing_param_paths( & [
175- "sierra_compiler_config.max_cpu_time" ,
176- "batcher_config.static_config.contract_class_manager_config.native_compiler_config.\
177- max_cpu_time",
178- "gateway_config.static_config.contract_class_manager_config.native_compiler_config.\
179- max_cpu_time",
180- ] ) ,
181- ) ,
182- ] ;
183- let mut common_execution_config = generate_optional_struct_pointer :: < VersionedConstantsOverrides > (
184- "versioned_constants_overrides" . to_owned ( ) ,
185- None ,
186- set_pointing_param_paths ( & [
187- "batcher_config.static_config.block_builder_config.versioned_constants_overrides" ,
188- "gateway_config.static_config.stateful_tx_validator_config.\
189- versioned_constants_overrides",
190- ] ) ,
191- ) ;
192- pointers. append ( & mut common_execution_config) ;
193-
194- let mut common_execution_config = generate_struct_pointer (
195- "revert_config" . to_owned ( ) ,
196- & RevertConfig :: default ( ) ,
197- set_pointing_param_paths ( & [
198- "state_sync_config.static_config.revert_config" ,
199- "consensus_manager_config.revert_config" ,
200- ] ) ,
201- ) ;
202- pointers. append ( & mut common_execution_config) ;
203-
204- pointers. push ( (
205- ser_pointer_target_param (
206- "behavior_mode" ,
207- & BehaviorMode :: Starknet ,
208- "Behavior mode: 'starknet' for production, 'echonet' for test/replay mode." ,
209- ) ,
210- set_pointing_param_paths ( & [
211- "consensus_manager_config.context_config.static_config.behavior_mode" ,
212- "mempool_config.static_config.behavior_mode" ,
213- ] ) ,
214- ) ) ;
215- pointers. push ( (
216- ser_pointer_target_param (
217- "validation_only" ,
218- & false ,
219- "If true, the node validates proposed blocks but does not build proposals. Requires \
220- gateway, http_server, and mempool to be disabled.",
221- ) ,
222- set_pointing_param_paths ( & [ "batcher_config.static_config.validation_only" ] ) ,
223- ) ) ;
224- pointers
225- } ) ;
226-
227- // Parameters that should 1) not be pointers, and 2) have a name matching a pointer target param.
228- pub static CONFIG_NON_POINTERS_WHITELIST : LazyLock < Pointers > =
229- LazyLock :: new ( HashSet :: < ParamPath > :: new) ;
230-
23149/// The configurations of the various components of the node.
23250#[ derive( Debug , Deserialize , Serialize , Clone , PartialEq , Validate ) ]
23351pub struct SequencerNodeConfig {
@@ -610,19 +428,18 @@ impl SequencerNodeConfig {
610428
611429 /// Asserts that the formerly-pointer-resolved values are equal across all present components.
612430 ///
613- /// The `CONFIG_POINTERS` mechanism copies a single source value into many nested component
614- /// fields at load time. Once those values are baked into the config (e.g. by jsonnet `build()`)
615- /// nothing re-checks that the copies actually agree. These present-only equality asserts are a
431+ /// The pointer mechanism copied a single source value into many nested component fields at load
432+ /// time. Once those values are baked into the config (e.g. by jsonnet `build()`) nothing
433+ /// re-checks that the copies actually agree. These present-only equality asserts are a
616434 /// defense-in-depth guard for hand-edited, test, or otherwise non-jsonnet-generated configs:
617435 /// for each pointer group with more than one target, every present component must hold the same
618436 /// value. Components that are absent (`None`) are skipped, so partial/distributed deployments
619437 /// that own only a subset of a group still validate. Each group below mirrors one multi-target
620- /// entry of `CONFIG_POINTERS`, plus `validation_only`: a single-target pointer whose target
621- /// (the batcher's copy) is checked against the always-present top-level source field, since
622- /// the node reads the two independently. Two single-target pointers are intentionally not
623- /// checked here: `starknet_url` (its targets are typed `String` vs `Url` and cannot be
624- /// compared directly) and `validator_id` (a lone target with no independent source to
625- /// disagree with).
438+ /// pointer group, plus `validation_only`: a single-target pointer whose target (the batcher's
439+ /// copy) is checked against the always-present top-level source field, since the node reads the
440+ /// two independently. Two single-target pointers are intentionally not checked here:
441+ /// `starknet_url` (its targets are typed `String` vs `Url` and cannot be compared directly) and
442+ /// `validator_id` (a lone target with no independent source to disagree with).
626443 fn validate_pointer_groups_equal ( & self ) -> Result < ( ) , ConfigError > {
627444 let batcher = self . batcher_config . as_ref ( ) ;
628445 let class_manager = self . class_manager_config . as_ref ( ) ;
0 commit comments