Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
c5a42ce
wip
kariy Oct 2, 2025
44fa634
hook up node impleemntion to the cli
kariy Oct 6, 2025
428a4b1
fix some stuff (i think)
kariy Oct 6, 2025
35d8954
wip
kariy Oct 7, 2025
c1f26b1
wip
kariy Oct 7, 2025
16409a2
wip
kariy Oct 8, 2025
f365435
wip
kariy Oct 8, 2025
fc01f96
working version of rpc server integration
kariy Oct 9, 2025
10e062e
wip
kariy Oct 9, 2025
2d6d332
wip
kariy Oct 14, 2025
4647955
wip
kariy Oct 14, 2025
db94098
wip
kariy Oct 15, 2025
32038c6
wip
kariy Oct 16, 2025
3fe2581
wip
kariy Oct 16, 2025
fb3bded
wip
kariy Oct 20, 2025
3fd9101
wip
kariy Oct 21, 2025
5a03307
wip
kariy Oct 21, 2025
6b41589
wip
kariy Oct 21, 2025
65ab1e0
wip
kariy Oct 21, 2025
45acb8a
wip
kariy Oct 22, 2025
81dd17d
wip
kariy Oct 22, 2025
21bc420
wip
kariy Oct 22, 2025
49e2a18
wip
kariy Oct 23, 2025
998edb9
wip
kariy Oct 25, 2025
3a297c1
wip
kariy Oct 25, 2025
1e99c90
update preconf state
kariy Oct 27, 2025
42a28dc
rpc pending provider
kariy Oct 27, 2025
303da6c
implement rpc pending provider to block producer
kariy Oct 27, 2025
3f9c88b
node integration
kariy Oct 27, 2025
218a69a
wip
kariy Oct 27, 2025
e0cf602
wip
kariy Oct 28, 2025
9a3ebe4
integrate pending provider
kariy Oct 28, 2025
3a1814c
wip
kariy Oct 28, 2025
971916f
wip
kariy Oct 28, 2025
fad6345
wip
kariy Oct 28, 2025
0856d09
wip
kariy Oct 28, 2025
d730845
wip
kariy Oct 29, 2025
72902cf
wip
kariy Oct 31, 2025
29d6338
Merge branch 'main' into feat/full-node-wip
kariy Nov 10, 2025
e332fc4
wip
kariy Nov 10, 2025
206e609
implement PoolTransaction for BroadcastedTxWithChainId
kariy Nov 10, 2025
c73d9da
wip
kariy Nov 10, 2025
67c9947
remove unused type
kariy Nov 10, 2025
c477ab0
verioned constant overrides refactor
kariy Nov 10, 2025
153df69
Merge branch 'main' into feat/full-node-wip
kariy Nov 11, 2025
04d8f16
remove unused stuff
kariy Nov 11, 2025
5d6b5b3
fmt
kariy Nov 11, 2025
94b2d36
revert
kariy Nov 12, 2025
3c0500c
remove unused dep
kariy Nov 12, 2025
2d9ae1a
wip
kariy Nov 12, 2025
dcd8a60
remove unused code
kariy Nov 12, 2025
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
6 changes: 6 additions & 0 deletions Cargo.lock

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

65 changes: 65 additions & 0 deletions crates/chain-spec/src/full_node.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
use katana_genesis::Genesis;
use katana_primitives::chain::ChainId;
use lazy_static::lazy_static;

use crate::{FeeContracts, SettlementLayer};

/// The full node chain specification.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ChainSpec {
/// The network chain id.
pub id: ChainId,

/// The chain's genesis states.
pub genesis: Genesis,

/// The chain fee token contract.
pub fee_contracts: FeeContracts,

/// The chain's settlement layer configurations (if any).
pub settlement: Option<SettlementLayer>,
}

//////////////////////////////////////////////////////////////
// ChainSpec implementations
//////////////////////////////////////////////////////////////

impl ChainSpec {
/// Creates a new [`ChainSpec`] for Starknet mainnet.
pub fn mainnet() -> Self {
MAINNET.clone()
}

/// Creates a new [`ChainSpec`] for Starknet sepolia testnet.
pub fn sepolia() -> Self {
SEPOLIA.clone()
}
}

//////////////////////////////////////////////////////////////
// Predefined ChainSpec instances
//////////////////////////////////////////////////////////////

lazy_static! {
/// Starknet mainnet chain specification.
pub static ref MAINNET: ChainSpec = ChainSpec {
id: ChainId::MAINNET,
genesis: Genesis::default(),
fee_contracts: FeeContracts {
eth: katana_genesis::constant::DEFAULT_ETH_FEE_TOKEN_ADDRESS,
strk: katana_genesis::constant::DEFAULT_STRK_FEE_TOKEN_ADDRESS,
},
settlement: None,
};

/// Starknet sepolia testnet chain specification.
pub static ref SEPOLIA: ChainSpec = ChainSpec {
id: ChainId::SEPOLIA,
genesis: Genesis::default(),
fee_contracts: FeeContracts {
eth: katana_genesis::constant::DEFAULT_ETH_FEE_TOKEN_ADDRESS,
strk: katana_genesis::constant::DEFAULT_STRK_FEE_TOKEN_ADDRESS,
},
settlement: None,
};
}
22 changes: 22 additions & 0 deletions crates/chain-spec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ use serde::{Deserialize, Serialize};
use url::Url;

pub mod dev;
pub mod full_node;
pub mod rollup;

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ChainSpec {
Dev(dev::ChainSpec),
Rollup(rollup::ChainSpec),
FullNode(full_node::ChainSpec),
}

//////////////////////////////////////////////////////////////
Expand All @@ -24,31 +26,45 @@ impl ChainSpec {
Self::Dev(dev::DEV.clone())
}

/// Creates a new [`ChainSpec`] for Starknet mainnet.
pub fn mainnet() -> Self {
Self::FullNode(full_node::ChainSpec::mainnet())
}

/// Creates a new [`ChainSpec`] for Starknet sepolia testnet.
pub fn sepolia() -> Self {
Self::FullNode(full_node::ChainSpec::sepolia())
}

pub fn id(&self) -> ChainId {
match self {
Self::Dev(spec) => spec.id,
Self::Rollup(spec) => spec.id,
Self::FullNode(spec) => spec.id,
}
}

pub fn genesis(&self) -> &Genesis {
match self {
Self::Dev(spec) => &spec.genesis,
Self::Rollup(spec) => &spec.genesis,
Self::FullNode(spec) => &spec.genesis,
}
}

pub fn settlement(&self) -> Option<&SettlementLayer> {
match self {
Self::Dev(spec) => spec.settlement.as_ref(),
Self::Rollup(spec) => Some(&spec.settlement),
Self::FullNode(spec) => spec.settlement.as_ref(),
}
}

pub fn fee_contracts(&self) -> &FeeContracts {
match self {
Self::Dev(spec) => &spec.fee_contracts,
Self::Rollup(spec) => &spec.fee_contracts,
Self::FullNode(spec) => &spec.fee_contracts,
}
}
}
Expand All @@ -65,6 +81,12 @@ impl From<rollup::ChainSpec> for ChainSpec {
}
}

impl From<full_node::ChainSpec> for ChainSpec {
fn from(spec: full_node::ChainSpec) -> Self {
Self::FullNode(spec)
}
}

impl Default for ChainSpec {
fn default() -> Self {
Self::dev()
Expand Down
122 changes: 119 additions & 3 deletions crates/cli/src/full.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
use std::path::PathBuf;

use anyhow::{anyhow, Result};
use anyhow::{Context, Result};
pub use clap::Parser;
use katana_node::config::db::DbConfig;
use katana_node::config::metrics::MetricsConfig;
use katana_node::config::rpc::RpcConfig;
use katana_node::full;
use katana_node::full::Network;
use serde::{Deserialize, Serialize};
use tracing::info;

use crate::options::*;

pub(crate) const LOG_TARGET: &str = "katana::cli::full";

#[derive(Parser, Debug, Serialize, Deserialize, Default, Clone, PartialEq)]
#[command(next_help_heading = "Full node options")]
pub struct FullNodeArgs {
Expand All @@ -19,7 +27,19 @@ pub struct FullNodeArgs {
/// previously initialized Katana database.
#[arg(long)]
#[arg(value_name = "PATH")]
pub db_dir: Option<PathBuf>,
pub db_dir: PathBuf,

#[arg(long = "eth.rpc")]
#[arg(value_name = "PATH")]
pub eth_rpc_url: String,

#[arg(long)]
pub network: Network,

/// Gateway API key for accessing the sequencer gateway.
#[arg(long)]
#[arg(value_name = "KEY")]
pub gateway_api_key: Option<String>,

#[command(flatten)]
pub logging: LoggingOptions,
Expand All @@ -42,6 +62,102 @@ pub struct FullNodeArgs {

impl FullNodeArgs {
pub async fn execute(&self) -> Result<()> {
Err(anyhow!("Full node is not implemented yet!"))
// Initialize logging with tracer
let tracer_config = self.tracer_config();
katana_tracing::init(self.logging.log_format, tracer_config).await?;
self.start_node().await
}

async fn start_node(&self) -> Result<()> {
// Build the node
let config = self.config()?;
let node = full::Node::build(config).context("failed to build full node")?;

if !self.silent {
info!(target: LOG_TARGET, "Starting full node");
}

// Launch the node
let handle = node.launch().await.context("failed to launch full node")?;

// Wait until an OS signal (ie SIGINT, SIGTERM) is received or the node is shutdown.
tokio::select! {
_ = katana_utils::wait_shutdown_signals() => {
// Gracefully shutdown the node before exiting
handle.stop().await?;
},

_ = handle.stopped() => { }
}

info!("Shutting down.");

Ok(())
}

fn config(&self) -> Result<full::Config> {
let db = self.db_config();
let rpc = self.rpc_config()?;
let metrics = self.metrics_config();

Ok(full::Config {
db,
rpc,
metrics,
network: self.network,
eth_rpc_url: self.eth_rpc_url.clone(),
gateway_api_key: self.gateway_api_key.clone(),
})
}

fn db_config(&self) -> DbConfig {
DbConfig { dir: Some(self.db_dir.clone()) }
}

fn rpc_config(&self) -> Result<RpcConfig> {
#[cfg(feature = "server")]
{
use std::time::Duration;

let cors_origins = self.server.http_cors_origins.clone();

Ok(RpcConfig {
apis: Default::default(),
port: self.server.http_port,
addr: self.server.http_addr,
max_connections: self.server.max_connections,
max_concurrent_estimate_fee_requests: None,
max_request_body_size: None,
max_response_body_size: None,
timeout: self.server.timeout.map(Duration::from_secs),
cors_origins,
#[cfg(feature = "explorer")]
explorer: self.explorer.explorer,
max_event_page_size: Some(self.server.max_event_page_size),
max_proof_keys: Some(self.server.max_proof_keys),
max_call_gas: Some(self.server.max_call_gas),
})
}

#[cfg(not(feature = "server"))]
{
Ok(RpcConfig::default())
}
}

fn metrics_config(&self) -> Option<MetricsConfig> {
#[cfg(feature = "server")]
if self.metrics.metrics {
Some(MetricsConfig { addr: self.metrics.metrics_addr, port: self.metrics.metrics_port })
} else {
None
}

#[cfg(not(feature = "server"))]
None
}

fn tracer_config(&self) -> Option<katana_tracing::TracerConfig> {
self.tracer.config()
}
}
2 changes: 2 additions & 0 deletions crates/cli/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ PREDEPLOYED CONTRACTS
cs.fee_contracts.strk, DEFAULT_LEGACY_ERC20_CLASS_HASH,
);
}

ChainSpec::FullNode(..) => {}
}

println!(
Expand Down
5 changes: 5 additions & 0 deletions crates/core/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ impl<EF: ExecutorFactory> Backend<EF> {
match self.chain_spec.as_ref() {
ChainSpec::Dev(cs) => self.init_dev_genesis(cs),
ChainSpec::Rollup(cs) => self.init_rollup_genesis(cs),
ChainSpec::FullNode(_) => {
// Full nodes sync from the network, so we skip genesis initialization
info!("Full node mode: genesis initialization skipped, will sync from network");
Ok(())
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion crates/gateway/gateway-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ version.workspace = true

[dependencies]
katana-gateway-types.workspace = true
katana-primitives.workspace = true
katana-executor.workspace = true
katana-core.workspace = true
katana-primitives.workspace = true
katana-metrics.workspace = true
katana-pool.workspace = true
katana-rpc-server.workspace = true
katana-pool-api.workspace = true
katana-rpc-api.workspace = true
katana-provider-api.workspace = true
serde-utils.workspace = true
Expand Down
Loading
Loading