@@ -2,15 +2,15 @@ use std::sync::Arc;
22use std:: time:: Duration ;
33
44use anyhow:: { Context , Result } ;
5- pub use clap:: Parser ;
5+ pub use clap:: { Args , Parser } ;
66use katana_node:: config:: dev:: DevConfig ;
77use katana_node:: config:: execution:: ExecutionConfig ;
88use katana_node:: config:: metrics:: MetricsConfig ;
99use katana_node:: config:: rpc:: RpcConfig ;
1010use katana_node:: shard:: config:: {
1111 ShardNodeConfig , DEFAULT_BLOCK_POLL_INTERVAL , DEFAULT_TIME_QUANTUM ,
1212} ;
13- use katana_node:: shard:: ShardNode ;
13+ use katana_node:: shard:: Node ;
1414use serde:: { Deserialize , Serialize } ;
1515use tracing:: info;
1616use url:: Url ;
@@ -34,46 +34,24 @@ pub struct ShardNodeArgs {
3434 #[ arg( long = "base-chain-url" , value_name = "URL" ) ]
3535 pub base_chain_url : Url ,
3636
37- /// Number of shard worker threads.
38- ///
39- /// Each worker runs on a dedicated OS thread and processes shards from the scheduler queue.
40- /// Defaults to the number of available CPU cores.
41- #[ arg( long = "workers" , value_name = "COUNT" ) ]
42- pub workers : Option < usize > ,
43-
44- /// Time quantum in milliseconds for worker preemption.
45- ///
46- /// Controls how long a worker processes a single shard before yielding to allow other
47- /// shards to be serviced.
48- #[ arg( long = "time-quantum" , value_name = "MILLISECONDS" ) ]
49- #[ arg( default_value_t = DEFAULT_TIME_QUANTUM . as_millis( ) as u64 ) ]
50- pub time_quantum_ms : u64 ,
51-
5237 /// Base chain block poll interval in seconds.
5338 ///
5439 /// How frequently the shard node polls the base chain for new block context.
5540 #[ arg( long = "block-poll-interval" , value_name = "SECONDS" ) ]
5641 #[ arg( default_value_t = DEFAULT_BLOCK_POLL_INTERVAL . as_secs( ) ) ]
5742 pub block_poll_interval_secs : u64 ,
5843
59- /// Disable charging fee when executing transactions.
60- #[ arg( long = "no-fee" ) ]
61- pub no_fee : bool ,
62-
63- /// Disable account validation when executing transactions.
64- ///
65- /// Skipping the transaction sender's account validation function.
66- #[ arg( long = "no-account-validation" ) ]
67- pub no_account_validation : bool ,
44+ #[ command( flatten) ]
45+ pub scheduler : SchedulerOptions ,
6846
6947 #[ command( flatten) ]
7048 pub logging : LoggingOptions ,
7149
7250 #[ command( flatten) ]
73- pub tracer : TracerOptions ,
51+ pub dev : DevOptions ,
7452
7553 #[ command( flatten) ]
76- pub starknet : EnvironmentOptions ,
54+ pub tracer : TracerOptions ,
7755
7856 #[ cfg( feature = "server" ) ]
7957 #[ command( flatten) ]
@@ -102,7 +80,7 @@ impl ShardNodeArgs {
10280
10381 async fn start_node ( & self ) -> Result < ( ) > {
10482 let config = self . config ( ) ?;
105- let node = ShardNode :: build ( config) . context ( "failed to build shard node" ) ?;
83+ let node = Node :: build ( config) . context ( "failed to build shard node" ) ?;
10684
10785 if !self . silent {
10886 info ! ( target: LOG_TARGET , "Starting shard node" ) ;
@@ -132,29 +110,23 @@ impl ShardNodeArgs {
132110 let metrics = self . metrics_config ( ) ;
133111
134112 let worker_count =
135- self . workers . unwrap_or_else ( katana_node:: shard:: config:: default_worker_count) ;
113+ self . scheduler . workers . unwrap_or_else ( katana_node:: shard:: config:: default_worker_count) ;
136114
137115 Ok ( ShardNodeConfig {
138116 chain,
139117 rpc,
140118 execution,
141119 dev,
142120 worker_count,
143- time_quantum : Duration :: from_millis ( self . time_quantum_ms ) ,
121+ time_quantum : Duration :: from_millis ( self . scheduler . time_quantum_ms ) ,
144122 base_chain_url : self . base_chain_url . clone ( ) ,
145123 block_poll_interval : Duration :: from_secs ( self . block_poll_interval_secs ) ,
146124 metrics,
147125 } )
148126 }
149127
150128 fn chain_spec ( & self ) -> Arc < katana_chain_spec:: ChainSpec > {
151- let mut chain_spec = katana_chain_spec:: dev:: DEV_UNALLOCATED . clone ( ) ;
152-
153- if let Some ( id) = self . starknet . chain_id {
154- chain_spec. id = id;
155- }
156-
157- Arc :: new ( katana_chain_spec:: ChainSpec :: Dev ( chain_spec) )
129+ Arc :: new ( katana_chain_spec:: ChainSpec :: Dev ( katana_chain_spec:: dev:: DEV_UNALLOCATED . clone ( ) ) )
158130 }
159131
160132 fn rpc_config ( & self ) -> Result < RpcConfig > {
@@ -187,19 +159,13 @@ impl ShardNodeArgs {
187159 }
188160
189161 fn execution_config ( & self ) -> ExecutionConfig {
190- ExecutionConfig {
191- invocation_max_steps : self . starknet . invoke_max_steps ,
192- validation_max_steps : self . starknet . validate_max_steps ,
193- #[ cfg( feature = "native" ) ]
194- compile_native : self . starknet . compile_native ,
195- ..Default :: default ( )
196- }
162+ ExecutionConfig :: default ( )
197163 }
198164
199165 fn dev_config ( & self ) -> DevConfig {
200166 DevConfig {
201- fee : !self . no_fee ,
202- account_validation : !self . no_account_validation ,
167+ fee : !self . dev . no_fee ,
168+ account_validation : !self . dev . no_account_validation ,
203169 fixed_gas_prices : None ,
204170 }
205171 }
@@ -220,3 +186,22 @@ impl ShardNodeArgs {
220186 self . tracer . config ( )
221187 }
222188}
189+
190+ #[ derive( Debug , Args , Clone , Serialize , Deserialize , PartialEq ) ]
191+ #[ command( next_help_heading = "Scheduler options" ) ]
192+ pub struct SchedulerOptions {
193+ /// Number of shard worker threads.
194+ ///
195+ /// Each worker runs on a dedicated OS thread and processes shards from the scheduler queue.
196+ /// Defaults to the number of available CPU cores.
197+ #[ arg( long = "scheduler.workers" , value_name = "COUNT" ) ]
198+ pub workers : Option < usize > ,
199+
200+ /// Time quantum in milliseconds for worker preemption.
201+ ///
202+ /// Controls how long a worker processes a single shard before yielding to allow other
203+ /// shards to be serviced.
204+ #[ arg( long = "scheduler.time-quantum" , value_name = "MILLISECONDS" ) ]
205+ #[ arg( default_value_t = DEFAULT_TIME_QUANTUM . as_millis( ) as u64 ) ]
206+ pub time_quantum_ms : u64 ,
207+ }
0 commit comments