Skip to content

Commit

Permalink
feat(katana): include more data in logs on tx flow status (#2657)
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy authored Nov 7, 2024
1 parent dddac32 commit ed8f546
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions crates/katana/executor/src/implementation/blockifier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ impl<'a> BlockExecutor<'a> for StarknetVMProcessor<'a> {
};

let tx = TxWithHash::from(&exec_tx);
let hash = tx.hash;
let res = utils::transact(&mut state.inner, block_context, flags, exec_tx);

match &res {
Expand All @@ -190,7 +191,7 @@ impl<'a> BlockExecutor<'a> for StarknetVMProcessor<'a> {
receipt.resources_used().vm_resources.n_steps as u128;

if let Some(reason) = receipt.revert_reason() {
info!(target: LOG_TARGET, %reason, "Transaction reverted.");
info!(target: LOG_TARGET, hash = format!("{hash:#x}"), %reason, "Transaction reverted.");
}

if let Some((class_hash, compiled, sierra)) = class_decl_artifacts {
Expand All @@ -201,7 +202,7 @@ impl<'a> BlockExecutor<'a> for StarknetVMProcessor<'a> {
}

ExecutionResult::Failed { error } => {
info!(target: LOG_TARGET, %error, "Executing transaction.");
info!(target: LOG_TARGET, hash = format!("{hash:#x}"), %error, "Executing transaction.");
}
};

Expand Down
12 changes: 6 additions & 6 deletions crates/katana/pool/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ where
let hash = tx.hash();
let id = TxId::new(tx.sender(), tx.nonce());

info!(hash = format!("{hash:#x}"), "Transaction received.");
info!(target: "pool", hash = format!("{hash:#x}"), "Transaction received.");

match self.inner.validator.validate(tx) {
Ok(outcome) => {
Expand All @@ -157,14 +157,14 @@ where
// TODO: create a small cache for rejected transactions to respect the rpc spec
// `getTransactionStatus`
ValidationOutcome::Invalid { error, .. } => {
warn!(hash = format!("{hash:#x}"), "Invalid transaction.");
warn!(target: "pool", hash = format!("{hash:#x}"), %error, "Invalid transaction.");
Err(PoolError::InvalidTransaction(Box::new(error)))
}

// return as error for now but ideally we should kept the tx in a separate
// queue and revalidate it when the parent tx is added to the pool
ValidationOutcome::Dependent { tx, tx_nonce, current_nonce } => {
info!(hash = format!("{hash:#x}"), "Dependent transaction.");
info!(target: "pool", hash = format!("{hash:#x}"), %tx_nonce, %current_nonce, "Dependent transaction.");
let err = InvalidTransactionError::InvalidNonce {
address: tx.sender(),
current_nonce,
Expand All @@ -175,9 +175,9 @@ where
}
}

Err(e @ crate::validation::Error { hash, .. }) => {
error!(hash = format!("{hash:#x}"), %e, "Failed to validate transaction.");
Err(PoolError::Internal(e.error))
Err(error @ crate::validation::Error { hash, .. }) => {
error!(target: "pool", hash = format!("{hash:#x}"), %error, "Failed to validate transaction.");
Err(PoolError::Internal(error.error))
}
}
}
Expand Down

0 comments on commit ed8f546

Please sign in to comment.