Skip to content

Commit

Permalink
replace DHT with authenticated discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
brewmaster012 committed Oct 25, 2024
1 parent ab5ac3d commit 84a4b29
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
25 changes: 24 additions & 1 deletion cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ import (
"time"

"github.com/cometbft/cometbft/crypto/secp256k1"
"github.com/davecgh/go-spew/spew"
"github.com/libp2p/go-libp2p/core/peer"
maddr "github.com/multiformats/go-multiaddr"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"gitlab.com/thorchain/tss/go-tss/conversion"

"github.com/zeta-chain/node/pkg/authz"
"github.com/zeta-chain/node/pkg/chains"
Expand Down Expand Up @@ -205,7 +208,16 @@ func start(_ *cobra.Command, _ []string) error {

telemetryServer.SetIPAddress(cfg.PublicIP)
// Create TSS server
server, err := mc.SetupTSSServer(peers, priKey, preParams, appContext.Config(), tssKeyPass, true)
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)
}
server, err := mc.SetupTSSServer(peers, priKey, preParams, appContext.Config(), tssKeyPass, true, whitelistedPeers)
if err != nil {
return fmt.Errorf("SetupTSSServer error: %w", err)
}
Expand All @@ -221,6 +233,17 @@ func start(_ *cobra.Command, _ []string) error {
masterLogger.Info().Msg("TSS listener received an action to shutdown zetaclientd.")
signalChannel <- syscall.SIGTERM
})
// debug: printout connected peers
go func() {
for {
time.Sleep(10 * time.Second)
peers := server.GetKnownPeers()
for _, p := range peers {
log.Info().Msgf("Connected peer(%d)", len(peers))
spew.Dump(p)
}
}
}()

// Generate a new TSS if keygen is set and add it into the tss server
// If TSS has already been generated, and keygen was successful ; we use the existing TSS
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -368,5 +368,6 @@ 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.10.26-spc
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-20241023185909-85fd6808d9fb
gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241025022814-d69c70db51bc
//gitlab.com/thorchain/tss/go-tss => ../go-tss
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4206,8 +4206,8 @@ github.com/zeta-chain/go-ethereum v1.10.26-spc h1:NvY4rR9yw52wfxWt7YoFsWbaIwVMyO
github.com/zeta-chain/go-ethereum v1.10.26-spc/go.mod h1:/6CsT5Ceen2WPLI/oCA3xMcZ5sWMF/D46SjM/ayY0Oo=
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-20241023185909-85fd6808d9fb h1:mO/e5wIB79UTAEU7WPtTy76vljmnIC1/pgqy+0HSPC8=
github.com/zeta-chain/go-tss v0.0.0-20241023185909-85fd6808d9fb/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc=
github.com/zeta-chain/go-tss v0.0.0-20241025022814-d69c70db51bc h1:8X5jIUKr/5Qkd8aGiacMJ0oB819xFLDEaLRLxfsMUmo=
github.com/zeta-chain/go-tss v0.0.0-20241025022814-d69c70db51bc/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc=
github.com/zeta-chain/keystone/keys v0.0.0-20240826165841-3874f358c138 h1:vck/FcIIpFOvpBUm0NO17jbEtmSz/W/a5Y4jRuSJl6I=
github.com/zeta-chain/keystone/keys v0.0.0-20240826165841-3874f358c138/go.mod h1:U494OsZTWsU75hqoriZgMdSsgSGP1mUL1jX+wN/Aez8=
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20241021075719-d40d2e28467c h1:ZoFxMMZtivRLquXVq1sEVlT45UnTPMO1MSXtc88nDv4=
Expand Down
2 changes: 2 additions & 0 deletions zetaclient/tss/tss_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ 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 Down Expand Up @@ -185,6 +186,7 @@ func SetupTSSServer(
preParams, // use pre-generated pre-params if non-nil
IP, // for docker test
tssPassword,
whitelistedPeers,

Check warning on line 189 in zetaclient/tss/tss_signer.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/tss/tss_signer.go#L189

Added line #L189 was not covered by tests
)
if err != nil {
log.Error().Err(err).Msg("NewTSS error")
Expand Down

0 comments on commit 84a4b29

Please sign in to comment.