deltadevsde / deltadevsde/prism

fix: track + log invalid transactions

Open
#319 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
134
Forks
41
PR merge metrics
No merged PRs in 30d

Description

**Track and return failed transactions.**

Failed transactions are only logged as warnings. The caller has no way to know which transactions failed, leading to potential silent failures.

Consider returning a result that includes both successful proofs and failed transactions:

```diff
-pub async fn execute_block(&self, transactions: Vec) -> Result> {
+pub async fn execute_block(&self, transactions: Vec) -> Result<(Vec, Vec<(Transaction, String)>)> {
debug!("executing block with {} transactions", transactions.len());

let mut proofs = Vec::new();
+ let mut failed_transactions = Vec::new();

for transaction in transactions {
match self.process_transaction_internal(transaction.clone()).await {
Ok(proof) => proofs.push(proof),
Err(e) => {
warn!(
"Failed to process transaction: {:?}. Error: {}",
transaction, e
);
+ failed_transactions.push((transaction, e.to_string()));
}
}
}

- Ok(proofs)
+ Ok((proofs, failed_transactions))
}
```

📝 Committable suggestion

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
pub async fn execute_block(&self, transactions: Vec) -> Result<(Vec, Vec<(Transaction, String)>)> {
debug!("executing block with {} transactions", transactions.len());

let mut proofs = Vec::new();
let mut failed_transactions = Vec::new();

for transaction in transactions {
match self.process_transaction_internal(transaction.clone()).await {
Ok(proof) => proofs.push(proof),
Err(e) => {
warn!(
"Failed to process transaction: {:?}. Error: {}",
transaction, e
);
failed_transactions.push((transaction, e.to_string()));
}
}
}

Ok((proofs, failed_transactions))
}
```

🤖 Prompt for AI Agents

```
In crates/node_types/prover/src/sequencer.rs around lines 159 to 177, the
execute_block function currently logs failed transactions but does not return
any information about them, causing silent failures. Modify the function to
return a result type that includes both the vector of successful proofs and a
collection of failed transactions or their errors. This can be done by defining
a custom return type or using a tuple to hold both successes and failures, and
updating the function logic to accumulate failed transactions alongside
successful proofs before returning them.
```

_Originally posted by @coderabbitai[bot] in https://github.com/deltadevsde/prism/pull/314#discussion_r2104641682_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.