Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check for lightclient only if req doesn't contain shards #1161

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions waku/v2/protocol/metadata/waku_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ func (wakuM *WakuMetadata) Request(ctx context.Context, peerID peer.ID) (*pb.Wak
request := &pb.WakuMetadataRequest{}
request.ClusterId = clusterID
request.Shards = shards
// TODO: remove with nwaku 0.28 deployment
request.ShardsDeprecated = shards // nolint: staticcheck

writer := pbio.NewDelimitedWriter(stream)
reader := pbio.NewDelimitedReader(stream, math.MaxInt32)
Expand Down Expand Up @@ -173,8 +171,6 @@ func (wakuM *WakuMetadata) onRequest(ctx context.Context) func(network.Stream) {
} else {
response.ClusterId = clusterID
response.Shards = shards
// TODO: remove with nwaku 0.28 deployment
response.ShardsDeprecated = shards // nolint: staticcheck
}

err = writer.WriteMsg(response)
Expand Down Expand Up @@ -245,14 +241,6 @@ func (wakuM *WakuMetadata) Connected(n network.Network, cc network.Conn) {
rClusterID := uint16(*response.ClusterId)
var rs protocol.RelayShards

if _, err = wakuM.h.Peerstore().SupportsProtocols(peerID, relay.WakuRelayID_v200); err == nil {
wakuM.log.Debug("light peer only checking clusterID")
if rClusterID != wakuM.clusterID {
wakuM.disconnectPeer(peerID, errors.New("different clusterID reported"))
}
return
}

wakuM.log.Debug("relay peer checking cluster and shards")

var rShardIDs []uint16
Expand All @@ -261,9 +249,12 @@ func (wakuM *WakuMetadata) Connected(n network.Network, cc network.Conn) {
rShardIDs = append(rShardIDs, uint16(i))
}
} else {
// TODO: remove with nwaku 0.28 deployment
for _, i := range response.ShardsDeprecated { // nolint: staticcheck
rShardIDs = append(rShardIDs, uint16(i))
if proto, err := wakuM.h.Peerstore().FirstSupportedProtocol(peerID, relay.WakuRelayID_v200); err == nil && proto == "" {
wakuM.log.Debug("light peer only checking clusterID")
if rClusterID != wakuM.clusterID {
wakuM.disconnectPeer(peerID, errors.New("different clusterID reported"))
}
return
}
}
wakuM.log.Debug("getting remote cluster and shards")
Expand Down
Loading