Skip to content

Commit b93a54a

Browse files
authored
Node/CCQ: Add gossipAdvertiseAddress option to proxy server (wormhole-foundation#3924)
1 parent 0f3ffe7 commit b93a54a

File tree

3 files changed

+41
-20
lines changed

3 files changed

+41
-20
lines changed

docs/query_proxy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ wormhole $build/bin/guardiand query-server \
5858
- The `telemetryLokiURL`, `telemetryNodeName` and `promRemoteURL` are used for telemetry purposes and
5959
the values will be provided by Wormhole Foundation personnel if appropriate.
6060

61+
Optional Parameters
62+
63+
- The `gossipAdvertiseAddress` argument allows you to specify an external IP to advertize on P2P (use if behind a NAT or running in k8s).
64+
- The `monitorPeers` flag will cause the proxy server to periodically check its connectivity to the P2P bootstrap peers, and attempt to reconnect if necessary.
65+
6166
#### Creating the Signing Key File
6267

6368
Do the following to create the signing key file. Note that the `block-type` must exactly match what is specified below,

node/cmd/ccq/p2p.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,24 @@ type P2PSub struct {
3838
host host.Host
3939
}
4040

41-
func runP2P(ctx context.Context, priv crypto.PrivKey, port uint, networkID, bootstrapPeers, ethRpcUrl, ethCoreAddr string, pendingResponses *PendingResponses, logger *zap.Logger, monitorPeers bool, loggingMap *LoggingMap) (*P2PSub, error) {
41+
func runP2P(
42+
ctx context.Context,
43+
priv crypto.PrivKey,
44+
port uint,
45+
networkID string,
46+
bootstrapPeers string,
47+
ethRpcUrl string,
48+
ethCoreAddr string,
49+
pendingResponses *PendingResponses,
50+
logger *zap.Logger,
51+
monitorPeers bool,
52+
loggingMap *LoggingMap,
53+
gossipAdvertiseAddress string,
54+
) (*P2PSub, error) {
4255
// p2p setup
4356
components := p2p.DefaultComponents()
4457
components.Port = port
58+
components.GossipAdvertiseAddress = gossipAdvertiseAddress
4559

4660
h, err := p2p.NewHost(logger, ctx, networkID, bootstrapPeers, components, priv)
4761
if err != nil {

node/cmd/ccq/query_server.go

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,25 @@ import (
2828
const CCQ_SERVER_SIGNING_KEY = "CCQ SERVER SIGNING KEY"
2929

3030
var (
31-
envStr *string
32-
p2pNetworkID *string
33-
p2pPort *uint
34-
p2pBootstrap *string
35-
listenAddr *string
36-
nodeKeyPath *string
37-
signerKeyPath *string
38-
permFile *string
39-
ethRPC *string
40-
ethContract *string
41-
logLevel *string
42-
telemetryLokiURL *string
43-
telemetryNodeName *string
44-
statusAddr *string
45-
promRemoteURL *string
46-
shutdownDelay1 *uint
47-
shutdownDelay2 *uint
48-
monitorPeers *bool
31+
envStr *string
32+
p2pNetworkID *string
33+
p2pPort *uint
34+
p2pBootstrap *string
35+
listenAddr *string
36+
nodeKeyPath *string
37+
signerKeyPath *string
38+
permFile *string
39+
ethRPC *string
40+
ethContract *string
41+
logLevel *string
42+
telemetryLokiURL *string
43+
telemetryNodeName *string
44+
statusAddr *string
45+
promRemoteURL *string
46+
shutdownDelay1 *uint
47+
shutdownDelay2 *uint
48+
monitorPeers *bool
49+
gossipAdvertiseAddress *string
4950
)
5051

5152
const DEV_NETWORK_ID = "/wormhole/dev"
@@ -67,6 +68,7 @@ func init() {
6768
statusAddr = QueryServerCmd.Flags().String("statusAddr", "[::]:6060", "Listen address for status server (disabled if blank)")
6869
promRemoteURL = QueryServerCmd.Flags().String("promRemoteURL", "", "Prometheus remote write URL (Grafana)")
6970
monitorPeers = QueryServerCmd.Flags().Bool("monitorPeers", false, "Should monitor bootstrap peers and attempt to reconnect")
71+
gossipAdvertiseAddress = QueryServerCmd.Flags().String("gossipAdvertiseAddress", "", "External IP to advertize on P2P (use if behind a NAT or running in k8s)")
7072

7173
// The default health check monitoring is every five seconds, with a five second timeout, and you have to miss two, for 20 seconds total.
7274
shutdownDelay1 = QueryServerCmd.Flags().Uint("shutdownDelay1", 25, "Seconds to delay after disabling health check on shutdown")
@@ -189,7 +191,7 @@ func runQueryServer(cmd *cobra.Command, args []string) {
189191

190192
// Run p2p
191193
pendingResponses := NewPendingResponses(logger)
192-
p2p, err := runP2P(ctx, priv, *p2pPort, networkID, *p2pBootstrap, *ethRPC, *ethContract, pendingResponses, logger, *monitorPeers, loggingMap)
194+
p2p, err := runP2P(ctx, priv, *p2pPort, networkID, *p2pBootstrap, *ethRPC, *ethContract, pendingResponses, logger, *monitorPeers, loggingMap, *gossipAdvertiseAddress)
193195
if err != nil {
194196
logger.Fatal("Failed to start p2p", zap.Error(err))
195197
}

0 commit comments

Comments
 (0)