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.
This commit is contained in:
Chirantan Ekbote 2023-01-04 16:34:56 +09:00 committed by Chirantan Ekbote
parent 4ddeca4dbd
commit 72e3a103b8
1 changed files with 5 additions and 1 deletions

View File

@ -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::<anyhow::Result<Vec<_>>>()
.context("failed to handle `Observation`")?;