Skip to content

Commit

Permalink
feat_: use fleet nodes as one of the preferred nodes for waku filter …
Browse files Browse the repository at this point in the history
…subscriptions
  • Loading branch information
chaitanyaprem committed Oct 24, 2024
1 parent fa1a552 commit b7fa5a5
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ require (
github.com/schollz/peerdiscovery v1.7.0
github.com/siphiuel/lc-proxy-wrapper v0.0.0-20230516150924-246507cee8c7
github.com/urfave/cli/v2 v2.27.2
github.com/waku-org/go-waku v0.8.1-0.20241018104939-8842d00df1b9
github.com/waku-org/go-waku v0.8.1-0.20241024093455-4e3d73c830fc
github.com/wk8/go-ordered-map/v2 v2.1.7
github.com/yeqown/go-qrcode/v2 v2.2.1
github.com/yeqown/go-qrcode/writer/standard v1.2.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2136,8 +2136,8 @@ github.com/waku-org/go-libp2p-pubsub v0.12.0-gowaku.0.20240823143342-b0f2429ca27
github.com/waku-org/go-libp2p-pubsub v0.12.0-gowaku.0.20240823143342-b0f2429ca27f/go.mod h1:Oi0zw9aw8/Y5GC99zt+Ef2gYAl+0nZlwdJonDyOz/sE=
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20240110193335-a67d1cc760a0 h1:R4YYx2QamhBRl/moIxkDCNW+OP7AHbyWLBygDc/xIMo=
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20240110193335-a67d1cc760a0/go.mod h1:EhZP9fee0DYjKH/IOQvoNSy1tSHp2iZadsHGphcAJgY=
github.com/waku-org/go-waku v0.8.1-0.20241018104939-8842d00df1b9 h1:0idZXdPAB4Xgbj6R9rJoeNWwVRarGioPIPIwapfJbQA=
github.com/waku-org/go-waku v0.8.1-0.20241018104939-8842d00df1b9/go.mod h1:1BRnyg2mQ2aBNLTBaPq6vEvobzywGykPOhGQFbHGf74=
github.com/waku-org/go-waku v0.8.1-0.20241024093455-4e3d73c830fc h1:lV+IVKozyHE3/JfKQ2hKFxXyaFtOBZKCtI2FAYJKs50=
github.com/waku-org/go-waku v0.8.1-0.20241024093455-4e3d73c830fc/go.mod h1:1BRnyg2mQ2aBNLTBaPq6vEvobzywGykPOhGQFbHGf74=
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59 h1:jisj+OCI6QydLtFq3Pyhu49wl9ytPN7oAHjMfepHDrA=
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59/go.mod h1:1PdBdPzyTaKt3VnpAHk3zj+r9dXPFOr3IHZP9nFle6E=
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230916172309-ee0ee61dde2b h1:KgZVhsLkxsj5gb/FfndSCQu6VYwALrCOgYI3poR95yE=
Expand Down
6 changes: 6 additions & 0 deletions params/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ var supportedFleets = map[FleetName]map[NodeType][]string{
FleetStatusStaging: {
WakuNodes: {
"enrtree://AI4W5N5IFEUIHF5LESUAOSMV6TKWF2MB6GU2YK7PU4TYUGUNOCEPW@boot.staging.status.nodes.status.im",
"/dns4/boot-01.do-ams3.status.staging.status.im/tcp/30303/p2p/16Uiu2HAmQE7FXQc6iZHdBzYfw3qCSDa9dLc1wsBJKoP4aZvztq2d",
"/dns4/boot-01.gc-us-central1-a.status.staging.status.im/tcp/30303/p2p/16Uiu2HAmGAA54bBTE78MYidSy3P7Q9yAWFNTAEReJYD69VRvtL5r",
"/dns4/boot-01.ac-cn-hongkong-c.status.staging.status.im/tcp/30303/p2p/16Uiu2HAmNTpGnyZ8W1BK2sXEmgSCNWiyDKgRU3NBR2DXST2HzxRU",
},
DiscV5BootstrapNodes: {
"enrtree://AI4W5N5IFEUIHF5LESUAOSMV6TKWF2MB6GU2YK7PU4TYUGUNOCEPW@boot.staging.status.nodes.status.im",
Expand All @@ -41,6 +44,9 @@ var supportedFleets = map[FleetName]map[NodeType][]string{
FleetStatusProd: {
WakuNodes: {
"enrtree://AMOJVZX4V6EXP7NTJPMAYJYST2QP6AJXYW76IU6VGJS7UVSNDYZG4@boot.prod.status.nodes.status.im",
"/dns4/boot-01.do-ams3.status.prod.status.im/tcp/30303/p2p/16Uiu2HAmAR24Mbb6VuzoyUiGx42UenDkshENVDj4qnmmbabLvo31",
"/dns4/boot-01.gc-us-central1-a.status.prod.status.im/tcp/30303/p2p/16Uiu2HAm8mUZ18tBWPXDQsaF7PbCKYA35z7WB2xNZH2EVq1qS8LJ",
"/dns4/boot-01.ac-cn-hongkong-c.status.prod.statusim.net/tcp/30303/p2p/16Uiu2HAmGwcE8v7gmJNEWFtZtojYpPMTHy2jBLL6xRk33qgDxFWX",
},
DiscV5BootstrapNodes: {
"enrtree://AMOJVZX4V6EXP7NTJPMAYJYST2QP6AJXYW76IU6VGJS7UVSNDYZG4@boot.prod.status.nodes.status.im",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ github.com/waku-org/go-discover/discover/v5wire
github.com/waku-org/go-libp2p-rendezvous
github.com/waku-org/go-libp2p-rendezvous/db
github.com/waku-org/go-libp2p-rendezvous/pb
# github.com/waku-org/go-waku v0.8.1-0.20241018104939-8842d00df1b9
# github.com/waku-org/go-waku v0.8.1-0.20241024093455-4e3d73c830fc
## explicit; go 1.21
github.com/waku-org/go-waku/logging
github.com/waku-org/go-waku/tests
Expand Down
29 changes: 27 additions & 2 deletions wakuv2/waku.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,6 @@ func (w *Waku) discoverAndConnectPeers() {
w.logger.Warn("invalid peer multiaddress", zap.String("ma", addrString), zap.Error(err))
continue
}

peerInfo, err := peer.AddrInfoFromP2pAddr(addr)
if err != nil {
w.logger.Warn("invalid peer multiaddress", zap.Stringer("addr", addr), zap.Error(err))
Expand Down Expand Up @@ -1202,7 +1201,8 @@ func (w *Waku) Start() error {
w.cfg.MinPeersForFilter,
w,
w.node.FilterLightnode(),
filterapi.WithBatchInterval(300*time.Millisecond))
filterapi.WithBatchInterval(300*time.Millisecond),
filterapi.WithPreferredServiceNodes(w.GetPreferredServiceNodes()))
}

err = w.setupRelaySubscriptions()
Expand Down Expand Up @@ -1702,6 +1702,31 @@ func (w *Waku) StopDiscV5() error {
return nil
}

func (w *Waku) GetPreferredServiceNodes() peer.IDSlice {
var bootnodes peer.IDSlice
for _, addrString := range w.cfg.WakuNodes {
addrString := addrString
if strings.HasPrefix(addrString, "enrtree://") {
continue
} else {
// It is a normal multiaddress
addr, err := multiaddr.NewMultiaddr(addrString)
if err != nil {
w.logger.Warn("invalid peer multiaddress", zap.String("ma", addrString), zap.Error(err))
continue
}
_, id := peer.SplitAddr(addr)
if id == "" {
w.logger.Warn("peer multiaddress doesn't contain peerID", zap.Stringer("addr", addr))
continue
}
bootnodes = append(bootnodes, id)
w.logger.Debug("adding peer to bootnodes for filter", zap.Stringer("id", id))
}
}
return bootnodes
}

func (w *Waku) handleNetworkChangeFromApp(state connection.State) {
//If connection state is reported by something other than peerCount becoming 0 e.g from mobile app, disconnect all peers
if (state.Offline && len(w.node.Host().Network().Peers()) > 0) ||
Expand Down

0 comments on commit b7fa5a5

Please sign in to comment.