Skip to content

Commit

Permalink
chore: revert go-tss to v21/v22 version
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed Nov 25, 2024
1 parent bb4b7ee commit e433659
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 48 deletions.
53 changes: 10 additions & 43 deletions cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ import (
"os/signal"
"path/filepath"
"strings"
"sync"
"syscall"
"time"

ecdsakeygen "github.com/bnb-chain/tss-lib/ecdsa/keygen"
"github.com/cometbft/cometbft/crypto/secp256k1"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/p2p/protocol/ping"
maddr "github.com/multiformats/go-multiaddr"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
"github.com/samber/lo"
"github.com/spf13/cobra"
"gitlab.com/thorchain/tss/go-tss/conversion"
"gitlab.com/thorchain/tss/go-tss/tss"

"github.com/zeta-chain/node/pkg/authz"
"github.com/zeta-chain/node/pkg/chains"
Expand Down Expand Up @@ -192,14 +191,6 @@ func Start(_ *cobra.Command, _ []string) error {
telemetryServer.SetIPAddress(cfg.PublicIP)

keygen := appContext.GetKeygen()
whitelistedPeers := []peer.ID{}
for _, pk := range keygen.GranteePubkeys {
pid, err := conversion.Bech32PubkeyToPeerID(pk)
if err != nil {
return err
}
whitelistedPeers = append(whitelistedPeers, pid)
}

// Create TSS server
tssServer, err := mc.SetupTSSServer(
Expand All @@ -209,7 +200,6 @@ func Start(_ *cobra.Command, _ []string) error {
appContext.Config(),
tssKeyPass,
true,
whitelistedPeers,
)
if err != nil {
return fmt.Errorf("SetupTSSServer error: %w", err)
Expand All @@ -225,37 +215,14 @@ func Start(_ *cobra.Command, _ []string) error {
go func() {
for {
time.Sleep(30 * time.Second)
ps := tssServer.GetKnownPeers()
metrics.NumConnectedPeers.Set(float64(len(ps)))
telemetryServer.SetConnectedPeers(ps)
}
}()
go func() {
host := tssServer.GetP2PHost()
pingRTT := make(map[peer.ID]int64)
pingRTTLock := sync.Mutex{}
for {
var wg sync.WaitGroup
for _, p := range whitelistedPeers {
wg.Add(1)
go func(p peer.ID) {
defer wg.Done()
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
result := <-ping.Ping(ctx, host, p)
pingRTTLock.Lock()
defer pingRTTLock.Unlock()
if result.Error != nil {
masterLogger.Error().Err(result.Error).Msg("ping error")
pingRTT[p] = -1 // RTT -1 indicate ping error
return
}
pingRTT[p] = result.RTT.Nanoseconds()
}(p)
}
wg.Wait()
telemetryServer.SetPingRTT(pingRTT)
time.Sleep(30 * time.Second)
knownPeersTss := tssServer.GetKnownPeers()
metrics.NumConnectedPeers.Set(float64(len(knownPeersTss)))
knownPeersAddrInfo := lo.Map(knownPeersTss, func(p tss.PeerInfo, _ int) peer.AddrInfo {
return peer.AddrInfo{
ID: peer.ID(p.ID),
}
})
telemetryServer.SetConnectedPeers(knownPeersAddrInfo)
}
}()
// pprof http server
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -371,5 +371,5 @@ replace (
github.com/bnb-chain/tss-lib => github.com/zeta-chain/tss-lib v0.0.0-20240916163010-2e6b438bd901
github.com/ethereum/go-ethereum => github.com/zeta-chain/go-ethereum v1.13.16-0.20241022183758-422c6ef93ccc
github.com/libp2p/go-libp2p => github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4
gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241115165301-8535262eb16f
gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241028192852-b5233fc8c2b3
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1527,8 +1527,8 @@ github.com/zeta-chain/go-ethereum v1.13.16-0.20241022183758-422c6ef93ccc h1:FVOt
github.com/zeta-chain/go-ethereum v1.13.16-0.20241022183758-422c6ef93ccc/go.mod h1:MgO2/CmxFnj6W7v/5hrz3ypco3kHkb8856pRnFkY4xQ=
github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 h1:FmO3HfVdZ7LzxBUfg6sVzV7ilKElQU2DZm8PxJ7KcYI=
github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4/go.mod h1:TBv5NY/CqWYIfUstXO1fDWrt4bDoqgCw79yihqBspg8=
github.com/zeta-chain/go-tss v0.0.0-20241115165301-8535262eb16f h1:zKBTanf2jf/oyr3f27GgvibSdVThmCdcV9sc5/6uOyQ=
github.com/zeta-chain/go-tss v0.0.0-20241115165301-8535262eb16f/go.mod h1:nqelgf4HKkqlXaVg8X38a61WfyYB+ivCt6nnjoTIgCc=
github.com/zeta-chain/go-tss v0.0.0-20241028192852-b5233fc8c2b3 h1:IecdEwyguY3dtI7xRT+yW6ml/Z9cfIVHiB4q6huBhc4=
github.com/zeta-chain/go-tss v0.0.0-20241028192852-b5233fc8c2b3/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc=
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20241021075719-d40d2e28467c h1:ZoFxMMZtivRLquXVq1sEVlT45UnTPMO1MSXtc88nDv4=
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20241021075719-d40d2e28467c/go.mod h1:SjT7QirtJE8stnAe1SlNOanxtfSfijJm3MGJ+Ax7w7w=
github.com/zeta-chain/protocol-contracts-solana/go-idl v0.0.0-20241108171442-e48d82f94892 h1:oI5qCrw2SXDf2a2UYAn0tpaKHbKpJcR+XDtceyY00wE=
Expand Down
3 changes: 1 addition & 2 deletions zetaclient/tss/tss_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ func SetupTSSServer(
cfg config.Config,
tssPassword string,
enableMonitor bool,
whitelistedPeers []gopeer.ID,
) (*tss.TssServer, error) {
bootstrapPeers := peer
log.Info().Msgf("Peers AddrList %v", bootstrapPeers)
Expand All @@ -176,6 +175,7 @@ func SetupTSSServer(
bootstrapPeers,
6668,
privkey,
"MetaMetaOpenTheDoor",
tsspath,
thorcommon.TssConfig{
EnableMonitor: enableMonitor,
Expand All @@ -187,7 +187,6 @@ func SetupTSSServer(
preParams, // use pre-generated pre-params if non-nil
IP, // for docker test
tssPassword,
whitelistedPeers,
)
if err != nil {
log.Error().Err(err).Msg("NewTSS error")
Expand Down

0 comments on commit e433659

Please sign in to comment.