From c5fefb8fa028bb60e1d14e9e280dad19bb985454 Mon Sep 17 00:00:00 2001 From: Steven Normore Date: Sat, 2 Sep 2023 20:03:35 -0400 Subject: [PATCH] Remove unused waku filter and lightpush code --- dev/e2e/docker/docker-compose.yml | 8 ------- dev/start | 2 -- pkg/server/options.go | 19 ---------------- pkg/server/server.go | 38 ------------------------------- pkg/testing/node.go | 1 - pkg/testing/relay.go | 10 -------- 6 files changed, 78 deletions(-) diff --git a/dev/e2e/docker/docker-compose.yml b/dev/e2e/docker/docker-compose.yml index 355abf91..280bbe5a 100644 --- a/dev/e2e/docker/docker-compose.yml +++ b/dev/e2e/docker/docker-compose.yml @@ -32,8 +32,6 @@ services: - --ws - --ws-port=6001 - --port=6000 - - --lightpush - - --filter - --api.authn.enable - --api.authn.allowlists - --log-encoding=json @@ -64,8 +62,6 @@ services: - --ws - --ws-port=6001 - --port=6000 - - --lightpush - - --filter - --api.authn.enable - --api.authn.allowlists - --log-encoding=json @@ -96,8 +92,6 @@ services: - --ws - --ws-port=6001 - --port=6000 - - --lightpush - - --filter - --api.authn.enable - --api.authn.allowlists - --log-encoding=json @@ -128,8 +122,6 @@ services: - --ws - --ws-port=6001 - --port=6000 - - --lightpush - - --filter - --api.authn.enable - --api.authn.allowlists - --log-encoding=json diff --git a/dev/start b/dev/start index 7b718582..345760eb 100755 --- a/dev/start +++ b/dev/start @@ -4,8 +4,6 @@ set -e PORT="${PORT:-9002}" dev/run \ - --filter \ - --lightpush \ --ws \ --ws-port="${PORT}" \ --api.authn.enable \ diff --git a/pkg/server/options.go b/pkg/server/options.go index e024371a..e9814617 100644 --- a/pkg/server/options.go +++ b/pkg/server/options.go @@ -13,23 +13,6 @@ type RelayOptions struct { MinRelayPeersToPublish int `long:"min-relay-peers-to-publish" description:"Minimum number of peers to publish to Relay" default:"0"` } -type FilterOptions struct { - Enable bool `long:"filter" description:"Enable filter protocol"` - Nodes []string `long:"filter-node" description:"Multiaddr of a peer that supports filter protocol. Option may be repeated"` - Timeout int `long:"filter-timeout" description:"Timeout for filter node in seconds" default:"14400"` -} - -// LightpushOptions are settings used to enable the lightpush protocol. This is -// a lightweight protocol used to avoid having to run the relay protocol which -// is more resource intensive. With this protocol a message is pushed to a peer -// that supports both the lightpush protocol and relay protocol. That peer will -// broadcast the message and return a confirmation that the message was -// broadcasted -type LightpushOptions struct { - Enable bool `long:"lightpush" description:"Enable lightpush protocol"` - Nodes []string `long:"lightpush-node" description:"Multiaddr of a peer that supports lightpush protocol. Option may be repeated"` -} - // MetricsOptions are settings used to start a prometheus server for obtaining // useful node metrics to monitor the health of behavior of the go-waku node. type MetricsOptions struct { @@ -87,8 +70,6 @@ type Options struct { Authz AuthzOptions `group:"Authz Options"` Relay RelayOptions `group:"Relay Options"` Store store.Options `group:"Store Options" namespace:"store"` - Filter FilterOptions `group:"Filter Options"` - LightPush LightpushOptions `group:"LightPush Options"` Metrics MetricsOptions `group:"Metrics Options"` Tracing TracingOptions `group:"DD APM Tracing Options"` Profiling ProfilingOptions `group:"DD APM Profiling Options" namespace:"profiling"` diff --git a/pkg/server/server.go b/pkg/server/server.go index 1b698476..46544356 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -22,8 +22,6 @@ import ( "github.com/multiformats/go-multiaddr" "github.com/pkg/errors" "github.com/status-im/go-waku/waku/v2/node" - "github.com/status-im/go-waku/waku/v2/protocol/filter" - "github.com/status-im/go-waku/waku/v2/protocol/lightpush" "github.com/status-im/go-waku/waku/v2/protocol/relay" "github.com/status-im/go-waku/waku/v2/utils" "github.com/uptrace/bun" @@ -132,10 +130,6 @@ func New(ctx context.Context, log *zap.Logger, options Options) (*Server, error) nodeOpts = append(nodeOpts, node.WithWakuRelayAndMinPeers(options.Relay.MinRelayPeersToPublish, wakurelayopts...)) } - if options.Filter.Enable { - nodeOpts = append(nodeOpts, node.WithWakuFilter(true, filter.WithTimeout(time.Duration(options.Filter.Timeout)*time.Second))) - } - if options.Authz.DbConnectionString != "" { db, err := createBunDB(options.Authz.DbConnectionString, options.WaitForDB, options.Authz.ReadTimeout, options.Authz.WriteTimeout, options.Store.MaxOpenConns) if err != nil { @@ -177,10 +171,6 @@ func New(ctx context.Context, log *zap.Logger, options Options) (*Server, error) } } - if options.LightPush.Enable { - nodeOpts = append(nodeOpts, node.WithLightPush()) - } - s.wakuNode, err = node.New(s.ctx, nodeOpts...) if err != nil { return nil, errors.Wrap(err, "initializing waku node") @@ -190,15 +180,6 @@ func New(ctx context.Context, log *zap.Logger, options Options) (*Server, error) tracing.GoPanicWrap(s.ctx, &s.wg, "status metrics", func(_ context.Context) { s.statusMetricsLoop(options) }) } - err = addPeers(s.wakuNode, options.LightPush.Nodes, string(lightpush.LightPushID_v20beta1)) - if err != nil { - return nil, errors.Wrap(err, "adding peer") - } - err = addPeers(s.wakuNode, options.Filter.Nodes, string(filter.FilterID_v20beta1)) - if err != nil { - return nil, errors.Wrap(err, "adding peer") - } - if err = s.wakuNode.Start(); err != nil { s.log.Fatal(fmt.Errorf("could not start waku node, %w", err).Error()) } @@ -371,25 +352,6 @@ func (s *Server) statusMetricsLoop(options Options) { } } -func addPeers(wakuNode *node.WakuNode, addresses []string, protocols ...string) error { - for _, addrString := range addresses { - if addrString == "" { - continue - } - - addr, err := multiaddr.NewMultiaddr(addrString) - if err != nil { - return errors.Wrap(err, "invalid multiaddress") - } - - _, err = wakuNode.AddPeer(addr, protocols...) - if err != nil { - return err - } - } - return nil -} - func loadPrivateKeyFromFile(path string) (*ecdsa.PrivateKey, error) { src, err := ioutil.ReadFile(path) if err != nil { diff --git a/pkg/testing/node.go b/pkg/testing/node.go index 1c0a9d77..69151412 100644 --- a/pkg/testing/node.go +++ b/pkg/testing/node.go @@ -71,7 +71,6 @@ func NewNode(t *testing.T, opts ...wakunode.WakuNodeOption) (*wakunode.WakuNode, wakunode.WithPrivateKey(prvKey), wakunode.WithHostAddress(hostAddr), wakunode.WithWakuRelay(), - wakunode.WithWakuFilter(true), wakunode.WithWebsockets("0.0.0.0", 0), }, opts...) node, err := wakunode.New(ctx, opts...) diff --git a/pkg/testing/relay.go b/pkg/testing/relay.go index 045256b0..1e2885fb 100644 --- a/pkg/testing/relay.go +++ b/pkg/testing/relay.go @@ -8,20 +8,10 @@ import ( wakunode "github.com/status-im/go-waku/waku/v2/node" "github.com/status-im/go-waku/waku/v2/protocol" - "github.com/status-im/go-waku/waku/v2/protocol/filter" "github.com/status-im/go-waku/waku/v2/protocol/pb" "github.com/stretchr/testify/require" ) -func SubscribeTo(t *testing.T, n *wakunode.WakuNode, contentTopics []string) chan *protocol.Envelope { - ctx := context.Background() - _, f, err := n.Filter().Subscribe(ctx, filter.ContentFilter{ - ContentTopics: contentTopics, - }) - require.NoError(t, err) - return f.Chan -} - func Subscribe(t *testing.T, n *wakunode.WakuNode) chan *protocol.Envelope { ctx := context.Background() sub, err := n.Relay().Subscribe(ctx)