Skip to content

Commit e4e7585

Browse files
kariyclaude
andauthored
refactor(node): split into config, sequencer, and full crates (#428)
Split `katana-node` into three separate crates under `crates/node/`: `katana-node-config` for shared config types (db, rpc, metrics), `katana-sequencer-node` for the sequencer node, and `katana-full-node` for the full node. Shared configs are re-exported from each node crate so consumers access them through a single path. All downstream crates (cli, utils, rpc-server, tests/snos) updated accordingly. Replaces `katana_rpc_server::cors::HeaderValue` with `http::HeaderValue` in shared config to avoid coupling config to the RPC server implementation. ``` crates/node/ ├── config/ → katana-node-config (shared: db, rpc, metrics) ├── sequencer/ → katana-sequencer-node (sequencer node) └── full/ → katana-full-node (full node) ``` --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 85c5fcc commit e4e7585

39 files changed

+258
-148
lines changed

Cargo.lock

Lines changed: 92 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ members = [
1818
"crates/grpc",
1919
"crates/messaging",
2020
"crates/metrics",
21-
"crates/node",
21+
"crates/node/config",
22+
"crates/node/sequencer",
23+
"crates/node/full",
2224
"crates/node-bindings",
2325
"crates/oracle/gas",
2426
"crates/pool/pool",
@@ -92,7 +94,9 @@ katana-genesis = { path = "crates/genesis" }
9294
katana-grpc = { path = "crates/grpc" }
9395
katana-messaging = { path = "crates/messaging" }
9496
katana-metrics = { path = "crates/metrics" }
95-
katana-node = { path = "crates/node" }
97+
katana-node-config = { path = "crates/node/config" }
98+
katana-sequencer-node = { path = "crates/node/sequencer" }
99+
katana-full-node = { path = "crates/node/full" }
96100
katana-node-bindings = { path = "crates/node-bindings" }
97101
katana-pipeline = { path = "crates/sync/pipeline" }
98102
katana-pool = { path = "crates/pool/pool" }

crates/cli/Cargo.toml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ version.workspace = true
99
katana-chain-spec.workspace = true
1010
katana-core.workspace = true
1111
katana-messaging.workspace = true
12-
katana-node.workspace = true
12+
katana-sequencer-node.workspace = true
13+
katana-full-node.workspace = true
1314
katana-genesis.workspace = true
1415
katana-primitives.workspace = true
1516
katana-rpc-server.workspace = true
@@ -42,23 +43,24 @@ starknet.workspace = true
4243
paymaster = [
4344
"dep:katana-paymaster",
4445
"dep:katana-slot-controller",
45-
"katana-node/paymaster",
46+
"katana-sequencer-node/paymaster",
4647
"katana-rpc-server/paymaster",
4748
]
4849
vrf = [
4950
"cartridge",
5051
"dep:cartridge",
51-
"katana-node/vrf",
52+
"katana-sequencer-node/vrf",
5253
"katana-rpc-server/vrf",
5354
]
5455
cartridge = [
55-
"katana-node/cartridge",
56+
"katana-sequencer-node/cartridge",
57+
"katana-full-node/cartridge",
5658
"katana-rpc-server/cartridge",
5759
"paymaster",
5860
]
59-
grpc = [ "katana-node/grpc" ]
61+
grpc = [ "katana-sequencer-node/grpc" ]
6062
default = ["server", "tee", "vrf", "paymaster", "cartridge", "grpc"]
61-
explorer = ["katana-node/explorer", "katana-utils/explorer"]
62-
native = ["katana-node/native"]
63+
explorer = ["katana-sequencer-node/explorer", "katana-full-node/explorer", "katana-utils/explorer"]
64+
native = ["katana-sequencer-node/native"]
6365
server = []
64-
tee = ["dep:katana-tee", "katana-node/tee", "katana-node/tee-snp", "katana-tee/snp"]
66+
tee = ["dep:katana-tee", "katana-sequencer-node/tee", "katana-sequencer-node/tee-snp", "katana-tee/snp"]

crates/cli/src/args.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,26 @@ use katana_core::constants::DEFAULT_SEQUENCER_ADDRESS;
1414
use katana_genesis::allocation::DevAllocationsGenerator;
1515
use katana_genesis::constant::DEFAULT_PREFUNDED_ACCOUNT_BALANCE;
1616
use katana_messaging::MessagingConfig;
17-
use katana_node::config::db::DbConfig;
18-
use katana_node::config::dev::{DevConfig, FixedL1GasPriceConfig};
19-
use katana_node::config::execution::ExecutionConfig;
20-
use katana_node::config::fork::ForkingConfig;
21-
use katana_node::config::gateway::GatewayConfig;
17+
use katana_sequencer_node::config::db::DbConfig;
18+
use katana_sequencer_node::config::dev::{DevConfig, FixedL1GasPriceConfig};
19+
use katana_sequencer_node::config::execution::ExecutionConfig;
20+
use katana_sequencer_node::config::fork::ForkingConfig;
21+
use katana_sequencer_node::config::gateway::GatewayConfig;
2222
#[cfg(all(feature = "server", feature = "grpc"))]
23-
use katana_node::config::grpc::GrpcConfig;
24-
use katana_node::config::metrics::MetricsConfig;
23+
use katana_sequencer_node::config::grpc::GrpcConfig;
24+
use katana_sequencer_node::config::metrics::MetricsConfig;
2525
#[cfg(feature = "cartridge")]
26-
use katana_node::config::paymaster::PaymasterConfig;
26+
use katana_sequencer_node::config::paymaster::PaymasterConfig;
2727
#[cfg(feature = "vrf")]
28-
use katana_node::config::paymaster::VrfConfig;
29-
use katana_node::config::rpc::RpcConfig;
28+
use katana_sequencer_node::config::paymaster::VrfConfig;
29+
use katana_sequencer_node::config::rpc::RpcConfig;
3030
#[cfg(feature = "server")]
31-
use katana_node::config::rpc::{RpcModuleKind, RpcModulesList};
32-
use katana_node::config::sequencing::SequencingConfig;
31+
use katana_sequencer_node::config::rpc::{RpcModuleKind, RpcModulesList};
32+
use katana_sequencer_node::config::sequencing::SequencingConfig;
3333
#[cfg(feature = "tee")]
34-
use katana_node::config::tee::TeeConfig;
35-
use katana_node::config::Config;
36-
use katana_node::Node;
34+
use katana_sequencer_node::config::tee::TeeConfig;
35+
use katana_sequencer_node::config::Config;
36+
use katana_sequencer_node::Node;
3737
use serde::{Deserialize, Serialize};
3838
use tracing::info;
3939
use url::Url;
@@ -616,7 +616,7 @@ impl SequencerNodeArgs {
616616

617617
use anyhow::anyhow;
618618
use katana_genesis::allocation::GenesisAccountAlloc;
619-
use katana_node::config::paymaster::CartridgeApiConfig;
619+
use katana_sequencer_node::config::paymaster::CartridgeApiConfig;
620620

621621
// Derive paymaster credentials from genesis account 0
622622
let (address, private_key) = {
@@ -780,13 +780,13 @@ mod test {
780780
DEFAULT_ETH_L1_DATA_GAS_PRICE, DEFAULT_ETH_L1_GAS_PRICE, DEFAULT_ETH_L2_GAS_PRICE,
781781
DEFAULT_STRK_L1_DATA_GAS_PRICE, DEFAULT_STRK_L1_GAS_PRICE,
782782
};
783-
use katana_node::config::execution::{
783+
use katana_primitives::chain::ChainId;
784+
use katana_primitives::{address, felt, Felt};
785+
use katana_sequencer_node::config::execution::{
784786
DEFAULT_INVOCATION_MAX_STEPS, DEFAULT_VALIDATION_MAX_STEPS,
785787
};
786788
#[cfg(feature = "server")]
787-
use katana_node::config::rpc::RpcModuleKind;
788-
use katana_primitives::chain::ChainId;
789-
use katana_primitives::{address, felt, Felt};
789+
use katana_sequencer_node::config::rpc::RpcModuleKind;
790790

791791
use super::*;
792792

crates/cli/src/full.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ use std::path::PathBuf;
22

33
use anyhow::{Context, Result};
44
pub use clap::Parser;
5-
use katana_node::config::db::DbConfig;
6-
use katana_node::config::metrics::MetricsConfig;
7-
use katana_node::config::rpc::RpcConfig;
8-
use katana_node::full;
9-
use katana_node::full::Network;
5+
use katana_full_node::config::db::DbConfig;
6+
use katana_full_node::config::metrics::MetricsConfig;
7+
use katana_full_node::config::rpc::RpcConfig;
8+
use katana_full_node::Network;
109
use serde::{Deserialize, Serialize};
1110
use tracing::info;
1211

@@ -78,7 +77,7 @@ impl FullNodeArgs {
7877
async fn start_node(&self) -> Result<()> {
7978
// Build the node
8079
let config = self.config()?;
81-
let node = full::Node::build(config).context("failed to build full node")?;
80+
let node = katana_full_node::Node::build(config).context("failed to build full node")?;
8281

8382
if !self.silent {
8483
info!(target: LOG_TARGET, "Starting full node");
@@ -102,13 +101,13 @@ impl FullNodeArgs {
102101
Ok(())
103102
}
104103

105-
fn config(&self) -> Result<full::Config> {
104+
fn config(&self) -> Result<katana_full_node::Config> {
106105
let db = self.db_config();
107106
let rpc = self.rpc_config()?;
108107
let metrics = self.metrics_config();
109108
let pruning = self.pruning_config();
110109

111-
Ok(full::Config {
110+
Ok(katana_full_node::Config {
112111
db,
113112
rpc,
114113
metrics,
@@ -118,7 +117,7 @@ impl FullNodeArgs {
118117
})
119118
}
120119

121-
fn pruning_config(&self) -> full::PruningConfig {
120+
fn pruning_config(&self) -> katana_full_node::PruningConfig {
122121
use crate::options::PruningMode;
123122

124123
// Translate CLI pruning mode to distance from tip
@@ -127,7 +126,7 @@ impl FullNodeArgs {
127126
PruningMode::Full(n) => Some(n),
128127
};
129128

130-
full::PruningConfig { distance }
129+
katana_full_node::PruningConfig { distance }
131130
}
132131

133132
fn db_config(&self) -> DbConfig {

0 commit comments

Comments
 (0)