Mixnet integration (#1346)

See #1345, <https://github.com/paritytech/substrate/pull/14207>.

This adds all the necessary mixnet components, and puts them together in
the "kitchen-sink" node/runtime. The components added are:

- A pallet (`frame/mixnet`). This is responsible for determining the
current mixnet session and phase, and the mixnodes to use in each
session. It provides a function that validators can call to register a
mixnode for the next session. The logic of this pallet is very similar
to that of the `im-online` pallet.
- A service (`client/mixnet`). This implements the core mixnet logic,
building on the `mixnet` crate. The service communicates with other
nodes using notifications sent over the "mixnet" protocol.
- An RPC interface. This currently only supports sending transactions
over the mixnet.

---------

Co-authored-by: David Emett <dave@sp4m.net>
Co-authored-by: Javier Viola <javier@parity.io>
This commit is contained in:
David Emett
2023-10-09 15:56:30 +02:00
committed by GitHub
parent 1dc935c715
commit a808a3a091
52 changed files with 3010 additions and 109 deletions
@@ -493,8 +493,8 @@ impl ProtocolController {
}
}
/// Remove the peer from the set of reserved peers. The peer is moved to the set of regular
/// nodes.
/// Remove the peer from the set of reserved peers. The peer is either moved to the set of
/// regular nodes or disconnected.
fn on_remove_reserved_peer(&mut self, peer_id: PeerId) {
let state = match self.reserved_nodes.remove(&peer_id) {
Some(state) => state,
@@ -508,7 +508,14 @@ impl ProtocolController {
};
if let PeerState::Connected(direction) = state {
if self.reserved_only {
// Disconnect if we're at (or over) the regular node limit
let disconnect = self.reserved_only ||
match direction {
Direction::Inbound => self.num_in >= self.max_in,
Direction::Outbound => self.num_out >= self.max_out,
};
if disconnect {
// Disconnect the node.
trace!(
target: LOG_TARGET,