-
Notifications
You must be signed in to change notification settings - Fork 186
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
Conversation
There was a problem hiding this 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; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗑️🚀
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.