Skip to content

Commit

Permalink
refactor(proof_upgrader): Log error on failure; don't panic
Browse files Browse the repository at this point in the history
If upgrading fails (whether in the course of transaction initaition
or third-party transaction proof upgrading), do not crash the
application; but log an error message instead.

Cf. #310.

Co-authored-by: Alan Szepieniec <[email protected]>
  • Loading branch information
Sword-Smith and aszepieniec committed Jan 6, 2025
1 parent 1d9e4e7 commit 2f40300
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main_loop/proof_upgrader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,15 @@ impl UpgradeJob {
(upgraded_tx, expected_utxos)
}
Err(e) => {
panic!("UpgradeProof job failed. error: {}", e);
error!("UpgradeProof job failed. error: {e}");
error!("upgrading of witness or proof in {tx_origin} transaction failed.");
error!(
"Consider lowering your proving capability to {}, in case it is set higher.\nCurrent proving \
capability is set to: {}.",
TxProvingCapability::ProofCollection,
global_state_lock.cli().proving_capability()
);
return;
}
};

Expand Down
11 changes: 11 additions & 0 deletions src/models/state/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ impl TransactionOrigin {
}
}

impl std::fmt::Display for TransactionOrigin {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let output = match self {
TransactionOrigin::Foreign => "third-party",
TransactionOrigin::Own => "own",
};

write!(f, "{output}")
}
}

#[derive(Debug, GetSize, Clone, Serialize, Deserialize)]
pub(crate) struct MempoolTransaction {
pub(crate) transaction: Transaction,
Expand Down

0 comments on commit 2f40300

Please sign in to comment.