Files
pezkuwi-subxt/substrate/client/mixnet/src/config.rs
T
David Emett a808a3a091 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>
2023-10-09 14:56:30 +01:00

89 lines
3.1 KiB
Rust

// This file is part of Substrate.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
pub use mixnet::core::Config as CoreConfig;
use std::time::Duration;
/// Substrate-specific mixnet configuration.
#[derive(Clone, Debug)]
pub struct SubstrateConfig {
/// Attempt to register the local node as a mixnode?
pub register: bool,
/// Maximum number of incoming mixnet connections to accept from non-mixnodes. If the local
/// node will never be a mixnode, this can be set to 0.
pub num_gateway_slots: u32,
/// Number of requests to the mixnet service that can be buffered, in addition to the one per
/// [`Api`](super::api::Api) instance. Note that this does not include requests that are being
/// actively handled.
pub request_buffer: usize,
/// Used to determine the number of SURBs to include in request messages: the maximum number of
/// SURBs needed for a single reply is multiplied by this. This should not be set to 0.
pub surb_factor: usize,
/// Maximum number of submit extrinsic requests waiting for their delay to elapse. When at the
/// limit, any submit extrinsic requests that arrive will simply be dropped.
pub extrinsic_queue_capacity: usize,
/// Mean delay between receiving a submit extrinsic request and actually submitting the
/// extrinsic. This should really be the same for all nodes!
pub mean_extrinsic_delay: Duration,
/// Maximum number of extrinsics being actively submitted. If a submit extrinsic request's
/// delay elapses and we are already at this limit, the request will simply be dropped.
pub max_pending_extrinsics: usize,
}
impl Default for SubstrateConfig {
fn default() -> Self {
Self {
register: true,
num_gateway_slots: 150,
request_buffer: 4,
surb_factor: 2,
extrinsic_queue_capacity: 50,
mean_extrinsic_delay: Duration::from_secs(1),
max_pending_extrinsics: 20,
}
}
}
/// Mixnet configuration.
#[derive(Clone, Debug)]
pub struct Config {
/// Core configuration.
pub core: CoreConfig,
/// Request manager configuration.
pub request_manager: mixnet::request_manager::Config,
/// Reply manager configuration.
pub reply_manager: mixnet::reply_manager::Config,
/// Substrate-specific configuration.
pub substrate: SubstrateConfig,
}
impl Default for Config {
fn default() -> Self {
Self {
core: Default::default(),
request_manager: Default::default(),
reply_manager: Default::default(),
substrate: Default::default(),
}
}
}