Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Mixnet integration #14207

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
317 changes: 257 additions & 60 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ members = [
"client/keystore",
"client/merkle-mountain-range",
"client/merkle-mountain-range/rpc",
"client/mixnet",
"client/network",
"client/network/transactions",
"client/network/statement",
Expand Down Expand Up @@ -169,6 +170,7 @@ members = [
"frame/preimage",
"frame/proxy",
"frame/message-queue",
"frame/mixnet",
"frame/nfts",
"frame/nfts/runtime-api",
"frame/nft-fractionalization",
Expand Down Expand Up @@ -256,6 +258,7 @@ members = [
"primitives/maybe-compressed-blob",
"primitives/merkle-mountain-range",
"primitives/metadata-ir",
"primitives/mixnet",
"primitives/npos-elections",
"primitives/npos-elections/fuzzer",
"primitives/offchain",
Expand Down
2 changes: 2 additions & 0 deletions bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ sp-keystore = { version = "0.27.0", path = "../../../primitives/keystore" }
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
sp-transaction-storage-proof = { version = "4.0.0-dev", path = "../../../primitives/transaction-storage-proof" }
sp-io = { path = "../../../primitives/io" }
sp-mixnet = { version = "0.1.0-dev", path = "../../../primitives/mixnet" }
sp-statement-store = { path = "../../../primitives/statement-store" }

# client dependencies
Expand All @@ -82,6 +83,7 @@ sc-service = { version = "0.10.0-dev", default-features = false, path = "../../.
sc-telemetry = { version = "4.0.0-dev", path = "../../../client/telemetry" }
sc-executor = { version = "0.10.0-dev", path = "../../../client/executor" }
sc-authority-discovery = { version = "0.10.0-dev", path = "../../../client/authority-discovery" }
sc-mixnet = { version = "0.1.0-dev", path = "../../../client/mixnet" }
sc-sync-state-rpc = { version = "0.10.0-dev", path = "../../../client/sync-state-rpc" }
sc-sysinfo = { version = "6.0.0-dev", path = "../../../client/sysinfo" }
sc-storage-monitor = { version = "0.1.0", path = "../../../client/storage-monitor" }
Expand Down
2 changes: 1 addition & 1 deletion bin/node/cli/benches/block_production.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
wasm_runtime_overrides: None,
};

node_cli::service::new_full_base(config, false, |_, _| ())
node_cli::service::new_full_base(config, None, false, |_, _| ())
.expect("creating a full node doesn't fail")
}

Expand Down
2 changes: 1 addition & 1 deletion bin/node/cli/benches/transaction_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
wasm_runtime_overrides: None,
};

node_cli::service::new_full_base(config, false, |_, _| ()).expect("Creates node")
node_cli::service::new_full_base(config, None, false, |_, _| ()).expect("Creates node")
}

fn create_accounts(num: usize) -> Vec<sr25519::Pair> {
Expand Down
32 changes: 28 additions & 4 deletions bin/node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use serde::{Deserialize, Serialize};
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_consensus_babe::AuthorityId as BabeId;
use sp_core::{crypto::UncheckedInto, sr25519, Pair, Public};
use sp_mixnet::types::AuthorityId as MixnetId;
use sp_runtime::{
traits::{IdentifyAccount, Verify},
Perbill,
Expand Down Expand Up @@ -72,8 +73,9 @@ fn session_keys(
babe: BabeId,
im_online: ImOnlineId,
authority_discovery: AuthorityDiscoveryId,
mixnet: MixnetId,
) -> SessionKeys {
SessionKeys { grandpa, babe, im_online, authority_discovery }
SessionKeys { grandpa, babe, im_online, authority_discovery, mixnet }
}

fn staging_testnet_config_genesis() -> RuntimeGenesisConfig {
Expand All @@ -93,6 +95,7 @@ fn staging_testnet_config_genesis() -> RuntimeGenesisConfig {
BabeId,
ImOnlineId,
AuthorityDiscoveryId,
MixnetId,
)> = vec![
(
// 5Fbsd6WXDGiLTxunqeK5BATNiocfCqu9bS1yArVjCgeBLkVy
Expand All @@ -111,6 +114,9 @@ fn staging_testnet_config_genesis() -> RuntimeGenesisConfig {
// 5EZaeQ8djPcq9pheJUhgerXQZt9YaHnMJpiHMRhwQeinqUW8
array_bytes::hex2array_unchecked("6e7e4eb42cbd2e0ab4cae8708ce5509580b8c04d11f6758dbf686d50fe9f9106")
.unchecked_into(),
// 5EZaeQ8djPcq9pheJUhgerXQZt9YaHnMJpiHMRhwQeinqUW8
array_bytes::hex2array_unchecked("6e7e4eb42cbd2e0ab4cae8708ce5509580b8c04d11f6758dbf686d50fe9f9106")
.unchecked_into(),
),
(
// 5ERawXCzCWkjVq3xz1W5KGNtVx2VdefvZ62Bw1FEuZW4Vny2
Expand All @@ -129,6 +135,9 @@ fn staging_testnet_config_genesis() -> RuntimeGenesisConfig {
// 5DhLtiaQd1L1LU9jaNeeu9HJkP6eyg3BwXA7iNMzKm7qqruQ
array_bytes::hex2array_unchecked("482dbd7297a39fa145c570552249c2ca9dd47e281f0c500c971b59c9dcdcd82e")
.unchecked_into(),
// 5DhLtiaQd1L1LU9jaNeeu9HJkP6eyg3BwXA7iNMzKm7qqruQ
array_bytes::hex2array_unchecked("482dbd7297a39fa145c570552249c2ca9dd47e281f0c500c971b59c9dcdcd82e")
.unchecked_into(),
),
(
// 5DyVtKWPidondEu8iHZgi6Ffv9yrJJ1NDNLom3X9cTDi98qp
Expand All @@ -147,6 +156,9 @@ fn staging_testnet_config_genesis() -> RuntimeGenesisConfig {
// 5DhKqkHRkndJu8vq7pi2Q5S3DfftWJHGxbEUNH43b46qNspH
array_bytes::hex2array_unchecked("482a3389a6cf42d8ed83888cfd920fec738ea30f97e44699ada7323f08c3380a")
.unchecked_into(),
// 5DhKqkHRkndJu8vq7pi2Q5S3DfftWJHGxbEUNH43b46qNspH
array_bytes::hex2array_unchecked("482a3389a6cf42d8ed83888cfd920fec738ea30f97e44699ada7323f08c3380a")
.unchecked_into(),
),
(
// 5HYZnKWe5FVZQ33ZRJK1rG3WaLMztxWrrNDb1JRwaHHVWyP9
Expand All @@ -165,6 +177,9 @@ fn staging_testnet_config_genesis() -> RuntimeGenesisConfig {
// 5C4vDQxA8LTck2xJEy4Yg1hM9qjDt4LvTQaMo4Y8ne43aU6x
array_bytes::hex2array_unchecked("00299981a2b92f878baaf5dbeba5c18d4e70f2a1fcd9c61b32ea18daf38f4378")
.unchecked_into(),
// 5C4vDQxA8LTck2xJEy4Yg1hM9qjDt4LvTQaMo4Y8ne43aU6x
array_bytes::hex2array_unchecked("00299981a2b92f878baaf5dbeba5c18d4e70f2a1fcd9c61b32ea18daf38f4378")
.unchecked_into(),
),
];

Expand Down Expand Up @@ -217,14 +232,15 @@ where
/// Helper function to generate stash, controller and session key from seed
pub fn authority_keys_from_seed(
seed: &str,
) -> (AccountId, AccountId, GrandpaId, BabeId, ImOnlineId, AuthorityDiscoveryId) {
) -> (AccountId, AccountId, GrandpaId, BabeId, ImOnlineId, AuthorityDiscoveryId, MixnetId) {
(
get_account_id_from_seed::<sr25519::Public>(&format!("{}//stash", seed)),
get_account_id_from_seed::<sr25519::Public>(seed),
get_from_seed::<GrandpaId>(seed),
get_from_seed::<BabeId>(seed),
get_from_seed::<ImOnlineId>(seed),
get_from_seed::<AuthorityDiscoveryId>(seed),
get_from_seed::<MixnetId>(seed),
)
}

Expand All @@ -237,6 +253,7 @@ pub fn testnet_genesis(
BabeId,
ImOnlineId,
AuthorityDiscoveryId,
MixnetId,
)>,
initial_nominators: Vec<AccountId>,
root_key: AccountId,
Expand Down Expand Up @@ -306,7 +323,13 @@ pub fn testnet_genesis(
(
x.0.clone(),
x.0.clone(),
session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone()),
session_keys(
x.2.clone(),
x.3.clone(),
x.4.clone(),
x.5.clone(),
x.6.clone(),
),
)
})
.collect::<Vec<_>>(),
Expand Down Expand Up @@ -365,6 +388,7 @@ pub fn testnet_genesis(
..Default::default()
},
glutton: Default::default(),
mixnet: Default::default(),
}
}

Expand Down Expand Up @@ -473,7 +497,7 @@ pub(crate) mod tests {

sc_service_test::connectivity(integration_test_config_with_two_authorities(), |config| {
let NewFullBase { task_manager, client, network, sync, transaction_pool, .. } =
new_full_base(config, false, |_, _| ())?;
new_full_base(config, None, false, |_, _| ())?;
Ok(sc_service_test::TestNetComponents::new(
task_manager,
client,
Expand Down
4 changes: 4 additions & 0 deletions bin/node/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ pub struct Cli {
#[clap(flatten)]
pub run: sc_cli::RunCmd,

#[allow(missing_docs)]
#[clap(flatten)]
pub mixnet_params: sc_cli::MixnetParams,

/// Disable automatic hardware benchmarks.
///
/// By default these benchmarks are automatically ran at startup and measure
Expand Down
19 changes: 10 additions & 9 deletions bin/node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub fn run() -> Result<()> {
},
BenchmarkCmd::Block(cmd) => {
// ensure that we keep the task manager alive
let partial = new_partial(&config)?;
let partial = new_partial(&config, None)?;
cmd.run(partial.client)
},
#[cfg(not(feature = "runtime-benchmarks"))]
Expand All @@ -128,15 +128,15 @@ pub fn run() -> Result<()> {
#[cfg(feature = "runtime-benchmarks")]
BenchmarkCmd::Storage(cmd) => {
// ensure that we keep the task manager alive
let partial = new_partial(&config)?;
let partial = new_partial(&config, None)?;
let db = partial.backend.expose_db();
let storage = partial.backend.expose_storage();

cmd.run(config, partial.client, db, storage)
},
BenchmarkCmd::Overhead(cmd) => {
// ensure that we keep the task manager alive
let partial = new_partial(&config)?;
let partial = new_partial(&config, None)?;
let ext_builder = RemarkBuilder::new(partial.client.clone());

cmd.run(
Expand All @@ -149,7 +149,7 @@ pub fn run() -> Result<()> {
},
BenchmarkCmd::Extrinsic(cmd) => {
// ensure that we keep the task manager alive
let partial = service::new_partial(&config)?;
let partial = service::new_partial(&config, None)?;
// Register the *Remark* and *TKA* builders.
let ext_factory = ExtrinsicFactory(vec![
Box::new(RemarkBuilder::new(partial.client.clone())),
Expand Down Expand Up @@ -184,29 +184,29 @@ pub fn run() -> Result<()> {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, import_queue, .. } =
new_partial(&config)?;
new_partial(&config, None)?;
Ok((cmd.run(client, import_queue), task_manager))
})
},
Some(Subcommand::ExportBlocks(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, .. } = new_partial(&config)?;
let PartialComponents { client, task_manager, .. } = new_partial(&config, None)?;
Ok((cmd.run(client, config.database), task_manager))
})
},
Some(Subcommand::ExportState(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, .. } = new_partial(&config)?;
let PartialComponents { client, task_manager, .. } = new_partial(&config, None)?;
Ok((cmd.run(client, config.chain_spec), task_manager))
})
},
Some(Subcommand::ImportBlocks(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, import_queue, .. } =
new_partial(&config)?;
new_partial(&config, None)?;
Ok((cmd.run(client, import_queue), task_manager))
})
},
Expand All @@ -217,7 +217,8 @@ pub fn run() -> Result<()> {
Some(Subcommand::Revert(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, backend, .. } = new_partial(&config)?;
let PartialComponents { client, task_manager, backend, .. } =
new_partial(&config, None)?;
let aux_revert = Box::new(|client: Arc<FullClient>, backend, blocks| {
sc_consensus_babe::revert(client.clone(), backend, blocks)?;
grandpa::revert(client, blocks)?;
Expand Down
Loading