Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mitigate unexpected state #233

Merged
merged 3 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions signer/cosigner_nonce_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,23 @@ func TestClearNonces(t *testing.T) {

for _, n := range cnc.cache.cache {
require.Len(t, n.Nonces, 2)
oneFound := false
twoFound := false
for _, cnr := range n.Nonces {
if cnr.Cosigner == cosigners[1] {
oneFound = true
}
if cnr.Cosigner == cosigners[2] {
twoFound = true
}
}
require.True(t, oneFound)
require.True(t, twoFound)
}

cnc.ClearNonces(cosigners[1])

require.Equal(t, 0, cnc.cache.Size())
}

type mockPruner struct {
Expand Down
5 changes: 5 additions & 0 deletions signer/threshold_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"os"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -734,6 +735,10 @@ func (pv *ThresholdValidator) Sign(ctx context.Context, chainID string, block Bl
"err", err.Error(),
)

if strings.Contains(err.Error(), "unexpected state, metadata does not exist for U:") {
pv.nonceCache.ClearNonces(cosigner)
}

if cosigner.GetID() == pv.myCosigner.GetID() {
return err
}
Expand Down
Loading