Skip to content

Commit

Permalink
Remove unused waku filter and lightpush code
Browse files Browse the repository at this point in the history
  • Loading branch information
snormore committed Sep 3, 2023
1 parent f8a8b6f commit c5fefb8
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 78 deletions.
8 changes: 0 additions & 8 deletions dev/e2e/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ services:
- --ws
- --ws-port=6001
- --port=6000
- --lightpush
- --filter
- --api.authn.enable
- --api.authn.allowlists
- --log-encoding=json
Expand Down Expand Up @@ -64,8 +62,6 @@ services:
- --ws
- --ws-port=6001
- --port=6000
- --lightpush
- --filter
- --api.authn.enable
- --api.authn.allowlists
- --log-encoding=json
Expand Down Expand Up @@ -96,8 +92,6 @@ services:
- --ws
- --ws-port=6001
- --port=6000
- --lightpush
- --filter
- --api.authn.enable
- --api.authn.allowlists
- --log-encoding=json
Expand Down Expand Up @@ -128,8 +122,6 @@ services:
- --ws
- --ws-port=6001
- --port=6000
- --lightpush
- --filter
- --api.authn.enable
- --api.authn.allowlists
- --log-encoding=json
Expand Down
2 changes: 0 additions & 2 deletions dev/start
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ set -e
PORT="${PORT:-9002}"

dev/run \
--filter \
--lightpush \
--ws \
--ws-port="${PORT}" \
--api.authn.enable \
Expand Down
19 changes: 0 additions & 19 deletions pkg/server/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"`
Expand Down
38 changes: 0 additions & 38 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
Expand All @@ -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())
}
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion pkg/testing/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down
10 changes: 0 additions & 10 deletions pkg/testing/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c5fefb8

Please sign in to comment.