-
Notifications
You must be signed in to change notification settings - Fork 445
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: pubsub configuration #404
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.
Yes, some tests in ./test/pubsub.node.js
to verify that toggling emitSelf works as expected would be great.
Thanks for updating the example as well!
@jacobheun Ok, I will soon add some tests! |
@jacobheun quick question: Do you want that I test the toggling of |
@a1300 1 implementation is fine, ultimately we're just verifying that it's getting the configuration. Those modules should handle more in depth testing for themselves. |
Even just testing that a mock Pubsub implementation is getting the right options would be sufficient. |
@jacobheun I am currently writing the tests, and I wondered if the following is not a bug on its own: The following code is the config that defines the default properties of the // Pubsub config
pubsub: s('object?', {
// Pubsub defaults
enabled: true,
emitSelf: true,
signMessages: true,
strictSigning: true
}) If I now create a const bundle = new libp2p({
modules: {
transport: [ TCP ],
streamMuxer: [ Mplex ],
connEncryption: [ SECIO ],
peerDiscovery: [ MulticastDNS ],
pubsub: Gossipsub
},
config: {
peerDiscovery: {
mdns: {
interval: 2000,
enabled: true
}
},
pubsub: {
enabled: true,
emitSelf: true
}
}
} The {
enabled: true,
emitSelf: true
} But I would expect that it would be called with: {
enabled: true,
emitSelf: true,
signMessages: true,
strictSigning: true
} Is this a bug or expected behavior? Thanks! |
It's expected, but not ideal. The config needs some improvements. Right now it's validating an optional object and not their sub properties. If any object is supplied it uses that and doesn't do any copying of the default properties. Ideally we'd get the defaults populated, while avoiding making the config too strict. The reason for this is that if we add a new config option in the future to pubsub or another module, we need to avoid libp2p config validation from throwing an error, so that it doesn't have to be updated to use the latest pubsub. I'll create a ticket to track improving the config, don't worry about it for this, you may just need to be verbose with configuration for some of the tests. (Note: Both existing pubsub modules do properly add defaults for the missing values, so we are catching it there as we should be). |
License: MIT Signed-off-by: Matthias Knopp <matthias-knopp@gmx.net>
License: MIT Signed-off-by: Matthias Knopp <matthias-knopp@gmx.net>
License: MIT Signed-off-by: Matthias Knopp <matthias-knopp@gmx.net>
License: MIT Signed-off-by: Matthias Knopp <matthias-knopp@gmx.net>
Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
License: MIT Signed-off-by: Matthias Knopp <matthias-knopp@gmx.net>
@jacobheun please review the tests 🙂 |
@a1300 looks good! I ran the example as well and everything looks good there too. Thanks for the PR! |
The `Providers` component takes a `ProvidersInit` object, but there's not actually a way to provide it with one from the `KadDHT` constructor. This means users aren't able to override the defaults for how long provider records are valid for and how frequently to clean up expired provider records. Co-authored-by: Alex Potsides <alex@achingbrain.net>
## [6.1.0](libp2p/js-libp2p-kad-dht@v6.0.4...v6.1.0) (2022-12-07) ### Features * allow passing ProvidersInit in KadDHT constructor ([libp2p#404](libp2p/js-libp2p-kad-dht#404)) ([e64af85](libp2p/js-libp2p-kad-dht@e64af85)) ### Bug Fixes * treat /dns, /dns4, and /dns6 addrs as public ([libp2p#406](libp2p/js-libp2p-kad-dht#406)) ([e27747a](libp2p/js-libp2p-kad-dht@e27747a)), closes [libp2p#377](libp2p/js-libp2p-kad-dht#377)
This PR fixes issue #401 and adds the following new
pubsub
configuration options:emitSelf
(boolean)signMessages
(boolean)strictSigning
(boolean)@jacobheun I wasn't sure if I should add tests for this bug fix because it seemed to me that this repository isn't testing if configuration is correctly passed to the Modules. Should I add some tests?
Thanks!