mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 12:17:58 +00:00
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:
@@ -589,6 +589,7 @@ impl_opaque_keys! {
|
||||
pub babe: Babe,
|
||||
pub im_online: ImOnline,
|
||||
pub authority_discovery: AuthorityDiscovery,
|
||||
pub mixnet: Mixnet,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1048,7 +1049,7 @@ impl pallet_democracy::Config for Runtime {
|
||||
pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 2, 3>;
|
||||
type InstantOrigin =
|
||||
pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 1, 1>;
|
||||
type InstantAllowed = frame_support::traits::ConstBool<true>;
|
||||
type InstantAllowed = ConstBool<true>;
|
||||
type FastTrackVotingPeriod = FastTrackVotingPeriod;
|
||||
// To cancel a proposal which has been passed, 2/3 of the council must agree to it.
|
||||
type CancellationOrigin =
|
||||
@@ -2028,6 +2029,29 @@ impl pallet_broker::Config for Runtime {
|
||||
type PriceAdapter = pallet_broker::Linear;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const MixnetNumCoverToCurrentBlocks: BlockNumber = 3;
|
||||
pub const MixnetNumRequestsToCurrentBlocks: BlockNumber = 3;
|
||||
pub const MixnetNumCoverToPrevBlocks: BlockNumber = 3;
|
||||
pub const MixnetNumRegisterStartSlackBlocks: BlockNumber = 3;
|
||||
pub const MixnetNumRegisterEndSlackBlocks: BlockNumber = 3;
|
||||
pub const MixnetRegistrationPriority: TransactionPriority = ImOnlineUnsignedPriority::get() - 1;
|
||||
}
|
||||
|
||||
impl pallet_mixnet::Config for Runtime {
|
||||
type MaxAuthorities = MaxAuthorities;
|
||||
type MaxExternalAddressSize = ConstU32<128>;
|
||||
type MaxExternalAddressesPerMixnode = ConstU32<16>;
|
||||
type NextSessionRotation = Babe;
|
||||
type NumCoverToCurrentBlocks = MixnetNumCoverToCurrentBlocks;
|
||||
type NumRequestsToCurrentBlocks = MixnetNumRequestsToCurrentBlocks;
|
||||
type NumCoverToPrevBlocks = MixnetNumCoverToPrevBlocks;
|
||||
type NumRegisterStartSlackBlocks = MixnetNumRegisterStartSlackBlocks;
|
||||
type NumRegisterEndSlackBlocks = MixnetNumRegisterEndSlackBlocks;
|
||||
type RegistrationPriority = MixnetRegistrationPriority;
|
||||
type MinMixnodes = ConstU32<7>; // Low to allow small testing networks
|
||||
}
|
||||
|
||||
construct_runtime!(
|
||||
pub struct Runtime
|
||||
{
|
||||
@@ -2104,6 +2128,7 @@ construct_runtime!(
|
||||
SafeMode: pallet_safe_mode,
|
||||
Statement: pallet_statement,
|
||||
Broker: pallet_broker,
|
||||
Mixnet: pallet_mixnet,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -2663,6 +2688,24 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_mixnet::runtime_api::MixnetApi<Block> for Runtime {
|
||||
fn session_status() -> sp_mixnet::types::SessionStatus {
|
||||
Mixnet::session_status()
|
||||
}
|
||||
|
||||
fn prev_mixnodes() -> Result<Vec<sp_mixnet::types::Mixnode>, sp_mixnet::types::MixnodesErr> {
|
||||
Mixnet::prev_mixnodes()
|
||||
}
|
||||
|
||||
fn current_mixnodes() -> Result<Vec<sp_mixnet::types::Mixnode>, sp_mixnet::types::MixnodesErr> {
|
||||
Mixnet::current_mixnodes()
|
||||
}
|
||||
|
||||
fn maybe_register(session_index: sp_mixnet::types::SessionIndex, mixnode: sp_mixnet::types::Mixnode) -> bool {
|
||||
Mixnet::maybe_register(session_index, mixnode)
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_session::SessionKeys<Block> for Runtime {
|
||||
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
|
||||
SessionKeys::generate(seed)
|
||||
|
||||
Reference in New Issue
Block a user