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

fix: replace DHT with private peer discovery #3041

Merged
merged 25 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ab5ac3d
import go-tss lib that removes DHT
brewmaster012 Oct 23, 2024
84a4b29
replace DHT with authenticated discovery
brewmaster012 Oct 25, 2024
331a424
use JSON serialization; add metric
robbwu Oct 25, 2024
21d9d7b
add new telemetry: 8123/connectedpeers; fix deadlock
robbwu Oct 25, 2024
102ccc1
use squashed go-tss commit
brewmaster012 Oct 25, 2024
7e439f2
clean up interface
brewmaster012 Oct 25, 2024
e927e2a
address review comments
brewmaster012 Oct 25, 2024
e772dd6
remove whiteliste peers
brewmaster012 Oct 25, 2024
46c1b60
fmt
brewmaster012 Oct 25, 2024
193dae7
remove rendezvous
brewmaster012 Oct 25, 2024
4394f95
use merged go-tss connection gater
brewmaster012 Oct 28, 2024
743d7cc
use latest go-tss from PR#34
brewmaster012 Oct 29, 2024
a910235
use merged #34 in go-tss lib
brewmaster012 Oct 31, 2024
0e817c3
merged origin/develop
brewmaster012 Oct 31, 2024
26f14d3
add ping RTT to telemetry
brewmaster012 Oct 31, 2024
29eece3
changelog
brewmaster012 Nov 1, 2024
1c9e3ad
make linter happy
brewmaster012 Nov 2, 2024
0e5cf02
pingrtt
brewmaster012 Nov 2, 2024
2aeb341
finer resolution on pingrtt time (milliseconds => nanoseconds)
brewmaster012 Nov 2, 2024
ee9ddd4
Merge remote-tracking branch 'origin/develop' into dht-removal
brewmaster012 Nov 4, 2024
ab06660
removed comments
brewmaster012 Nov 4, 2024
b79af05
Merge remote-tracking branch 'origin/develop' into dht-removal
brewmaster012 Nov 4, 2024
737dafd
Merge remote-tracking branch 'origin/develop' into dht-removal
brewmaster012 Nov 6, 2024
6d5eaa9
bump go-tss to the merged commit in master branch
brewmaster012 Nov 6, 2024
e5b77df
revert back to the go-tss commit
brewmaster012 Nov 6, 2024
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
230 changes: 0 additions & 230 deletions cmd/zetaclientd/p2p_diagnostics.go

This file was deleted.

43 changes: 36 additions & 7 deletions cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import (
"os/signal"
"path/filepath"
"strings"
"sync"
"syscall"
"time"

"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"
Expand Down Expand Up @@ -181,13 +183,6 @@ func start(_ *cobra.Command, _ []string) error {
log.Error().Err(err).Msg("peer address error")
}
initPreParams(cfg.PreParamsPath)
if cfg.P2PDiagnostic {
err := RunDiagnostics(startLogger, peers, hotkeyPk, cfg)
if err != nil {
startLogger.Error().Err(err).Msg("RunDiagnostics error")
return err
}
}

m, err := metrics.NewMetrics()
if err != nil {
Expand Down Expand Up @@ -234,6 +229,40 @@ 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() {
brewmaster012 marked this conversation as resolved.
Show resolved Hide resolved
for {
time.Sleep(30 * time.Second)
brewmaster012 marked this conversation as resolved.
Show resolved Hide resolved
ps := server.GetKnownPeers()
brewmaster012 marked this conversation as resolved.
Show resolved Hide resolved
metrics.NumConnectedPeers.Set(float64(len(ps)))
telemetryServer.SetConnectedPeers(ps)
}
}()
go func() {
host := server.GetP2PHost()
pingRTT := make(map[peer.ID]int64)
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)
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.Milliseconds()
}(p)
}
wg.Wait()
telemetryServer.SetPingRTT(pingRTT)
time.Sleep(30 * time.Second)
}
}()

// 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
17 changes: 4 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ require (
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/libp2p/go-libp2p v0.27.8
github.com/libp2p/go-libp2p-kad-dht v0.24.2
github.com/mattn/go-sqlite3 v1.14.19 // indirect
github.com/multiformats/go-multiaddr v0.9.0
github.com/nanmu42/etherscan-api v1.10.0
Expand Down Expand Up @@ -190,15 +189,11 @@ require (
github.com/huin/goupnp v1.2.0 // indirect
github.com/iancoleman/orderedmap v0.3.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/ipfs/boxo v0.10.0 // indirect
github.com/ipfs/go-cid v0.4.1 // indirect
github.com/ipfs/go-datastore v0.6.0 // indirect
github.com/ipfs/go-log v1.0.5 // indirect
github.com/ipfs/go-log/v2 v2.5.1 // indirect
github.com/ipld/go-ipld-prime v0.20.0 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
github.com/jbenet/goprocess v0.1.4 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand All @@ -212,8 +207,6 @@ require (
github.com/libp2p/go-cidranger v1.1.0 // indirect
github.com/libp2p/go-flow-metrics v0.1.0 // indirect
github.com/libp2p/go-libp2p-asn-util v0.3.0 // indirect
github.com/libp2p/go-libp2p-kbucket v0.6.3 // indirect
github.com/libp2p/go-libp2p-record v0.2.0 // indirect
github.com/libp2p/go-msgio v0.3.0 // indirect
github.com/libp2p/go-nat v0.1.0 // indirect
github.com/libp2p/go-netroute v0.2.1 // indirect
Expand Down Expand Up @@ -241,7 +234,7 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mostynb/zstdpool-freelist v0.0.0-20201229113212-927304c0c3b1 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/mr-tron/base58 v1.2.0
github.com/mtibben/percent v0.2.1 // indirect
github.com/multiformats/go-base32 v0.1.0 // indirect
github.com/multiformats/go-base36 v0.2.0 // indirect
Expand All @@ -261,7 +254,6 @@ require (
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/polydawn/refmt v0.89.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
Expand Down Expand Up @@ -293,7 +285,6 @@ require (
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect
github.com/yudai/gojsondiff v1.0.0 // indirect
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
github.com/zondax/hid v0.9.2 // indirect
Expand All @@ -319,7 +310,6 @@ require (
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
gonum.org/v1/gonum v0.13.0 // indirect
google.golang.org/api v0.155.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect
Expand All @@ -334,14 +324,15 @@ require (

require (
github.com/bnb-chain/tss-lib v1.5.0
github.com/montanaflynn/stats v0.7.1
github.com/showa-93/go-mask v0.6.2
github.com/tonkeeper/tongo v1.9.3
)

require (
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20220328075252-7dd334e3daae // indirect
github.com/onsi/ginkgo/v2 v2.9.5 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/snksoft/crc v1.1.0 // indirect
Expand All @@ -368,5 +359,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.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-20241028203048-62ae2bb54949
gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241031223543-18765295f992
)
Loading
Loading