Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy committed Sep 30, 2024
1 parent b4b7f26 commit 4aff604
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions crates/katana/rpc/rpc/src/starknet/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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::{BlockHashProvider, BlockNumberProvider, BlockProvider};
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;
Expand All @@ -21,7 +21,7 @@ use starknet::core::types::{
use super::StarknetApi;

impl<EF: ExecutorFactory> StarknetApi<EF> {
pub fn simulate_txs(
fn simulate_txs(
&self,
block_id: BlockIdOrTag,
transactions: Vec<BroadcastedTx>,
Expand Down Expand Up @@ -111,7 +111,7 @@ impl<EF: ExecutorFactory> StarknetApi<EF> {
Ok(simulated)
}

Check warning on line 112 in crates/katana/rpc/rpc/src/starknet/trace.rs

View check run for this annotation

Codecov / codecov/patch

crates/katana/rpc/rpc/src/starknet/trace.rs#L111-L112

Added lines #L111 - L112 were not covered by tests

pub fn block_traces(
fn block_traces(
&self,
block_id: BlockIdOrTag,
) -> Result<Vec<TransactionTraceWithHash>, StarknetApiError> {
Expand All @@ -138,14 +138,15 @@ impl<EF: ExecutorFactory> StarknetApi<EF> {
return Ok(traces.collect::<Vec<TransactionTraceWithHash>>());

Check warning on line 138 in crates/katana/rpc/rpc/src/starknet/trace.rs

View check run for this annotation

Codecov / codecov/patch

crates/katana/rpc/rpc/src/starknet/trace.rs#L136-L138

Added lines #L136 - L138 were not covered by tests
}

None => provider.latest_hash()?.into(),
// if there is no pending block, return the latest block
None => provider.latest_number()?.into(),

Check warning on line 142 in crates/katana/rpc/rpc/src/starknet/trace.rs

View check run for this annotation

Codecov / codecov/patch

crates/katana/rpc/rpc/src/starknet/trace.rs#L142

Added line #L142 was not covered by tests
},
BlockIdOrTag::Tag(BlockTag::Latest) => provider.latest_number()?.into(),

Check warning on line 144 in crates/katana/rpc/rpc/src/starknet/trace.rs

View check run for this annotation

Codecov / codecov/patch

crates/katana/rpc/rpc/src/starknet/trace.rs#L144

Added line #L144 was not covered by tests
BlockIdOrTag::Number(num) => num.into(),
BlockIdOrTag::Hash(hash) => hash.into(),

Check warning on line 146 in crates/katana/rpc/rpc/src/starknet/trace.rs

View check run for this annotation

Codecov / codecov/patch

crates/katana/rpc/rpc/src/starknet/trace.rs#L146

Added line #L146 was not covered by tests
};

// TODO: this could probably be reduced to a single query
// 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)?;
Expand All @@ -161,7 +162,7 @@ impl<EF: ExecutorFactory> StarknetApi<EF> {
Ok(result)
}

pub fn trace(&self, tx_hash: TxHash) -> Result<TransactionTrace, StarknetApiError> {
fn trace(&self, tx_hash: TxHash) -> Result<TransactionTrace, StarknetApiError> {
use StarknetApiError::TxnHashNotFound;
let provider = self.inner.backend.blockchain.provider();
let trace = provider.transaction_execution(tx_hash)?.ok_or(TxnHashNotFound)?;
Expand Down

0 comments on commit 4aff604

Please sign in to comment.