Skip to content

Commit

Permalink
fix: replace DHT with private peer discovery (#3041)
Browse files Browse the repository at this point in the history
* import go-tss lib that removes DHT

* replace DHT with authenticated discovery

* use JSON serialization; add metric

* add new telemetry: 8123/connectedpeers; fix deadlock

in a few other 8123 handlers

* use squashed go-tss commit

* clean up interface

* address review comments

* remove whiteliste peers

* fmt

* remove rendezvous

* use merged go-tss connection gater

* use latest go-tss from PR#34

* use merged #34 in go-tss lib

* add ping RTT to telemetry

* changelog

* make linter happy

* pingrtt

* finer resolution on pingrtt time (milliseconds => nanoseconds)

* removed comments

* bump go-tss to the merged commit in master branch

* revert back to the go-tss commit

until the PR commit is merged.

---------

Co-authored-by: pwu <armiuswu@gmail.com>
  • Loading branch information
2 people authored and gartnera committed Nov 13, 2024
1 parent 156c77b commit b6e14a2
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 297 deletions.
16 changes: 12 additions & 4 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@

* [3073](https://github.com/zeta-chain/node/pull/3073) - improve ZETA deposit check with max supply check

### Refactor

### Tests

### Fixes
* [3041](https://github.com/zeta-chain/node/pull/3041) - replace libp2p public DHT with private gossip peer discovery and connection gater for inbound connections


## v21.0.0

### Features
Expand Down Expand Up @@ -142,7 +150,7 @@
* [2518](https://github.com/zeta-chain/node/pull/2518) - add support for Solana address in zetacore
* [2483](https://github.com/zeta-chain/node/pull/2483) - add priorityFee (gasTipCap) gas to the state
* [2567](https://github.com/zeta-chain/node/pull/2567) - add sign latency metric to zetaclient (zetaclient_sign_latency)
* [2524](https://github.com/zeta-chain/node/pull/2524) - add inscription envelop parsing
* [2524](https://github.com/zeta-chain/node/pull/2524) - add inscription envelop parsing
* [2560](https://github.com/zeta-chain/node/pull/2560) - add support for Solana SOL token withdraw
* [2533](https://github.com/zeta-chain/node/pull/2533) - parse memo from both OP_RETURN and inscription
* [2765](https://github.com/zeta-chain/node/pull/2765) - bitcoin depositor fee improvement
Expand Down Expand Up @@ -224,7 +232,7 @@

### CI

* [2388](https://github.com/zeta-chain/node/pull/2388) - added GitHub attestations of binaries produced in the release workflow.
* [2388](https://github.com/zeta-chain/node/pull/2388) - added GitHub attestations of binaries produced in the release workflow.
* [2285](https://github.com/zeta-chain/node/pull/2285) - added nightly EVM performance testing pipeline, modified localnet testing docker image to utilize debian:bookworm, removed build-jet runners where applicable, removed deprecated/removed upgrade path testing pipeline
* [2268](https://github.com/zeta-chain/node/pull/2268) - updated the publish-release pipeline to utilize the Github Actions Ubuntu 20.04 Runners
* [2070](https://github.com/zeta-chain/node/pull/2070) - Added commands to build binaries from the working branch as a live full node rpc to test non-governance changes
Expand Down Expand Up @@ -636,7 +644,7 @@ Getting the correct TSS address for Bitcoin now requires providing the Bitcoin c

### Tests

* Add unit tests for adding votes to a ballot
* Add unit tests for adding votes to a ballot

### CI

Expand Down Expand Up @@ -676,7 +684,7 @@ Getting the correct TSS address for Bitcoin now requires providing the Bitcoin c
### Refactoring

* [1226](https://github.com/zeta-chain/node/pull/1226) - call `onCrossChainCall` when depositing to a contract
* [1238](https://github.com/zeta-chain/node/pull/1238) - change default mempool version in config
* [1238](https://github.com/zeta-chain/node/pull/1238) - change default mempool version in config
* [1279](https://github.com/zeta-chain/node/pull/1279) - remove duplicate funtion name IsEthereum
* [1289](https://github.com/zeta-chain/node/pull/1289) - skip gas stability pool funding when gasLimit is equal gasUsed

Expand Down
229 changes: 0 additions & 229 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 @@ -235,6 +230,40 @@ func start(_ *cobra.Command, _ []string) error {
signalChannel <- syscall.SIGTERM
})

go func() {
for {
time.Sleep(30 * time.Second)
ps := server.GetKnownPeers()
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.Nanoseconds()
}(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
err = GenerateTSS(ctx, masterLogger, zetacoreClient, server)
Expand Down
Loading

0 comments on commit b6e14a2

Please sign in to comment.