From 25092b85b6882b86763f933b42c39eede23211bf Mon Sep 17 00:00:00 2001 From: Ammar Arif Date: Mon, 30 Sep 2024 18:07:24 -0400 Subject: [PATCH 1/4] feat(katana-rpc): add `traceTransaction` and `traceBlockTransactions` API (#2486) --- .../src/implementation/blockifier/utils.rs | 7 +- crates/katana/primitives/src/trace.rs | 105 +++- crates/katana/primitives/src/transaction.rs | 32 ++ crates/katana/rpc/rpc/src/starknet/trace.rs | 467 +++++++++++------- crates/katana/rpc/rpc/tests/starknet.rs | 147 +++++- .../starknet_getTransactionStatus.hurl | 1 + examples/rpc/starknet/starknet_trace.hurl | 32 +- 7 files changed, 585 insertions(+), 206 deletions(-) diff --git a/crates/katana/executor/src/implementation/blockifier/utils.rs b/crates/katana/executor/src/implementation/blockifier/utils.rs index 4568a387f6..544b14c0f8 100644 --- a/crates/katana/executor/src/implementation/blockifier/utils.rs +++ b/crates/katana/executor/src/implementation/blockifier/utils.rs @@ -49,7 +49,7 @@ use katana_primitives::fee::TxFeeInfo; use katana_primitives::state::{StateUpdates, StateUpdatesWithDeclaredClasses}; use katana_primitives::trace::{L1Gas, TxExecInfo, TxResources}; use katana_primitives::transaction::{ - DeclareTx, DeployAccountTx, ExecutableTx, ExecutableTxWithHash, InvokeTx, + DeclareTx, DeployAccountTx, ExecutableTx, ExecutableTxWithHash, InvokeTx, TxType, }; use katana_primitives::{class, event, message, trace, Felt}; use katana_provider::traits::contract::ContractClassProvider; @@ -126,7 +126,7 @@ pub fn transact( match transact_inner(state, block_context, simulation_flags, to_executor_tx(tx.clone())) { Ok((info, fee)) => { // get the trace and receipt from the execution info - let trace = to_exec_info(info); + let trace = to_exec_info(info, tx.r#type()); let receipt = build_receipt(tx.tx_ref(), fee, &trace); ExecutionResult::new_success(receipt, trace) } @@ -563,8 +563,9 @@ fn starknet_api_ethaddr_to_felt(value: katana_cairo::starknet_api::core::EthAddr Felt::from_bytes_be(&bytes) } -pub fn to_exec_info(exec_info: TransactionExecutionInfo) -> TxExecInfo { +pub fn to_exec_info(exec_info: TransactionExecutionInfo, r#type: TxType) -> TxExecInfo { TxExecInfo { + r#type, validate_call_info: exec_info.validate_call_info.map(to_call_info), execute_call_info: exec_info.execute_call_info.map(to_call_info), fee_transfer_call_info: exec_info.fee_transfer_call_info.map(to_call_info), diff --git a/crates/katana/primitives/src/trace.rs b/crates/katana/primitives/src/trace.rs index 3530f5e251..8a69871ed3 100644 --- a/crates/katana/primitives/src/trace.rs +++ b/crates/katana/primitives/src/trace.rs @@ -1,11 +1,13 @@ -use std::collections::HashSet; +use std::collections::{HashMap, HashSet}; +use katana_cairo::cairo_vm::types::builtin_name::BuiltinName; use katana_cairo::cairo_vm::vm; use crate::class::ClassHash; use crate::contract::ContractAddress; use crate::event::OrderedEvent; use crate::message::OrderedL2ToL1Message; +use crate::transaction::TxType; use crate::Felt; pub type ExecutionResources = vm::runners::cairo_runner::ExecutionResources; @@ -26,6 +28,8 @@ pub struct TxExecInfo { pub actual_resources: TxResources, /// Error string for reverted transactions; [None] if transaction execution was successful. pub revert_error: Option, + /// The transaction type of this execution info. + pub r#type: TxType, } #[derive(Debug, Clone, PartialEq, Eq, Default)] @@ -107,3 +111,102 @@ pub struct CallInfo { /// True if the execution has failed, false otherwise. pub failed: bool, } + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct BuiltinCounters(HashMap); + +impl BuiltinCounters { + /// Returns the number of instances of the `output` builtin, if any. + pub fn output(&self) -> Option { + self.builtin(BuiltinName::output) + } + + /// Returns the number of instances of the `range_check` builtin, if any. + pub fn range_check(&self) -> Option { + self.builtin(BuiltinName::range_check) + } + + /// Returns the number of instances of the `pedersen` builtin, if any. + pub fn pedersen(&self) -> Option { + self.builtin(BuiltinName::pedersen) + } + + /// Returns the number of instances of the `ecdsa` builtin, if any. + pub fn ecdsa(&self) -> Option { + self.builtin(BuiltinName::ecdsa) + } + + /// Returns the number of instances of the `keccak` builtin, if any. + pub fn keccak(&self) -> Option { + self.builtin(BuiltinName::keccak) + } + + /// Returns the number of instances of the `bitwise` builtin, if any. + pub fn bitwise(&self) -> Option { + self.builtin(BuiltinName::bitwise) + } + + /// Returns the number of instances of the `ec_op` builtin, if any. + pub fn ec_op(&self) -> Option { + self.builtin(BuiltinName::ec_op) + } + + /// Returns the number of instances of the `poseidon` builtin, if any. + pub fn poseidon(&self) -> Option { + self.builtin(BuiltinName::poseidon) + } + + /// Returns the number of instances of the `segment_arena` builtin, if any. + pub fn segment_arena(&self) -> Option { + self.builtin(BuiltinName::segment_arena) + } + + /// Returns the number of instances of the `range_check96` builtin, if any. + pub fn range_check96(&self) -> Option { + self.builtin(BuiltinName::range_check96) + } + + /// Returns the number of instances of the `add_mod` builtin, if any. + pub fn add_mod(&self) -> Option { + self.builtin(BuiltinName::add_mod) + } + + /// Returns the number of instances of the `mul_mod` builtin, if any. + pub fn mul_mod(&self) -> Option { + self.builtin(BuiltinName::mul_mod) + } + + fn builtin(&self, builtin: BuiltinName) -> Option { + self.0.get(&builtin).map(|&x| x as u64) + } +} + +impl From> for BuiltinCounters { + fn from(map: HashMap) -> Self { + // Filter out the builtins with 0 count. + let filtered = map.into_iter().filter(|(_, count)| *count != 0).collect(); + BuiltinCounters(filtered) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_builtin_counters_from_hashmap_removes_zero_entries() { + let mut map = HashMap::new(); + map.insert(BuiltinName::output, 1); + map.insert(BuiltinName::range_check, 0); + map.insert(BuiltinName::pedersen, 2); + map.insert(BuiltinName::ecdsa, 0); + + let counters = BuiltinCounters::from(map); + + assert_eq!(counters.output(), Some(1)); + assert_eq!(counters.range_check(), None); + assert_eq!(counters.pedersen(), Some(2)); + assert_eq!(counters.ecdsa(), None); + } +} diff --git a/crates/katana/primitives/src/transaction.rs b/crates/katana/primitives/src/transaction.rs index 0fe976d77b..54f039c05b 100644 --- a/crates/katana/primitives/src/transaction.rs +++ b/crates/katana/primitives/src/transaction.rs @@ -17,6 +17,29 @@ pub type TxHash = Felt; /// The sequential number for all the transactions. pub type TxNumber = u64; +/// The transaction types as defined by the [Starknet API]. +/// +/// [Starknet API]: https://github.com/starkware-libs/starknet-specs/blob/b5c43955b1868b8e19af6d1736178e02ec84e678/api/starknet_api_openrpc.json +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub enum TxType { + /// Invokes a function of a contract. + #[default] + Invoke, + + /// Declares new contract class. + Declare, + + /// Deploys new account contracts. + DeployAccount, + + /// Function invocation that is instantiated from the L1. + /// + /// It is only used internally for handling messages sent from L1. Therefore, it is not a + /// transaction that can be broadcasted like the other transaction types. + L1Handler, +} + #[derive(Debug, Clone, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Tx { @@ -63,6 +86,15 @@ impl ExecutableTx { ExecutableTx::DeployAccount(tx) => TxRef::DeployAccount(tx), } } + + pub fn r#type(&self) -> TxType { + match self { + ExecutableTx::Invoke(_) => TxType::Invoke, + ExecutableTx::Declare(_) => TxType::Declare, + ExecutableTx::L1Handler(_) => TxType::L1Handler, + ExecutableTx::DeployAccount(_) => TxType::DeployAccount, + } + } } #[derive(Debug, Clone, AsRef, Deref)] diff --git a/crates/katana/rpc/rpc/src/starknet/trace.rs b/crates/katana/rpc/rpc/src/starknet/trace.rs index dade31c98e..ac98527efb 100644 --- a/crates/katana/rpc/rpc/src/starknet/trace.rs +++ b/crates/katana/rpc/rpc/src/starknet/trace.rs @@ -1,32 +1,192 @@ -use jsonrpsee::core::{async_trait, Error, RpcResult}; -use jsonrpsee::types::error::{CallError, METHOD_NOT_FOUND_CODE}; -use jsonrpsee::types::ErrorObject; +use jsonrpsee::core::{async_trait, RpcResult}; use katana_executor::{ExecutionResult, ExecutorFactory, ResultAndStates}; -use katana_primitives::block::BlockIdOrTag; -use katana_primitives::receipt::Receipt; -use katana_primitives::transaction::{ExecutableTx, ExecutableTxWithHash, TxHash}; +use katana_primitives::block::{BlockHashOrNumber, BlockIdOrTag}; +use katana_primitives::fee::TxFeeInfo; +use katana_primitives::trace::{BuiltinCounters, TxExecInfo}; +use katana_primitives::transaction::{ExecutableTx, ExecutableTxWithHash, TxHash, TxType}; +use katana_provider::traits::block::{BlockNumberProvider, BlockProvider}; +use katana_provider::traits::transaction::{TransactionTraceProvider, TransactionsProviderExt}; use katana_rpc_api::starknet::StarknetTraceApiServer; use katana_rpc_types::error::starknet::StarknetApiError; use katana_rpc_types::trace::FunctionInvocation; use katana_rpc_types::transaction::BroadcastedTx; use katana_rpc_types::{FeeEstimate, SimulationFlag}; use starknet::core::types::{ - ComputationResources, DataAvailabilityResources, DataResources, DeclareTransactionTrace, - DeployAccountTransactionTrace, ExecuteInvocation, ExecutionResources, InvokeTransactionTrace, - L1HandlerTransactionTrace, RevertedInvocation, SimulatedTransaction, TransactionTrace, - TransactionTraceWithHash, + BlockTag, ComputationResources, DataAvailabilityResources, DataResources, + DeclareTransactionTrace, DeployAccountTransactionTrace, ExecuteInvocation, ExecutionResources, + InvokeTransactionTrace, L1HandlerTransactionTrace, RevertedInvocation, SimulatedTransaction, + TransactionTrace, TransactionTraceWithHash, }; use super::StarknetApi; +impl StarknetApi { + fn simulate_txs( + &self, + block_id: BlockIdOrTag, + transactions: Vec, + simulation_flags: Vec, + ) -> Result, StarknetApiError> { + let chain_id = self.inner.backend.chain_id; + + let executables = transactions + .into_iter() + .map(|tx| { + let tx = match tx { + BroadcastedTx::Invoke(tx) => { + let is_query = tx.is_query(); + ExecutableTxWithHash::new_query( + ExecutableTx::Invoke(tx.into_tx_with_chain_id(chain_id)), + is_query, + ) + } + BroadcastedTx::Declare(tx) => { + let is_query = tx.is_query(); + ExecutableTxWithHash::new_query( + ExecutableTx::Declare( + tx.try_into_tx_with_chain_id(chain_id) + .map_err(|_| StarknetApiError::InvalidContractClass)?, + ), + is_query, + ) + } + BroadcastedTx::DeployAccount(tx) => { + let is_query = tx.is_query(); + ExecutableTxWithHash::new_query( + ExecutableTx::DeployAccount(tx.into_tx_with_chain_id(chain_id)), + is_query, + ) + } + }; + Result::::Ok(tx) + }) + .collect::, _>>()?; + + // If the node is run with transaction validation disabled, then we should not validate + // even if the `SKIP_VALIDATE` flag is not set. + #[allow(deprecated)] + let should_validate = !(simulation_flags.contains(&SimulationFlag::SkipValidate) + || self.inner.backend.config.disable_validate); + + // If the node is run with fee charge disabled, then we should disable charing fees even + // if the `SKIP_FEE_CHARGE` flag is not set. + #[allow(deprecated)] + let should_skip_fee = !(simulation_flags.contains(&SimulationFlag::SkipFeeCharge) + || self.inner.backend.config.disable_fee); + + let flags = katana_executor::SimulationFlag { + skip_validate: !should_validate, + skip_fee_transfer: !should_skip_fee, + ..Default::default() + }; + + // get the state and block env at the specified block for execution + let state = self.state(&block_id)?; + let env = self.block_env_at(&block_id)?; + + // create the executor + let executor = self.inner.backend.executor_factory.with_state_and_block_env(state, env); + let results = executor.simulate(executables, flags); + + let mut simulated = Vec::with_capacity(results.len()); + for (i, ResultAndStates { result, .. }) in results.into_iter().enumerate() { + match result { + ExecutionResult::Success { trace, receipt } => { + let transaction_trace = to_rpc_trace(trace); + let fee_estimation = to_rpc_fee_estimate(receipt.fee().clone()); + let value = SimulatedTransaction { transaction_trace, fee_estimation }; + simulated.push(value) + } + + ExecutionResult::Failed { error } => { + let error = StarknetApiError::TransactionExecutionError { + transaction_index: i, + execution_error: error.to_string(), + }; + return Err(error); + } + } + } + + Ok(simulated) + } + + fn block_traces( + &self, + block_id: BlockIdOrTag, + ) -> Result, StarknetApiError> { + use StarknetApiError::BlockNotFound; + + let provider = self.inner.backend.blockchain.provider(); + + let block_id: BlockHashOrNumber = match block_id { + BlockIdOrTag::Tag(BlockTag::Pending) => match self.pending_executor() { + Some(state) => { + let pending_block = state.read(); + + // extract the txs from the pending block + let traces = pending_block.transactions().iter().filter_map(|(t, r)| { + if let Some(trace) = r.trace() { + let transaction_hash = t.hash; + let trace_root = to_rpc_trace(trace.clone()); + Some(TransactionTraceWithHash { transaction_hash, trace_root }) + } else { + None + } + }); + + return Ok(traces.collect::>()); + } + + // if there is no pending block, return the latest block + None => provider.latest_number()?.into(), + }, + BlockIdOrTag::Tag(BlockTag::Latest) => provider.latest_number()?.into(), + BlockIdOrTag::Number(num) => num.into(), + BlockIdOrTag::Hash(hash) => hash.into(), + }; + + // TODO: we should probably simplify this query + let indices = provider.block_body_indices(block_id)?.ok_or(BlockNotFound)?; + let hashes = provider.transaction_hashes_in_range(indices.into())?; + let traces = provider.transaction_executions_by_block(block_id)?.ok_or(BlockNotFound)?; + + // convert to rpc types + let traces = traces.into_iter().map(to_rpc_trace); + let result = hashes + .into_iter() + .zip(traces) + .map(|(h, r)| TransactionTraceWithHash { transaction_hash: h, trace_root: r }) + .collect::>(); + + Ok(result) + } + + fn trace(&self, tx_hash: TxHash) -> Result { + use StarknetApiError::TxnHashNotFound; + + // Check in the pending block first + if let Some(state) = self.pending_executor() { + let pending_block = state.read(); + let tx = pending_block.transactions().iter().find(|(t, _)| t.hash == tx_hash); + + if let Some(trace) = tx.and_then(|(_, res)| res.trace()) { + return Ok(to_rpc_trace(trace.clone())); + } + } + + // If not found in pending block, fallback to the provider + let provider = self.inner.backend.blockchain.provider(); + let trace = provider.transaction_execution(tx_hash)?.ok_or(TxnHashNotFound)?; + + Ok(to_rpc_trace(trace)) + } +} + #[async_trait] impl StarknetTraceApiServer for StarknetApi { - async fn trace_transaction(&self, _: TxHash) -> RpcResult { - Err(Error::Call(CallError::Custom(ErrorObject::owned( - METHOD_NOT_FOUND_CODE, - "Unsupported method - starknet_traceTransaction".to_string(), - None::<()>, - )))) + async fn trace_transaction(&self, transaction_hash: TxHash) -> RpcResult { + self.on_io_blocking_task(move |this| Ok(this.trace(transaction_hash)?)).await } async fn simulate_transactions( @@ -36,188 +196,111 @@ impl StarknetTraceApiServer for StarknetApi { simulation_flags: Vec, ) -> RpcResult> { self.on_cpu_blocking_task(move |this| { - let chain_id = this.inner.backend.chain_id; - - let executables = transactions - .into_iter() - .map(|tx| { - let tx = match tx { - BroadcastedTx::Invoke(tx) => { - let is_query = tx.is_query(); - ExecutableTxWithHash::new_query( - ExecutableTx::Invoke(tx.into_tx_with_chain_id(chain_id)), - is_query, - ) - } - BroadcastedTx::Declare(tx) => { - let is_query = tx.is_query(); - ExecutableTxWithHash::new_query( - ExecutableTx::Declare( - tx.try_into_tx_with_chain_id(chain_id) - .map_err(|_| StarknetApiError::InvalidContractClass)?, - ), - is_query, - ) - } - BroadcastedTx::DeployAccount(tx) => { - let is_query = tx.is_query(); - ExecutableTxWithHash::new_query( - ExecutableTx::DeployAccount(tx.into_tx_with_chain_id(chain_id)), - is_query, - ) - } - }; - Result::::Ok(tx) - }) - .collect::, _>>()?; - - // If the node is run with transaction validation disabled, then we should not validate - // even if the `SKIP_VALIDATE` flag is not set. - #[allow(deprecated)] - let should_validate = !(simulation_flags.contains(&SimulationFlag::SkipValidate) - || this.inner.backend.config.disable_validate); - - // If the node is run with fee charge disabled, then we should disable charing fees even - // if the `SKIP_FEE_CHARGE` flag is not set. - #[allow(deprecated)] - let should_skip_fee = !(simulation_flags.contains(&SimulationFlag::SkipFeeCharge) - || this.inner.backend.config.disable_fee); - - let flags = katana_executor::SimulationFlag { - skip_validate: !should_validate, - skip_fee_transfer: !should_skip_fee, - ..Default::default() - }; - - // get the state and block env at the specified block for execution - let state = this.state(&block_id)?; - let env = this.block_env_at(&block_id)?; - - // create the executor - let executor = this.inner.backend.executor_factory.with_state_and_block_env(state, env); - let results = executor.simulate(executables, flags); - - let mut simulated = Vec::with_capacity(results.len()); - for (i, ResultAndStates { result, .. }) in results.into_iter().enumerate() { - match result { - ExecutionResult::Success { trace, receipt } => { - let fee_transfer_invocation = - trace.fee_transfer_call_info.map(|f| FunctionInvocation::from(f).0); - let validate_invocation = - trace.validate_call_info.map(|f| FunctionInvocation::from(f).0); - let execute_invocation = - trace.execute_call_info.map(|f| FunctionInvocation::from(f).0); - let revert_reason = trace.revert_error; - // TODO: compute the state diff - let state_diff = None; - - let execution_resources = ExecutionResources { - computation_resources: ComputationResources { - steps: 0, - memory_holes: None, - segment_arena_builtin: None, - ecdsa_builtin_applications: None, - ec_op_builtin_applications: None, - keccak_builtin_applications: None, - bitwise_builtin_applications: None, - pedersen_builtin_applications: None, - poseidon_builtin_applications: None, - range_check_builtin_applications: None, - }, - data_resources: DataResources { - data_availability: DataAvailabilityResources { - l1_gas: 0, - l1_data_gas: 0, - }, - }, - }; - - let transaction_trace = match receipt { - Receipt::Invoke(_) => { - TransactionTrace::Invoke(InvokeTransactionTrace { - fee_transfer_invocation, - validate_invocation, - state_diff, - execute_invocation: if let Some(revert_reason) = revert_reason { - ExecuteInvocation::Reverted(RevertedInvocation { - revert_reason, - }) - } else { - ExecuteInvocation::Success( - execute_invocation - .expect("should exist if not reverted"), - ) - }, - execution_resources: execution_resources.clone(), - }) - } - - Receipt::Declare(_) => { - TransactionTrace::Declare(DeclareTransactionTrace { - fee_transfer_invocation, - validate_invocation, - state_diff, - execution_resources: execution_resources.clone(), - }) - } - - Receipt::DeployAccount(_) => { - TransactionTrace::DeployAccount(DeployAccountTransactionTrace { - fee_transfer_invocation, - validate_invocation, - state_diff, - constructor_invocation: execute_invocation - .expect("should exist bcs tx succeed"), - execution_resources: execution_resources.clone(), - }) - } - - Receipt::L1Handler(_) => { - TransactionTrace::L1Handler(L1HandlerTransactionTrace { - state_diff, - function_invocation: execute_invocation - .expect("should exist bcs tx succeed"), - execution_resources, - }) - } - }; - - let fee = receipt.fee(); - simulated.push(SimulatedTransaction { - transaction_trace, - fee_estimation: FeeEstimate { - unit: fee.unit, - gas_price: fee.gas_price.into(), - overall_fee: fee.overall_fee.into(), - gas_consumed: fee.gas_consumed.into(), - data_gas_price: Default::default(), - data_gas_consumed: Default::default(), - }, - }) - } - - ExecutionResult::Failed { error } => { - return Err(Error::from(StarknetApiError::TransactionExecutionError { - transaction_index: i, - execution_error: error.to_string(), - })); - } - } - } - - Ok(simulated) + Ok(this.simulate_txs(block_id, transactions, simulation_flags)?) }) .await } async fn trace_block_transactions( &self, - _: BlockIdOrTag, + block_id: BlockIdOrTag, ) -> RpcResult> { - Err(Error::Call(CallError::Custom(ErrorObject::owned( - METHOD_NOT_FOUND_CODE, - "Unsupported method - starknet_traceBlockTransactions".to_string(), - None::<()>, - )))) + self.on_io_blocking_task(move |this| Ok(this.block_traces(block_id)?)).await + } +} + +// TODO: move this conversion to katana_rpc_types + +fn to_rpc_trace(trace: TxExecInfo) -> TransactionTrace { + let fee_transfer_invocation = + trace.fee_transfer_call_info.map(|f| FunctionInvocation::from(f).0); + let validate_invocation = trace.validate_call_info.map(|f| FunctionInvocation::from(f).0); + let execute_invocation = trace.execute_call_info.map(|f| FunctionInvocation::from(f).0); + let revert_reason = trace.revert_error; + // TODO: compute the state diff + let state_diff = None; + + let execution_resources = to_rpc_resources(trace.actual_resources.vm_resources); + + match trace.r#type { + TxType::Invoke => { + let execute_invocation = if let Some(revert_reason) = revert_reason { + let invocation = RevertedInvocation { revert_reason }; + ExecuteInvocation::Reverted(invocation) + } else { + let invocation = execute_invocation.expect("should exist if not reverted"); + ExecuteInvocation::Success(invocation) + }; + + TransactionTrace::Invoke(InvokeTransactionTrace { + fee_transfer_invocation, + execution_resources, + validate_invocation, + execute_invocation, + state_diff, + }) + } + + TxType::Declare => TransactionTrace::Declare(DeclareTransactionTrace { + fee_transfer_invocation, + validate_invocation, + execution_resources, + state_diff, + }), + + TxType::DeployAccount => { + let constructor_invocation = execute_invocation.expect("should exist if not reverted"); + TransactionTrace::DeployAccount(DeployAccountTransactionTrace { + fee_transfer_invocation, + constructor_invocation, + validate_invocation, + execution_resources, + state_diff, + }) + } + + TxType::L1Handler => { + let function_invocation = execute_invocation.expect("should exist if not reverted"); + TransactionTrace::L1Handler(L1HandlerTransactionTrace { + execution_resources, + function_invocation, + state_diff, + }) + } + } +} + +fn to_rpc_resources(resources: katana_primitives::trace::ExecutionResources) -> ExecutionResources { + let steps = resources.n_steps as u64; + let memory_holes = resources.n_memory_holes as u64; + let builtins = BuiltinCounters::from(resources.builtin_instance_counter); + + let data_availability = DataAvailabilityResources { l1_gas: 0, l1_data_gas: 0 }; + let data_resources = DataResources { data_availability }; + + let computation_resources = ComputationResources { + steps, + memory_holes: Some(memory_holes), + ecdsa_builtin_applications: builtins.ecdsa(), + ec_op_builtin_applications: builtins.ec_op(), + keccak_builtin_applications: builtins.keccak(), + segment_arena_builtin: builtins.segment_arena(), + bitwise_builtin_applications: builtins.bitwise(), + pedersen_builtin_applications: builtins.pedersen(), + poseidon_builtin_applications: builtins.poseidon(), + range_check_builtin_applications: builtins.range_check(), + }; + + ExecutionResources { data_resources, computation_resources } +} + +fn to_rpc_fee_estimate(fee: TxFeeInfo) -> FeeEstimate { + FeeEstimate { + unit: fee.unit, + gas_price: fee.gas_price.into(), + overall_fee: fee.overall_fee.into(), + gas_consumed: fee.gas_consumed.into(), + data_gas_price: Default::default(), + data_gas_consumed: Default::default(), } } diff --git a/crates/katana/rpc/rpc/tests/starknet.rs b/crates/katana/rpc/rpc/tests/starknet.rs index 281cadde81..72c9f08931 100644 --- a/crates/katana/rpc/rpc/tests/starknet.rs +++ b/crates/katana/rpc/rpc/tests/starknet.rs @@ -26,7 +26,7 @@ use starknet::core::types::contract::legacy::LegacyContractClass; use starknet::core::types::{ BlockId, BlockTag, Call, DeclareTransactionReceipt, DeployAccountTransactionReceipt, EventFilter, EventsPage, ExecutionResult, Felt, StarknetError, TransactionFinalityStatus, - TransactionReceipt, + TransactionReceipt, TransactionTrace, }; use starknet::core::utils::get_contract_address; use starknet::macros::{felt, selector}; @@ -756,3 +756,148 @@ async fn get_events_with_pending() -> Result<()> { Ok(()) } + +#[tokio::test] +async fn trace() -> Result<()> { + let sequencer = TestSequencer::start( + SequencerConfig { no_mining: true, ..Default::default() }, + get_default_test_starknet_config(), + ) + .await; + + let provider = sequencer.provider(); + let account = sequencer.account(); + let rpc_client = HttpClientBuilder::default().build(sequencer.url())?; + + // setup contract to interact with (can be any existing contract that can be interacted with) + let contract = Erc20Contract::new(DEFAULT_FEE_TOKEN_ADDRESS.into(), &account); + + // setup contract function params + let recipient = felt!("0x1"); + let amount = Uint256 { low: felt!("0x1"), high: Felt::ZERO }; + + // ----------------------------------------------------------------------- + // Transactions not in pending block + + let mut hashes = Vec::new(); + + for _ in 0..2 { + let res = contract.transfer(&recipient, &amount).send().await?; + dojo_utils::TransactionWaiter::new(res.transaction_hash, &provider).await?; + hashes.push(res.transaction_hash); + } + + // Generate a block to include the transactions. The generated block will have block number 1. + rpc_client.generate_block().await?; + + for hash in hashes { + let trace = provider.trace_transaction(hash).await?; + assert_matches!(trace, TransactionTrace::Invoke(_)); + } + + // ----------------------------------------------------------------------- + // Transactions in pending block + + for _ in 0..2 { + let res = contract.transfer(&recipient, &amount).send().await?; + dojo_utils::TransactionWaiter::new(res.transaction_hash, &provider).await?; + + let trace = provider.trace_transaction(res.transaction_hash).await?; + assert_matches!(trace, TransactionTrace::Invoke(_)); + } + + Ok(()) +} + +#[tokio::test] +async fn block_traces() -> Result<()> { + let sequencer = TestSequencer::start( + SequencerConfig { no_mining: true, ..Default::default() }, + get_default_test_starknet_config(), + ) + .await; + + let provider = sequencer.provider(); + let account = sequencer.account(); + let rpc_client = HttpClientBuilder::default().build(sequencer.url())?; + + // setup contract to interact with (can be any existing contract that can be interacted with) + let contract = Erc20Contract::new(DEFAULT_FEE_TOKEN_ADDRESS.into(), &account); + + // setup contract function params + let recipient = felt!("0x1"); + let amount = Uint256 { low: felt!("0x1"), high: Felt::ZERO }; + + let mut hashes = Vec::new(); + + // ----------------------------------------------------------------------- + // Block 1 + + for _ in 0..5 { + let res = contract.transfer(&recipient, &amount).send().await?; + dojo_utils::TransactionWaiter::new(res.transaction_hash, &provider).await?; + hashes.push(res.transaction_hash); + } + + // Generate a block to include the transactions. The generated block will have block number 1. + rpc_client.generate_block().await?; + + // Get the traces of the transactions in block 1. + let block_id = BlockId::Number(1); + let traces = provider.trace_block_transactions(block_id).await?; + assert_eq!(traces.len(), 5); + + for i in 0..5 { + assert_eq!(traces[i].transaction_hash, hashes[i]); + assert_matches!(&traces[i].trace_root, TransactionTrace::Invoke(_)); + } + + // ----------------------------------------------------------------------- + // Block 2 + + // remove the previous transaction hashes + hashes.clear(); + + for _ in 0..2 { + let res = contract.transfer(&recipient, &amount).send().await?; + dojo_utils::TransactionWaiter::new(res.transaction_hash, &provider).await?; + hashes.push(res.transaction_hash); + } + + // Generate a block to include the transactions. The generated block will have block number 2. + rpc_client.generate_block().await?; + + // Get the traces of the transactions in block 2. + let block_id = BlockId::Number(2); + let traces = provider.trace_block_transactions(block_id).await?; + assert_eq!(traces.len(), 2); + + for i in 0..2 { + assert_eq!(traces[i].transaction_hash, hashes[i]); + assert_matches!(&traces[i].trace_root, TransactionTrace::Invoke(_)); + } + + // ----------------------------------------------------------------------- + // Block 3 (Pending) + + // remove the previous transaction hashes + hashes.clear(); + + for _ in 0..3 { + let res = contract.transfer(&recipient, &amount).send().await?; + dojo_utils::TransactionWaiter::new(res.transaction_hash, &provider).await?; + hashes.push(res.transaction_hash); + } + + // Get the traces of the transactions in block 3 (pending). + let block_id = BlockId::Tag(BlockTag::Pending); + let traces = provider.trace_block_transactions(block_id).await?; + assert_eq!(traces.len(), 3); + + for i in 0..3 { + assert_eq!(traces[i].transaction_hash, hashes[i]); + assert_matches!(&traces[i].trace_root, TransactionTrace::Invoke(_)); + } + + Ok(()) +} diff --git a/examples/rpc/starknet/starknet_getTransactionStatus.hurl b/examples/rpc/starknet/starknet_getTransactionStatus.hurl index 13cc11f322..ca4de48efe 100644 --- a/examples/rpc/starknet/starknet_getTransactionStatus.hurl +++ b/examples/rpc/starknet/starknet_getTransactionStatus.hurl @@ -12,4 +12,5 @@ Content-Type: application/json HTTP 200 [Asserts] jsonpath "$.error.message" equals "Transaction hash not found" +jsonpath "$.error.code" == 29 jsonpath "$.result" not exists diff --git a/examples/rpc/starknet/starknet_trace.hurl b/examples/rpc/starknet/starknet_trace.hurl index 56f5f9bdeb..7ab6217154 100644 --- a/examples/rpc/starknet/starknet_trace.hurl +++ b/examples/rpc/starknet/starknet_trace.hurl @@ -4,15 +4,14 @@ Content-Type: application/json { "jsonrpc": "2.0", "method": "starknet_traceTransaction", - "params": ["0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"], - "id": 2 + "params": ["0x1337"], + "id": 1 } HTTP 200 [Asserts] -jsonpath "$.error" exists -jsonpath "$.error.code" == -32601 -jsonpath "$.error.message" == "Unsupported method - starknet_traceTransaction" +jsonpath "$.error.message" equals "Transaction hash not found" +jsonpath "$.error.code" == 29 jsonpath "$.result" not exists # starknet_traceBlockTransactions @@ -21,13 +20,28 @@ Content-Type: application/json { "jsonrpc": "2.0", "method": "starknet_traceBlockTransactions", - "params": ["latest"], + "params": [{ "block_number": 0 }], + "id": 1 +} + +HTTP 200 +[Asserts] +jsonpath "$.result" exists +jsonpath "$.result" isEmpty +jsonpath "$.error" not exists + +# starknet_traceBlockTransactions +POST http://0.0.0.0:5050 +Content-Type: application/json +{ + "jsonrpc": "2.0", + "method": "starknet_traceBlockTransactions", + "params": [{ "block_number": 677 }], "id": 1 } HTTP 200 [Asserts] -jsonpath "$.error" exists -jsonpath "$.error.code" == -32601 -jsonpath "$.error.message" == "Unsupported method - starknet_traceBlockTransactions" +jsonpath "$.error.message" equals "Block not found" +jsonpath "$.error.code" == 24 jsonpath "$.result" not exists From afb86a95d7d0fbc3e67c8fa613ef3132b88ac161 Mon Sep 17 00:00:00 2001 From: Ammar Arif Date: Mon, 30 Sep 2024 19:07:26 -0400 Subject: [PATCH 2/4] chore: implement `From` for address type (#2488) --- crates/katana/controller/src/lib.rs | 7 ++----- crates/katana/primitives/src/contract.rs | 13 +++++++++++++ crates/katana/primitives/src/da/encoding.rs | 9 +++++---- .../storage/provider/src/providers/fork/state.rs | 3 ++- crates/katana/storage/provider/src/test_utils.rs | 3 ++- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/crates/katana/controller/src/lib.rs b/crates/katana/controller/src/lib.rs index 4d85a216ac..c3763473f7 100644 --- a/crates/katana/controller/src/lib.rs +++ b/crates/katana/controller/src/lib.rs @@ -47,8 +47,7 @@ fn add_controller_account_inner(genesis: &mut Genesis, user: slot::account::Acco storage: Some(get_contract_storage(credential_id, public_key)?), }; - let address = - ContractAddress::from(Felt::from_bytes_be(&user.contract_address.to_bytes_be())); + let address = ContractAddress::from(user.contract_address); (address, GenesisAllocation::Contract(account)) }; @@ -97,9 +96,7 @@ pub mod json { storage: Some(get_contract_storage(credential_id, public_key)?), }; - let address = ContractAddress::from(Felt::from_bytes_be( - &user.account.contract_address.to_bytes_be(), - )); + let address = ContractAddress::from(user.account.contract_address); (address, account) }; diff --git a/crates/katana/primitives/src/contract.rs b/crates/katana/primitives/src/contract.rs index fe93ec1712..08f2831da9 100644 --- a/crates/katana/primitives/src/contract.rs +++ b/crates/katana/primitives/src/contract.rs @@ -1,5 +1,6 @@ use std::fmt; +use num_bigint::BigUint; use starknet::core::utils::normalize_address; use crate::class::ClassHash; @@ -50,6 +51,18 @@ impl From for Felt { } } +impl From<&BigUint> for ContractAddress { + fn from(biguint: &BigUint) -> Self { + Self::new(Felt::from_bytes_le_slice(&biguint.to_bytes_le())) + } +} + +impl From for ContractAddress { + fn from(biguint: BigUint) -> Self { + Self::new(Felt::from_bytes_le_slice(&biguint.to_bytes_le())) + } +} + #[macro_export] macro_rules! address { ($value:expr) => { diff --git a/crates/katana/primitives/src/da/encoding.rs b/crates/katana/primitives/src/da/encoding.rs index aabf055532..832aebdd1f 100644 --- a/crates/katana/primitives/src/da/encoding.rs +++ b/crates/katana/primitives/src/da/encoding.rs @@ -139,7 +139,7 @@ pub fn decode_state_updates(value: &[BigUint]) -> Result { @@ -352,9 +353,9 @@ mod tests { assert_eq!(state_updates.declared_classes.len(), 1); assert_eq!(state_updates.deployed_contracts.len(), 0); - let address: ContractAddress = - felt!("2019172390095051323869047481075102003731246132997057518965927979101413600827") - .into(); + let address = address!( + "2019172390095051323869047481075102003731246132997057518965927979101413600827" + ); assert_eq!(state_updates.nonce_updates.get(&address), Some(&Felt::ONE)); diff --git a/crates/katana/storage/provider/src/providers/fork/state.rs b/crates/katana/storage/provider/src/providers/fork/state.rs index aa181cd480..77e0605205 100644 --- a/crates/katana/storage/provider/src/providers/fork/state.rs +++ b/crates/katana/storage/provider/src/providers/fork/state.rs @@ -219,6 +219,7 @@ impl ContractClassProvider for ForkedSnapshot { mod tests { use std::collections::BTreeMap; + use katana_primitives::address; use katana_primitives::state::{StateUpdates, StateUpdatesWithDeclaredClasses}; use starknet::macros::felt; @@ -229,7 +230,7 @@ mod tests { fn test_get_nonce() { let backend = create_forked_backend("http://localhost:8080", 1); - let address: ContractAddress = felt!("1").into(); + let address = address!("1"); let class_hash = felt!("11"); let remote_nonce = felt!("111"); let local_nonce = felt!("1111"); diff --git a/crates/katana/storage/provider/src/test_utils.rs b/crates/katana/storage/provider/src/test_utils.rs index 151ad7a560..54d230a957 100644 --- a/crates/katana/storage/provider/src/test_utils.rs +++ b/crates/katana/storage/provider/src/test_utils.rs @@ -2,6 +2,7 @@ use std::sync::Arc; use alloy_primitives::U256; use katana_db::mdbx::{test_utils, DbEnvKind}; +use katana_primitives::address; use katana_primitives::block::{BlockHash, FinalityStatus}; use katana_primitives::class::CompiledClass; use katana_primitives::contract::ContractAddress; @@ -49,7 +50,7 @@ fn initialize_test_provider(provider: &P) { /// - An account with simple `__execute__` function, deployed at address `0x1`. pub fn create_genesis_for_testing() -> Genesis { let class_hash = felt!("0x111"); - let address = ContractAddress::from(felt!("0x1")); + let address = address!("0x1"); // TODO: we should have a genesis builder that can do all of this for us. let class = { From 5eb722ac28080d656599de5f681942e0e5762f6d Mon Sep 17 00:00:00 2001 From: Ammar Arif Date: Mon, 30 Sep 2024 19:08:11 -0400 Subject: [PATCH 3/4] chore: replace `reth-metrics-derive` with the new standalone version (#2487) the reth team has made the previously named reth-metrics-derive into a standalone crate, metrics-derive --- Cargo.lock | 26 +++++++++++++------------- crates/metrics/Cargo.toml | 2 +- crates/metrics/src/lib.rs | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8152a03bd0..bebf29f266 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4497,10 +4497,10 @@ dependencies = [ "jemalloc-ctl", "jemallocator", "metrics", + "metrics-derive", "metrics-exporter-prometheus", "metrics-process", "metrics-util", - "reth-metrics-derive", "thiserror", "tokio", "tracing", @@ -9183,6 +9183,18 @@ dependencies = [ "portable-atomic", ] +[[package]] +name = "metrics-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3dbdd96ed57d565ec744cba02862d707acf373c5772d152abae6ec5c4e24f6c" +dependencies = [ + "proc-macro2", + "quote", + "regex", + "syn 2.0.77", +] + [[package]] name = "metrics-exporter-prometheus" version = "0.15.3" @@ -11448,18 +11460,6 @@ dependencies = [ "libc", ] -[[package]] -name = "reth-metrics-derive" -version = "1.0.3" -source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.3#390f30aadebcdd509e72cc04327c3b854de076a6" -dependencies = [ - "once_cell", - "proc-macro2", - "quote", - "regex", - "syn 2.0.77", -] - [[package]] name = "rfc6979" version = "0.4.0" diff --git a/crates/metrics/Cargo.toml b/crates/metrics/Cargo.toml index 3a8818c217..6aaace8d77 100644 --- a/crates/metrics/Cargo.toml +++ b/crates/metrics/Cargo.toml @@ -14,10 +14,10 @@ tracing.workspace = true # Metrics metrics.workspace = true +metrics-derive = "0.1" metrics-exporter-prometheus = "0.15.3" metrics-process = "2.1.0" metrics-util = "0.17.0" -reth-metrics-derive = { git = "https://github.com/paradigmxyz/reth.git", tag = "v1.0.3" } [target.'cfg(not(windows))'.dependencies] jemalloc-ctl = { version = "0.5.0", optional = true } diff --git a/crates/metrics/src/lib.rs b/crates/metrics/src/lib.rs index c9dc3209a1..8c0e84e00f 100644 --- a/crates/metrics/src/lib.rs +++ b/crates/metrics/src/lib.rs @@ -4,10 +4,10 @@ pub mod prometheus_exporter; use jemallocator as _; /// Re-export the metrics crate pub use metrics; +/// Re-export the metrics derive macro +pub use metrics_derive::Metrics; /// Re-export the metrics-process crate pub use metrics_process; -/// Re-export the metrics derive macro -pub use reth_metrics_derive::Metrics; // We use jemalloc for performance reasons #[cfg(all(feature = "jemalloc", unix))] From edc8840cc008c2d5b14910fdc4169796c3de3343 Mon Sep 17 00:00:00 2001 From: Ammar Arif Date: Mon, 30 Sep 2024 22:38:31 -0400 Subject: [PATCH 4/4] chore: remove unused deps (#2489) --- Cargo.lock | 433 +++------------------- Cargo.toml | 1 + crates/dojo-lang/Cargo.toml | 25 +- crates/dojo-lang/src/lib.rs | 2 + crates/dojo-test-utils/Cargo.toml | 9 - crates/dojo-test-utils/src/lib.rs | 2 + crates/katana/runner/macro/Cargo.toml | 3 - crates/katana/storage/provider/Cargo.toml | 1 - crates/katana/tasks/Cargo.toml | 2 +- crates/sozo/ops/Cargo.toml | 1 - crates/torii/client/Cargo.toml | 11 +- crates/torii/core/Cargo.toml | 19 +- crates/torii/core/src/lib.rs | 2 + crates/torii/graphql/Cargo.toml | 12 +- crates/torii/grpc/Cargo.toml | 16 +- crates/torii/grpc/src/lib.rs | 2 + crates/torii/libp2p/Cargo.toml | 8 +- crates/torii/libp2p/src/lib.rs | 2 + 18 files changed, 97 insertions(+), 454 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bebf29f266..edd4c36a60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1831,18 +1831,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bigdecimal" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6773ddc0eafc0e509fb60e48dff7f450f8e674a0686ae8605e8d9901bd5eefa" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits 0.2.19", - "serde", -] - [[package]] name = "bigdecimal" version = "0.4.5" @@ -2990,7 +2978,7 @@ version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8bd5c8c127b9362a12ffb9dede38e792c81b4ded5a98b448baec157b745f47d1" dependencies = [ - "env_logger 0.11.5", + "env_logger", "hashbrown 0.14.5", "indexmap 2.5.0", "itertools 0.12.1", @@ -4428,15 +4416,12 @@ name = "dojo-lang" version = "1.0.0-alpha.13" dependencies = [ "anyhow", - "assert_fs", - "cainome", "cairo-lang-compiler", "cairo-lang-debug", "cairo-lang-defs", "cairo-lang-diagnostics", "cairo-lang-filesystem", "cairo-lang-formatter", - "cairo-lang-lowering", "cairo-lang-parser", "cairo-lang-plugins", "cairo-lang-project", @@ -4450,17 +4435,12 @@ dependencies = [ "cairo-lang-utils", "camino", "convert_case 0.6.0", - "directories", "dojo-test-utils", "dojo-types", "dojo-world", - "env_logger 0.10.2", "indoc 1.0.9", "itertools 0.12.1", - "lazy_static", - "num-traits 0.2.19", "once_cell", - "pretty_assertions", "regex", "salsa", "scarb", @@ -4468,12 +4448,9 @@ dependencies = [ "semver 1.0.23", "serde", "serde_json", - "serde_with 3.9.0", "smol_str", "starknet 0.12.0", - "starknet-crypto 0.7.2", "test-log", - "thiserror", "toml 0.8.19", "tracing", "url", @@ -4513,10 +4490,6 @@ dependencies = [ "anyhow", "assert_fs", "async-trait", - "cairo-lang-compiler", - "cairo-lang-filesystem", - "cairo-lang-project", - "cairo-lang-starknet", "camino", "dojo-lang", "dojo-world", @@ -4531,14 +4504,9 @@ dependencies = [ "scarb-ui", "serde", "serde_json", - "serde_with 3.9.0", - "smol_str", - "starknet 0.10.0", "starknet 0.12.0", "thiserror", - "tokio", "toml 0.8.19", - "tracing", "url", ] @@ -4818,19 +4786,6 @@ dependencies = [ "regex", ] -[[package]] -name = "env_logger" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - [[package]] name = "env_logger" version = "0.11.5" @@ -8065,7 +8020,6 @@ dependencies = [ "anyhow", "auto_impl", "futures", - "katana-core", "katana-db", "katana-primitives", "katana-runner", @@ -8194,7 +8148,6 @@ version = "1.0.0-alpha.13" dependencies = [ "proc-macro2", "quote", - "starknet 0.12.0", "syn 2.0.77", ] @@ -8399,9 +8352,9 @@ dependencies = [ "getrandom", "libp2p-allow-block-list", "libp2p-connection-limits", - "libp2p-core 0.42.0", + "libp2p-core", "libp2p-dns", - "libp2p-gossipsub 0.47.1", + "libp2p-gossipsub", "libp2p-identify", "libp2p-identity", "libp2p-mdns", @@ -8410,14 +8363,14 @@ dependencies = [ "libp2p-ping", "libp2p-quic", "libp2p-relay", - "libp2p-swarm 0.45.1", + "libp2p-swarm", "libp2p-tcp", "libp2p-upnp", "libp2p-websocket", "libp2p-yamux", "multiaddr 0.18.1", "pin-project", - "rw-stream-sink 0.4.0 (git+https://github.com/libp2p/rust-libp2p?rev=cdc9638)", + "rw-stream-sink", "thiserror", ] @@ -8426,9 +8379,9 @@ name = "libp2p-allow-block-list" version = "0.4.1" source = "git+https://github.com/libp2p/rust-libp2p?rev=cdc9638#cdc9638ac1256f8a5305adb2f50a188de8874a0f" dependencies = [ - "libp2p-core 0.42.0", + "libp2p-core", "libp2p-identity", - "libp2p-swarm 0.45.1", + "libp2p-swarm", "void", ] @@ -8437,38 +8390,10 @@ name = "libp2p-connection-limits" version = "0.4.0" source = "git+https://github.com/libp2p/rust-libp2p?rev=cdc9638#cdc9638ac1256f8a5305adb2f50a188de8874a0f" dependencies = [ - "libp2p-core 0.42.0", - "libp2p-identity", - "libp2p-swarm 0.45.1", - "void", -] - -[[package]] -name = "libp2p-core" -version = "0.41.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5a8920cbd8540059a01950c1e5c96ea8d89eb50c51cd366fc18bdf540a6e48f" -dependencies = [ - "either", - "fnv", - "futures", - "futures-timer", + "libp2p-core", "libp2p-identity", - "multiaddr 0.18.1", - "multihash 0.19.1", - "multistream-select 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "once_cell", - "parking_lot 0.12.3", - "pin-project", - "quick-protobuf", - "rand", - "rw-stream-sink 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec", - "thiserror", - "tracing", - "unsigned-varint 0.8.0", + "libp2p-swarm", "void", - "web-time", ] [[package]] @@ -8483,13 +8408,13 @@ dependencies = [ "libp2p-identity", "multiaddr 0.18.1", "multihash 0.19.1", - "multistream-select 0.13.0 (git+https://github.com/libp2p/rust-libp2p?rev=cdc9638)", + "multistream-select", "once_cell", "parking_lot 0.12.3", "pin-project", "quick-protobuf", "rand", - "rw-stream-sink 0.4.0 (git+https://github.com/libp2p/rust-libp2p?rev=cdc9638)", + "rw-stream-sink", "smallvec", "thiserror", "tracing", @@ -8506,44 +8431,13 @@ dependencies = [ "async-trait", "futures", "hickory-resolver", - "libp2p-core 0.42.0", + "libp2p-core", "libp2p-identity", "parking_lot 0.12.3", "smallvec", "tracing", ] -[[package]] -name = "libp2p-gossipsub" -version = "0.46.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d665144a616dadebdc5fff186b1233488cdcd8bfb1223218ff084b6d052c94f7" -dependencies = [ - "asynchronous-codec", - "base64 0.21.7", - "byteorder", - "bytes", - "either", - "fnv", - "futures", - "futures-ticker", - "getrandom", - "hex_fmt", - "instant", - "libp2p-core 0.41.3", - "libp2p-identity", - "libp2p-swarm 0.44.2", - "prometheus-client", - "quick-protobuf", - "quick-protobuf-codec 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand", - "regex", - "sha2 0.10.8", - "smallvec", - "tracing", - "void", -] - [[package]] name = "libp2p-gossipsub" version = "0.47.1" @@ -8559,12 +8453,12 @@ dependencies = [ "futures-ticker", "getrandom", "hex_fmt", - "libp2p-core 0.42.0", + "libp2p-core", "libp2p-identity", - "libp2p-swarm 0.45.1", + "libp2p-swarm", "prometheus-client", "quick-protobuf", - "quick-protobuf-codec 0.3.1 (git+https://github.com/libp2p/rust-libp2p?rev=cdc9638)", + "quick-protobuf-codec", "rand", "regex", "sha2 0.10.8", @@ -8584,12 +8478,12 @@ dependencies = [ "futures", "futures-bounded", "futures-timer", - "libp2p-core 0.42.0", + "libp2p-core", "libp2p-identity", - "libp2p-swarm 0.45.1", + "libp2p-swarm", "lru", "quick-protobuf", - "quick-protobuf-codec 0.3.1 (git+https://github.com/libp2p/rust-libp2p?rev=cdc9638)", + "quick-protobuf-codec", "smallvec", "thiserror", "tracing", @@ -8623,9 +8517,9 @@ dependencies = [ "futures", "hickory-proto", "if-watch", - "libp2p-core 0.42.0", + "libp2p-core", "libp2p-identity", - "libp2p-swarm 0.45.1", + "libp2p-swarm", "rand", "smallvec", "socket2 0.5.7", @@ -8640,13 +8534,13 @@ version = "0.15.0" source = "git+https://github.com/libp2p/rust-libp2p?rev=cdc9638#cdc9638ac1256f8a5305adb2f50a188de8874a0f" dependencies = [ "futures", - "libp2p-core 0.42.0", - "libp2p-gossipsub 0.47.1", + "libp2p-core", + "libp2p-gossipsub", "libp2p-identify", "libp2p-identity", "libp2p-ping", "libp2p-relay", - "libp2p-swarm 0.45.1", + "libp2p-swarm", "pin-project", "prometheus-client", "web-time", @@ -8661,7 +8555,7 @@ dependencies = [ "bytes", "curve25519-dalek", "futures", - "libp2p-core 0.42.0", + "libp2p-core", "libp2p-identity", "multiaddr 0.18.1", "multihash 0.19.1", @@ -8685,9 +8579,9 @@ dependencies = [ "either", "futures", "futures-timer", - "libp2p-core 0.42.0", + "libp2p-core", "libp2p-identity", - "libp2p-swarm 0.45.1", + "libp2p-swarm", "rand", "tracing", "void", @@ -8703,7 +8597,7 @@ dependencies = [ "futures", "futures-timer", "if-watch", - "libp2p-core 0.42.0", + "libp2p-core", "libp2p-identity", "libp2p-tls", "parking_lot 0.12.3", @@ -8728,11 +8622,11 @@ dependencies = [ "futures", "futures-bounded", "futures-timer", - "libp2p-core 0.42.0", + "libp2p-core", "libp2p-identity", - "libp2p-swarm 0.45.1", + "libp2p-swarm", "quick-protobuf", - "quick-protobuf-codec 0.3.1 (git+https://github.com/libp2p/rust-libp2p?rev=cdc9638)", + "quick-protobuf-codec", "rand", "static_assertions", "thiserror", @@ -8741,28 +8635,6 @@ dependencies = [ "web-time", ] -[[package]] -name = "libp2p-swarm" -version = "0.44.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80cae6cb75f89dbca53862f9ebe0b9f463aa7b302762fcfaafb9e51dcc9b0f7e" -dependencies = [ - "either", - "fnv", - "futures", - "futures-timer", - "instant", - "libp2p-core 0.41.3", - "libp2p-identity", - "lru", - "multistream-select 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "once_cell", - "rand", - "smallvec", - "tracing", - "void", -] - [[package]] name = "libp2p-swarm" version = "0.45.1" @@ -8773,11 +8645,11 @@ dependencies = [ "futures", "futures-timer", "getrandom", - "libp2p-core 0.42.0", + "libp2p-core", "libp2p-identity", "libp2p-swarm-derive", "lru", - "multistream-select 0.13.0 (git+https://github.com/libp2p/rust-libp2p?rev=cdc9638)", + "multistream-select", "once_cell", "rand", "smallvec", @@ -8808,7 +8680,7 @@ dependencies = [ "futures-timer", "if-watch", "libc", - "libp2p-core 0.42.0", + "libp2p-core", "libp2p-identity", "socket2 0.5.7", "tokio", @@ -8822,9 +8694,9 @@ source = "git+https://github.com/libp2p/rust-libp2p?rev=cdc9638#cdc9638ac1256f8a dependencies = [ "futures", "futures-rustls", - "libp2p-core 0.42.0", + "libp2p-core", "libp2p-identity", - "rcgen 0.11.3", + "rcgen", "ring 0.17.8", "rustls 0.23.13", "rustls-webpki 0.101.7", @@ -8841,8 +8713,8 @@ dependencies = [ "futures", "futures-timer", "igd-next", - "libp2p-core 0.42.0", - "libp2p-swarm 0.45.1", + "libp2p-core", + "libp2p-swarm", "tokio", "tracing", "void", @@ -8859,13 +8731,13 @@ dependencies = [ "futures-timer", "hex", "if-watch", - "libp2p-core 0.42.0", + "libp2p-core", "libp2p-identity", "libp2p-noise", "libp2p-webrtc-utils", "multihash 0.19.1", "rand", - "rcgen 0.11.3", + "rcgen", "serde", "stun 0.6.0", "thiserror", @@ -8885,11 +8757,11 @@ dependencies = [ "bytes", "futures", "hex", - "libp2p-core 0.42.0", + "libp2p-core", "libp2p-identity", "libp2p-noise", "quick-protobuf", - "quick-protobuf-codec 0.3.1 (git+https://github.com/libp2p/rust-libp2p?rev=cdc9638)", + "quick-protobuf-codec", "rand", "serde", "sha2 0.10.8", @@ -8908,7 +8780,7 @@ dependencies = [ "getrandom", "hex", "js-sys", - "libp2p-core 0.42.0", + "libp2p-core", "libp2p-identity", "libp2p-webrtc-utils", "send_wrapper 0.6.0", @@ -8927,11 +8799,11 @@ dependencies = [ "either", "futures", "futures-rustls", - "libp2p-core 0.42.0", + "libp2p-core", "libp2p-identity", "parking_lot 0.12.3", "pin-project-lite", - "rw-stream-sink 0.4.0 (git+https://github.com/libp2p/rust-libp2p?rev=cdc9638)", + "rw-stream-sink", "soketto 0.8.0", "thiserror", "tracing", @@ -8947,7 +8819,7 @@ dependencies = [ "bytes", "futures", "js-sys", - "libp2p-core 0.42.0", + "libp2p-core", "parking_lot 0.12.3", "send_wrapper 0.6.0", "thiserror", @@ -8963,7 +8835,7 @@ source = "git+https://github.com/libp2p/rust-libp2p?rev=cdc9638#cdc9638ac1256f8a dependencies = [ "either", "futures", - "libp2p-core 0.42.0", + "libp2p-core", "thiserror", "tracing", "yamux 0.12.1", @@ -9451,20 +9323,6 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" -[[package]] -name = "multistream-select" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0df8e5eec2298a62b326ee4f0d7fe1a6b90a09dfcf9df37b38f947a8c42f19" -dependencies = [ - "bytes", - "futures", - "log", - "pin-project", - "smallvec", - "unsigned-varint 0.7.2", -] - [[package]] name = "multistream-select" version = "0.13.0" @@ -10996,19 +10854,6 @@ dependencies = [ "byteorder", ] -[[package]] -name = "quick-protobuf-codec" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15a0580ab32b169745d7a39db2ba969226ca16738931be152a3209b409de2474" -dependencies = [ - "asynchronous-codec", - "bytes", - "quick-protobuf", - "thiserror", - "unsigned-varint 0.8.0", -] - [[package]] name = "quick-protobuf-codec" version = "0.3.1" @@ -11207,19 +11052,6 @@ dependencies = [ "yasna", ] -[[package]] -name = "rcgen" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54077e1872c46788540de1ea3d7f4ccb1983d12f9aa909b234468676c1a36779" -dependencies = [ - "pem", - "ring 0.17.8", - "rustls-pki-types", - "time", - "yasna", -] - [[package]] name = "redb" version = "2.1.3" @@ -12009,17 +11841,6 @@ dependencies = [ "wait-timeout", ] -[[package]] -name = "rw-stream-sink" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8c9026ff5d2f23da5e45bbc283f156383001bfb09c4e44256d02c1a685fe9a1" -dependencies = [ - "futures", - "pin-project", - "static_assertions", -] - [[package]] name = "rw-stream-sink" version = "0.4.0" @@ -12111,7 +11932,7 @@ version = "1.0.0-alpha.13" dependencies = [ "anyhow", "async-trait", - "bigdecimal 0.4.5", + "bigdecimal", "cairo-felt", "cairo-proof-parser", "celestia-rpc", @@ -13044,7 +12865,7 @@ dependencies = [ "anyhow", "assert_fs", "async-trait", - "bigdecimal 0.4.5", + "bigdecimal", "cainome", "cairo-lang-compiler", "cairo-lang-defs", @@ -13108,7 +12929,7 @@ dependencies = [ "anyhow", "assert_fs", "async-trait", - "bigdecimal 0.4.5", + "bigdecimal", "cainome", "cairo-lang-compiler", "cairo-lang-defs", @@ -13149,7 +12970,6 @@ dependencies = [ "sozo-walnut", "starknet 0.12.0", "starknet-crypto 0.7.2", - "tee", "thiserror", "tokio", "toml 0.8.19", @@ -13442,22 +13262,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "starknet" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20b9a7b7bfd87287af85854f7458b8170ba6aa59c39113436532b7ff3d2fcbd8" -dependencies = [ - "starknet-accounts 0.9.0", - "starknet-contract 0.9.0", - "starknet-core 0.10.0", - "starknet-crypto 0.6.2", - "starknet-ff", - "starknet-macros 0.1.7", - "starknet-providers 0.10.0", - "starknet-signers 0.8.0", -] - [[package]] name = "starknet" version = "0.11.0" @@ -13468,7 +13272,7 @@ dependencies = [ "starknet-contract 0.10.0", "starknet-core 0.11.1", "starknet-crypto 0.7.2", - "starknet-macros 0.2.1", + "starknet-macros", "starknet-providers 0.11.0", "starknet-signers 0.9.0", ] @@ -13483,25 +13287,11 @@ dependencies = [ "starknet-contract 0.11.0", "starknet-core 0.12.0", "starknet-crypto 0.7.2", - "starknet-macros 0.2.1", + "starknet-macros", "starknet-providers 0.12.0", "starknet-signers 0.10.0", ] -[[package]] -name = "starknet-accounts" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2095d7584608ae1707bd1cf2889368ab3734d9f54e4fcef4765cba1f3b3f7618" -dependencies = [ - "async-trait", - "auto_impl", - "starknet-core 0.10.0", - "starknet-providers 0.10.0", - "starknet-signers 0.8.0", - "thiserror", -] - [[package]] name = "starknet-accounts" version = "0.10.0" @@ -13532,21 +13322,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "starknet-contract" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb3b73d437b4d62241612d13fce612602de6684c149cccf696e76a20757e2156" -dependencies = [ - "serde", - "serde_json", - "serde_with 2.3.3", - "starknet-accounts 0.9.0", - "starknet-core 0.10.0", - "starknet-providers 0.10.0", - "thiserror", -] - [[package]] name = "starknet-contract" version = "0.10.0" @@ -13577,24 +13352,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "starknet-core" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ed286d637e34fb8ae1cd2f9615120ec8ff38d1cffd311ed7fdd497cdd2bd01f" -dependencies = [ - "base64 0.21.7", - "flate2", - "hex", - "serde", - "serde_json", - "serde_json_pythonic", - "serde_with 2.3.3", - "sha3", - "starknet-crypto 0.6.2", - "starknet-ff", -] - [[package]] name = "starknet-core" version = "0.11.1" @@ -13737,22 +13494,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7abf1b44ec5b18d87c1ae5f54590ca9d0699ef4dd5b2ffa66fc97f24613ec585" dependencies = [ "ark-ff 0.4.2", - "bigdecimal 0.3.1", "crypto-bigint", "getrandom", "hex", - "num-bigint", - "serde", -] - -[[package]] -name = "starknet-macros" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95d549d3078bdbe775d0deaa8ddb57a19942989ce7c1f2dfd60beeb322bb4945" -dependencies = [ - "starknet-core 0.10.0", - "syn 2.0.77", ] [[package]] @@ -13765,26 +13509,6 @@ dependencies = [ "syn 2.0.77", ] -[[package]] -name = "starknet-providers" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6abf40ffcbe3b887b4d5cfc8ab73170c816b4aa78d1d4ad59abd3fb3b0f53cd" -dependencies = [ - "async-trait", - "auto_impl", - "ethereum-types", - "flate2", - "log", - "reqwest 0.11.27", - "serde", - "serde_json", - "serde_with 2.3.3", - "starknet-core 0.10.0", - "thiserror", - "url", -] - [[package]] name = "starknet-providers" version = "0.11.0" @@ -13827,22 +13551,6 @@ dependencies = [ "url", ] -[[package]] -name = "starknet-signers" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e9a2bd4fd66090003c3b7f0d76476e5b63cd44f6a49ede2442673f4427d5a40" -dependencies = [ - "async-trait", - "auto_impl", - "crypto-bigint", - "eth-keystore", - "rand", - "starknet-core 0.10.0", - "starknet-crypto 0.6.2", - "thiserror", -] - [[package]] name = "starknet-signers" version = "0.9.0" @@ -14239,12 +13947,6 @@ dependencies = [ "xattr", ] -[[package]] -name = "tee" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37c12559dba7383625faaff75be24becf35bfc885044375bcab931111799a3da" - [[package]] name = "tempfile" version = "3.12.0" @@ -14269,15 +13971,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - [[package]] name = "termtree" version = "0.4.1" @@ -14290,7 +13983,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dffced63c2b5c7be278154d76b479f9f9920ed34e7574201407f0b14e2bbb93" dependencies = [ - "env_logger 0.11.5", + "env_logger", "test-log-macros", "tracing-subscriber", ] @@ -14818,7 +14511,6 @@ dependencies = [ "dojo-world", "futures", "futures-util", - "libp2p-gossipsub 0.46.1", "num-traits 0.2.19", "parking_lot 0.12.3", "prost 0.11.9", @@ -14847,7 +14539,6 @@ dependencies = [ "cainome", "camino", "chrono", - "clap", "crypto-bigint", "dojo-test-utils", "dojo-types", @@ -14856,25 +14547,19 @@ dependencies = [ "futures-channel", "futures-util", "hashlink 0.9.1", - "hex", "katana-runner", - "lazy_static", - "log", "num-traits 0.2.19", "once_cell", "reqwest 0.12.7", "scarb", - "scarb-ui", "serde", "serde_json", "slab", - "sozo-ops", "sqlx", "starknet 0.12.0", "starknet-crypto 0.7.2", "thiserror", "tokio", - "tokio-stream", "tokio-util", "tracing", ] @@ -14926,7 +14611,6 @@ dependencies = [ name = "torii-grpc" version = "1.0.0-alpha.13" dependencies = [ - "bytes", "cainome", "camino", "crypto-bigint", @@ -14936,12 +14620,9 @@ dependencies = [ "dojo-world", "futures", "futures-util", - "hex", "hyper 0.14.30", - "itertools 0.12.1", "katana-runner", "num-traits 0.2.19", - "parking_lot 0.12.3", "prost 0.11.9", "prost 0.12.6", "rand", @@ -14949,7 +14630,6 @@ dependencies = [ "scarb", "serde", "serde_json", - "sozo-ops", "sqlx", "starknet 0.12.0", "starknet-crypto 0.7.2", @@ -14968,7 +14648,6 @@ dependencies = [ "torii-core", "tower 0.4.13", "tracing", - "url", ] [[package]] @@ -14976,11 +14655,9 @@ name = "torii-relay" version = "1.0.0-alpha.13" dependencies = [ "anyhow", - "async-trait", "cainome", "chrono", "crypto-bigint", - "dojo-test-utils", "dojo-types", "dojo-world", "futures", @@ -14991,8 +14668,6 @@ dependencies = [ "libp2p-webrtc-websys", "libp2p-websocket-websys", "rand", - "rcgen 0.13.1", - "regex", "serde", "serde_json", "sqlx", @@ -15903,7 +15578,7 @@ dependencies = [ "log", "pem", "rand", - "rcgen 0.11.3", + "rcgen", "regex", "ring 0.16.20", "rtcp", @@ -15967,7 +15642,7 @@ dependencies = [ "pem", "rand", "rand_core", - "rcgen 0.11.3", + "rcgen", "ring 0.16.20", "rustls 0.21.12", "sec1", diff --git a/Cargo.toml b/Cargo.toml index 0e5ed4668d..fd827c9873 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -197,6 +197,7 @@ tempfile = "3.9.0" test-log = "0.2.11" thiserror = "1.0.32" tokio = { version = "1.39.2", features = [ "full" ] } +tokio-util = "0.7.12" toml = "0.8" tower = "0.4.13" tower-http = "0.4.4" diff --git a/crates/dojo-lang/Cargo.toml b/crates/dojo-lang/Cargo.toml index 9ea864b22e..54856968ca 100644 --- a/crates/dojo-lang/Cargo.toml +++ b/crates/dojo-lang/Cargo.toml @@ -11,15 +11,11 @@ testing = [ ] [dependencies] anyhow.workspace = true -cainome.workspace = true cairo-lang-compiler.workspace = true -cairo-lang-debug.workspace = true cairo-lang-defs.workspace = true cairo-lang-diagnostics.workspace = true cairo-lang-filesystem.workspace = true cairo-lang-formatter.workspace = true -cairo-lang-lowering.workspace = true -cairo-lang-parser.workspace = true cairo-lang-plugins.workspace = true cairo-lang-project.workspace = true cairo-lang-semantic.workspace = true @@ -31,35 +27,28 @@ cairo-lang-test-plugin.workspace = true cairo-lang-utils.workspace = true camino.workspace = true convert_case.workspace = true -directories = "5" -dojo-types = { path = "../dojo-types" } -dojo-world = { path = "../dojo-world", features = [ "manifest", "metadata" ] } +dojo-types.workspace = true +dojo-world = { workspace = true, features = [ "manifest", "metadata" ] } indoc.workspace = true itertools.workspace = true -lazy_static.workspace = true -num-traits.workspace = true -once_cell.workspace = true regex.workspace = true -salsa.workspace = true scarb.workspace = true scarb-ui.workspace = true semver.workspace = true serde.workspace = true serde_json.workspace = true -serde_with.workspace = true smol_str.workspace = true starknet.workspace = true -starknet-crypto.workspace = true -thiserror.workspace = true toml.workspace = true tracing.workspace = true url.workspace = true [dev-dependencies] -assert_fs.workspace = true +cairo-lang-debug.workspace = true +cairo-lang-parser.workspace = true cairo-lang-semantic.workspace = true cairo-lang-test-utils.workspace = true -dojo-test-utils = { path = "../dojo-test-utils" } -env_logger = "0.10.0" -pretty_assertions.workspace = true +dojo-test-utils.workspace = true +once_cell.workspace = true +salsa.workspace = true test-log.workspace = true diff --git a/crates/dojo-lang/src/lib.rs b/crates/dojo-lang/src/lib.rs index 4ed4b70c41..234fe5eb3a 100644 --- a/crates/dojo-lang/src/lib.rs +++ b/crates/dojo-lang/src/lib.rs @@ -1,3 +1,5 @@ +#![warn(unused_crate_dependencies)] + //! Dojo capabilities and utilities on top of Starknet. //! //! Dojo is a full stack toolchain for developing onchain games in Cairo. diff --git a/crates/dojo-test-utils/Cargo.toml b/crates/dojo-test-utils/Cargo.toml index ebd89181f2..9a2bd63c95 100644 --- a/crates/dojo-test-utils/Cargo.toml +++ b/crates/dojo-test-utils/Cargo.toml @@ -9,10 +9,6 @@ version.workspace = true anyhow.workspace = true assert_fs.workspace = true async-trait.workspace = true -cairo-lang-compiler.workspace = true -cairo-lang-filesystem.workspace = true -cairo-lang-project.workspace = true -cairo-lang-starknet.workspace = true camino.workspace = true dojo-lang = { path = "../dojo-lang" } dojo-world = { path = "../dojo-world", features = [ "manifest", "migration" ] } @@ -23,18 +19,13 @@ katana-node.workspace = true katana-primitives = { path = "../katana/primitives" } katana-rpc = { path = "../katana/rpc/rpc" } katana-rpc-api = { path = "../katana/rpc/rpc-api" } -katana-starknet = { package = "starknet", version = "=0.10.0" } scarb.workspace = true scarb-ui.workspace = true serde.workspace = true serde_json.workspace = true -serde_with.workspace = true -smol_str.workspace = true starknet.workspace = true thiserror.workspace = true -tokio = { version = "1.28.0", features = [ "full" ] } toml.workspace = true -tracing.workspace = true url.workspace = true [build-dependencies] diff --git a/crates/dojo-test-utils/src/lib.rs b/crates/dojo-test-utils/src/lib.rs index 9ec340c425..48fcaf5848 100644 --- a/crates/dojo-test-utils/src/lib.rs +++ b/crates/dojo-test-utils/src/lib.rs @@ -1,3 +1,5 @@ +#![warn(unused_crate_dependencies)] + pub mod compiler; pub mod migration; pub mod rpc; diff --git a/crates/katana/runner/macro/Cargo.toml b/crates/katana/runner/macro/Cargo.toml index 45c0ce5064..a8e2689be0 100644 --- a/crates/katana/runner/macro/Cargo.toml +++ b/crates/katana/runner/macro/Cargo.toml @@ -11,6 +11,3 @@ proc-macro = true proc-macro2 = "1.0.86" quote = "1.0" syn = { version = "2.0", features = [ "fold", "full" ] } - -[dev-dependencies] -starknet.workspace = true diff --git a/crates/katana/storage/provider/Cargo.toml b/crates/katana/storage/provider/Cargo.toml index b9c0379152..4cf24e81b8 100644 --- a/crates/katana/storage/provider/Cargo.toml +++ b/crates/katana/storage/provider/Cargo.toml @@ -32,7 +32,6 @@ test-utils = [ "dep:alloy-primitives", "dep:serde_json" ] [dev-dependencies] alloy-primitives.workspace = true -katana-core.workspace = true katana-runner.workspace = true lazy_static.workspace = true rand.workspace = true diff --git a/crates/katana/tasks/Cargo.toml b/crates/katana/tasks/Cargo.toml index fda68dc089..cc4a897f39 100644 --- a/crates/katana/tasks/Cargo.toml +++ b/crates/katana/tasks/Cargo.toml @@ -11,5 +11,5 @@ rayon.workspace = true thiserror.workspace = true tokio.workspace = true tokio-metrics = "0.3.1" -tokio-util = { version = "0.7.11", features = [ "rt" ] } +tokio-util = { workspace = true, features = [ "rt" ] } tracing.workspace = true diff --git a/crates/sozo/ops/Cargo.toml b/crates/sozo/ops/Cargo.toml index a3ff511a4a..0204596429 100644 --- a/crates/sozo/ops/Cargo.toml +++ b/crates/sozo/ops/Cargo.toml @@ -60,7 +60,6 @@ assert_fs.workspace = true dojo-test-utils = { workspace = true, features = [ "build-examples" ] } ipfs-api-backend-hyper = { git = "https://github.com/ferristseng/rust-ipfs-api", rev = "af2c17f7b19ef5b9898f458d97a90055c3605633", features = [ "with-hyper-rustls" ] } katana-runner.workspace = true -tee = "0.1.0" [features] test-utils = [ "dep:dojo-test-utils", "dep:katana-runner" ] diff --git a/crates/torii/client/Cargo.toml b/crates/torii/client/Cargo.toml index 459f1b8b84..0c7f7ec51b 100644 --- a/crates/torii/client/Cargo.toml +++ b/crates/torii/client/Cargo.toml @@ -8,11 +8,10 @@ version.workspace = true [dependencies] async-trait.workspace = true crypto-bigint.workspace = true -dojo-types = { path = "../../dojo-types" } -dojo-world = { path = "../../dojo-world", features = [ "contracts" ] } +dojo-types.workspace = true +dojo-world = { workspace = true, features = [ "contracts" ] } futures.workspace = true futures-util.workspace = true -libp2p-gossipsub = "0.46.1" num-traits.workspace = true parking_lot.workspace = true serde.workspace = true @@ -21,8 +20,8 @@ starknet.workspace = true starknet-crypto.workspace = true thiserror.workspace = true tokio = { version = "1.32.0", features = [ "sync" ], default-features = false } -torii-grpc = { path = "../grpc", features = [ "client" ] } -torii-relay = { path = "../libp2p" } +torii-grpc = { workspace = true, features = [ "client" ] } +torii-relay = { workspace = true } url.workspace = true [target.'cfg(not(target_arch = "wasm32"))'.dependencies] @@ -35,5 +34,5 @@ wasm-tonic.workspace = true [dev-dependencies] camino.workspace = true -dojo-world = { path = "../../dojo-world" } +dojo-world.workspace = true tokio.workspace = true diff --git a/crates/torii/core/Cargo.toml b/crates/torii/core/Cargo.toml index d21c4c06b0..a1221b1f0d 100644 --- a/crates/torii/core/Cargo.toml +++ b/crates/torii/core/Cargo.toml @@ -12,39 +12,32 @@ version.workspace = true anyhow.workspace = true async-trait.workspace = true base64.workspace = true +bitflags = "2.6.0" cainome.workspace = true chrono.workspace = true crypto-bigint.workspace = true -dojo-types = { path = "../../dojo-types" } -dojo-world = { path = "../../dojo-world", features = [ "contracts", "manifest" ] } +dojo-types.workspace = true +dojo-world = { workspace = true, features = [ "contracts", "manifest" ] } futures-channel = "0.3.0" futures-util.workspace = true hashlink.workspace = true -hex.workspace = true -lazy_static.workspace = true -log.workspace = true num-traits.workspace = true once_cell.workspace = true reqwest.workspace = true -scarb-ui.workspace = true serde.workspace = true serde_json.workspace = true slab = "0.4.2" -sozo-ops.workspace = true sqlx.workspace = true -starknet-crypto.workspace = true starknet.workspace = true +starknet-crypto.workspace = true thiserror.workspace = true tokio = { version = "1.32.0", features = [ "sync" ], default-features = true } -tokio-stream = "0.1.11" -tokio-util = "0.7.7" +tokio-util.workspace = true tracing.workspace = true -clap.workspace = true -bitflags = "2.6.0" [dev-dependencies] camino.workspace = true -dojo-test-utils = { path = "../../dojo-test-utils" } +dojo-test-utils.workspace = true dojo-utils.workspace = true katana-runner.workspace = true scarb.workspace = true diff --git a/crates/torii/core/src/lib.rs b/crates/torii/core/src/lib.rs index df6e8b3adc..fe7ae8f4bc 100644 --- a/crates/torii/core/src/lib.rs +++ b/crates/torii/core/src/lib.rs @@ -1,3 +1,5 @@ +#![warn(unused_crate_dependencies)] + pub mod cache; pub mod engine; pub mod error; diff --git a/crates/torii/graphql/Cargo.toml b/crates/torii/graphql/Cargo.toml index 464dddefb6..fd7c03236e 100644 --- a/crates/torii/graphql/Cargo.toml +++ b/crates/torii/graphql/Cargo.toml @@ -18,33 +18,33 @@ base64.workspace = true cainome.workspace = true chrono.workspace = true convert_case = "0.6.0" -dojo-types = { path = "../../dojo-types" } +dojo-types.workspace = true lazy_static.workspace = true regex.workspace = true scarb-ui.workspace = true serde.workspace = true serde_json.workspace = true -sozo-ops.workspace = true sqlx.workspace = true strum.workspace = true strum_macros.workspace = true thiserror.workspace = true +tokio.workspace = true tokio-stream = "0.1.11" tokio-util = "0.7.7" -tokio.workspace = true toml.workspace = true -torii-core = { path = "../core" } +torii-core.workspace = true tracing.workspace = true url.workspace = true warp.workspace = true [dev-dependencies] camino.workspace = true -dojo-test-utils = { path = "../../dojo-test-utils", features = [ "build-examples" ] } +dojo-test-utils = { workspace = true, features = [ "build-examples" ] } dojo-utils.workspace = true dojo-world.workspace = true katana-runner.workspace = true scarb.workspace = true serial_test = "2.0.0" -starknet-crypto.workspace = true +sozo-ops.workspace = true starknet.workspace = true +starknet-crypto.workspace = true diff --git a/crates/torii/grpc/Cargo.toml b/crates/torii/grpc/Cargo.toml index c4eb6021e7..492cc9da34 100644 --- a/crates/torii/grpc/Cargo.toml +++ b/crates/torii/grpc/Cargo.toml @@ -6,16 +6,13 @@ repository.workspace = true version.workspace = true [dependencies] -bytes.workspace = true -dojo-types = { path = "../../dojo-types" } -futures-util.workspace = true +dojo-types.workspace = true futures.workspace = true +futures-util.workspace = true num-traits.workspace = true -parking_lot.workspace = true rayon.workspace = true -itertools.workspace = true -starknet-crypto.workspace = true starknet.workspace = true +starknet-crypto.workspace = true thiserror.workspace = true torii-core = { path = "../core", optional = true } @@ -26,7 +23,6 @@ strum_macros.workspace = true # server dojo-world = { path = "../../dojo-world", features = [ "contracts" ] } -hex.workspace = true hyper.workspace = true rand.workspace = true serde_json.workspace = true @@ -40,7 +36,6 @@ dojo-test-utils.workspace = true dojo-utils.workspace = true katana-runner.workspace = true scarb.workspace = true -sozo-ops.workspace = true [target.'cfg(target_arch = "wasm32")'.dependencies] tonic-web-wasm-client.workspace = true @@ -50,12 +45,11 @@ wasm-tonic.workspace = true [target.'cfg(not(target_arch = "wasm32"))'.dependencies] prost.workspace = true sqlx.workspace = true -tokio-stream = "0.1.14" tokio.workspace = true +tokio-stream = "0.1.14" +tonic.workspace = true tonic-reflection.workspace = true tonic-web.workspace = true -tonic.workspace = true -url.workspace = true [build-dependencies] tonic-build.workspace = true diff --git a/crates/torii/grpc/src/lib.rs b/crates/torii/grpc/src/lib.rs index 1fb5da7eb7..ea54cebf02 100644 --- a/crates/torii/grpc/src/lib.rs +++ b/crates/torii/grpc/src/lib.rs @@ -1,3 +1,5 @@ +#![warn(unused_crate_dependencies)] + #[cfg(target_arch = "wasm32")] extern crate wasm_prost as prost; #[cfg(target_arch = "wasm32")] diff --git a/crates/torii/libp2p/Cargo.toml b/crates/torii/libp2p/Cargo.toml index b9d14ace28..ee7abd13a1 100644 --- a/crates/torii/libp2p/Cargo.toml +++ b/crates/torii/libp2p/Cargo.toml @@ -13,32 +13,28 @@ rand.workspace = true serde.workspace = true # preserve order anyhow.workspace = true -async-trait.workspace = true cainome.workspace = true chrono.workspace = true crypto-bigint.workspace = true dojo-types.workspace = true dojo-world = { path = "../../dojo-world", features = [ "contracts" ] } indexmap.workspace = true -regex.workspace = true serde_json.workspace = true starknet.workspace = true starknet-crypto.workspace = true thiserror.workspace = true tracing.workspace = true -tracing-subscriber = { version = "0.3", features = [ "env-filter" ] } [dev-dependencies] -dojo-test-utils.workspace = true katana-runner.workspace = true tempfile.workspace = true +tokio.workspace = true +tracing-subscriber.workspace = true [target.'cfg(not(target_arch = "wasm32"))'.dependencies] libp2p = { git = "https://github.com/libp2p/rust-libp2p", features = [ "dns", "ed25519", "gossipsub", "identify", "macros", "noise", "ping", "quic", "relay", "tcp", "tokio", "websocket", "yamux" ], rev = "cdc9638" } libp2p-webrtc = { git = "https://github.com/libp2p/rust-libp2p", features = [ "pem", "tokio" ], rev = "cdc9638" } -rcgen = "0.13.1" sqlx.workspace = true -tokio.workspace = true torii-core.workspace = true [target.'cfg(target_arch = "wasm32")'.dependencies] diff --git a/crates/torii/libp2p/src/lib.rs b/crates/torii/libp2p/src/lib.rs index 1eaf1a17bd..9d08de68c6 100644 --- a/crates/torii/libp2p/src/lib.rs +++ b/crates/torii/libp2p/src/lib.rs @@ -1,3 +1,5 @@ +#![warn(unused_crate_dependencies)] + pub mod client; mod constants; pub mod errors;