From 6297a92e85416be87cf406f3064bd92c5b8f1356 Mon Sep 17 00:00:00 2001 From: Max Summe Date: Wed, 18 Dec 2024 15:59:13 -0800 Subject: [PATCH] Handle edge case --- rs/nns/governance/src/governance.rs | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/rs/nns/governance/src/governance.rs b/rs/nns/governance/src/governance.rs index 9624e8c8052..2a613615345 100644 --- a/rs/nns/governance/src/governance.rs +++ b/rs/nns/governance/src/governance.rs @@ -6992,19 +6992,30 @@ impl Governance { // This is different from what we do in most places because we usually rely // on trapping to retain the lock, but we can't do that here since we're not // working on a single neuron. - self.with_neuron_mut(&neuron_id, |neuron| { - neuron.maturity_e8s_equivalent = neuron_stake; - neuron.cached_neuron_stake_e8s = 0; - neuron.spawn_at_timestamp_seconds = - original_spawn_at_timestamp_seconds; - }); println!( "{}Error spawning neuron: {:?}. Ledger update failed with err: {:?}. \ - Reverted state, so another attempt can be made.", + Reverting state, so another attempt can be made.", LOG_PREFIX, neuron_id, error, - ); + ); + match self.with_neuron_mut(&neuron_id, |neuron| { + neuron.maturity_e8s_equivalent = neuron_stake; + neuron.cached_neuron_stake_e8s = 0; + neuron.spawn_at_timestamp_seconds = + original_spawn_at_timestamp_seconds; + }) { + Ok(_) => (), + Err(e) => { + println!( + "{} Error reverting state for neuron: {:?}. Retaining lock: {}", + LOG_PREFIX, + neuron_id, + e + ); + lock.retain(); + } + }; } }; }