Skip to content

Commit

Permalink
chore(nwaku)_: ping storenodes using AddrInfo (#6004)
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-ramos committed Oct 29, 2024
1 parent 948c6d3 commit e829dea
Show file tree
Hide file tree
Showing 20 changed files with 85 additions and 120 deletions.
5 changes: 0 additions & 5 deletions eth-node/bridge/geth/waku.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ func (w *GethWakuWrapper) StopDiscV5() error {
return errors.New("not available in WakuV1")
}

// PeerCount function only added for compatibility with waku V2
func (w *GethWakuWrapper) AddStorePeer(address multiaddr.Multiaddr) (peer.ID, error) {
return "", errors.New("not available in WakuV1")
}

// SubscribeToPubsubTopic function only added for compatibility with waku V2
func (w *GethWakuWrapper) SubscribeToPubsubTopic(topic string, optPublicKey *ecdsa.PublicKey) error {
// not available in WakuV1
Expand Down
4 changes: 0 additions & 4 deletions eth-node/bridge/geth/wakuv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ func (w *gethWakuV2Wrapper) RemovePubsubTopicKey(topic string) error {
return w.waku.RemovePubsubTopicKey(topic)
}

func (w *gethWakuV2Wrapper) AddStorePeer(address multiaddr.Multiaddr) (peer.ID, error) {
return w.waku.AddStorePeer(address)
}

func (w *gethWakuV2Wrapper) AddRelayPeer(address multiaddr.Multiaddr) (peer.ID, error) {
return w.waku.AddRelayPeer(address)
}
Expand Down
2 changes: 0 additions & 2 deletions eth-node/types/waku.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ type Waku interface {

RemovePubsubTopicKey(topic string) error

AddStorePeer(address multiaddr.Multiaddr) (peer.ID, error)

AddRelayPeer(address multiaddr.Multiaddr) (peer.ID, error)

DialPeer(address multiaddr.Multiaddr) error
Expand Down
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.20241024184757-fdb3c3d0b35a
github.com/waku-org/go-waku v0.8.1-0.20241028194639-dd82c24e0057
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 @@ -2140,8 +2140,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.20241024184757-fdb3c3d0b35a h1:epN2bp1mPzdg3S7S2iR72GsUPix7irc3UgM4W9NZJpU=
github.com/waku-org/go-waku v0.8.1-0.20241024184757-fdb3c3d0b35a/go.mod h1:1BRnyg2mQ2aBNLTBaPq6vEvobzywGykPOhGQFbHGf74=
github.com/waku-org/go-waku v0.8.1-0.20241028194639-dd82c24e0057 h1:C/UCg3Z4avOxvZEvY0JzYmeAoqZUBnSE6PK/SaxfEAM=
github.com/waku-org/go-waku v0.8.1-0.20241028194639-dd82c24e0057/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
9 changes: 1 addition & 8 deletions protocol/messenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,18 +833,11 @@ func (m *Messenger) Start() (*MessengerResponse, error) {
}
response := &MessengerResponse{}

storenodes, err := m.AllMailservers()
response.Mailservers, err = m.AllMailservers()

Check warning on line 836 in protocol/messenger.go

View check run for this annotation

Codecov / codecov/patch

protocol/messenger.go#L836

Added line #L836 was not covered by tests
if err != nil {
return nil, err
}

err = m.setupStorenodes(storenodes)
if err != nil {
return nil, err
}

response.Mailservers = storenodes

m.transport.SetStorenodeConfigProvider(m)

Check warning on line 841 in protocol/messenger.go

View check run for this annotation

Codecov / codecov/patch

protocol/messenger.go#L841

Added line #L841 was not covered by tests

if err := m.communityStorenodes.ReloadFromDB(); err != nil {
Expand Down
49 changes: 13 additions & 36 deletions protocol/messenger_mailserver_cycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"github.com/libp2p/go-libp2p/core/peer"
"go.uber.org/zap"

"github.com/waku-org/go-waku/waku/v2/utils"

gocommon "github.com/status-im/status-go/common"
"github.com/status-im/status-go/params"
"github.com/status-im/status-go/services/mailservers"
Expand Down Expand Up @@ -39,28 +37,6 @@ func (m *Messenger) AllMailservers() ([]mailservers.Mailserver, error) {
return allMailservers, nil
}

func (m *Messenger) setupStorenodes(storenodes []mailservers.Mailserver) error {
if m.transport.WakuVersion() != 2 {
return nil
}

for _, storenode := range storenodes {

peerInfo, err := storenode.PeerInfo()
if err != nil {
return err
}

for _, addr := range utils.EncapsulatePeerID(peerInfo.ID, peerInfo.Addrs...) {
_, err := m.transport.AddStorePeer(addr)
if err != nil {
return err
}
}
}
return nil
}

func (m *Messenger) getFleet() (string, error) {
var fleet string
dbFleet, err := m.settings.GetFleet()

Check warning on line 42 in protocol/messenger_mailserver_cycle.go

View check run for this annotation

Codecov / codecov/patch

protocol/messenger_mailserver_cycle.go#L40-L42

Added lines #L40 - L42 were not covered by tests
Expand Down Expand Up @@ -93,63 +69,64 @@ func (m *Messenger) asyncRequestAllHistoricMessages() {
}()
}

func (m *Messenger) GetPinnedStorenode() (peer.ID, error) {
func (m *Messenger) GetPinnedStorenode() (peer.AddrInfo, error) {

Check warning on line 72 in protocol/messenger_mailserver_cycle.go

View check run for this annotation

Codecov / codecov/patch

protocol/messenger_mailserver_cycle.go#L72

Added line #L72 was not covered by tests
fleet, err := m.getFleet()
if err != nil {
return "", err
return peer.AddrInfo{}, err

Check warning on line 75 in protocol/messenger_mailserver_cycle.go

View check run for this annotation

Codecov / codecov/patch

protocol/messenger_mailserver_cycle.go#L75

Added line #L75 was not covered by tests
}

pinnedMailservers, err := m.settings.GetPinnedMailservers()
if err != nil {
return "", err
return peer.AddrInfo{}, err

Check warning on line 80 in protocol/messenger_mailserver_cycle.go

View check run for this annotation

Codecov / codecov/patch

protocol/messenger_mailserver_cycle.go#L80

Added line #L80 was not covered by tests
}

pinnedMailserver, ok := pinnedMailservers[fleet]
if !ok {
return "", nil
return peer.AddrInfo{}, nil

Check warning on line 85 in protocol/messenger_mailserver_cycle.go

View check run for this annotation

Codecov / codecov/patch

protocol/messenger_mailserver_cycle.go#L85

Added line #L85 was not covered by tests
}

fleetMailservers := mailservers.DefaultMailservers()

for _, c := range fleetMailservers {
if c.Fleet == fleet && c.ID == pinnedMailserver {
return c.PeerID()
return c.PeerInfo()

Check warning on line 92 in protocol/messenger_mailserver_cycle.go

View check run for this annotation

Codecov / codecov/patch

protocol/messenger_mailserver_cycle.go#L92

Added line #L92 was not covered by tests
}
}

if m.mailserversDatabase != nil {
customMailservers, err := m.mailserversDatabase.Mailservers()
if err != nil {
return "", err
return peer.AddrInfo{}, err

Check warning on line 99 in protocol/messenger_mailserver_cycle.go

View check run for this annotation

Codecov / codecov/patch

protocol/messenger_mailserver_cycle.go#L99

Added line #L99 was not covered by tests
}

for _, c := range customMailservers {
if c.Fleet == fleet && c.ID == pinnedMailserver {
return c.PeerID()
return c.PeerInfo()

Check warning on line 104 in protocol/messenger_mailserver_cycle.go

View check run for this annotation

Codecov / codecov/patch

protocol/messenger_mailserver_cycle.go#L104

Added line #L104 was not covered by tests
}
}
}

return "", nil
return peer.AddrInfo{}, nil

Check warning on line 109 in protocol/messenger_mailserver_cycle.go

View check run for this annotation

Codecov / codecov/patch

protocol/messenger_mailserver_cycle.go#L109

Added line #L109 was not covered by tests
}

func (m *Messenger) UseStorenodes() (bool, error) {
return m.settings.CanUseMailservers()

Check warning on line 113 in protocol/messenger_mailserver_cycle.go

View check run for this annotation

Codecov / codecov/patch

protocol/messenger_mailserver_cycle.go#L112-L113

Added lines #L112 - L113 were not covered by tests
}

func (m *Messenger) Storenodes() ([]peer.ID, error) {
func (m *Messenger) Storenodes() ([]peer.AddrInfo, error) {
mailservers, err := m.AllMailservers()
if err != nil {
return nil, err

Check warning on line 119 in protocol/messenger_mailserver_cycle.go

View check run for this annotation

Codecov / codecov/patch

protocol/messenger_mailserver_cycle.go#L116-L119

Added lines #L116 - L119 were not covered by tests
}

var result []peer.ID
var result []peer.AddrInfo
for _, m := range mailservers {

Check warning on line 123 in protocol/messenger_mailserver_cycle.go

View check run for this annotation

Codecov / codecov/patch

protocol/messenger_mailserver_cycle.go#L122-L123

Added lines #L122 - L123 were not covered by tests
peerID, err := m.PeerID()

peerInfo, err := m.PeerInfo()
if err != nil {
return nil, err

Check warning on line 127 in protocol/messenger_mailserver_cycle.go

View check run for this annotation

Codecov / codecov/patch

protocol/messenger_mailserver_cycle.go#L125-L127

Added lines #L125 - L127 were not covered by tests
}
result = append(result, peerID)
result = append(result, peerInfo)

Check warning on line 129 in protocol/messenger_mailserver_cycle.go

View check run for this annotation

Codecov / codecov/patch

protocol/messenger_mailserver_cycle.go#L129

Added line #L129 was not covered by tests
}

return result, nil

Check warning on line 132 in protocol/messenger_mailserver_cycle.go

View check run for this annotation

Codecov / codecov/patch

protocol/messenger_mailserver_cycle.go#L132

Added line #L132 was not covered by tests
Expand Down
4 changes: 0 additions & 4 deletions protocol/messenger_peers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import (
"github.com/status-im/status-go/eth-node/types"
)

func (m *Messenger) AddStorePeer(address multiaddr.Multiaddr) (peer.ID, error) {
return m.transport.AddStorePeer(address)
}

func (m *Messenger) AddRelayPeer(address multiaddr.Multiaddr) (peer.ID, error) {
return m.transport.AddRelayPeer(address)
}
Expand Down
4 changes: 0 additions & 4 deletions protocol/transport/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,6 @@ func (t *Transport) ENR() (*enode.Node, error) {
return t.waku.ENR()
}

func (t *Transport) AddStorePeer(address multiaddr.Multiaddr) (peer.ID, error) {
return t.waku.AddStorePeer(address)
}

func (t *Transport) AddRelayPeer(address multiaddr.Multiaddr) (peer.ID, error) {
return t.waku.AddRelayPeer(address)
}
Expand Down
8 changes: 0 additions & 8 deletions services/ext/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1478,14 +1478,6 @@ func (api *PublicAPI) StorePubsubTopicKey(topic string, privKey string) error {
return api.service.messenger.StorePubsubTopicKey(topic, p)
}

func (api *PublicAPI) AddStorePeer(address string) (peer.ID, error) {
maddr, err := multiaddr.NewMultiaddr(address)
if err != nil {
return "", err
}
return api.service.messenger.AddStorePeer(maddr)
}

func (api *PublicAPI) AddRelayPeer(address string) (peer.ID, error) {
maddr, err := multiaddr.NewMultiaddr(address)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions services/mailservers/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ type Mailserver struct {
FailedRequests uint `json:"-"`
}

func (m Mailserver) PeerInfo() (*peer.AddrInfo, error) {
func (m Mailserver) PeerInfo() (peer.AddrInfo, error) {

Check warning on line 52 in services/mailservers/database.go

View check run for this annotation

Codecov / codecov/patch

services/mailservers/database.go#L52

Added line #L52 was not covered by tests
var maddrs []multiaddr.Multiaddr

if m.ENR != nil {
addrInfo, err := enr.EnodeToPeerInfo(m.ENR)
if err != nil {
return nil, err
return peer.AddrInfo{}, err

Check warning on line 58 in services/mailservers/database.go

View check run for this annotation

Codecov / codecov/patch

services/mailservers/database.go#L58

Added line #L58 was not covered by tests
}
addrInfo.Addrs = utils.EncapsulatePeerID(addrInfo.ID, addrInfo.Addrs...)
maddrs = append(maddrs, addrInfo.Addrs...)
Expand All @@ -67,14 +67,14 @@ func (m Mailserver) PeerInfo() (*peer.AddrInfo, error) {

p, err := peer.AddrInfosFromP2pAddrs(maddrs...)
if err != nil {
return nil, err
return peer.AddrInfo{}, err

Check warning on line 70 in services/mailservers/database.go

View check run for this annotation

Codecov / codecov/patch

services/mailservers/database.go#L70

Added line #L70 was not covered by tests
}

if len(p) != 1 {
return nil, errors.New("invalid mailserver setup")
return peer.AddrInfo{}, errors.New("invalid mailserver setup")

Check warning on line 74 in services/mailservers/database.go

View check run for this annotation

Codecov / codecov/patch

services/mailservers/database.go#L74

Added line #L74 was not covered by tests
}

return &p[0], nil
return p[0], nil

Check warning on line 77 in services/mailservers/database.go

View check run for this annotation

Codecov / codecov/patch

services/mailservers/database.go#L77

Added line #L77 was not covered by tests
}

func (m Mailserver) PeerID() (peer.ID, error) {
Expand Down
2 changes: 1 addition & 1 deletion third_party/nwaku
Submodule nwaku updated 44 files
+0 −3 .github/workflows/ci.yml
+42 −6 Makefile
+6 −6 apps/liteprotocoltester/.env
+38 −39 apps/liteprotocoltester/Dockerfile.liteprotocoltester.compile
+127 −37 apps/liteprotocoltester/README.md
+50 −69 apps/liteprotocoltester/diagnose_connections.nim
+3 −0 apps/liteprotocoltester/docker-compose.yml
+80 −35 apps/liteprotocoltester/filter_subscriber.nim
+102 −39 apps/liteprotocoltester/lightpush_publisher.nim
+60 −15 apps/liteprotocoltester/liteprotocoltester.nim
+16 −0 apps/liteprotocoltester/lpt_metrics.nim
+930 −72 apps/liteprotocoltester/monitoring/configuration/dashboards/liter-protocol-test-monitoring.json
+21 −4 apps/liteprotocoltester/monitoring/prometheus-config.yml
+17 −1 apps/liteprotocoltester/run_tester_node.sh
+217 −0 apps/liteprotocoltester/service_peer_management.nim
+2 −2 apps/liteprotocoltester/statistics.nim
+30 −7 apps/liteprotocoltester/tester_config.nim
+7 −5 apps/sonda/.env.example
+21 −1 apps/sonda/Dockerfile.sonda
+18 −11 apps/sonda/docker-compose.yml
+10 −9 apps/sonda/sonda.py
+2 −2 apps/wakunode2/wakunode2.nim
+93 −0 ci/Jenkinsfile.lpt
+1 −1 examples/wakustealthcommitments/node_spec.nim
+1 −1 library/waku_thread/inter_thread_communication/requests/node_lifecycle_request.nim
+5 −2 library/waku_thread/inter_thread_communication/requests/ping_request.nim
+5 −5 tests/factory/test_node_factory.nim
+5 −15 tests/test_peer_manager.nim
+2 −2 tests/test_waku_switch.nim
+3 −3 tests/test_wakunode.nim
+4 −4 tests/wakunode2/test_app.nim
+4 −7 tests/wakunode_rest/test_rest_admin.nim
+6 −1 waku/common/utils/nat.nim
+36 −0 waku/discovery/autonat_service.nim
+18 −2 waku/discovery/waku_discv5.nim
+14 −2 waku/factory/builder.nim
+11 −1 waku/factory/external_config.nim
+8 −11 waku/factory/node_factory.nim
+100 −13 waku/factory/waku.nim
+37 −46 waku/node/waku_node.nim
+3 −5 waku/node/waku_switch.nim
+68 −11 waku/waku_core/peers.nim
+0 −1 waku/waku_core/time.nim
+7 −0 waku/waku_relay/protocol.nim

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.

29 changes: 17 additions & 12 deletions vendor/github.com/waku-org/go-waku/waku/v2/api/history/cycle.go

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.

Loading

0 comments on commit e829dea

Please sign in to comment.