From 6c9fad6fe6c898f357d9e318078fce187f4a92ca Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Fri, 3 May 2024 14:08:31 +0200 Subject: [PATCH] Modified the required number of signatures during inactivity claim --- pkg/protocol/inactivity/member.go | 5 ++--- pkg/protocol/inactivity/states.go | 21 ++++++++------------- pkg/tbtc/inactivity.go | 20 +++++++++++++++++++- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/pkg/protocol/inactivity/member.go b/pkg/protocol/inactivity/member.go index e993a7a7c3..7720fc7112 100644 --- a/pkg/protocol/inactivity/member.go +++ b/pkg/protocol/inactivity/member.go @@ -37,9 +37,8 @@ func newSigningMember( sessionID string, ) *signingMember { return &signingMember{ - logger: logger, - memberIndex: memberIndex, - // TODO: Check is this is a correct way to create the group. + logger: logger, + memberIndex: memberIndex, group: group.NewGroup(dishonestThreshold, groupSize), membershipValidator: membershipValidator, sessionID: sessionID, diff --git a/pkg/protocol/inactivity/states.go b/pkg/protocol/inactivity/states.go index 6574cf79f9..ef97e482bb 100644 --- a/pkg/protocol/inactivity/states.go +++ b/pkg/protocol/inactivity/states.go @@ -80,19 +80,14 @@ func (css *claimSigningState) Receive(netMessage net.Message) error { } func (css *claimSigningState) CanTransition() bool { - // Although there is no hard requirement to expect signature messages - // from all participants, it makes sense to do so because this is an - // additional participant availability check that allows to maximize - // the final count of active participants. Moreover, this check does not - // bound the signing state to a fixed duration and one can move to the - // next state as soon as possible. - messagingDone := len(receivedMessages[*claimSignatureMessage](css.BaseAsyncState)) == - len(css.member.group.OperatingMemberIndexes())-1 - - // TODO: Modify the above code so that only 51 members are needed. Since it - // is executed after a failed heartbeat, we cannot expect all the - // members to sign the claim. In the future consider taking the number - // of active signers from the heartbeat procedure. + // Require the number of received signatures to be at least the honest + // threshold. Unlike in the case of DKG, we cannot expect all the members to + // participate in signing as we know we are dealing with some problem + // arising from operator inactivity. + // TODO: Consider passing the number of required signatures from the code + // that launched the inactivity operator execution. + messagingDone := len(receivedMessages[*claimSignatureMessage](css.BaseAsyncState)) >= + css.member.group.HonestThreshold() return messagingDone } diff --git a/pkg/tbtc/inactivity.go b/pkg/tbtc/inactivity.go index b09117abe9..937d02ada9 100644 --- a/pkg/tbtc/inactivity.go +++ b/pkg/tbtc/inactivity.go @@ -2,6 +2,7 @@ package tbtc import ( "context" + "errors" "fmt" "math/big" "sync" @@ -134,7 +135,7 @@ func (ice *inactivityClaimExecutor) publishClaim( ) defer cancelCtx() - ice.publish( + err := ice.publish( ctx, execLogger, message, @@ -148,6 +149,23 @@ func (ice *inactivityClaimExecutor) publishClaim( claim, ) + if err != nil { + if errors.Is(err, context.Canceled) { + execLogger.Infof( + "[member:%v] inactivity claim is no longer awaiting "+ + "publishing; aborting inactivity claim publishing", + signer.signingGroupMemberIndex, + ) + return + } + + execLogger.Errorf( + "[member:%v] inactivity claim publishing failed [%v]", + signer.signingGroupMemberIndex, + err, + ) + return + } }(currentSigner) }