-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[DO NOT MERGE] Command peer connections from runtime #6863
[DO NOT MERGE] Command peer connections from runtime #6863
Conversation
Hi, @bkchr @shawntabrizi do you guys mind giving another review? I'd like take the feedback early and hopefully it can be merged soon and catch the release train. Also Ping @gavofyork here in case you are interested and missed the request for review. |
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.
Would be good to add this pallet to the node client.
@riusricardo From my understanding, node client also serves for a public testnet, |
… restrict-node-connection
This looks really cool! I'd just started looking at doing something similar myself when @gautamdhameja pointed me to this. I'd be really interested in hearing why the approach taken was to use a well-known storage item? When I first saw paritytech/polkadot-sdk#358 I felt that option was really restrictive in terms of network topologies that can be created. It would be really nice if this was abstracted out such that the runtime could decide how the peer list should be determined. I guess I'm kind of concerned, especially given where the changes are needed, that this will make it difficult to expand upon this functionality in future. |
@mattdean-digicatapult From my understanding to the issue and requirements of a permissioned network, the list of peers should reach consensus within participants, which means the list should be stored on-chain. I found two ways for this purpose:
A runtime can always has its own logic for this well known storage. It's now assuming to use governance system to determine the peer list. |
Yes my first thought would be a runtime api with regular storage. This means a runtime could implement it's own interpretation of how the network should be laid out. My instinct btw was to have an api that took the current node's identity and returned the identities of nodes that it can connect to.
When I was thinking about this @kaichaosun I was thinking of a single multi-organisation permissioned chain. In a setup like this you need to decide who can add or remove nodes from the peer list, how and what peers should connect to what other peers. That may depend on the role of the node; so for a simple example
You also have more complex examples with sub-organisations etc. I've seen these sorts of models come up in other private chain solutions as well. |
It's now quite blurred to me which part should be on-chain and which part off-chain. There is an alternative to use CLI to command a node with flag
It makes sense to me, but before implementing this runtime api, I'd like we think about the second option listed in the issue, since it seems aimed for more adaptive scenarios, probably includes yours. This |
I think to a point having these things on-chain is a convenience thing. You could synchronise this information, either within an organisation or with the wider network, via a side channel and just use the cli args. Fundementally if someone wants to break the rules on sharing data from the private network they can do this unilaterally anyway so there's not a whole lot of protection against bad actors anyway. Using a side channel would be error prone however and given we have a bft data sharing mechanism and the data volumes are v. low it makes sense to me to use it imho.
The second option is very interesting and definitely would provide for the sort of scenarios I mentioned. The main benefit I think over the runtime api approach is that it allows the setting of the network conditions to be governed by the runtime with very little involvement from the node. This looks a lot more complex to me though to implement and the node could still relatively easily change the rules for itself by modifying the client. My concern with this PR however is that any approach beyond this may be excluded meerly by the presense of the |
Please do not merge this PR but happy to take more feedback, I am also working on using offchain worker to set reserved nodes. |
I think this approach has the most potential. Because you can still decide in a pallet to store the list of nodes and use one of the democracy pallets to manage this list (or using a sudo). Really interested in this PR because it will really pave the way forward for permissioned chains. Let me know if you need some help. |
Close it since we have an better solution #6996. |
Related paritytech/polkadot-sdk#358.
This PR is in early stage and unclean, I'd like take some feedback before move too far in the wrong direction.
The intention is: a chain can
with cli param.permissioned-network
TODOs:
struct Peer
in client/network/test/src/lib.rs need Backend trait bound forNetworkWorker
, LightBackend and Backend both used and stuck at abstraction. (help needed)decide if node wants to contain this module or not since there is another cli flagpermissioned_network
Thanks for the mentorship from @tomaka.
Edited:
The benchmark weight will be put in another PR if make sense.