diff --git a/Cargo.lock b/Cargo.lock index f12cc5c211..6c69d4d273 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1673,7 +1673,6 @@ dependencies = [ "dojo-world", "futures", "hex", - "katana-core", "katana-runner", "lazy_static", "proptest", @@ -8378,7 +8377,6 @@ dependencies = [ "alloy-primitives", "anyhow", "assert_matches", - "cfg-if", "clap", "clap_complete", "common 1.0.0-alpha.0", @@ -8392,7 +8390,6 @@ dependencies = [ "katana-slot-controller", "serde_json", "shellexpand", - "starknet_api", "tokio", "tracing", "tracing-subscriber", @@ -8410,6 +8407,7 @@ dependencies = [ "cairo-lang-starknet-classes 2.6.3", "cairo-lang-utils 2.6.3", "cairo-vm 0.9.2", + "starknet_api", ] [[package]] @@ -8439,20 +8437,16 @@ dependencies = [ "alloy-primitives", "alloy-provider 0.1.0", "alloy-rpc-types", - "alloy-signer 0.1.0", "alloy-sol-types", "alloy-transport 0.1.0", "anyhow", "assert_matches", "async-trait", "cairo-vm 0.9.2", - "convert_case 0.6.0", "derive_more", "dojo-metrics", - "flate2", "futures", "hex", - "k256", "katana-db", "katana-executor", "katana-primitives", @@ -8462,13 +8456,10 @@ dependencies = [ "metrics", "num-traits 0.2.19", "parking_lot 0.12.3", - "rand", "reqwest 0.12.5", "serde", "serde_json", - "serde_with 2.3.3", "starknet 0.11.0", - "starknet_api", "tempfile", "thiserror", "tokio", @@ -8481,9 +8472,9 @@ name = "katana-db" version = "1.0.0-alpha.0" dependencies = [ "anyhow", - "cairo-lang-starknet 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", "cairo-vm 0.9.2", "criterion", + "katana-cairo", "katana-primitives", "page_size", "parking_lot 0.12.3", @@ -8493,7 +8484,6 @@ dependencies = [ "serde", "serde_json", "starknet 0.11.0", - "starknet_api", "tempfile", "thiserror", ] @@ -8507,7 +8497,6 @@ dependencies = [ "blockifier", "convert_case 0.6.0", "criterion", - "futures", "katana-cairo", "katana-primitives", "katana-provider", @@ -8519,7 +8508,6 @@ dependencies = [ "serde_json", "similar-asserts", "starknet 0.11.0", - "starknet_api", "thiserror", "tokio", "tracing", @@ -8558,8 +8546,6 @@ dependencies = [ "similar-asserts", "starknet 0.11.0", "starknet-crypto 0.7.1", - "starknet_api", - "strum 0.25.0", "strum_macros 0.25.3", "thiserror", ] @@ -8598,16 +8584,13 @@ dependencies = [ "anyhow", "assert_matches", "cainome 0.2.3 (git+https://github.com/cartridge-gg/cainome?tag=v0.3.0)", - "cairo-lang-starknet 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-starknet-classes 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", "dojo-metrics", "dojo-test-utils", "dojo-world", - "flate2", "futures", - "hex", "hyper 0.14.29", "jsonrpsee 0.16.3", + "katana-cairo", "katana-core", "katana-executor", "katana-primitives", @@ -8622,11 +8605,8 @@ dependencies = [ "rand", "serde", "serde_json", - "serde_with 2.3.3", "starknet 0.11.0", - "starknet_api", "tempfile", - "thiserror", "tokio", "tower", "tower-http", @@ -12453,32 +12433,22 @@ dependencies = [ "cairo-vm 0.9.2", "celestia-rpc", "celestia-types", - "convert_case 0.6.0", "dojo-world", - "flate2", "futures", "itertools 0.12.1", - "katana-db", - "katana-executor", "katana-primitives", "katana-provider", "katana-rpc-types", - "lazy_static", "num-bigint", "num-traits 0.2.19", "once_cell", - "parking_lot 0.12.3", "prover-sdk", - "rand", - "reqwest 0.12.5", "saya-provider", "serde", "serde_json", - "serde_with 2.3.3", "starknet 0.11.0", "starknet-crypto 0.7.1", "starknet-types-core", - "starknet_api", "thiserror", "tokio", "tracing", @@ -12497,6 +12467,7 @@ dependencies = [ "flate2", "futures", "jsonrpsee 0.16.3", + "katana-cairo", "katana-db", "katana-executor", "katana-primitives", @@ -12509,7 +12480,6 @@ dependencies = [ "serde_json", "serde_with 2.3.3", "starknet 0.11.0", - "starknet_api", "thiserror", "tokio", "tracing", diff --git a/bin/katana/Cargo.toml b/bin/katana/Cargo.toml index a9e8ec4442..e6d20018b5 100644 --- a/bin/katana/Cargo.toml +++ b/bin/katana/Cargo.toml @@ -9,7 +9,6 @@ version.workspace = true [dependencies] alloy-primitives.workspace = true anyhow.workspace = true -cfg-if = "1.0.0" clap.workspace = true clap_complete.workspace = true common.workspace = true @@ -22,7 +21,6 @@ katana-rpc-api.workspace = true katana-rpc.workspace = true serde_json.workspace = true shellexpand = "3.1.0" -starknet_api.workspace = true tokio.workspace = true tracing-subscriber.workspace = true tracing.workspace = true diff --git a/bin/katana/src/main.rs b/bin/katana/src/main.rs index b3edb21a49..516b7619f9 100644 --- a/bin/katana/src/main.rs +++ b/bin/katana/src/main.rs @@ -1,3 +1,5 @@ +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + use std::io; use std::net::SocketAddr; use std::sync::Arc; diff --git a/bin/sozo/src/commands/mod.rs b/bin/sozo/src/commands/mod.rs index 788d0b8fe2..158fd8bfed 100644 --- a/bin/sozo/src/commands/mod.rs +++ b/bin/sozo/src/commands/mod.rs @@ -53,8 +53,8 @@ pub enum Commands { Init(InitArgs), #[command(about = "Remove generated artifacts, manifests and abis")] Clean(CleanArgs), - #[command(about = "Run a migration, declaring and deploying contracts as necessary to update \ - the world")] + #[command(about = "Run a migration, declaring and deploying contracts as necessary to \ + update the world")] Migrate(Box), #[command(about = "Developer mode: watcher for building and migration")] Dev(DevArgs), diff --git a/crates/benches/Cargo.toml b/crates/benches/Cargo.toml index 279b24fe50..e46982d00c 100644 --- a/crates/benches/Cargo.toml +++ b/crates/benches/Cargo.toml @@ -9,7 +9,7 @@ version.workspace = true clap_builder = "4.4.6" reqwest = { workspace = true, features = [ "blocking", "json", "rustls-tls" ], default-features = false } -katana-core = { path = "../katana/core" } +# katana-core = { path = "../katana/core" } katana-runner.workspace = true anyhow.workspace = true diff --git a/crates/katana/cairo/Cargo.toml b/crates/katana/cairo/Cargo.toml index db98902c83..03023d508f 100644 --- a/crates/katana/cairo/Cargo.toml +++ b/crates/katana/cairo/Cargo.toml @@ -17,3 +17,4 @@ cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo", tag = " cairo-lang-starknet-classes = { git = "https://github.com/starkware-libs/cairo", tag = "v2.6.3" } cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo", tag = "v2.6.3" } cairo-vm = "0.9.2" +starknet_api = "0.11.0" diff --git a/crates/katana/cairo/src/lib.rs b/crates/katana/cairo/src/lib.rs index c8e39061e4..cd07971926 100644 --- a/crates/katana/cairo/src/lib.rs +++ b/crates/katana/cairo/src/lib.rs @@ -10,4 +10,4 @@ pub mod lang { }; } -pub use cairo_vm; +pub use {cairo_vm, starknet_api}; diff --git a/crates/katana/core/Cargo.toml b/crates/katana/core/Cargo.toml index 7497cd7441..a452c5ad5e 100644 --- a/crates/katana/core/Cargo.toml +++ b/crates/katana/core/Cargo.toml @@ -14,25 +14,19 @@ katana-provider.workspace = true katana-tasks.workspace = true anyhow.workspace = true -async-trait.workspace = true +async-trait = { workspace = true, optional = true } cairo-vm.workspace = true -convert_case.workspace = true derive_more.workspace = true dojo-metrics.workspace = true -flate2.workspace = true futures.workspace = true -k256 = { version = "0.13", default-features = false, features = [ "ecdsa", "std" ] } lazy_static.workspace = true metrics.workspace = true num-traits.workspace = true parking_lot.workspace = true -rand = { workspace = true, features = [ "small_rng" ] } -reqwest.workspace = true -serde.workspace = true -serde_json.workspace = true -serde_with.workspace = true +reqwest = { workspace = true, optional = true } +serde = { workspace = true, optional = true } +serde_json = { workspace = true, optional = true } starknet.workspace = true -starknet_api.workspace = true thiserror.workspace = true tokio.workspace = true tracing.workspace = true @@ -45,7 +39,6 @@ alloy-contract = { version = "0.1.0", default-features = false, optional = true alloy-network = { version = "0.1.0", default-features = false, optional = true } alloy-provider = { version = "0.1.0", default-features = false, optional = true, features = [ "reqwest" ] } alloy-rpc-types = { version = "0.1.0", default-features = false, optional = true } -alloy-signer = { version = "0.1.0", default-features = false, optional = true } alloy-transport = { version = "0.1.0", default-features = false, optional = true } [dev-dependencies] @@ -59,8 +52,11 @@ messaging = [ "alloy-network", "alloy-provider", "alloy-rpc-types", - "alloy-signer", "alloy-sol-types", "alloy-transport", + "async-trait", + "reqwest", + "serde", + "serde_json", ] starknet-messaging = [ ] diff --git a/crates/katana/core/src/lib.rs b/crates/katana/core/src/lib.rs index 44d3fa5ab0..bbeede3914 100644 --- a/crates/katana/core/src/lib.rs +++ b/crates/katana/core/src/lib.rs @@ -1,3 +1,5 @@ +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + pub mod backend; pub mod constants; pub mod env; diff --git a/crates/katana/executor/Cargo.toml b/crates/katana/executor/Cargo.toml index 5e984c5bae..462d330958 100644 --- a/crates/katana/executor/Cargo.toml +++ b/crates/katana/executor/Cargo.toml @@ -11,16 +11,11 @@ katana-primitives.workspace = true katana-provider.workspace = true convert_case.workspace = true -futures.workspace = true parking_lot.workspace = true -serde_json.workspace = true -starknet.workspace = true -starknet_api.workspace = true +starknet = { workspace = true, optional = true } thiserror.workspace = true tracing.workspace = true -alloy-primitives.workspace = true - # blockifier deps blockifier = { git = "https://github.com/dojoengine/blockifier", rev = "57c11586", features = [ "testing" ], optional = true } katana-cairo = { workspace = true, optional = true } @@ -32,6 +27,7 @@ katana-cairo = { workspace = true, optional = true } # starknet-types-core = { version = "0.0.9", optional = true } [dev-dependencies] +alloy-primitives.workspace = true anyhow.workspace = true katana-cairo.workspace = true katana-provider = { workspace = true, features = [ "test-utils" ] } @@ -46,7 +42,7 @@ criterion.workspace = true pprof = { version = "0.13.0", features = [ "criterion", "flamegraph" ] } [features] -blockifier = [ "dep:blockifier", "dep:katana-cairo" ] +blockifier = [ "dep:blockifier", "dep:katana-cairo", "dep:starknet" ] default = [ "blockifier" ] # native = [ "sir", "sir/cairo-native" ] # sir = [ "dep:sir", "dep:starknet-types-core" ] diff --git a/crates/katana/executor/src/implementation/blockifier/mod.rs b/crates/katana/executor/src/implementation/blockifier/mod.rs index 94a344aab8..c9d856fe11 100644 --- a/crates/katana/executor/src/implementation/blockifier/mod.rs +++ b/crates/katana/executor/src/implementation/blockifier/mod.rs @@ -8,13 +8,13 @@ use blockifier::block::{BlockInfo, GasPrices}; use blockifier::context::BlockContext; use blockifier::state::cached_state::{self, GlobalContractCache, MutRefState}; use blockifier::state::state_api::StateReader; +use katana_cairo::starknet_api::block::{BlockNumber, BlockTimestamp}; use katana_primitives::block::{ExecutableBlock, GasPrices as KatanaGasPrices, PartialHeader}; use katana_primitives::env::{BlockEnv, CfgEnv}; use katana_primitives::fee::TxFeeInfo; use katana_primitives::transaction::{ExecutableTx, ExecutableTxWithHash, TxWithHash}; use katana_primitives::FieldElement; use katana_provider::traits::state::StateProvider; -use starknet_api::block::{BlockNumber, BlockTimestamp}; use tracing::info; use self::state::CachedState; diff --git a/crates/katana/executor/src/implementation/blockifier/state.rs b/crates/katana/executor/src/implementation/blockifier/state.rs index 49d4b17462..05de7b05c2 100644 --- a/crates/katana/executor/src/implementation/blockifier/state.rs +++ b/crates/katana/executor/src/implementation/blockifier/state.rs @@ -4,6 +4,8 @@ use std::sync::Arc; use blockifier::state::cached_state::{self, GlobalContractCache}; use blockifier::state::errors::StateError; use blockifier::state::state_api::{StateReader, StateResult}; +use katana_cairo::starknet_api::core::{ClassHash, CompiledClassHash, Nonce}; +use katana_cairo::starknet_api::state::StorageKey; use katana_primitives::class::{CompiledClass, FlattenedSierraClass}; use katana_primitives::FieldElement; use katana_provider::error::ProviderError; @@ -11,8 +13,6 @@ use katana_provider::traits::contract::ContractClassProvider; use katana_provider::traits::state::StateProvider; use katana_provider::ProviderResult; use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard}; -use starknet_api::core::{ClassHash, CompiledClassHash, Nonce}; -use starknet_api::state::StorageKey; use super::utils::{self, to_felt, to_stark_felt}; use super::CACHE_SIZE; @@ -26,8 +26,8 @@ impl StateDb for T where T: StateProvider + StateReader {} impl<'a> StateReader for StateProviderDb<'a> { fn get_class_hash_at( &mut self, - contract_address: starknet_api::core::ContractAddress, - ) -> StateResult { + contract_address: katana_cairo::starknet_api::core::ContractAddress, + ) -> StateResult { self.0 .class_hash_of_contract(utils::to_address(contract_address)) .map(|v| ClassHash(to_stark_felt(v.unwrap_or_default()))) @@ -36,8 +36,8 @@ impl<'a> StateReader for StateProviderDb<'a> { fn get_compiled_class_hash( &mut self, - class_hash: starknet_api::core::ClassHash, - ) -> StateResult { + class_hash: katana_cairo::starknet_api::core::ClassHash, + ) -> StateResult { if let Some(hash) = self .0 .compiled_class_hash_of_class_hash(to_felt(class_hash.0)) @@ -69,8 +69,8 @@ impl<'a> StateReader for StateProviderDb<'a> { fn get_nonce_at( &mut self, - contract_address: starknet_api::core::ContractAddress, - ) -> StateResult { + contract_address: katana_cairo::starknet_api::core::ContractAddress, + ) -> StateResult { self.0 .nonce(utils::to_address(contract_address)) .map(|n| Nonce(to_stark_felt(n.unwrap_or_default()))) @@ -79,9 +79,9 @@ impl<'a> StateReader for StateProviderDb<'a> { fn get_storage_at( &mut self, - contract_address: starknet_api::core::ContractAddress, - key: starknet_api::state::StorageKey, - ) -> StateResult { + contract_address: katana_cairo::starknet_api::core::ContractAddress, + key: katana_cairo::starknet_api::state::StorageKey, + ) -> StateResult { self.0 .storage(utils::to_address(contract_address), to_felt(*key.0.key())) .map(|v| to_stark_felt(v.unwrap_or_default())) @@ -215,7 +215,7 @@ impl StateProvider for CachedState { impl StateReader for CachedState { fn get_class_hash_at( &mut self, - contract_address: starknet_api::core::ContractAddress, + contract_address: katana_cairo::starknet_api::core::ContractAddress, ) -> StateResult { self.write().inner.get_class_hash_at(contract_address) } @@ -233,16 +233,16 @@ impl StateReader for CachedState { fn get_nonce_at( &mut self, - contract_address: starknet_api::core::ContractAddress, + contract_address: katana_cairo::starknet_api::core::ContractAddress, ) -> StateResult { self.write().inner.get_nonce_at(contract_address) } fn get_storage_at( &mut self, - contract_address: starknet_api::core::ContractAddress, + contract_address: katana_cairo::starknet_api::core::ContractAddress, key: StorageKey, - ) -> StateResult { + ) -> StateResult { self.write().inner.get_storage_at(contract_address, key) } } @@ -251,6 +251,9 @@ impl StateReader for CachedState { mod tests { use blockifier::state::state_api::{State, StateReader}; + use katana_cairo::starknet_api::core::PatriciaKey; + use katana_cairo::starknet_api::hash::StarkHash; + use katana_cairo::starknet_api::patricia_key; use katana_primitives::class::{CompiledClass, FlattenedSierraClass}; use katana_primitives::contract::ContractAddress; use katana_primitives::genesis::constant::{ @@ -263,9 +266,6 @@ mod tests { use katana_provider::traits::contract::ContractClassWriter; use katana_provider::traits::state::{StateFactoryProvider, StateProvider, StateWriter}; use starknet::macros::felt; - use starknet_api::core::PatriciaKey; - use starknet_api::hash::StarkHash; - use starknet_api::patricia_key; use super::{CachedState, *}; use crate::StateProviderDb; diff --git a/crates/katana/executor/src/implementation/blockifier/utils.rs b/crates/katana/executor/src/implementation/blockifier/utils.rs index 9a07699b15..4a6114b89d 100644 --- a/crates/katana/executor/src/implementation/blockifier/utils.rs +++ b/crates/katana/executor/src/implementation/blockifier/utils.rs @@ -28,6 +28,21 @@ use blockifier::transaction::transactions::{ use blockifier::versioned_constants::VersionedConstants; use katana_cairo::cairo_vm::types::errors::program_errors::ProgramError; use katana_cairo::cairo_vm::vm::runners::cairo_runner::ExecutionResources; +use katana_cairo::starknet_api::block::{BlockNumber, BlockTimestamp}; +use katana_cairo::starknet_api::core::{ + self, ChainId, ClassHash, CompiledClassHash, ContractAddress, Nonce, +}; +use katana_cairo::starknet_api::data_availability::DataAvailabilityMode; +use katana_cairo::starknet_api::deprecated_contract_class::EntryPointType; +use katana_cairo::starknet_api::hash::StarkFelt; +use katana_cairo::starknet_api::transaction::{ + AccountDeploymentData, Calldata, ContractAddressSalt, + DeclareTransaction as ApiDeclareTransaction, DeclareTransactionV0V1, DeclareTransactionV2, + DeclareTransactionV3, DeployAccountTransaction as ApiDeployAccountTransaction, + DeployAccountTransactionV1, DeployAccountTransactionV3, Fee, + InvokeTransaction as ApiInvokeTransaction, PaymasterData, Resource, ResourceBounds, + ResourceBoundsMapping, Tip, TransactionHash, TransactionSignature, TransactionVersion, +}; use katana_primitives::env::{BlockEnv, CfgEnv}; use katana_primitives::fee::TxFeeInfo; use katana_primitives::state::{StateUpdates, StateUpdatesWithDeclaredClasses}; @@ -39,19 +54,6 @@ use katana_primitives::{class, event, message, trace, FieldElement}; use katana_provider::traits::contract::ContractClassProvider; use starknet::core::types::PriceUnit; use starknet::core::utils::parse_cairo_short_string; -use starknet_api::block::{BlockNumber, BlockTimestamp}; -use starknet_api::core::{self, ChainId, ClassHash, CompiledClassHash, ContractAddress, Nonce}; -use starknet_api::data_availability::DataAvailabilityMode; -use starknet_api::deprecated_contract_class::EntryPointType; -use starknet_api::hash::StarkFelt; -use starknet_api::transaction::{ - AccountDeploymentData, Calldata, ContractAddressSalt, - DeclareTransaction as ApiDeclareTransaction, DeclareTransactionV0V1, DeclareTransactionV2, - DeclareTransactionV3, DeployAccountTransaction as ApiDeployAccountTransaction, - DeployAccountTransactionV1, DeployAccountTransactionV3, Fee, - InvokeTransaction as ApiInvokeTransaction, PaymasterData, Resource, ResourceBounds, - ResourceBoundsMapping, Tip, TransactionHash, TransactionSignature, TransactionVersion, -}; use super::state::{CachedState, StateDb}; use super::CACHE_SIZE; @@ -180,13 +182,15 @@ fn to_executor_tx(tx: ExecutableTxWithHash) -> Transaction { let signature = tx.signature.into_iter().map(to_stark_felt).collect(); Transaction::AccountTransaction(AccountTransaction::Invoke(InvokeTransaction { - tx: ApiInvokeTransaction::V1(starknet_api::transaction::InvokeTransactionV1 { - max_fee: Fee(tx.max_fee), - nonce: Nonce(to_stark_felt(tx.nonce)), - sender_address: to_blk_address(tx.sender_address), - signature: TransactionSignature(signature), - calldata: Calldata(Arc::new(calldata)), - }), + tx: ApiInvokeTransaction::V1( + katana_cairo::starknet_api::transaction::InvokeTransactionV1 { + max_fee: Fee(tx.max_fee), + nonce: Nonce(to_stark_felt(tx.nonce)), + sender_address: to_blk_address(tx.sender_address), + signature: TransactionSignature(signature), + calldata: Calldata(Arc::new(calldata)), + }, + ), tx_hash: TransactionHash(to_stark_felt(hash)), only_query: false, })) @@ -203,18 +207,20 @@ fn to_executor_tx(tx: ExecutableTxWithHash) -> Transaction { let nonce_data_availability_mode = to_api_da_mode(tx.nonce_data_availability_mode); Transaction::AccountTransaction(AccountTransaction::Invoke(InvokeTransaction { - tx: ApiInvokeTransaction::V3(starknet_api::transaction::InvokeTransactionV3 { - tip: Tip(tx.tip), - nonce: Nonce(to_stark_felt(tx.nonce)), - sender_address: to_blk_address(tx.sender_address), - signature: TransactionSignature(signature), - calldata: Calldata(Arc::new(calldata)), - paymaster_data: PaymasterData(paymaster_data), - account_deployment_data: AccountDeploymentData(account_deploy_data), - fee_data_availability_mode, - nonce_data_availability_mode, - resource_bounds: to_api_resource_bounds(tx.resource_bounds), - }), + tx: ApiInvokeTransaction::V3( + katana_cairo::starknet_api::transaction::InvokeTransactionV3 { + tip: Tip(tx.tip), + nonce: Nonce(to_stark_felt(tx.nonce)), + sender_address: to_blk_address(tx.sender_address), + signature: TransactionSignature(signature), + calldata: Calldata(Arc::new(calldata)), + paymaster_data: PaymasterData(paymaster_data), + account_deployment_data: AccountDeploymentData(account_deploy_data), + fee_data_availability_mode, + nonce_data_availability_mode, + resource_bounds: to_api_resource_bounds(tx.resource_bounds), + }, + ), tx_hash: TransactionHash(to_stark_felt(hash)), only_query: false, })) @@ -344,7 +350,7 @@ fn to_executor_tx(tx: ExecutableTxWithHash) -> Transaction { let calldata = tx.calldata.into_iter().map(to_stark_felt).collect(); Transaction::L1HandlerTransaction(L1HandlerTransaction { paid_fee_on_l1: Fee(tx.paid_fee_on_l1), - tx: starknet_api::transaction::L1HandlerTransaction { + tx: katana_cairo::starknet_api::transaction::L1HandlerTransaction { nonce: core::Nonce(to_stark_felt(tx.nonce)), calldata: Calldata(Arc::new(calldata)), version: TransactionVersion(1u128.into()), @@ -556,11 +562,14 @@ pub fn to_class(class: class::CompiledClass) -> Result } /// TODO: remove this function once starknet api 0.8.0 is supported. -fn starknet_api_ethaddr_to_felt(value: starknet_api::core::EthAddress) -> FieldElement { +fn starknet_api_ethaddr_to_felt( + value: katana_cairo::starknet_api::core::EthAddress, +) -> FieldElement { let mut bytes = [0u8; 32]; // Padding H160 with zeros to 32 bytes (big endian) bytes[12..32].copy_from_slice(value.0.as_bytes()); - let stark_felt = starknet_api::hash::StarkFelt::new(bytes).expect("valid slice for stark felt"); + let stark_felt = katana_cairo::starknet_api::hash::StarkFelt::new(bytes) + .expect("valid slice for stark felt"); to_felt(stark_felt) } @@ -670,12 +679,12 @@ mod tests { use std::collections::HashSet; use katana_cairo::cairo_vm::vm::runners::cairo_runner::ExecutionResources; + use katana_cairo::starknet_api::core::EntryPointSelector; + use katana_cairo::starknet_api::hash::StarkFelt; + use katana_cairo::starknet_api::stark_felt; + use katana_cairo::starknet_api::transaction::{EventContent, EventData, EventKey}; use katana_primitives::chain::{ChainId, NamedChainId}; use katana_primitives::felt::FieldElement; - use starknet_api::core::EntryPointSelector; - use starknet_api::hash::StarkFelt; - use starknet_api::stark_felt; - use starknet_api::transaction::{EventContent, EventData, EventKey}; use super::*; use crate::implementation::blockifier::utils; diff --git a/crates/katana/executor/src/lib.rs b/crates/katana/executor/src/lib.rs index 58b15c5484..6b2175b0d2 100644 --- a/crates/katana/executor/src/lib.rs +++ b/crates/katana/executor/src/lib.rs @@ -1,3 +1,5 @@ +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + pub mod implementation; mod utils; diff --git a/crates/katana/primitives/Cargo.toml b/crates/katana/primitives/Cargo.toml index 880ea906db..e7849582dd 100644 --- a/crates/katana/primitives/Cargo.toml +++ b/crates/katana/primitives/Cargo.toml @@ -11,23 +11,21 @@ anyhow.workspace = true base64.workspace = true derive_more.workspace = true lazy_static.workspace = true -num-traits.workspace = true rand = { workspace = true, features = [ "small_rng" ] } serde.workspace = true serde_json.workspace = true serde_with.workspace = true starknet-crypto.workspace = true starknet.workspace = true -strum.workspace = true strum_macros.workspace = true thiserror.workspace = true alloy-primitives.workspace = true flate2.workspace = true katana-cairo.workspace = true -starknet_api.workspace = true [dev-dependencies] +num-traits.workspace = true similar-asserts.workspace = true [features] diff --git a/crates/katana/primitives/src/class.rs b/crates/katana/primitives/src/class.rs index 2d73310fb5..e825e5c889 100644 --- a/crates/katana/primitives/src/class.rs +++ b/crates/katana/primitives/src/class.rs @@ -13,7 +13,8 @@ pub type SierraClass = starknet::core::types::contract::SierraClass; pub type FlattenedSierraClass = starknet::core::types::FlattenedSierraClass; /// Deprecated legacy (Cairo 0) CASM class -pub type DeprecatedCompiledClass = ::starknet_api::deprecated_contract_class::ContractClass; +pub type DeprecatedCompiledClass = + ::katana_cairo::starknet_api::deprecated_contract_class::ContractClass; /// Represents an executable Sierra program. #[derive(Debug, Clone, Eq, PartialEq)] diff --git a/crates/katana/primitives/src/conversion/rpc.rs b/crates/katana/primitives/src/conversion/rpc.rs index a21a47e7c2..f2d1ca7e81 100644 --- a/crates/katana/primitives/src/conversion/rpc.rs +++ b/crates/katana/primitives/src/conversion/rpc.rs @@ -4,6 +4,9 @@ use std::mem; use anyhow::{Context, Result}; use katana_cairo::lang::starknet_classes::casm_contract_class::CasmContractClass; +use katana_cairo::starknet_api::deprecated_contract_class::{ + ContractClassAbiEntry, EntryPoint, EntryPointType, TypedParameter, +}; use serde::Deserialize; use serde_json::json; use serde_with::serde_as; @@ -19,9 +22,6 @@ use starknet::core::types::{ LegacyFunctionAbiEntry, LegacyFunctionAbiType, LegacyStructAbiEntry, LegacyStructAbiType, LegacyStructMember, LegacyTypedParameter, }; -use starknet_api::deprecated_contract_class::{ - ContractClassAbiEntry, EntryPoint, EntryPointType, TypedParameter, -}; use crate::class::{ ClassHash, CompiledClassHash, DeprecatedCompiledClass, FlattenedSierraClass, @@ -202,7 +202,7 @@ fn rpc_to_cairo_contract_class( } fn compress_legacy_program_data( - legacy_program: starknet_api::deprecated_contract_class::Program, + legacy_program: katana_cairo::starknet_api::deprecated_contract_class::Program, ) -> Result, io::Error> { let bytes = serde_json::to_vec(&legacy_program)?; diff --git a/crates/katana/primitives/src/lib.rs b/crates/katana/primitives/src/lib.rs index 7accc01ceb..636a3bd7d5 100644 --- a/crates/katana/primitives/src/lib.rs +++ b/crates/katana/primitives/src/lib.rs @@ -1,3 +1,5 @@ +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + pub mod block; pub mod chain; pub mod class; diff --git a/crates/katana/rpc/rpc/Cargo.toml b/crates/katana/rpc/rpc/Cargo.toml index a5d5cbaf42..d50fbe53fb 100644 --- a/crates/katana/rpc/rpc/Cargo.toml +++ b/crates/katana/rpc/rpc/Cargo.toml @@ -7,8 +7,11 @@ repository.workspace = true version.workspace = true [dependencies] -dojo-world = { workspace = true } +anyhow.workspace = true dojo-metrics.workspace = true +futures.workspace = true +hyper.workspace = true +jsonrpsee = { workspace = true, features = [ "server" ] } katana-core.workspace = true katana-executor.workspace = true katana-primitives.workspace = true @@ -17,43 +20,26 @@ katana-rpc-api.workspace = true katana-rpc-types-builder.workspace = true katana-rpc-types.workspace = true katana-tasks.workspace = true -tempfile = "3.8.1" -anyhow.workspace = true -flate2.workspace = true -futures.workspace = true -hex = { workspace = true } -hyper.workspace = true -jsonrpsee = { workspace = true, features = [ "server" ] } metrics.workspace = true -rand.workspace = true -serde.workspace = true serde_json.workspace = true -serde_with.workspace = true starknet.workspace = true -starknet_api.workspace = true -thiserror.workspace = true -tokio.workspace = true tower = { workspace = true, features = [ "full" ] } tower-http = { workspace = true, features = [ "full" ] } tracing.workspace = true -cainome.workspace = true [dev-dependencies] +alloy = { git = "https://github.com/alloy-rs/alloy", features = [ "contract", "network", "node-bindings", "provider-http", "providers", "signer-local" ] } assert_matches.workspace = true -cairo-lang-starknet-classes.workspace = true -cairo-lang-starknet.workspace = true +cainome.workspace = true dojo-test-utils.workspace = true dojo-world.workspace = true jsonrpsee = { workspace = true, features = [ "client" ] } +katana-cairo.workspace = true katana-rpc-api = { workspace = true, features = [ "client" ] } katana-runner.workspace = true num-traits.workspace = true +rand.workspace = true +serde.workspace = true +tempfile.workspace = true +tokio.workspace = true url.workspace = true -alloy = { git = "https://github.com/alloy-rs/alloy", features = [ - "contract", - "network", - "providers", - "signer-local", - "provider-http", - "node-bindings" -] } diff --git a/crates/katana/rpc/rpc/src/lib.rs b/crates/katana/rpc/rpc/src/lib.rs index a3ee286fca..2c51606f67 100644 --- a/crates/katana/rpc/rpc/src/lib.rs +++ b/crates/katana/rpc/rpc/src/lib.rs @@ -1,4 +1,5 @@ #![allow(clippy::blocks_in_conditions)] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] pub mod config; pub mod dev; diff --git a/crates/katana/rpc/rpc/tests/common/mod.rs b/crates/katana/rpc/rpc/tests/common/mod.rs index e0aa36bdb2..1239748df5 100644 --- a/crates/katana/rpc/rpc/tests/common/mod.rs +++ b/crates/katana/rpc/rpc/tests/common/mod.rs @@ -2,8 +2,8 @@ use std::fs::File; use std::path::PathBuf; use anyhow::{anyhow, Result}; -use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; -use cairo_lang_starknet_classes::contract_class::ContractClass; +use katana_cairo::lang::starknet_classes::casm_contract_class::CasmContractClass; +use katana_cairo::lang::starknet_classes::contract_class::ContractClass; use katana_primitives::conversion::rpc::CompiledClass; use starknet::accounts::Call; use starknet::core::types::contract::SierraClass; diff --git a/crates/katana/storage/db/Cargo.toml b/crates/katana/storage/db/Cargo.toml index d0ed3c1e2a..c03d4ba58d 100644 --- a/crates/katana/storage/db/Cargo.toml +++ b/crates/katana/storage/db/Cargo.toml @@ -7,6 +7,7 @@ version.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +katana-cairo = { workspace = true } katana-primitives = { workspace = true } anyhow.workspace = true @@ -19,7 +20,6 @@ thiserror.workspace = true cairo-vm.workspace = true roaring = { version = "0.10.3", features = [ "serde" ] } -starknet_api.workspace = true # codecs [dependencies.postcard] @@ -34,7 +34,7 @@ package = "reth-libmdbx" rev = "b34b0d3" [dev-dependencies] -cairo-lang-starknet.workspace = true +# cairo-lang-starknet.workspace = true criterion.workspace = true starknet.workspace = true tempfile.workspace = true diff --git a/crates/katana/storage/provider/src/error.rs b/crates/katana/storage/provider/src/error.rs index 3876bbeec7..c02fda220d 100644 --- a/crates/katana/storage/provider/src/error.rs +++ b/crates/katana/storage/provider/src/error.rs @@ -73,7 +73,9 @@ pub enum ProviderError { /// Error when a contract nonce change entry is not found but the block number of when the /// change happen exists in the nonce change list. - #[error("Missing contract nonce change entry for contract {contract_address} at block {block}")] + #[error( + "Missing contract nonce change entry for contract {contract_address} at block {block}" + )] MissingContractNonceChangeEntry { /// The block number of when the change happen. block: BlockNumber, diff --git a/crates/saya/core/Cargo.toml b/crates/saya/core/Cargo.toml index 051b8f3c9d..2e716f6577 100644 --- a/crates/saya/core/Cargo.toml +++ b/crates/saya/core/Cargo.toml @@ -7,8 +7,6 @@ repository.workspace = true version.workspace = true [dependencies] -katana-db.workspace = true -katana-executor.workspace = true katana-primitives.workspace = true katana-provider.workspace = true katana-rpc-types.workspace = true @@ -19,22 +17,14 @@ async-trait.workspace = true bigdecimal.workspace = true cairo-proof-parser.workspace = true cairo-vm.workspace = true -convert_case.workspace = true dojo-world = { workspace = true, features = [ "contracts", "manifest", "metadata", "migration" ] } -flate2.workspace = true futures.workspace = true itertools.workspace = true -lazy_static.workspace = true -parking_lot.workspace = true -rand = { workspace = true, features = [ "small_rng" ] } -reqwest = { workspace = true, features = [ "rustls-tls" ] } serde.workspace = true serde_json.workspace = true -serde_with.workspace = true starknet-crypto.workspace = true starknet-types-core = { version = "0.1.4", default-features = false, features = [ "curve", "num-traits", "serde" ] } starknet.workspace = true -starknet_api.workspace = true thiserror.workspace = true tokio.workspace = true tracing.workspace = true diff --git a/crates/saya/core/src/lib.rs b/crates/saya/core/src/lib.rs index 030b2bd6ca..60f8d985cd 100644 --- a/crates/saya/core/src/lib.rs +++ b/crates/saya/core/src/lib.rs @@ -1,5 +1,7 @@ //! Saya core library. +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + use std::ops::RangeInclusive; use std::sync::Arc; diff --git a/crates/saya/provider/Cargo.toml b/crates/saya/provider/Cargo.toml index 2c1d7f15df..002e3d09f3 100644 --- a/crates/saya/provider/Cargo.toml +++ b/crates/saya/provider/Cargo.toml @@ -22,13 +22,13 @@ convert_case.workspace = true flate2.workspace = true futures.workspace = true jsonrpsee = { workspace = true, features = [ "client" ] } +katana-cairo.workspace = true lazy_static.workspace = true num-traits.workspace = true serde.workspace = true serde_json.workspace = true serde_with.workspace = true starknet.workspace = true -starknet_api.workspace = true thiserror.workspace = true tokio.workspace = true tracing.workspace = true