From 5b2df531aa06a5f5904fce757fd745bab62af84f Mon Sep 17 00:00:00 2001 From: Phuong N Date: Tue, 28 Nov 2023 00:13:05 +0000 Subject: [PATCH] Protocol loop should continue on error --- node/src/protocol/mod.rs | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/node/src/protocol/mod.rs b/node/src/protocol/mod.rs index 0122418f1..775974d48 100644 --- a/node/src/protocol/mod.rs +++ b/node/src/protocol/mod.rs @@ -189,13 +189,28 @@ impl MpcSignProtocol { } } - let mut state = { - let guard = self.state.write().await; + let state = { + let guard = self.state.read().await; guard.clone() }; - state = state.progress(&self.ctx).await?; - state = state.advance(&self.ctx, contract_state).await?; - state.handle(&self.ctx, &mut queue).await?; + let state = match state.progress(&self.ctx).await { + Ok(state) => state, + Err(err) => { + tracing::info!("protocol unable to progress: {err:?}"); + continue; + } + }; + let mut state = match state.advance(&self.ctx, contract_state).await { + Ok(state) => state, + Err(err) => { + tracing::info!("protocol unable to advance: {err:?}"); + continue; + } + }; + if let Err(err) = state.handle(&self.ctx, &mut queue).await { + tracing::info!("protocol unable to handle messages: {err:?}"); + continue; + } let mut guard = self.state.write().await; *guard = state;