chore: remove v1 code and legacy filter from chat2

Also removes the private API from RPC. C-Bindings are not affected, but future revisions might remove the asymmetric/symmetric functions for lightpush and relay and replace them instead by separate encoding functions
This commit is contained in:
Richard Ramos 2023-08-04 09:07:43 -04:00 committed by richΛrd
parent 045fcf02d9
commit df78d21dfd
20 changed files with 73 additions and 608 deletions

View File

@ -496,13 +496,6 @@ var (
Destination: &options.RPCServer.Admin,
EnvVars: []string{"WAKUNODE2_RPC_ADMIN"},
})
RPCPrivate = altsrc.NewBoolFlag(&cli.BoolFlag{
Name: "rpc-private",
Value: false,
Usage: "Enable access to JSON-RPC Private API",
Destination: &options.RPCServer.Private,
EnvVars: []string{"WAKUNODE2_RPC_PRIVATE"},
})
RESTFlag = altsrc.NewBoolFlag(&cli.BoolFlag{
Name: "rest",
Usage: "Enable Waku REST HTTP server",
@ -537,13 +530,6 @@ var (
Destination: &options.RESTServer.Admin,
EnvVars: []string{"WAKUNODE2_REST_ADMIN"},
})
RESTPrivate = altsrc.NewBoolFlag(&cli.BoolFlag{
Name: "rest-private",
Value: false,
Usage: "Enable access to REST HTTP Private API",
Destination: &options.RESTServer.Private,
EnvVars: []string{"WAKUNODE2_REST_PRIVATE"},
})
PProf = altsrc.NewBoolFlag(&cli.BoolFlag{
Name: "pprof",
Usage: "provides runtime profiling data at /debug/pprof in both REST and RPC servers if they're enabled",

View File

@ -86,13 +86,11 @@ func main() {
RPCAddress,
RPCRelayCacheCapacity,
RPCAdmin,
RPCPrivate,
RESTFlag,
RESTAddress,
RESTPort,
RESTRelayCacheCapacity,
RESTAdmin,
RESTPrivate,
PProf,
}

View File

@ -457,14 +457,14 @@ func Execute(options Options) {
var rpcServer *rpc.WakuRpc
if options.RPCServer.Enable {
rpcServer = rpc.NewWakuRpc(wakuNode, options.RPCServer.Address, options.RPCServer.Port, options.RPCServer.Admin, options.RPCServer.Private, options.PProf, options.RPCServer.RelayCacheCapacity, logger)
rpcServer = rpc.NewWakuRpc(wakuNode, options.RPCServer.Address, options.RPCServer.Port, options.RPCServer.Admin, options.PProf, options.RPCServer.RelayCacheCapacity, logger)
rpcServer.Start()
}
var restServer *rest.WakuRest
if options.RESTServer.Enable {
wg.Add(1)
restServer = rest.NewWakuRest(wakuNode, options.RESTServer.Address, options.RESTServer.Port, options.RESTServer.Admin, options.RESTServer.Private, options.PProf, options.RESTServer.RelayCacheCapacity, logger)
restServer = rest.NewWakuRest(wakuNode, options.RESTServer.Address, options.RESTServer.Port, options.RESTServer.Admin, options.PProf, options.RESTServer.RelayCacheCapacity, logger)
restServer.Start(ctx, &wg)
}

View File

@ -106,7 +106,6 @@ type RPCServerOptions struct {
Port int
Address string
Admin bool
Private bool
RelayCacheCapacity int
}
@ -116,7 +115,6 @@ type RESTServerOptions struct {
Port int
Address string
Admin bool
Private bool
RelayCacheCapacity int
}

View File

@ -21,7 +21,7 @@ type WakuRest struct {
relayService *RelayService
}
func NewWakuRest(node *node.WakuNode, address string, port int, enableAdmin bool, enablePrivate bool, enablePProf bool, relayCacheCapacity int, log *zap.Logger) *WakuRest {
func NewWakuRest(node *node.WakuNode, address string, port int, enableAdmin bool, enablePProf bool, relayCacheCapacity int, log *zap.Logger) *WakuRest {
wrpc := new(WakuRest)
wrpc.log = log.Named("rest")

View File

@ -13,7 +13,7 @@ func TestWakuRest(t *testing.T) {
n, err := node.New(options)
require.NoError(t, err)
rpc := NewWakuRest(n, "127.0.0.1", 8080, true, true, false, 10, utils.Logger())
rpc := NewWakuRest(n, "127.0.0.1", 8080, true, false, 10, utils.Logger())
require.NotNil(t, rpc.server)
require.Equal(t, rpc.server.Addr, "127.0.0.1:8080")
}

View File

@ -1,270 +0,0 @@
package rpc
import (
"crypto/ecdsa"
"crypto/rand"
"fmt"
"net/http"
"strings"
"sync"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"github.com/waku-org/go-waku/waku/v2/node"
"github.com/waku-org/go-waku/waku/v2/payload"
"github.com/waku-org/go-waku/waku/v2/protocol"
"github.com/waku-org/go-waku/waku/v2/protocol/pb"
"github.com/waku-org/go-waku/waku/v2/protocol/relay"
"github.com/waku-org/go-waku/waku/v2/utils"
"go.uber.org/zap"
)
type PrivateService struct {
node *node.WakuNode
log *zap.Logger
messages map[string][]*pb.WakuMessage
cacheCapacity int
messagesMutex sync.RWMutex
runner *runnerService
}
type SymmetricKeyReply string
type KeyPairReply struct {
PrivateKey string `json:"privateKey"`
PublicKey string `json:"publicKey"`
}
type SymmetricMessageArgs struct {
Topic string `json:"topic"`
Message *RPCWakuMessage `json:"message"`
SymKey string `json:"symkey"`
}
type AsymmetricMessageArgs struct {
Topic string `json:"topic"`
Message *RPCWakuMessage `json:"message"`
PublicKey string `json:"publicKey"`
}
type SymmetricMessagesArgs struct {
Topic string `json:"topic"`
SymKey string `json:"symkey"`
}
type AsymmetricMessagesArgs struct {
Topic string `json:"topic"`
PrivateKey string `json:"privateKey"`
}
func NewPrivateService(node *node.WakuNode, cacheCapacity int, log *zap.Logger) *PrivateService {
p := &PrivateService{
node: node,
cacheCapacity: cacheCapacity,
messages: make(map[string][]*pb.WakuMessage),
log: log.Named("private"),
}
p.runner = newRunnerService(node.Broadcaster(), p.addEnvelope)
return p
}
func (p *PrivateService) addEnvelope(envelope *protocol.Envelope) {
p.messagesMutex.Lock()
defer p.messagesMutex.Unlock()
if _, ok := p.messages[envelope.PubsubTopic()]; !ok {
p.messages[envelope.PubsubTopic()] = make([]*pb.WakuMessage, 0)
}
// Keep a specific max number of messages per topic
if len(p.messages[envelope.PubsubTopic()]) >= p.cacheCapacity {
p.messages[envelope.PubsubTopic()] = p.messages[envelope.PubsubTopic()][1:]
}
p.messages[envelope.PubsubTopic()] = append(p.messages[envelope.PubsubTopic()], envelope.Message())
}
func (p *PrivateService) GetV1SymmetricKey(req *http.Request, args *Empty, reply *SymmetricKeyReply) error {
key := [32]byte{}
_, err := rand.Read(key[:])
if err != nil {
return err
}
*reply = SymmetricKeyReply(hexutil.Encode(key[:]))
return nil
}
func (p *PrivateService) GetV1AsymmetricKeypair(req *http.Request, args *Empty, reply *KeyPairReply) error {
privateKey, err := crypto.GenerateKey()
if err != nil {
return err
}
privateKeyBytes := crypto.FromECDSA(privateKey)
publicKey := privateKey.Public()
publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey)
if !ok {
return fmt.Errorf("cannot assert type: publicKey is not of type *ecdsa.PublicKey")
}
publicKeyBytes := crypto.FromECDSAPub(publicKeyECDSA)
reply.PrivateKey = hexutil.Encode(privateKeyBytes[:])
reply.PublicKey = hexutil.Encode(publicKeyBytes[:])
return nil
}
func (p *PrivateService) PostV1SymmetricMessage(req *http.Request, args *SymmetricMessageArgs, reply *SuccessReply) error {
symKeyBytes, err := utils.DecodeHexString(args.SymKey)
if err != nil {
return fmt.Errorf("invalid symmetric key: %w", err)
}
keyInfo := new(payload.KeyInfo)
keyInfo.Kind = payload.Symmetric
keyInfo.SymKey = symKeyBytes
msg := args.Message
msg.Version = 1
protoMsg := msg.toProto()
err = payload.EncodeWakuMessage(protoMsg, keyInfo)
if err != nil {
return err
}
topic := args.Topic
if topic == "" {
topic = relay.DefaultWakuTopic
}
_, err = p.node.Relay().PublishToTopic(req.Context(), protoMsg, topic)
if err != nil {
return err
}
*reply = true
return nil
}
func (p *PrivateService) PostV1AsymmetricMessage(req *http.Request, args *AsymmetricMessageArgs, reply *bool) error {
keyInfo := new(payload.KeyInfo)
keyInfo.Kind = payload.Asymmetric
pubKeyBytes, err := utils.DecodeHexString(args.PublicKey)
if err != nil {
return fmt.Errorf("public key cannot be decoded: %v", err)
}
pubKey, err := crypto.UnmarshalPubkey(pubKeyBytes)
if err != nil {
return fmt.Errorf("public key cannot be unmarshalled: %v", err)
}
keyInfo.PubKey = *pubKey
msg := args.Message
msg.Version = 1
protoMsg := msg.toProto()
err = payload.EncodeWakuMessage(protoMsg, keyInfo)
if err != nil {
return err
}
topic := args.Topic
if topic == "" {
topic = relay.DefaultWakuTopic
}
_, err = p.node.Relay().PublishToTopic(req.Context(), protoMsg, topic)
if err != nil {
return err
}
*reply = true
return nil
}
func (p *PrivateService) GetV1SymmetricMessages(req *http.Request, args *SymmetricMessagesArgs, reply *MessagesReply) error {
p.messagesMutex.Lock()
defer p.messagesMutex.Unlock()
if _, ok := p.messages[args.Topic]; !ok {
p.messages[args.Topic] = make([]*pb.WakuMessage, 0)
}
symKeyBytes, err := utils.DecodeHexString(args.SymKey)
if err != nil {
return fmt.Errorf("invalid symmetric key: %w", err)
}
messages := make([]*pb.WakuMessage, len(p.messages[args.Topic]))
copy(messages, p.messages[args.Topic])
p.messages[args.Topic] = make([]*pb.WakuMessage, 0)
var decodedMessages []*pb.WakuMessage
for _, msg := range messages {
err := payload.DecodeWakuMessage(msg, &payload.KeyInfo{
Kind: payload.Symmetric,
SymKey: symKeyBytes,
})
if err != nil {
continue
}
decodedMessages = append(decodedMessages, msg)
}
for i := range decodedMessages {
*reply = append(*reply, ProtoToRPC(decodedMessages[i]))
}
return nil
}
func (p *PrivateService) GetV1AsymmetricMessages(req *http.Request, args *AsymmetricMessagesArgs, reply *MessagesReply) error {
p.messagesMutex.Lock()
defer p.messagesMutex.Unlock()
if _, ok := p.messages[args.Topic]; !ok {
p.messages[args.Topic] = make([]*pb.WakuMessage, 0)
}
messages := make([]*pb.WakuMessage, len(p.messages[args.Topic]))
copy(messages, p.messages[args.Topic])
p.messages[args.Topic] = make([]*pb.WakuMessage, 0)
privKey, err := crypto.HexToECDSA(strings.TrimPrefix(args.PrivateKey, "0x"))
if err != nil {
return fmt.Errorf("invalid asymmetric key: %w", err)
}
var decodedMessages []*pb.WakuMessage
for _, msg := range messages {
err := payload.DecodeWakuMessage(msg, &payload.KeyInfo{
Kind: payload.Asymmetric,
PrivKey: privKey,
})
if err != nil {
continue
}
decodedMessages = append(decodedMessages, msg)
}
for _, msg := range decodedMessages {
*reply = append(*reply, ProtoToRPC(msg))
}
return nil
}
func (p *PrivateService) Start() {
p.runner.Start()
}
func (p *PrivateService) Stop() {
p.runner.Stop()
}

View File

@ -1,175 +0,0 @@
package rpc
import (
"context"
"testing"
"time"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/require"
"github.com/waku-org/go-waku/waku/v2/node"
"github.com/waku-org/go-waku/waku/v2/protocol/pb"
"github.com/waku-org/go-waku/waku/v2/utils"
)
func makePrivateService(t *testing.T) *PrivateService {
n, err := node.New(node.WithWakuRelayAndMinPeers(0))
require.NoError(t, err)
err = n.Start(context.Background())
require.NoError(t, err)
return NewPrivateService(n, 30, utils.Logger())
}
func TestGetV1SymmetricKey(t *testing.T) {
d := makePrivateService(t)
defer d.node.Stop()
var reply SymmetricKeyReply
err := d.GetV1SymmetricKey(
makeRequest(t),
&Empty{},
&reply,
)
require.NoError(t, err)
require.NotEmpty(t, reply)
}
func TestGetV1AsymmetricKey(t *testing.T) {
d := makePrivateService(t)
defer d.node.Stop()
var reply KeyPairReply
err := d.GetV1AsymmetricKeypair(
makeRequest(t),
&Empty{},
&reply,
)
require.NoError(t, err)
require.NotEmpty(t, reply.PublicKey)
require.NotEmpty(t, reply.PrivateKey)
}
func TestPostV1SymmetricMessage(t *testing.T) {
d := makePrivateService(t)
defer d.node.Stop()
var reply SuccessReply
err := d.PostV1SymmetricMessage(
makeRequest(t),
&SymmetricMessageArgs{
Topic: "test",
Message: ProtoToRPC(&pb.WakuMessage{Payload: []byte("test")}),
SymKey: "0x1122334455667788991011223344556677889910112233445566778899101122",
},
&reply,
)
require.NoError(t, err)
require.True(t, reply)
}
func TestPostV1AsymmetricMessage(t *testing.T) {
d := makePrivateService(t)
defer d.node.Stop()
var reply bool
err := d.PostV1AsymmetricMessage(
makeRequest(t),
&AsymmetricMessageArgs{
Topic: "test",
Message: ProtoToRPC(&pb.WakuMessage{Payload: []byte("test")}),
PublicKey: "0x045ded6a56c88173e87a88c55b96956964b1bd3351b5fcb70950a4902fbc1bc0ceabb0ac846c3a4b8f2f6024c0e19f0a7f6a4865035187de5463f34012304fc7c5",
},
&reply,
)
require.NoError(t, err)
require.True(t, reply)
}
func TestGetV1SymmetricMessages(t *testing.T) {
d := makePrivateService(t)
go d.Start()
defer d.node.Stop()
// Subscribing topic to test getter
sub, err := d.node.Relay().SubscribeToTopic(context.TODO(), "test")
require.NoError(t, err)
go func() {
for range sub.Ch {
}
}()
var reply SuccessReply
err = d.PostV1SymmetricMessage(
makeRequest(t),
&SymmetricMessageArgs{
Topic: "test",
Message: ProtoToRPC(&pb.WakuMessage{Payload: []byte("test")}),
SymKey: "0x1122334455667788991011223344556677889910112233445566778899101122",
},
&reply,
)
require.NoError(t, err)
require.True(t, reply)
time.Sleep(500 * time.Millisecond)
var getReply MessagesReply
err = d.GetV1SymmetricMessages(
makeRequest(t),
&SymmetricMessagesArgs{
Topic: "test",
SymKey: "0x1122334455667788991011223344556677889910112233445566778899101122",
},
&getReply,
)
require.NoError(t, err)
require.Len(t, getReply, 1)
d.Stop() // not neccessary as wakuNode.Stop() calls broadcaster.Stop() which calls uses all the receiving channels
}
func TestGetV1AsymmetricMessages(t *testing.T) {
d := makePrivateService(t)
go d.Start()
defer d.node.Stop()
// Subscribing topic to test getter
sub, err := d.node.Relay().SubscribeToTopic(context.TODO(), "test")
require.NoError(t, err)
go func() {
for range sub.Ch {
}
}()
prvKey, err := crypto.GenerateKey()
require.NoError(t, err)
var reply bool
err = d.PostV1AsymmetricMessage(
makeRequest(t),
&AsymmetricMessageArgs{
Topic: "test",
Message: ProtoToRPC(&pb.WakuMessage{Payload: []byte("test")}),
PublicKey: hexutil.Encode(crypto.FromECDSAPub(&prvKey.PublicKey)),
},
&reply,
)
require.NoError(t, err)
require.True(t, reply)
time.Sleep(500 * time.Millisecond)
var getReply MessagesReply
err = d.GetV1AsymmetricMessages(
makeRequest(t),
&AsymmetricMessagesArgs{
Topic: "test",
PrivateKey: hexutil.Encode(crypto.FromECDSA(prvKey)),
},
&getReply,
)
require.NoError(t, err)
require.Len(t, getReply, 1)
}

View File

@ -19,13 +19,12 @@ type WakuRpc struct {
log *zap.Logger
relayService *RelayService
filterService *FilterService
privateService *PrivateService
adminService *AdminService
relayService *RelayService
filterService *FilterService
adminService *AdminService
}
func NewWakuRpc(node *node.WakuNode, address string, port int, enableAdmin bool, enablePrivate bool, enablePProf bool, cacheCapacity int, log *zap.Logger) *WakuRpc {
func NewWakuRpc(node *node.WakuNode, address string, port int, enableAdmin bool, enablePProf bool, cacheCapacity int, log *zap.Logger) *WakuRpc {
wrpc := new(WakuRpc)
wrpc.log = log.Named("rpc")
@ -80,15 +79,6 @@ func NewWakuRpc(node *node.WakuNode, address string, port int, enableAdmin bool,
wrpc.log.Error("registering filter service", zap.Error(err))
}
if enablePrivate {
privateService := NewPrivateService(node, cacheCapacity, log)
err = s.RegisterService(privateService, "Private")
if err != nil {
wrpc.log.Error("registering private service", zap.Error(err))
}
wrpc.privateService = privateService
}
listenAddr := fmt.Sprintf("%s:%d", address, port)
server := &http.Server{
@ -102,9 +92,6 @@ func NewWakuRpc(node *node.WakuNode, address string, port int, enableAdmin bool,
if relayService != nil {
relayService.Stop()
}
if wrpc.privateService != nil {
wrpc.privateService.Stop()
}
})
wrpc.node = node
@ -121,9 +108,6 @@ func (r *WakuRpc) Start() {
}
go r.filterService.Start()
if r.privateService != nil {
go r.privateService.Start()
}
go func() {
_ = r.server.ListenAndServe()

View File

@ -13,7 +13,7 @@ func TestWakuRpc(t *testing.T) {
n, err := node.New(options)
require.NoError(t, err)
rpc := NewWakuRpc(n, "127.0.0.1", 8080, true, true, false, 30, utils.Logger())
rpc := NewWakuRpc(n, "127.0.0.1", 8080, true, false, 30, utils.Logger())
require.NotNil(t, rpc.server)
require.Equal(t, rpc.server.Addr, "127.0.0.1:8080")
}

View File

@ -18,7 +18,6 @@ import (
"github.com/waku-org/go-waku/waku/v2/payload"
"github.com/waku-org/go-waku/waku/v2/protocol"
"github.com/waku-org/go-waku/waku/v2/protocol/filter"
"github.com/waku-org/go-waku/waku/v2/protocol/legacy_filter"
"github.com/waku-org/go-waku/waku/v2/protocol/lightpush"
wpb "github.com/waku-org/go-waku/waku/v2/protocol/pb"
"github.com/waku-org/go-waku/waku/v2/protocol/relay"
@ -59,47 +58,24 @@ func NewChat(ctx context.Context, node *node.WakuNode, connNotifier <-chan node.
chat.ui = NewUIModel(chat.uiReady, chat.inputChan)
if options.Filter.Enable {
if options.Filter.UseV2 {
cf := filter.ContentFilter{
Topic: relay.DefaultWakuTopic,
ContentTopics: []string{options.ContentTopic},
}
var filterOpt filter.FilterSubscribeOption
peerID, err := options.Filter.NodePeerID()
if err != nil {
filterOpt = filter.WithAutomaticPeerSelection()
} else {
filterOpt = filter.WithPeer(peerID)
chat.ui.InfoMessage(fmt.Sprintf("Subscribing to filter node %s", peerID))
}
theFilter, err := node.FilterLightnode().Subscribe(ctx, cf, filterOpt)
if err != nil {
chat.ui.ErrorMessage(err)
} else {
chat.C = theFilter.C
}
} else {
// TODO: remove
cf := legacy_filter.ContentFilter{
Topic: relay.DefaultWakuTopic,
ContentTopics: []string{options.ContentTopic},
}
var filterOpt legacy_filter.FilterSubscribeOption
peerID, err := options.Filter.NodePeerID()
if err != nil {
filterOpt = legacy_filter.WithAutomaticPeerSelection()
} else {
filterOpt = legacy_filter.WithPeer(peerID)
chat.ui.InfoMessage(fmt.Sprintf("Subscribing to filter node %s", peerID))
}
_, theFilter, err := node.LegacyFilter().Subscribe(ctx, cf, filterOpt)
if err != nil {
chat.ui.ErrorMessage(err)
} else {
chat.C = theFilter.Chan
}
cf := filter.ContentFilter{
Topic: relay.DefaultWakuTopic,
ContentTopics: []string{options.ContentTopic},
}
var filterOpt filter.FilterSubscribeOption
peerID, err := options.Filter.NodePeerID()
if err != nil {
filterOpt = filter.WithAutomaticPeerSelection()
} else {
filterOpt = filter.WithPeer(peerID)
chat.ui.InfoMessage(fmt.Sprintf("Subscribing to filter node %s", peerID))
}
theFilter, err := node.FilterLightnode().Subscribe(ctx, cf, filterOpt)
if err != nil {
chat.ui.ErrorMessage(err)
} else {
chat.C = theFilter.C
}
} else {
sub, err := node.Relay().Subscribe(ctx)
if err != nil {
@ -161,7 +137,7 @@ func (c *Chat) receiveMessages() {
continue // Discard messages from other topics
}
msg, err := decodeMessage(c.options.UsePayloadV1, c.options.ContentTopic, value.Message())
msg, err := decodeMessage(c.options.ContentTopic, value.Message())
if err == nil {
// send valid messages to the UI
c.ui.ChatMessage(int64(msg.Timestamp), msg.Nick, string(msg.Payload))
@ -303,17 +279,10 @@ func (c *Chat) publish(ctx context.Context, message string) error {
return err
}
var version uint32
var timestamp int64 = utils.GetUnixEpochFrom(c.node.Timesource().Now())
var keyInfo *payload.KeyInfo = &payload.KeyInfo{}
if c.options.UsePayloadV1 { // Use WakuV1 encryption
keyInfo.Kind = payload.Symmetric
keyInfo.SymKey = generateSymKey(c.options.ContentTopic)
version = 1
} else {
keyInfo.Kind = payload.None
version = 0
version := uint32(0)
timestamp := utils.GetUnixEpochFrom(c.node.Timesource().Now())
keyInfo := &payload.KeyInfo{
Kind: payload.None,
}
p := new(payload.Payload)
@ -361,13 +330,9 @@ func (c *Chat) publish(ctx context.Context, message string) error {
return err
}
func decodeMessage(useV1Payload bool, contentTopic string, wakumsg *wpb.WakuMessage) (*pb.Chat2Message, error) {
var keyInfo *payload.KeyInfo = &payload.KeyInfo{}
if useV1Payload { // Use WakuV1 encryption
keyInfo.Kind = payload.Symmetric
keyInfo.SymKey = generateSymKey(contentTopic)
} else {
keyInfo.Kind = payload.None
func decodeMessage(contentTopic string, wakumsg *wpb.WakuMessage) (*pb.Chat2Message, error) {
keyInfo := &payload.KeyInfo{
Kind: payload.None,
}
payload, err := payload.DecodePayload(wakumsg, keyInfo)

View File

@ -13,7 +13,6 @@ import (
"github.com/waku-org/go-waku/waku/v2/node"
"github.com/waku-org/go-waku/waku/v2/peers"
"github.com/waku-org/go-waku/waku/v2/protocol/filter"
"github.com/waku-org/go-waku/waku/v2/protocol/legacy_filter"
"github.com/waku-org/go-waku/waku/v2/protocol/lightpush"
"github.com/waku-org/go-waku/waku/v2/protocol/pb"
"github.com/waku-org/go-waku/waku/v2/protocol/store"
@ -94,11 +93,7 @@ func execute(options Options) {
}
if options.Filter.Enable {
if options.Filter.UseV2 {
opts = append(opts, node.WithWakuFilterLightNode())
} else {
opts = append(opts, node.WithLegacyWakuFilter(false))
}
opts = append(opts, node.WithWakuFilterLightNode())
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
@ -121,11 +116,8 @@ func execute(options Options) {
return
}
if options.Filter.UseV2 {
err = addPeer(wakuNode, options.Filter.Node, filter.FilterSubscribeID_v20beta1)
} else {
err = addPeer(wakuNode, options.Filter.Node, legacy_filter.FilterID_v20beta1)
}
err = addPeer(wakuNode, options.Filter.Node, filter.FilterSubscribeID_v20beta1)
if err != nil {
fmt.Println(err.Error())
return

View File

@ -104,12 +104,6 @@ func getFlags() []cli.Flag {
Usage: "Enable relay protocol",
Destination: &options.Relay.Enable,
},
&cli.BoolFlag{
Name: "payloadV1",
Value: false,
Usage: "use Waku v1 payload encoding/encryption",
Destination: &options.UsePayloadV1,
},
&cli.StringSliceFlag{
Name: "topics",
Usage: "List of topics to listen",
@ -133,11 +127,6 @@ func getFlags() []cli.Flag {
Usage: "Enable filter protocol",
Destination: &options.Filter.Enable,
},
&cli.BoolFlag{
Name: "use-filterv2",
Usage: "Use filterV2 protocol (experimental)",
Destination: &options.Filter.UseV2,
},
&cli.GenericFlag{
Name: "filternode",
Usage: "Multiaddr of a peer that supports filter protocol.",

View File

@ -17,7 +17,7 @@ require (
github.com/multiformats/go-multiaddr v0.9.0
github.com/urfave/cli/v2 v2.24.4
github.com/waku-org/go-waku v0.2.3-0.20221109195301-b2a5a68d28ba
github.com/waku-org/go-zerokit-rln v0.1.12
github.com/waku-org/go-zerokit-rln v0.1.13-0.20230726180145-0496a42e60fb
golang.org/x/crypto v0.9.0
golang.org/x/term v0.8.0
google.golang.org/protobuf v1.31.0
@ -126,9 +126,9 @@ require (
github.com/tklauser/numcpus v0.2.2 // indirect
github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98 // indirect
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 // indirect
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230331231302-258cacb91327 // indirect
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230331223149-f90e66aebb0d // indirect
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230331181847-cba74520bae9 // indirect
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230726162122-13b66414cd5b // indirect
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230726162204-c48a56712ef0 // indirect
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230726162310-d761ca9911d8 // indirect
github.com/wk8/go-ordered-map v1.0.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
go.opencensus.io v0.24.0 // indirect

View File

@ -693,14 +693,14 @@ github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98 h1:xwY0kW5XZF
github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98/go.mod h1:eBHgM6T4EG0RZzxpxKy+rGz/6Dw2Nd8DWxS0lm9ESDw=
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 h1:0e1h+p84yBp0IN7AqgbZlV7lgFBjm214lgSOE7CeJmE=
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7/go.mod h1:pFvOZ9YTFsW0o5zJW7a0B5tr1owAijRWJctXJ2toL04=
github.com/waku-org/go-zerokit-rln v0.1.12 h1:66+tU6sTlmUpuUlEv7kCFOGZ37MwZYFJBXHcm8QquwU=
github.com/waku-org/go-zerokit-rln v0.1.12/go.mod h1:MUW+wB6Yj7UBMdZrhko7oHfUZeY2wchggXYjpUiMoac=
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230331231302-258cacb91327 h1:Q5XQqo+PEmvrybT8D7BEsKCwIYDi80s+00Q49cfm9Gs=
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230331231302-258cacb91327/go.mod h1:KYykqtdApHVYZ3G0spwMnoxc5jH5eI3jyO9SwsSfi48=
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230331223149-f90e66aebb0d h1:Kcg85Y2xGU6hqZ/kMfkLQF2jAog8vt+tw1/VNidzNtE=
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230331223149-f90e66aebb0d/go.mod h1:7cSGUoGVIla1IpnChrLbkVjkYgdOcr7rcifEfh4ReR4=
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230331181847-cba74520bae9 h1:u+YUlWDltHiK5upSb7M6mStc84zdc4vTCNNOz7R5RaY=
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230331181847-cba74520bae9/go.mod h1:+LeEYoW5/uBUTVjtBGLEVCUe9mOYAlu5ZPkIxLOSr5Y=
github.com/waku-org/go-zerokit-rln v0.1.13-0.20230726180145-0496a42e60fb h1:pxPRTh2DWCPCC5dhFisHuBCm1k54fMtR8VR6hUWD734=
github.com/waku-org/go-zerokit-rln v0.1.13-0.20230726180145-0496a42e60fb/go.mod h1:QYTnrByLh6OXvMzSvPNs5aykT/w4fQb4krGcZfKgSZw=
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230726162122-13b66414cd5b h1:wWs8b91SVrxYy37gdNnFDCbjv1hMUHMTwaJUktyjrJE=
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230726162122-13b66414cd5b/go.mod h1:KYykqtdApHVYZ3G0spwMnoxc5jH5eI3jyO9SwsSfi48=
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230726162204-c48a56712ef0 h1:JU5aMzRFeyG/DOiMwLy3F1AMuuXjzPrUKZpW72kAHxE=
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230726162204-c48a56712ef0/go.mod h1:7cSGUoGVIla1IpnChrLbkVjkYgdOcr7rcifEfh4ReR4=
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230726162310-d761ca9911d8 h1:pQmTryFdSQuUe8dxt/dHgEfRdLwqf1DEGeReuMcJ9Yg=
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230726162310-d761ca9911d8/go.mod h1:+LeEYoW5/uBUTVjtBGLEVCUe9mOYAlu5ZPkIxLOSr5Y=
github.com/willf/bitset v1.1.3/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
github.com/wk8/go-ordered-map v1.0.0 h1:BV7z+2PaK8LTSd/mWgY12HyMAo5CEgkHqbkVq2thqr8=
github.com/wk8/go-ordered-map v1.0.0/go.mod h1:9ZIbRunKbuvfPKyBP1SIKLcXNlv74YCOZ3t3VTS6gRk=

View File

@ -61,7 +61,6 @@ func nodePeerID(node *multiaddr.Multiaddr) (peer.ID, error) {
// restricted devices.
type FilterOptions struct {
Enable bool
UseV2 bool
Node *multiaddr.Multiaddr
}
@ -118,7 +117,6 @@ type Options struct {
Address string
NodeKey *ecdsa.PrivateKey
ContentTopic string
UsePayloadV1 bool
Nickname string
LogLevel string
StaticNodes []multiaddr.Multiaddr

View File

@ -106,10 +106,10 @@ require (
github.com/tklauser/numcpus v0.2.2 // indirect
github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98 // indirect
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 // indirect
github.com/waku-org/go-zerokit-rln v0.1.12 // indirect
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230331231302-258cacb91327 // indirect
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230331223149-f90e66aebb0d // indirect
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230331181847-cba74520bae9 // indirect
github.com/waku-org/go-zerokit-rln v0.1.13-0.20230726180145-0496a42e60fb // indirect
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230726162122-13b66414cd5b // indirect
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230726162204-c48a56712ef0 // indirect
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230726162310-d761ca9911d8 // indirect
github.com/wk8/go-ordered-map v1.0.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/atomic v1.11.0 // indirect

View File

@ -658,14 +658,14 @@ github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98 h1:xwY0kW5XZF
github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98/go.mod h1:eBHgM6T4EG0RZzxpxKy+rGz/6Dw2Nd8DWxS0lm9ESDw=
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 h1:0e1h+p84yBp0IN7AqgbZlV7lgFBjm214lgSOE7CeJmE=
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7/go.mod h1:pFvOZ9YTFsW0o5zJW7a0B5tr1owAijRWJctXJ2toL04=
github.com/waku-org/go-zerokit-rln v0.1.12 h1:66+tU6sTlmUpuUlEv7kCFOGZ37MwZYFJBXHcm8QquwU=
github.com/waku-org/go-zerokit-rln v0.1.12/go.mod h1:MUW+wB6Yj7UBMdZrhko7oHfUZeY2wchggXYjpUiMoac=
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230331231302-258cacb91327 h1:Q5XQqo+PEmvrybT8D7BEsKCwIYDi80s+00Q49cfm9Gs=
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230331231302-258cacb91327/go.mod h1:KYykqtdApHVYZ3G0spwMnoxc5jH5eI3jyO9SwsSfi48=
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230331223149-f90e66aebb0d h1:Kcg85Y2xGU6hqZ/kMfkLQF2jAog8vt+tw1/VNidzNtE=
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230331223149-f90e66aebb0d/go.mod h1:7cSGUoGVIla1IpnChrLbkVjkYgdOcr7rcifEfh4ReR4=
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230331181847-cba74520bae9 h1:u+YUlWDltHiK5upSb7M6mStc84zdc4vTCNNOz7R5RaY=
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230331181847-cba74520bae9/go.mod h1:+LeEYoW5/uBUTVjtBGLEVCUe9mOYAlu5ZPkIxLOSr5Y=
github.com/waku-org/go-zerokit-rln v0.1.13-0.20230726180145-0496a42e60fb h1:pxPRTh2DWCPCC5dhFisHuBCm1k54fMtR8VR6hUWD734=
github.com/waku-org/go-zerokit-rln v0.1.13-0.20230726180145-0496a42e60fb/go.mod h1:QYTnrByLh6OXvMzSvPNs5aykT/w4fQb4krGcZfKgSZw=
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230726162122-13b66414cd5b h1:wWs8b91SVrxYy37gdNnFDCbjv1hMUHMTwaJUktyjrJE=
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230726162122-13b66414cd5b/go.mod h1:KYykqtdApHVYZ3G0spwMnoxc5jH5eI3jyO9SwsSfi48=
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230726162204-c48a56712ef0 h1:JU5aMzRFeyG/DOiMwLy3F1AMuuXjzPrUKZpW72kAHxE=
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230726162204-c48a56712ef0/go.mod h1:7cSGUoGVIla1IpnChrLbkVjkYgdOcr7rcifEfh4ReR4=
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230726162310-d761ca9911d8 h1:pQmTryFdSQuUe8dxt/dHgEfRdLwqf1DEGeReuMcJ9Yg=
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230726162310-d761ca9911d8/go.mod h1:+LeEYoW5/uBUTVjtBGLEVCUe9mOYAlu5ZPkIxLOSr5Y=
github.com/willf/bitset v1.1.3/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
github.com/wk8/go-ordered-map v1.0.0 h1:BV7z+2PaK8LTSd/mWgY12HyMAo5CEgkHqbkVq2thqr8=
github.com/wk8/go-ordered-map v1.0.0/go.mod h1:9ZIbRunKbuvfPKyBP1SIKLcXNlv74YCOZ3t3VTS6gRk=

View File

@ -109,10 +109,10 @@ require (
github.com/tklauser/numcpus v0.2.2 // indirect
github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98 // indirect
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 // indirect
github.com/waku-org/go-zerokit-rln v0.1.12 // indirect
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230331231302-258cacb91327 // indirect
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230331223149-f90e66aebb0d // indirect
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230331181847-cba74520bae9 // indirect
github.com/waku-org/go-zerokit-rln v0.1.13-0.20230726180145-0496a42e60fb // indirect
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230726162122-13b66414cd5b // indirect
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230726162204-c48a56712ef0 // indirect
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230726162310-d761ca9911d8 // indirect
github.com/wk8/go-ordered-map v1.0.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/atomic v1.11.0 // indirect

View File

@ -660,14 +660,14 @@ github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 h1:0
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7/go.mod h1:pFvOZ9YTFsW0o5zJW7a0B5tr1owAijRWJctXJ2toL04=
github.com/waku-org/go-noise v0.0.4 h1:ZfQDcCw8pazm89EBl5SXY7GGAnzDQb9AHFXlw3Ktbvk=
github.com/waku-org/go-noise v0.0.4/go.mod h1:+PWRfs2eSOVwKrPcQlfhwDngSh3faL/1QoxvoqggEKc=
github.com/waku-org/go-zerokit-rln v0.1.12 h1:66+tU6sTlmUpuUlEv7kCFOGZ37MwZYFJBXHcm8QquwU=
github.com/waku-org/go-zerokit-rln v0.1.12/go.mod h1:MUW+wB6Yj7UBMdZrhko7oHfUZeY2wchggXYjpUiMoac=
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230331231302-258cacb91327 h1:Q5XQqo+PEmvrybT8D7BEsKCwIYDi80s+00Q49cfm9Gs=
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230331231302-258cacb91327/go.mod h1:KYykqtdApHVYZ3G0spwMnoxc5jH5eI3jyO9SwsSfi48=
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230331223149-f90e66aebb0d h1:Kcg85Y2xGU6hqZ/kMfkLQF2jAog8vt+tw1/VNidzNtE=
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230331223149-f90e66aebb0d/go.mod h1:7cSGUoGVIla1IpnChrLbkVjkYgdOcr7rcifEfh4ReR4=
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230331181847-cba74520bae9 h1:u+YUlWDltHiK5upSb7M6mStc84zdc4vTCNNOz7R5RaY=
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230331181847-cba74520bae9/go.mod h1:+LeEYoW5/uBUTVjtBGLEVCUe9mOYAlu5ZPkIxLOSr5Y=
github.com/waku-org/go-zerokit-rln v0.1.13-0.20230726180145-0496a42e60fb h1:pxPRTh2DWCPCC5dhFisHuBCm1k54fMtR8VR6hUWD734=
github.com/waku-org/go-zerokit-rln v0.1.13-0.20230726180145-0496a42e60fb/go.mod h1:QYTnrByLh6OXvMzSvPNs5aykT/w4fQb4krGcZfKgSZw=
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230726162122-13b66414cd5b h1:wWs8b91SVrxYy37gdNnFDCbjv1hMUHMTwaJUktyjrJE=
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230726162122-13b66414cd5b/go.mod h1:KYykqtdApHVYZ3G0spwMnoxc5jH5eI3jyO9SwsSfi48=
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230726162204-c48a56712ef0 h1:JU5aMzRFeyG/DOiMwLy3F1AMuuXjzPrUKZpW72kAHxE=
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230726162204-c48a56712ef0/go.mod h1:7cSGUoGVIla1IpnChrLbkVjkYgdOcr7rcifEfh4ReR4=
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230726162310-d761ca9911d8 h1:pQmTryFdSQuUe8dxt/dHgEfRdLwqf1DEGeReuMcJ9Yg=
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230726162310-d761ca9911d8/go.mod h1:+LeEYoW5/uBUTVjtBGLEVCUe9mOYAlu5ZPkIxLOSr5Y=
github.com/willf/bitset v1.1.3/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
github.com/wk8/go-ordered-map v1.0.0 h1:BV7z+2PaK8LTSd/mWgY12HyMAo5CEgkHqbkVq2thqr8=
github.com/wk8/go-ordered-map v1.0.0/go.mod h1:9ZIbRunKbuvfPKyBP1SIKLcXNlv74YCOZ3t3VTS6gRk=