From 72e3a103b84a369b2b1905e2c45f859e96731715 Mon Sep 17 00:00:00 2001 From: Chirantan Ekbote Date: Wed, 4 Jan 2023 16:34:56 +0900 Subject: [PATCH] cosmwasm: accounting: Identify failed transfer in batch When we fail to handle an observation in a batch, include the transfer key as part of the error context so that it's easier to figure out which observation caused the error. --- cosmwasm/contracts/wormchain-accounting/src/contract.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cosmwasm/contracts/wormchain-accounting/src/contract.rs b/cosmwasm/contracts/wormchain-accounting/src/contract.rs index 343515f43..961bb9bb6 100644 --- a/cosmwasm/contracts/wormchain-accounting/src/contract.rs +++ b/cosmwasm/contracts/wormchain-accounting/src/contract.rs @@ -119,7 +119,11 @@ fn submit_observations( let events = observations .into_iter() - .map(|o| handle_observation(deps.branch(), o, guardian_set_index, quorum, signature)) + .map(|o| { + let key = transfer::Key::new(o.emitter_chain, o.emitter_address.into(), o.sequence); + handle_observation(deps.branch(), o, guardian_set_index, quorum, signature) + .with_context(|| format!("failed to handle observation for key {key}")) + }) .filter_map(Result::transpose) .collect::>>() .context("failed to handle `Observation`")?;