From 79e4783cb1454e914db03026f42db16f00164ffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Fri, 30 Aug 2024 11:54:30 +0100 Subject: [PATCH] governance: refactor proposal tx error handling --- crates/node/src/shell/finalize_block.rs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/crates/node/src/shell/finalize_block.rs b/crates/node/src/shell/finalize_block.rs index e30a018b084..68e4ffe17ca 100644 --- a/crates/node/src/shell/finalize_block.rs +++ b/crates/node/src/shell/finalize_block.rs @@ -1172,25 +1172,28 @@ where Ok(extended_tx_result) => match extended_tx_result .tx_result .get_inner_tx_result(None, either::Right(&cmt)) + .expect("Proposal tx must have a result") { - Some(Ok(batched_result)) - if batched_result.is_accepted() => - { - state.write_log_mut().commit_batch_and_current_tx(); - Ok(true) + Ok(batched_result) => { + if batched_result.is_accepted() { + state.write_log_mut().commit_batch_and_current_tx(); + Ok(true) + } else { + tracing::warn!( + "Governance proposal rejected by VP(s): {}", + batched_result.vps_result + ); + state.write_log_mut().drop_batch(); + Ok(false) + } } - Some(Err(e)) => { + Err(e) => { tracing::warn!( "Error executing governance proposal {e}", ); state.write_log_mut().drop_batch(); Ok(false) } - _ => { - tracing::warn!("not sure what happen"); - state.write_log_mut().drop_batch(); - Ok(false) - } }, Err(e) => { tracing::warn!(