Skip to content

Commit

Permalink
feat: replace DefaultPubsubTopic by Shard 32
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-ramos committed Oct 16, 2023
1 parent f2464cc commit dc97f40
Show file tree
Hide file tree
Showing 2,295 changed files with 114,039 additions and 455 deletions.
7 changes: 4 additions & 3 deletions cmd/ping-community/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/status-im/status-go/protocol/common"
"github.com/status-im/status-go/protocol/identity/alias"
"github.com/status-im/status-go/protocol/protobuf"
"github.com/status-im/status-go/protocol/transport"
wakuextn "github.com/status-im/status-go/services/wakuext"
)

Expand All @@ -47,8 +48,8 @@ var (
seedPhrase = flag.String("seed-phrase", "", "Seed phrase")
version = flag.Bool("version", false, "Print version and dump configuration")
communityID = flag.String("community-id", "", "The id of the community")
shardCluster = flag.Int("shard-cluster", common.UndefinedShardValue, "The shard cluster in which the of the community is published")
shardIndex = flag.Int("shard-index", common.UndefinedShardValue, "The shard index in which the community is published")
shardCluster = flag.Int("shard-cluster", transport.UndefinedShardValue, "The shard cluster in which the of the community is published")
shardIndex = flag.Int("shard-index", transport.UndefinedShardValue, "The shard index in which the community is published")
chatID = flag.String("chat-id", "", "The id of the chat")

dataDir = flag.String("dir", getDefaultDataDir(), "Directory used by node to store data")
Expand Down Expand Up @@ -148,7 +149,7 @@ func main() {
messenger := wakuextservice.Messenger()

var shard *common.Shard = nil
if shardCluster != nil && shardIndex != nil && *shardCluster != common.UndefinedShardValue && *shardIndex != common.UndefinedShardValue {
if shardCluster != nil && shardIndex != nil && *shardCluster != transport.UndefinedShardValue && *shardIndex != transport.UndefinedShardValue {
shard = &common.Shard{
Cluster: uint16(*shardCluster),
Index: uint16(*shardIndex),
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ require github.com/fogleman/gg v1.3.0
require (
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
github.com/andybalholm/brotli v1.0.5
github.com/cenkalti/backoff/v4 v4.2.1
github.com/gorilla/sessions v1.2.1
github.com/ipfs/go-log/v2 v2.5.1
github.com/jellydator/ttlcache/v3 v3.1.0
Expand All @@ -85,7 +86,7 @@ require (
github.com/mutecomm/go-sqlcipher/v4 v4.4.2
github.com/schollz/peerdiscovery v1.7.0
github.com/siphiuel/lc-proxy-wrapper v0.0.0-20230516150924-246507cee8c7
github.com/waku-org/go-waku v0.8.1-0.20230930175749-dcc828749f67
github.com/waku-org/go-waku v0.8.1-0.20231016192236-5dd87d44061f
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 Expand Up @@ -128,7 +129,6 @@ require (
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/containerd/cgroups v1.1.0 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
Expand Down
7 changes: 2 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,10 @@ github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0Bsq
github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE=
github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34=
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/cenkalti/backoff/v3 v3.2.2 h1:cfUAAO3yvKMYKPrvhDuHSwQnhZNk/RMHKdZqKTxfm6M=
github.com/cenkalti/backoff/v3 v3.2.2/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4rc0ij+ULvLYs=
github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo=
github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
Expand Down Expand Up @@ -820,7 +818,6 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA=
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
Expand Down Expand Up @@ -2100,8 +2097,8 @@ 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-waku v0.8.1-0.20230930175749-dcc828749f67 h1:EL0KljfCIFPXbY1IfT0JjVIjJekuF951ys1WL2WnWyM=
github.com/waku-org/go-waku v0.8.1-0.20230930175749-dcc828749f67/go.mod h1:MnMLFtym7XUt+GNN4zTkjm5NJCsm7TERLWVPOV/Ct6w=
github.com/waku-org/go-waku v0.8.1-0.20231016192236-5dd87d44061f h1:vKFJsdTjonyf/W8gM14XGe9Ajtp2dhV9JeRWd2Cj/7Q=
github.com/waku-org/go-waku v0.8.1-0.20231016192236-5dd87d44061f/go.mod h1:MnMLFtym7XUt+GNN4zTkjm5NJCsm7TERLWVPOV/Ct6w=
github.com/waku-org/go-zerokit-rln v0.1.14-0.20230916173259-d284a3d8f2fd h1:cu7CsUo7BK6ac/v193RIaqAzUcmpa6MNY4xYW9AenQI=
github.com/waku-org/go-zerokit-rln v0.1.14-0.20230916173259-d284a3d8f2fd/go.mod h1:1PdBdPzyTaKt3VnpAHk3zj+r9dXPFOr3IHZP9nFle6E=
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230916172309-ee0ee61dde2b h1:KgZVhsLkxsj5gb/FfndSCQu6VYwALrCOgYI3poR95yE=
Expand Down
40 changes: 21 additions & 19 deletions node/status_node_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"reflect"
"time"

"github.com/status-im/status-go/protocol/transport"
"github.com/status-im/status-go/server"
"github.com/status-im/status-go/signal"
"github.com/status-im/status-go/transactions"
Expand Down Expand Up @@ -310,25 +311,26 @@ func (b *StatusNode) wakuService(wakuCfg *params.WakuConfig, clusterCfg *params.
func (b *StatusNode) wakuV2Service(nodeConfig *params.NodeConfig, telemetryServerURL string) (*wakuv2.Waku, error) {
if b.wakuV2Srvc == nil {
cfg := &wakuv2.Config{
MaxMessageSize: wakucommon.DefaultMaxMessageSize,
Host: nodeConfig.WakuV2Config.Host,
Port: nodeConfig.WakuV2Config.Port,
LightClient: nodeConfig.WakuV2Config.LightClient,
KeepAliveInterval: nodeConfig.WakuV2Config.KeepAliveInterval,
Rendezvous: nodeConfig.Rendezvous,
WakuNodes: nodeConfig.ClusterConfig.WakuNodes,
PeerExchange: nodeConfig.WakuV2Config.PeerExchange,
EnableFilterFullNode: nodeConfig.WakuV2Config.EnableFilterFullNode,
EnableStore: nodeConfig.WakuV2Config.EnableStore,
StoreCapacity: nodeConfig.WakuV2Config.StoreCapacity,
StoreSeconds: nodeConfig.WakuV2Config.StoreSeconds,
DiscoveryLimit: nodeConfig.WakuV2Config.DiscoveryLimit,
DiscV5BootstrapNodes: nodeConfig.ClusterConfig.DiscV5BootstrapNodes,
Nameserver: nodeConfig.WakuV2Config.Nameserver,
EnableDiscV5: nodeConfig.WakuV2Config.EnableDiscV5,
UDPPort: nodeConfig.WakuV2Config.UDPPort,
AutoUpdate: nodeConfig.WakuV2Config.AutoUpdate,
TelemetryServerURL: telemetryServerURL,
MaxMessageSize: wakucommon.DefaultMaxMessageSize,
Host: nodeConfig.WakuV2Config.Host,
Port: nodeConfig.WakuV2Config.Port,
LightClient: nodeConfig.WakuV2Config.LightClient,
KeepAliveInterval: nodeConfig.WakuV2Config.KeepAliveInterval,
Rendezvous: nodeConfig.Rendezvous,
WakuNodes: nodeConfig.ClusterConfig.WakuNodes,
PeerExchange: nodeConfig.WakuV2Config.PeerExchange,
EnableFilterFullNode: nodeConfig.WakuV2Config.EnableFilterFullNode,
EnableStore: nodeConfig.WakuV2Config.EnableStore,
StoreCapacity: nodeConfig.WakuV2Config.StoreCapacity,
StoreSeconds: nodeConfig.WakuV2Config.StoreSeconds,
DiscoveryLimit: nodeConfig.WakuV2Config.DiscoveryLimit,
DiscV5BootstrapNodes: nodeConfig.ClusterConfig.DiscV5BootstrapNodes,
Nameserver: nodeConfig.WakuV2Config.Nameserver,
EnableDiscV5: nodeConfig.WakuV2Config.EnableDiscV5,
UDPPort: nodeConfig.WakuV2Config.UDPPort,
AutoUpdate: nodeConfig.WakuV2Config.AutoUpdate,
DefaultShardPubsubTopic: transport.DefaultShardPubsubTopic(),
TelemetryServerURL: telemetryServerURL,
}

if nodeConfig.WakuV2Config.MaxMessageSize > 0 {
Expand Down
4 changes: 1 addition & 3 deletions protocol/common/message_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
datasyncproto "github.com/vacp2p/mvds/protobuf"
"go.uber.org/zap"

"github.com/waku-org/go-waku/waku/v2/protocol/relay"

"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/protocol/datasync"
Expand Down Expand Up @@ -399,7 +397,7 @@ func (s *MessageSender) sendPrivate(

messageID := v1protocol.MessageID(&rawMessage.Sender.PublicKey, wrappedMessage)
rawMessage.ID = types.EncodeHex(messageID)
rawMessage.PubsubTopic = relay.DefaultWakuTopic // TODO: determine which pubsub topic should be used for 1:1 messages
rawMessage.PubsubTopic = transport.DefaultShardPubsubTopic() // TODO: determine which pubsub topic should be used for 1:1 messages

if rawMessage.BeforeDispatch != nil {
if err := rawMessage.BeforeDispatch(rawMessage); err != nil {
Expand Down
18 changes: 0 additions & 18 deletions protocol/common/shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@ package common
import (
"github.com/status-im/status-go/protocol/protobuf"
"github.com/status-im/status-go/protocol/transport"
"github.com/waku-org/go-waku/waku/v2/protocol/relay"
)

const MainStatusShardCluster = 16
const NonProtectedShardIndex = 64
const UndefinedShardValue = 0

type Shard struct {
Cluster uint16 `json:"cluster"`
Index uint16 `json:"index"`
Expand Down Expand Up @@ -47,16 +42,3 @@ func (s *Shard) Protobuffer() *protobuf.Shard {
Index: int32(s.Index),
}
}

func DefaultNonProtectedPubsubTopic(shard *Shard) string {
// TODO: remove the condition once DefaultWakuTopic usage
// is removed
if shard != nil {
return transport.GetPubsubTopic(&transport.Shard{
Cluster: MainStatusShardCluster,
Index: NonProtectedShardIndex,
})
}

return relay.DefaultWakuTopic
}
4 changes: 1 addition & 3 deletions protocol/communities/community.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (
"github.com/golang/protobuf/proto"
"go.uber.org/zap"

"github.com/waku-org/go-waku/waku/v2/protocol/relay"

"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/images"
Expand Down Expand Up @@ -1268,7 +1266,7 @@ func (o *Community) DefaultFilters() []transport.FiltersToInitialize {

return []transport.FiltersToInitialize{
{ChatID: cID, PubsubTopic: communityPubsubTopic},
{ChatID: uncompressedPubKey, PubsubTopic: relay.DefaultWakuTopic}, // TODO: messages that are not protected are sent in default pubsub topic for now
{ChatID: uncompressedPubKey, PubsubTopic: transport.DefaultShardPubsubTopic()}, // TODO: messages that are not protected are sent in default pubsub topic for now
{ChatID: uncompressedPubKey, PubsubTopic: communityPubsubTopic},
{ChatID: updatesChannelID, PubsubTopic: communityPubsubTopic},
{ChatID: mlChannelID, PubsubTopic: communityPubsubTopic},
Expand Down
4 changes: 1 addition & 3 deletions protocol/communities/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import (
"github.com/anacrolix/torrent/metainfo"
"github.com/golang/protobuf/proto"

"github.com/waku-org/go-waku/waku/v2/protocol/relay"

"github.com/google/uuid"
"github.com/pkg/errors"
"go.uber.org/zap"
Expand Down Expand Up @@ -3350,7 +3348,7 @@ func (m *Manager) GetPubsubTopic(communityID string) (string, error) {
}

if community == nil {
return relay.DefaultWakuTopic, nil
return transport.DefaultShardPubsubTopic(), nil
}

return transport.GetPubsubTopic(community.Shard().TransportShard()), nil
Expand Down
6 changes: 2 additions & 4 deletions protocol/messenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
"go.uber.org/zap"
"golang.org/x/time/rate"

"github.com/waku-org/go-waku/waku/v2/protocol/relay"

gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/event"
Expand Down Expand Up @@ -1618,7 +1616,7 @@ func (m *Messenger) Init() error {
logger := m.logger.With(zap.String("site", "Init"))

// Community requests will arrive in this pubsub topic
err := m.SubscribeToPubsubTopic(common.DefaultNonProtectedPubsubTopic(nil), nil)
err := m.SubscribeToPubsubTopic(transport.DefaultNonProtectedPubsubTopic(nil), nil)
if err != nil {
return err
}
Expand Down Expand Up @@ -1731,7 +1729,7 @@ func (m *Messenger) Init() error {

switch chat.ChatType {
case ChatTypePublic, ChatTypeProfile:
filtersToInit = append(filtersToInit, transport.FiltersToInitialize{ChatID: chat.ID, PubsubTopic: relay.DefaultWakuTopic})
filtersToInit = append(filtersToInit, transport.FiltersToInitialize{ChatID: chat.ID, PubsubTopic: transport.DefaultShardPubsubTopic()})
case ChatTypeCommunityChat:
communityID, err := hexutil.Decode(chat.CommunityID)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions protocol/messenger_communities.go
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ func (m *Messenger) RequestToJoinCommunity(request *requests.RequestToJoinCommun
CommunityID: community.ID(),
SkipProtocolLayer: true,
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_JOIN,
PubsubTopic: common.DefaultNonProtectedPubsubTopic(community.Shard()),
PubsubTopic: transport.DefaultNonProtectedPubsubTopic(community.Shard().TransportShard()),
}

_, err = m.sender.SendCommunityMessage(context.Background(), rawMessage)
Expand Down Expand Up @@ -1413,7 +1413,7 @@ func (m *Messenger) CancelRequestToJoinCommunity(request *requests.CancelRequest
CommunityID: community.ID(),
SkipProtocolLayer: true,
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_CANCEL_REQUEST_TO_JOIN,
PubsubTopic: common.DefaultNonProtectedPubsubTopic(community.Shard()),
PubsubTopic: transport.DefaultNonProtectedPubsubTopic(community.Shard().TransportShard()),
}
_, err = m.sender.SendCommunityMessage(context.Background(), rawMessage)

Expand Down Expand Up @@ -1529,7 +1529,7 @@ func (m *Messenger) AcceptRequestToJoinCommunity(request *requests.AcceptRequest
Sender: community.PrivateKey(),
SkipProtocolLayer: true,
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_JOIN_RESPONSE,
PubsubTopic: common.DefaultNonProtectedPubsubTopic(community.Shard()),
PubsubTopic: transport.DefaultNonProtectedPubsubTopic(community.Shard().TransportShard()),
}

_, err = m.sender.SendPrivate(context.Background(), pk, rawMessage)
Expand Down
4 changes: 1 addition & 3 deletions protocol/messenger_contacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
"github.com/golang/protobuf/proto"
"go.uber.org/zap"

"github.com/waku-org/go-waku/waku/v2/protocol/relay"

"github.com/status-im/status-go/deprecation"
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types"
Expand Down Expand Up @@ -470,7 +468,7 @@ func (m *Messenger) addContact(ctx context.Context, pubKey, ensName, nickname, d
if !deprecation.ChatProfileDeprecated {
response.AddChat(profileChat)

_, err = m.transport.InitFilters([]transport.FiltersToInitialize{{ChatID: profileChat.ID, PubsubTopic: relay.DefaultWakuTopic}}, []*ecdsa.PublicKey{publicKey})
_, err = m.transport.InitFilters([]transport.FiltersToInitialize{{ChatID: profileChat.ID, PubsubTopic: transport.DefaultShardPubsubTopic()}}, []*ecdsa.PublicKey{publicKey})
if err != nil {
return nil, err
}
Expand Down
4 changes: 1 addition & 3 deletions protocol/messenger_mailserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"github.com/pkg/errors"
"go.uber.org/zap"

"github.com/waku-org/go-waku/waku/v2/protocol/relay"

"github.com/status-im/status-go/connection"
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types"
Expand Down Expand Up @@ -252,7 +250,7 @@ func (m *Messenger) syncBackup() error {

to := m.calculateMailserverTo()
from := uint32(m.getTimesource().GetCurrentTime()/1000) - oneMonthInSeconds
batch := MailserverBatch{From: from, To: to, PubsubTopic: relay.DefaultWakuTopic, Topics: []types.TopicType{filter.ContentTopic}}
batch := MailserverBatch{From: from, To: to, PubsubTopic: transport.DefaultShardPubsubTopic(), Topics: []types.TopicType{filter.ContentTopic}}
err := m.processMailserverBatch(batch)
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion protocol/requests/set_community_shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/protocol/common"
"github.com/status-im/status-go/protocol/transport"
)

type SetCommunityShard struct {
Expand All @@ -19,7 +20,7 @@ func (s *SetCommunityShard) Validate() error {
}
if s.Shard != nil {
// TODO: for now only MainStatusShard(16) is accepted
if s.Shard.Cluster != common.MainStatusShardCluster {
if s.Shard.Cluster != transport.MainStatusShardCluster {
return errors.New("invalid shard cluster")
}
if s.Shard.Index > 1023 {
Expand Down
16 changes: 7 additions & 9 deletions protocol/transport/filters_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
"github.com/pkg/errors"
"go.uber.org/zap"

"github.com/waku-org/go-waku/waku/v2/protocol/relay"

"github.com/status-im/status-go/eth-node/types"
)

Expand Down Expand Up @@ -163,8 +161,8 @@ func (f *FiltersManager) InitCommunityFilters(communityFiltersToInitialize []Com

communityPubsubTopic := GetPubsubTopic(cf.Shard)
topics := []string{communityPubsubTopic}
if communityPubsubTopic != relay.DefaultWakuTopic {
topics = append(topics, relay.DefaultWakuTopic)
if communityPubsubTopic != DefaultShardPubsubTopic() {
topics = append(topics, DefaultShardPubsubTopic())
}

// TODO: requests to join / cancels are currently being sent into the default waku topic.
Expand Down Expand Up @@ -387,7 +385,7 @@ func (f *FiltersManager) LoadPersonal(publicKey *ecdsa.PublicKey, identity *ecds
return f.filters[chatID], nil
}

pubsubTopic := relay.DefaultWakuTopic
pubsubTopic := DefaultShardPubsubTopic()

// We set up a filter so we can publish,
// but we discard envelopes if listen is false.
Expand Down Expand Up @@ -428,7 +426,7 @@ func (f *FiltersManager) loadPartitioned(publicKey *ecdsa.PublicKey, identity *e
return f.filters[chatID], nil
}

pubsubTopic := relay.DefaultWakuTopic
pubsubTopic := DefaultShardPubsubTopic()

// We set up a filter so we can publish,
// but we discard envelopes if listen is false.
Expand Down Expand Up @@ -467,7 +465,7 @@ func (f *FiltersManager) LoadNegotiated(secret types.NegotiatedSecret) (*Filter,
return f.filters[chatID], nil
}

pubsubTopic := relay.DefaultWakuTopic
pubsubTopic := DefaultShardPubsubTopic()
keyString := hex.EncodeToString(secret.Key)
filter, err := f.addSymmetric(keyString, pubsubTopic)
if err != nil {
Expand Down Expand Up @@ -521,7 +519,7 @@ func (f *FiltersManager) LoadDiscovery() ([]*Filter, error) {
personalDiscoveryChat := &Filter{
ChatID: personalDiscoveryTopic,
Identity: identityStr,
PubsubTopic: relay.DefaultWakuTopic,
PubsubTopic: DefaultShardPubsubTopic(),
Discovery: true,
Listen: true,
OneToOne: true,
Expand Down Expand Up @@ -592,7 +590,7 @@ func (f *FiltersManager) LoadContactCode(pubKey *ecdsa.PublicKey) (*Filter, erro
return f.filters[chatID], nil
}

pubsubTopic := relay.DefaultWakuTopic
pubsubTopic := DefaultShardPubsubTopic()

contactCodeFilter, err := f.addSymmetric(chatID, pubsubTopic)
if err != nil {
Expand Down
Loading

0 comments on commit dc97f40

Please sign in to comment.