fix: weird state from dropped channels

This commit is contained in:
Cassandra Heart 2024-01-16 01:14:00 -06:00
parent 175a35edec
commit d151e14166
No known key found for this signature in database
GPG Key ID: 6352152859385958
3 changed files with 18 additions and 9 deletions

View File

@ -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

View File

@ -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{

View File

@ -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")
}
}