Skip to content

Commit

Permalink
make local cosigner nonce cache expiration twice the leader nonce cache
Browse files Browse the repository at this point in the history
  • Loading branch information
agouin committed Nov 16, 2023
1 parent 19c9558 commit 99e23b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion signer/cosigner_nonce_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const (
defaultGetNoncesInterval = 3 * time.Second
defaultGetNoncesTimeout = 4 * time.Second
cachePreSize = 10000
nonceCacheExpiration = 10 * time.Second // half of the local cosigner cache expiration
)

type CosignerNonceCache struct {
Expand Down Expand Up @@ -201,7 +202,7 @@ func (cnc *CosignerNonceCache) LoadN(ctx context.Context, n int) {
var wg sync.WaitGroup
wg.Add(len(cnc.cosigners))

expiration := time.Now().Add(nonceExpiration)
expiration := time.Now().Add(nonceCacheExpiration)

for i, p := range cnc.cosigners {
i := i
Expand Down
4 changes: 3 additions & 1 deletion signer/local_cosigner.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import (

var _ Cosigner = &LocalCosigner{}

const nonceExpiration = 10 * time.Second
// double the CosignerNonceCache expiration so that sign requests from the leader
// never reference nonces which have expired here in the LocalCosigner.
const nonceExpiration = 20 * time.Second

// LocalCosigner responds to sign requests.
// It maintains a high watermark to avoid double-signing.
Expand Down

0 comments on commit 99e23b4

Please sign in to comment.