From 3cb44f33bed476a4764eb64bf25bf06109f8eaee Mon Sep 17 00:00:00 2001 From: Phuong Nguyen Date: Mon, 27 Nov 2023 16:55:39 -0800 Subject: [PATCH] Protocol loop should continue on error (#387) --- 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;