[backport to v0.37.x] config: add bootstrap peers (tendermint#9680)#1019
[backport to v0.37.x] config: add bootstrap peers (tendermint#9680)#1019
Conversation
b1f263f to
e27d3c8
Compare
|
|
||
| # Comma separated list of peers to be added to the peer store | ||
| # on startup. Either BootstrapPeers or PersistentPeers are | ||
| # needed for peer discovery |
There was a problem hiding this comment.
Maybe write down what the difference is between them although most people already know.
There was a problem hiding this comment.
The affirmation is not even true. One node can discovery peers by only having SeedNodes config parameter set.
There was a problem hiding this comment.
So, again, should we make those changes here, which is a backport PR, or in the original content on main?
There was a problem hiding this comment.
So, here there are several points which are not clear:
- A node can discovery peers provided it has any address on its address book (
BootrstapPeersflag ensures this), any peer configured as persistent, or any address configured as seed node - Persistent peers is not meant for peer discovery. It is mostly used by validator nodes that don't run the PEX reactor, namely, don't participate on the peer discovery protocol
- There is no peer store. There is an address book with addresses of potential peers
jmalicevic
left a comment
There was a problem hiding this comment.
Minor comment but LGTM.
| return nil, fmt.Errorf("could not create addrbook: %w", err) | ||
| } | ||
|
|
||
| for _, addr := range splitAndTrimEmpty(config.P2P.BootstrapPeers, ",", " ") { |
There was a problem hiding this comment.
As this is hard to unit-test (code in Node usually is), would it make sense to add support for this in the e2e manifest (no need to touch the generator) so we can test this in, e.g., networks/ci.toml?
There was a problem hiding this comment.
The addresses here are directly passed to the address book, the address book unit tests should cover this. If not, the PEX reactor unit test, which requires setting up the address book, should also cover this.
There was a problem hiding this comment.
I didn't get the point here.
As a general rule, when we add production code, we need to add some (unit) test code that hits the new code.
Here, I think unit testing would be cumbersome and pointless (but I might be wrong, as I didn't look around into UTs that test neighboring code... it may be simpler), so I was suggesting to add the config option as part of networks/ci.toml so that it's part of e2e
The addresses here are directly passed to the address book, the address book unit tests should cover this. If not, the PEX reactor unit test, which requires setting up the address book, should also cover this.
Can you point at the test cases that are testing this new code?
There was a problem hiding this comment.
There is no test unit covering this flag specifically. In particular because this is not a flag that is considered by the p2p layer.
What I meant is that there are test cases covering the addrBook.AddAddress() method, which is a very basic method of the PEX implementation, that is invoked for all addresses parsed from this config flag.
There was a problem hiding this comment.
so I was suggesting to add the config option as part of networks/ci.toml so that it's part of e2e
Ok, I will take a look on this file.
There was a problem hiding this comment.
Ok, found it, but this is a specific config triggering some scenarios. I don't see the use of this flag in the network setup/topology enforced in those runs. Actually, those runs do not cover the user case of this new flag, as node rely on persistent peers and a seed node for establishing connections. The option there would be to replace a persistent peer in a given node by a bootstrap peer, but this would mean changing the semantics of the setup, as the node will not necessarily connect to the configured bootstrap peer, as it can retrieve other addresses from the nodes configured as persistent or seeds beforehand.
There was a problem hiding this comment.
OK, if you think it makes no sense to test this using e2e, then we're back with unit tests.
I took a closer look at relevant existing UTs. There is TestNodeNewNodeCustomReactors which is testing the NewNode function where your new code is. So I see several options:
- You can create a similar test case, next to it, where you modify the config before passing it to
NewNodeso that in contains relevant bootstrap peer config. The easiest is to feed incorrect config, to exercise the error paths introduced by the new code (where you are returning an error). - For testing the happy path, I think it's best to modify
TestP2PConfigto include correct bootstrap config, and then re-running all UTs and make sure they all pass. Alternatively, you can just test the happy path as part of the new UT where you're testing the error paths
|
So, I am ok to apply the suggested changes provided they are not part of this PR. This PR is meant to backport the code and operation present on I can take the opportunity to update the documentation (this includes comments on source files and descriptions on config files) so that they are more precise and clear. But I would rather do that as part of a different issue/PR, and first on |
|
I've created this new issue to handle updates on the p2p parameters: #1038 |
| @@ -0,0 +1,3 @@ | |||
| - `[config]` Introduce `BootstrapPeers` to the config to allow | |||
There was a problem hiding this comment.
| - `[config]` Introduce `BootstrapPeers` to the config to allow | |
| - `[config]` Introduce `p2p.bootstrap_peers` to the config to allow |
Operators don't see the BootstrapPeers variable - they see the configuration file entry.
| * A new config field, `BootstrapPeers` has been introduced as a means of | ||
| adding a list of addresses to the addressbook upon initializing a node. This is an | ||
| alternative to `PersistentPeers`. `PersistentPeers` shold be only used for | ||
| nodes that you want to keep a constant connection with i.e. sentry nodes |
There was a problem hiding this comment.
| * A new config field, `BootstrapPeers` has been introduced as a means of | |
| adding a list of addresses to the addressbook upon initializing a node. This is an | |
| alternative to `PersistentPeers`. `PersistentPeers` shold be only used for | |
| nodes that you want to keep a constant connection with i.e. sentry nodes | |
| * A new config field, `p2p.bootstrap_peers` has been introduced as a means of | |
| adding a list of addresses to the addressbook upon initializing a node. This is an | |
| alternative to `p2p.persistent_peers`. `p2p.persistent_peers` should be only used for | |
| nodes that you want to keep a constant connection with i.e. sentry nodes. |
| seeds = "{{ .P2P.Seeds }}" | ||
|
|
||
| # Comma separated list of peers to be added to the peer store | ||
| # on startup. Either BootstrapPeers or PersistentPeers are |
There was a problem hiding this comment.
| # on startup. Either BootstrapPeers or PersistentPeers are | |
| # on startup. Either bootstrap_peers or persistent_peers are |
The configuration file has no notion of BootstrapPeers - this is the Go code field name. The representation in the config file is bootstrap_peers.
I see. Then the UTs were missing on the initial PR. Please add the UTs I am requesting on |
| if err != nil { | ||
| return nil, fmt.Errorf("invalid bootstrap peer address: %w", err) | ||
| } | ||
| err = addrBook.AddAddress(netAddrs, netAddrs) |
There was a problem hiding this comment.
I've just realize that the source address (second parameter) should not be that one.
In fact, when we manually add addresses to the address book, the source should be the node itself. Refer to the implementation spec (point 3. referring to the source address) and to the way we add addresses of configured persistent peers on the switch.
|
I think we should block (if not drop) this PR, since the implementation of this feature in the For instance:
While none of those problems are critical, it would be good to fix them on |
|
@cason I think I agree with you overall. Here's the next steps I suggest
Also, this PR was in response to a user's request wasn't it? |
Yes, #1016 |
|
Then, whichever option we take, we need to drive it to completion, so #1016 can be considered done |
e27d3c8 to
6d70663
Compare
|
I don't know what is the best solution here. Fixing the documentation of the p2p parameters is an issue I plan to tackle from next week, as part of #1038. This issue is more extensive, but in particular addresses the documentation of the parameter introduced by this PR. Reverting the original PR on |
Yes, please, go ahead and drive it to completion. I don't think it's a lot of work to fix the doc messages on the original patch, and add a UT to test the added code. |
|
Rejected. Please refer to #1109 for more detailed reasons. |
Closes #1016.
Reviewers, please help with the
.changelog/entry. The remain is just a simple backport from main.