From d151e1416677b5974e996078eb1c164f5e4d1364 Mon Sep 17 00:00:00 2001 From: Cassandra Heart Date: Tue, 16 Jan 2024 01:14:00 -0600 Subject: [PATCH] fix: weird state from dropped channels --- .../ceremony/application/ceremony_application.go | 4 ++-- .../ceremony_application_in_progress.go | 14 +++++++------- .../ceremony/ceremony_execution_engine.go | 9 +++++++++ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/node/execution/ceremony/application/ceremony_application.go b/node/execution/ceremony/application/ceremony_application.go index 78a824d..b1c7614 100644 --- a/node/execution/ceremony/application/ceremony_application.go +++ b/node/execution/ceremony/application/ceremony_application.go @@ -884,10 +884,10 @@ func (a *CeremonyApplication) ApplyTransition( maxRounds = maxRounds << 1 } - if a.RoundCount == maxRounds && + if a.RoundCount >= maxRounds && uint64(len(a.TranscriptRoundAdvanceCommits)) == a.RoundCount && len(a.ActiveParticipants) == - len(a.TranscriptRoundAdvanceCommits[a.RoundCount-1].Commits) { + len(a.TranscriptRoundAdvanceCommits[maxRounds-1].Commits) { a.LobbyState = CEREMONY_APPLICATION_STATE_FINALIZING a.FinalCommits = a.TranscriptRoundAdvanceCommits[a.RoundCount-1].Commits a.RoundCount = 0 diff --git a/node/execution/ceremony/application/ceremony_application_in_progress.go b/node/execution/ceremony/application/ceremony_application_in_progress.go index b61e5f3..df38dd5 100644 --- a/node/execution/ceremony/application/ceremony_application_in_progress.go +++ b/node/execution/ceremony/application/ceremony_application_in_progress.go @@ -220,15 +220,15 @@ func (a *CeremonyApplication) applyTranscriptCommit( } } + if maxRounds < a.RoundCount-1 { + return errors.Wrap( + errors.New("round limit exceeded"), + "apply transcript commit", + ) + } + if len(a.TranscriptRoundAdvanceCommits[a.RoundCount-1].Commits) == len(a.ActiveParticipants) { - if maxRounds == - uint64(len(a.TranscriptRoundAdvanceCommits)) { - return errors.Wrap( - errors.New("round limit exceeded"), - "apply transcript commit", - ) - } a.TranscriptRoundAdvanceCommits = append( a.TranscriptRoundAdvanceCommits, &protobufs.CeremonyAdvanceRound{ diff --git a/node/execution/ceremony/ceremony_execution_engine.go b/node/execution/ceremony/ceremony_execution_engine.go index fd8239b..71fc5a2 100644 --- a/node/execution/ceremony/ceremony_execution_engine.go +++ b/node/execution/ceremony/ceremony_execution_engine.go @@ -425,6 +425,7 @@ func (e *CeremonyExecutionEngine) RunWorker() { err := e.connectToActivePeers(app, position) if err != nil { e.logger.Error("error while connecting to peers", zap.Error(err)) + e.publishDroppedParticipant(e.proverPublicKey) continue } } @@ -703,6 +704,14 @@ func (e *CeremonyExecutionEngine) connectToActivePeers( e.pubSub, ) if err != nil { + e.logger.Error( + "could not establish p2p channel", + zap.Binary( + "proving_key", + p.PublicKeySignatureEd448.PublicKey.KeyValue, + ), + zap.Error(err), + ) return errors.Wrap(err, "connect to active peers") } }