-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat: Pubsub.SeenMessagesTTL #9372
Conversation
5a9aa6c
to
c74d8c0
Compare
c74d8c0
to
27a4bd1
Compare
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.
lgtm, but this needs tests – if we expose this setting, we must be sure it continues working across any future refactors (both Kubo and go-libp2p)
@@ -77,6 +77,7 @@ func LibP2P(bcfg *BuildCfg, cfg *config.Config) fx.Option { | |||
pubsubOptions = append( | |||
pubsubOptions, | |||
pubsub.WithMessageSigning(!cfg.Pubsub.DisableSigning), | |||
pubsub.WithSeenMessagesTTL(cfg.Pubsub.SeenMessagesTTL.WithDefault(pubsub.TimeCacheDuration)), |
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 PR needs a basic regression test that ensures Pubsub.SeenMessagesTTL
set by the user is respected.
Unsure what is the best way to test this, you'd need to set it too low and then observe duplicates?
@smrz2001 we have some prior art in test/sharness/t0320-pubsub.sh
if that helps.
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.
Hey @lidel, it took me a bit to get everything figured out and setup with sharness
. After playing around with it a bit, I'm realizing that there isn't really a good way to induce duplicate pubsub messages. The API (rightly) doesn't allow setting a message ID explicitly.
func (t *Topic) Publish(ctx context.Context, data []byte, opts ...PubOpt) error {
.
.
.
return t.p.val.PushLocal(&Message{m, "", t.p.host.ID(), nil, pub.local})
}
The only option I can currently come up with is to use tc netem
via command line or code to simulate network traffic duplication.
Does this seems like a viable approach? Not sure what the restrictions are around what tests are/aren't allowed to do. I've used tc netem
before so I can figure this out, if acceptable.
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.
Thank you for looking into this. I hoped there is an easier way, but I guess we've hit an edge case on this one.
We already have some helpers for sharness in ./test/dependencies
, such as pollEndpoint
, so that is a potential path forward (golang helper is a bit more future-proof, could be reused when we move away from the sharness). Using tc netem
is also an option, if we can get it to work on CI.
@marten-seemann @vyzo is there a better / less painful way to test WithSeenMessagesTTL
/ simulate duplicated messages?
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'm thinking aloud here but I could also make a libp2p-sim
tool under test/dependencies
that connects to libp2p like a normal node but is capable of sending spurious messages. Might be useful in other contexts too perhaps.
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.
probably not, we do go out of our way to supress them.
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.
What do you think about having a libp2p-sim that implements it's own Publish and can send dups?
This and libp2p/go-libp2p-pubsub#502 both sound sensible 👍
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.
@lidel, would it be possible to do a regular Golang unit test here instead of adding to sharness
?
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.
@lidel, after a lot of hair pulling, I was unable to set up a libp2p simulator but I was able to figure out how to write a Go test under test/integration
that does the job, IMO. Would it work to keep the test there? Let me know what you think.
FYI, this test uncovered another pubsub/cache bug, which I will fix under this issue.
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.
Thank you for doing due diligence on this, yes, your approach is acceptable: this is the best we can do given tools at hand, and it still acts as an early warning if go-libp2p APIs change, or a regression is introduced.
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.
Thank you for driving this @smrz2001, and being patient with test work. I'm merging this, so we can include it in Kubo 0.18.0-rc1 (ETA second week of December, or beginning of January).
Excellent, thanks so much, @lidel!! 🙏🏼🙏🏼
I'll try to get the other bugs fixed soon as well, and will update the dependencies and tests accordingly.
3c73341
to
4b8eafa
Compare
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.
Thank you for driving this @smrz2001, and being patient with test work.
I'm merging this, so we can include it in Kubo 0.18.0-rc1 (ETA second week of December, or beginning of January).
@@ -77,6 +77,7 @@ func LibP2P(bcfg *BuildCfg, cfg *config.Config) fx.Option { | |||
pubsubOptions = append( | |||
pubsubOptions, | |||
pubsub.WithMessageSigning(!cfg.Pubsub.DisableSigning), | |||
pubsub.WithSeenMessagesTTL(cfg.Pubsub.SeenMessagesTTL.WithDefault(pubsub.TimeCacheDuration)), |
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.
Thank you for doing due diligence on this, yes, your approach is acceptable: this is the best we can do given tools at hand, and it still acts as an early warning if go-libp2p APIs change, or a regression is introduced.
Here's a PR for this issue, @lidel.
cc @stbrody
Closes #9371