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

Remove support for multi-topic messages #388

Merged
merged 1 commit into from
Oct 8, 2020
Merged

Conversation

vyzo
Copy link
Collaborator

@vyzo vyzo commented Oct 8, 2020

This was a fringe / half-baked feature in the wire protocol that has no direct users or API exposure.

Not only we didn't provide an API to do multi-topic publishing, but also the recent introduction of the topic handle abstraction created impedance mismatch.

So this feature adds bloat with no visible gain, and this PR proposes simplification by removal.

Migration path

There is no visible consequence for go-libp2p-pubsub users. At the wire level, due to the way that Protobuf serialises repeated fields, this causes no breakage. If direct wire protocol users (e.g. other libp2p implementations) were using the variadic topics field, this patch will make Protobuf pick the last topic in the list.

@vyzo vyzo requested a review from raulk October 8, 2020 14:19
Copy link
Member

@raulk raulk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Glad to see this go. This feature complicated our code substantially, and it wasn't even exposed via the API.

In the future, we could provide some porcelain function to fan out a message on many topics.

@@ -0,0 +1,12 @@
syntax = "proto2";

package compat.pb;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This is a great technique we should keep using across the board on protobuf changes ;-)

if err != nil {
t.Fatal(err)
}
if newMessage.GetTopic() != topic2 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, this verifies that indeed the last topic in the list survives.

From: []byte(attacker.ID()),
Seqno: []byte{byte(i + 1)},
Data: []byte("some data" + strconv.Itoa(i)),
Topic: &mytopic,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should remove the optional trait from the protobuf file for the topic. It is compulsory (AFAIK) and it would remove this annoying indirection, and speed things up slightly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. But it's a bit of work, so let's do it in a future pr.

@@ -18,7 +18,7 @@ message Message {
optional bytes from = 1;
optional bytes data = 2;
optional bytes seqno = 3;
repeated string topicIDs = 4;
optional string topic = 4;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to do here, but we should drop the optional here.

// check against the mesh delivery window -- if the validated time is passed as 0, then
// the message was received before we finished validation and thus falls within the mesh
// delivery window.
if !validated.IsZero() && time.Since(validated) > tparams.MeshMessageDeliveriesWindow {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much readable, thanks!

@@ -300,471 +293,3 @@ func TestValidateAssortedOptions(t *testing.T) {
}
}
}

func TestValidateMultitopic(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗑️🚀

@vyzo vyzo merged commit d6c20b5 into master Oct 8, 2020
@vyzo vyzo deleted the feat/kill-multiple-topics branch October 8, 2020 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants