Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 2 additions & 4 deletions tss/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

var (
initiatePeriod = 1 * time.Second
tssTimeout = 30 * time.Second
)

type TssProcess interface {
Expand All @@ -35,6 +34,7 @@ type TssProcess interface {
StartParams(readyPeers []peer.ID) []byte
SessionID() string
ValidCoordinators() []peer.ID
Timeout() time.Duration
}

type Coordinator struct {
Expand All @@ -46,7 +46,6 @@ type Coordinator struct {
processLock sync.Mutex

CoordinatorTimeout time.Duration
TssTimeout time.Duration
InitiatePeriod time.Duration
}

Expand All @@ -62,7 +61,6 @@ func NewCoordinator(

pendingProcesses: make(map[string]bool),

TssTimeout: tssTimeout,
InitiatePeriod: initiatePeriod,
}
}
Expand Down Expand Up @@ -162,7 +160,7 @@ func (c *Coordinator) handleError(ctx context.Context, err error, tssProcesses [
func (c *Coordinator) watchExecution(ctx context.Context, tssProcess TssProcess, coordinator peer.ID, cancel context.CancelFunc) error {
failChn := make(chan *comm.WrappedMessage)
subscriptionID := c.communication.Subscribe(tssProcess.SessionID(), comm.TssFailMsg, failChn)
ticker := time.NewTicker(c.TssTimeout)
ticker := time.NewTicker(tssProcess.Timeout())
defer func() {
ticker.Stop()
c.communication.UnSubscribe(subscriptionID)
Expand Down
6 changes: 6 additions & 0 deletions tss/ecdsa/common/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"math/big"
"runtime/debug"
"time"

"github.com/binance-chain/tss-lib/tss"
"github.com/libp2p/go-libp2p/core/host"
Expand All @@ -33,6 +34,7 @@ type BaseTss struct {
Communication comm.Communication
Peers []peer.ID
Log zerolog.Logger
TssTimeout time.Duration

Cancel context.CancelFunc
}
Expand Down Expand Up @@ -128,3 +130,7 @@ func (b *BaseTss) BroadcastPeers(msg tss.Message) ([]peer.ID, error) {
func (b *BaseTss) SessionID() string {
return b.SID
}

func (b *BaseTss) Timeout() time.Duration {
return b.TssTimeout
}
2 changes: 2 additions & 0 deletions tss/ecdsa/keygen/keygen.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"errors"
"math/big"
"time"

"github.com/binance-chain/tss-lib/ecdsa/keygen"
"github.com/binance-chain/tss-lib/tss"
Expand Down Expand Up @@ -51,6 +52,7 @@ func NewKeygen(
SID: sessionID,
Log: log.With().Str("SessionID", sessionID).Str("Process", "keygen").Logger(),
Cancel: func() {},
TssTimeout: time.Minute * 10,
},
storer: storer,
threshold: threshold,
Expand Down
2 changes: 1 addition & 1 deletion tss/ecdsa/keygen/keygen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (s *KeygenTestSuite) Test_KeygenTimeout() {
keygen := keygen.NewKeygen("keygen2", s.Threshold, host, &communication, s.MockECDSAStorer)
electorFactory := elector.NewCoordinatorElectorFactory(host, s.BullyConfig)
coordinator := tss.NewCoordinator(host, &communication, electorFactory)
coordinator.TssTimeout = time.Millisecond
keygen.TssTimeout = time.Millisecond
coordinators = append(coordinators, coordinator)
processes = append(processes, keygen)
}
Expand Down
2 changes: 2 additions & 0 deletions tss/ecdsa/resharing/resharing.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/json"
"errors"
"math/big"
"time"

"github.com/binance-chain/tss-lib/ecdsa/keygen"
"github.com/binance-chain/tss-lib/ecdsa/resharing"
Expand Down Expand Up @@ -68,6 +69,7 @@ func NewResharing(
SID: sessionID,
Log: log.With().Str("SessionID", sessionID).Str("Process", "resharing").Logger(),
Cancel: func() {},
TssTimeout: time.Minute * 10,
},
key: key,
storer: storer,
Expand Down
1 change: 1 addition & 0 deletions tss/ecdsa/signing/signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func NewSigning(
SID: sessionID,
Log: log.With().Str("SessionID", sessionID).Str("messageID", messageID).Str("Process", "signing").Logger(),
Cancel: func() {},
TssTimeout: time.Second * 30,
},
key: key,
msg: msg,
Expand Down
2 changes: 1 addition & 1 deletion tss/ecdsa/signing/signing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (s *SigningTestSuite) Test_SigningTimeout() {
}
electorFactory := elector.NewCoordinatorElectorFactory(host, s.BullyConfig)
coordinator := tss.NewCoordinator(host, &communication, electorFactory)
coordinator.TssTimeout = time.Nanosecond
signing.TssTimeout = time.Nanosecond
coordinators = append(coordinators, coordinator)
processes = append(processes, signing)
}
Expand Down
Loading