diff --git a/.rustfmt.toml b/.rustfmt.toml index 9847684..441913f 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,8 +1,23 @@ -binop_separator = "Front" -brace_style = "SameLineWhere" -edition = "2018" -format_code_in_doc_comments = true -imports_granularity = "Preserve" -imports_layout = "Mixed" -indent_style = "Block" -match_arm_leading_pipes = "Always" +# Basic +hard_tabs = true +max_width = 100 +use_small_heuristics = "Max" +# Imports +imports_granularity = "Crate" +reorder_imports = true +# Consistency +newline_style = "Unix" +# Format comments +comment_width = 100 +wrap_comments = true +# Misc +chain_width = 80 +spaces_around_ranges = false +binop_separator = "Back" +reorder_impl_items = false +match_arm_leading_pipes = "Preserve" +match_arm_blocks = false +match_block_trailing_comma = true +trailing_comma = "Vertical" +trailing_semicolon = false +use_field_init_shorthand = true diff --git a/Cargo.lock b/Cargo.lock index 70b7da6..0122a79 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3917,20 +3917,6 @@ dependencies = [ "sp-timestamp", ] -[[package]] -name = "pallet-trackback" -version = "0.0.1" -dependencies = [ - "frame-support", - "frame-system", - "parity-scale-codec", - "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-transaction-payment" version = "3.0.0" @@ -7771,7 +7757,6 @@ dependencies = [ "pallet-session", "pallet-sudo", "pallet-timestamp", - "pallet-trackback", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", "parity-scale-codec", diff --git a/LICENSE b/LICENCE similarity index 100% rename from LICENSE rename to LICENCE diff --git a/Limitations.md b/Limitations.md new file mode 100644 index 0000000..ee3d41e --- /dev/null +++ b/Limitations.md @@ -0,0 +1,18 @@ +# TrackBack Node Limitations (Minimum Viable Product). + + +## Disclaimer +* This node created as minimum viable product +* Do not use ina production environment +* Released for test purposes only + +## Limitations +* No [token](https://docs.substrate.io/how-to-guides/v3/basics/mint-token/) economic models around managing Decentralised Identifiers +* No staking rewards +* Default configuration has 2 validators and a not well known node ( 3 node network ) +* OnChain data will recycle after 6 weeks ( subject to change ) +* Does not have the complete functionality for [DIDComms](https://identity.foundation/didcomm-messaging/spec/) +* Covers the functionality for creation, revocation, update and retrieve a DID only +* Provides support for Ledger based DIDs only. +* Does not cover Ledger Middleware DIDs, Peer DIDs, Static DIDs and Alternative DIDs +* Tight bindings between a Controller and the Chain limited to default accounts diff --git a/README.md b/README.md index 7b1574c..d003a27 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ -

TrackBack

-Blockchain for decentralised identifiers and verifiable credentials. +Blockchain for `Self Sovereign Identity`, `Decentralised Identifiers` and `Verifiable Credentials` .
Substrate 3.0.0 @@ -15,9 +14,16 @@ Blockchain for decentralised identifiers and verifiable credentials. Substrate 3.0.0 + +TrackBack-Node 0.0.1 + + ## Features -* DID Pallet -* Verifiable Credential Pallet (Late 2021) +* DID Pallet +* Verifiable Credentials Pallet (Q2-2021) + +# Limitations +* [Limitations](Limitations.md) ## Setting up the chain * [Install](https://substrate.dev/docs/en/knowledgebase/getting-started/) substrate diff --git a/buildspec.yml b/buildspec.yml index cb11fef..1f34fb6 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -32,7 +32,7 @@ phases: - COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7) - IMAGE_TAG=latest - echo "Build docker image" - - docker build -t ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${IMAGE_NAME}:${IMAGE_TAG} . + - docker build -f ./docker/Dockerfile.prod -t ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${IMAGE_NAME}:${IMAGE_TAG} . build: commands: - echo "Login to ECR" diff --git a/docker-compose.dev.yml b/deployment/docker-compose.dev.yml similarity index 100% rename from docker-compose.dev.yml rename to deployment/docker-compose.dev.yml diff --git a/docker-compose.yml b/deployment/docker-compose.yml similarity index 100% rename from docker-compose.yml rename to deployment/docker-compose.yml diff --git a/docker-prom.yaml b/deployment/docker-prom.yaml similarity index 100% rename from docker-prom.yaml rename to deployment/docker-prom.yaml diff --git a/Dockerfile b/docker/Dockerfile similarity index 78% rename from Dockerfile rename to docker/Dockerfile index b25d2ab..4b858df 100644 --- a/Dockerfile +++ b/docker/Dockerfile @@ -5,11 +5,11 @@ WORKDIR /build ARG FEATURES=default COPY ./.git/ /build/.git/ -COPY ./node /build/node -COPY ./pallets /build/pallets -COPY ./runtime /build/runtime -COPY ./Cargo.lock /build/Cargo.lock -COPY ./Cargo.toml /build/Cargo.toml +COPY ../node /build/node +COPY ../pallets /build/pallets +COPY ../runtime /build/runtime +COPY ../Cargo.lock /build/Cargo.lock +COPY ../Cargo.toml /build/Cargo.toml RUN cargo build --release --features $FEATURES @@ -20,7 +20,7 @@ ARG WEB_SOCKET_PORT=9944 ARG P2P_PORT=30333 ARG NODE_TYPE=trackback-node -COPY ./LICENSE /build/LICENSE +COPY ../LICENCE /build/LICENSE COPY --from=builder /build/target/release/$NODE_TYPE /usr/local/bin/node-executable RUN useradd -m -u 1000 -U -s /bin/sh -d /node node && \ diff --git a/Dockerfile.dev b/docker/Dockerfile.dev similarity index 100% rename from Dockerfile.dev rename to docker/Dockerfile.dev diff --git a/docker/Dockerfile.prod b/docker/Dockerfile.prod index 02822ed..2649519 100644 --- a/docker/Dockerfile.prod +++ b/docker/Dockerfile.prod @@ -20,7 +20,7 @@ ARG WEB_SOCKET_PORT=9944 ARG P2P_PORT=30333 ARG NODE_TYPE=trackback-node -COPY ./LICENSE /build/LICENSE +COPY ./LICENCE /build/LICENCE COPY --from=builder /build/target/release/$NODE_TYPE /usr/local/bin/node-executable RUN useradd -m -u 1000 -U -s /bin/sh -d /node node && \ diff --git a/makefile b/makefile index 760a09b..11b1273 100644 --- a/makefile +++ b/makefile @@ -1,7 +1,6 @@ #!make SHELL:=/bin/bash -.DEFAULT=all export PROJECT_NAME := tanz-demo-node export TARGET_PORT := 80 @@ -10,11 +9,6 @@ export ECR_REPO_URL := 533545012068.dkr.ecr.ap-southeast-2.amazonaws.com export VERSION := latest export BRANCH_NAME :=$(shell git branch --show-current) -all: deploy - -destroy: - cd terraform/ap-southeast-2/deployec2 && terraform destroy -var="branch_name=$(BRANCH_NAME)" --auto-approve - ecr: aws ecr get-login-password \ --region ${REGION} \ @@ -28,8 +22,5 @@ build: ecr docker tag $(PROJECT_NAME):latest $(ECR_REPO_URL)/$(PROJECT_NAME):$(VERSION) docker push $(ECR_REPO_URL)/$(PROJECT_NAME):$(VERSION) -deploy: destroy - cd terraform/ap-southeast-2/deployec2 && terraform apply -var="branch_name=$(BRANCH_NAME)" --auto-approve - run-dev: ecr - docker-compose -f docker-compose.dev.yml up --build --force-recreate --remove-orphans -d + docker-compose -f ./deployment/docker-compose.dev.yml up --build --force-recreate --remove-orphans -d diff --git a/node/build.rs b/node/build.rs index e6a912e..a5b1735 100644 --- a/node/build.rs +++ b/node/build.rs @@ -1,6 +1,6 @@ use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed}; fn main() { - generate_cargo_keys(); - rerun_if_git_head_changed(); + generate_cargo_keys(); + rerun_if_git_head_changed(); } diff --git a/node/chain_specs/live-net.json b/node/chain_specs/live-net.json deleted file mode 100644 index e69de29..0000000 diff --git a/node/chain_specs/test-net.json b/node/chain_specs/test-net.json index 234ea1d..7ceaf18 100644 --- a/node/chain_specs/test-net.json +++ b/node/chain_specs/test-net.json @@ -93,5 +93,4 @@ "key": "5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu" } } - } -} + }, diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index cac2f2f..2394b23 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -1,13 +1,12 @@ -use trackback_node_runtime::{ - AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, Signature, SudoConfig, - SystemConfig, WASM_BINARY, -}; use sc_service::ChainType; use sp_consensus_aura::sr25519::AuthorityId as AuraId; -use sp_core::{sr25519, Pair, Public, OpaquePeerId}; +use sp_core::{sr25519, OpaquePeerId, Pair, Public}; use sp_finality_grandpa::AuthorityId as GrandpaId; use sp_runtime::traits::{IdentifyAccount, Verify}; -use trackback_node_runtime::NodeAuthorizationConfig; +use trackback_node_runtime::{ + AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, NodeAuthorizationConfig, + Signature, SudoConfig, SystemConfig, WASM_BINARY, +}; // The URL for the telemetry server. // const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; @@ -16,9 +15,9 @@ pub type ChainSpec = sc_service::GenericChainSpec; /// Generate a crypto pair from seed. pub fn get_from_seed(seed: &str) -> ::Public { - TPublic::Pair::from_string(&format!("//{}", seed), None) - .expect("static values are valid; qed") - .public() + TPublic::Pair::from_string(&format!("//{}", seed), None) + .expect("static values are valid; qed") + .public() } type AccountPublic = ::Signer; @@ -26,161 +25,157 @@ type AccountPublic = ::Signer; /// Generate an account ID from seed. pub fn get_account_id_from_seed(seed: &str) -> AccountId where - AccountPublic: From<::Public>, + AccountPublic: From<::Public>, { - AccountPublic::from(get_from_seed::(seed)).into_account() + AccountPublic::from(get_from_seed::(seed)).into_account() } /// Generate an Aura authority key. pub fn authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) { - (get_from_seed::(s), get_from_seed::(s)) + (get_from_seed::(s), get_from_seed::(s)) } pub fn development_config() -> Result { - let wasm_binary = - WASM_BINARY.ok_or_else(|| "Development wasm binary not available".to_string())?; + let wasm_binary = + WASM_BINARY.ok_or_else(|| "Development wasm binary not available".to_string())?; - Ok(ChainSpec::from_genesis( - // Name - "Development", - // ID - "dev", - ChainType::Development, - move || { - testnet_genesis( - wasm_binary, - // Initial PoA authorities - vec![authority_keys_from_seed("Alice")], - // Sudo account - get_account_id_from_seed::("Alice"), - // Pre-funded accounts - vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Alice//stash"), - get_account_id_from_seed::("Bob//stash"), - ], - true, - ) - }, - // Bootnodes - vec![], - // Telemetry - None, - // Protocol ID - None, - // Properties - None, - // Extensions - None, - )) + Ok(ChainSpec::from_genesis( + // Name + "Development", + // ID + "dev", + ChainType::Development, + move || { + testnet_genesis( + wasm_binary, + // Initial PoA authorities + vec![authority_keys_from_seed("Alice")], + // Sudo account + get_account_id_from_seed::("Alice"), + // Pre-funded accounts + vec![ + get_account_id_from_seed::("Alice"), + get_account_id_from_seed::("Bob"), + get_account_id_from_seed::("Alice//stash"), + get_account_id_from_seed::("Bob//stash"), + ], + true, + ) + }, + // Bootnodes + vec![], + // Telemetry + None, + // Protocol ID + None, + // Properties + None, + // Extensions + None, + )) } pub fn test_net_config() -> ChainSpec { - // ChainSpec::from_json_file(PathBuf::from("../chain_specs/test-net.json")).unwrap() - ChainSpec::from_json_bytes(&include_bytes!("../chain_specs/staging-net.json")[..]).unwrap() + ChainSpec::from_json_bytes(&include_bytes!("../chain_specs/staging-net.json")[..]).unwrap() } pub fn local_testnet_config() -> Result { - let wasm_binary = - WASM_BINARY.ok_or_else(|| "Development wasm binary not available".to_string())?; + let wasm_binary = + WASM_BINARY.ok_or_else(|| "Development wasm binary not available".to_string())?; - Ok(ChainSpec::from_genesis( - // Name - "Local Testnet", - // ID - "local_testnet", - ChainType::Local, - move || { - testnet_genesis( - wasm_binary, - // Initial PoA authorities - vec![ - authority_keys_from_seed("Alice"), - authority_keys_from_seed("Bob"), - ], - // Sudo account - get_account_id_from_seed::("Alice"), - // Pre-funded accounts - vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Charlie"), - get_account_id_from_seed::("Dave"), - get_account_id_from_seed::("Eve"), - get_account_id_from_seed::("Ferdie"), - get_account_id_from_seed::("Alice//stash"), - get_account_id_from_seed::("Bob//stash"), - get_account_id_from_seed::("Charlie//stash"), - get_account_id_from_seed::("Dave//stash"), - get_account_id_from_seed::("Eve//stash"), - get_account_id_from_seed::("Ferdie//stash"), - ], - true, - ) - }, - // Bootnodes - vec![], - // Telemetry - None, - // Protocol ID - None, - // Properties - None, - // Extensions - None, - )) + Ok(ChainSpec::from_genesis( + // Name + "Local Testnet", + // ID + "local_testnet", + ChainType::Local, + move || { + testnet_genesis( + wasm_binary, + // Initial PoA authorities + vec![authority_keys_from_seed("Alice"), authority_keys_from_seed("Bob")], + // Sudo account + get_account_id_from_seed::("Alice"), + // Pre-funded accounts + vec![ + get_account_id_from_seed::("Alice"), + get_account_id_from_seed::("Bob"), + get_account_id_from_seed::("Charlie"), + get_account_id_from_seed::("Dave"), + get_account_id_from_seed::("Eve"), + get_account_id_from_seed::("Ferdie"), + get_account_id_from_seed::("Alice//stash"), + get_account_id_from_seed::("Bob//stash"), + get_account_id_from_seed::("Charlie//stash"), + get_account_id_from_seed::("Dave//stash"), + get_account_id_from_seed::("Eve//stash"), + get_account_id_from_seed::("Ferdie//stash"), + ], + true, + ) + }, + // Bootnodes + vec![], + // Telemetry + None, + // Protocol ID + None, + // Properties + None, + // Extensions + None, + )) } /// Configure initial storage state for FRAME modules. fn testnet_genesis( - wasm_binary: &[u8], - initial_authorities: Vec<(AuraId, GrandpaId)>, - root_key: AccountId, - endowed_accounts: Vec, - _enable_println: bool, + wasm_binary: &[u8], + initial_authorities: Vec<(AuraId, GrandpaId)>, + root_key: AccountId, + endowed_accounts: Vec, + _enable_println: bool, ) -> GenesisConfig { - GenesisConfig { - frame_system: Some(SystemConfig { - // Add Wasm runtime to storage. - code: wasm_binary.to_vec(), - changes_trie_config: Default::default(), - }), - pallet_balances: Some(BalancesConfig { - // Configure endowed accounts with initial balance of 1 << 60. - balances: endowed_accounts - .iter() - .cloned() - .map(|k| (k, 1 << 60)) - .collect(), - }), - pallet_aura: Some(AuraConfig { - authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(), - }), - pallet_grandpa: Some(GrandpaConfig { - authorities: initial_authorities - .iter() - .map(|x| (x.1.clone(), 1)) - .collect(), - }), - pallet_sudo: Some(SudoConfig { - // Assign network admin rights. - key: root_key, - }), - // TODO: this configuration is only for MVP chain - // TODO: Change this for live net - pallet_node_authorization: Some(NodeAuthorizationConfig { - nodes: vec![ - ( - OpaquePeerId(bs58::decode("12D3KooWBmAwcd4PJNJvfV89HwE48nwkRmAgo8Vy3uQEyNNHBox2").into_vec().unwrap()), - endowed_accounts[0].clone() - ), - ( - OpaquePeerId(bs58::decode("12D3KooWQYV9dGMFoRzNStwpXztXaBUjtPqi6aU76ZgUriHhKust").into_vec().unwrap()), - endowed_accounts[1].clone() - ), - ], - }), - - } + GenesisConfig { + frame_system: Some(SystemConfig { + // Add Wasm runtime to storage. + code: wasm_binary.to_vec(), + changes_trie_config: Default::default(), + }), + pallet_balances: Some(BalancesConfig { + // Configure endowed accounts with initial balance of 1 << 60. + balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(), + }), + pallet_aura: Some(AuraConfig { + authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(), + }), + pallet_grandpa: Some(GrandpaConfig { + authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(), + }), + pallet_sudo: Some(SudoConfig { + // Assign network admin rights. + key: root_key, + }), + // TODO: this configuration is only for MVP chain + // TODO: Change this for live net + pallet_node_authorization: Some(NodeAuthorizationConfig { + nodes: vec![ + ( + OpaquePeerId( + bs58::decode("12D3KooWBmAwcd4PJNJvfV89HwE48nwkRmAgo8Vy3uQEyNNHBox2") + .into_vec() + .unwrap(), + ), + endowed_accounts[0].clone(), + ), + ( + OpaquePeerId( + bs58::decode("12D3KooWQYV9dGMFoRzNStwpXztXaBUjtPqi6aU76ZgUriHhKust") + .into_vec() + .unwrap(), + ), + endowed_accounts[1].clone(), + ), + ], + }), + } } diff --git a/node/src/cli.rs b/node/src/cli.rs index c6f3515..8b55105 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -3,39 +3,39 @@ use structopt::StructOpt; #[derive(Debug, StructOpt)] pub struct Cli { - #[structopt(subcommand)] - pub subcommand: Option, + #[structopt(subcommand)] + pub subcommand: Option, - #[structopt(flatten)] - pub run: RunCmd, + #[structopt(flatten)] + pub run: RunCmd, } #[derive(Debug, StructOpt)] pub enum Subcommand { - /// Key management cli utilities - Key(sc_cli::KeySubcommand), - /// Build a chain specification. - BuildSpec(sc_cli::BuildSpecCmd), + /// Key management cli utilities + Key(sc_cli::KeySubcommand), + /// Build a chain specification. + BuildSpec(sc_cli::BuildSpecCmd), - /// Validate blocks. - CheckBlock(sc_cli::CheckBlockCmd), + /// Validate blocks. + CheckBlock(sc_cli::CheckBlockCmd), - /// Export blocks. - ExportBlocks(sc_cli::ExportBlocksCmd), + /// Export blocks. + ExportBlocks(sc_cli::ExportBlocksCmd), - /// Export the state of a given block into a chain spec. - ExportState(sc_cli::ExportStateCmd), + /// Export the state of a given block into a chain spec. + ExportState(sc_cli::ExportStateCmd), - /// Import blocks. - ImportBlocks(sc_cli::ImportBlocksCmd), + /// Import blocks. + ImportBlocks(sc_cli::ImportBlocksCmd), - /// Remove the whole chain. - PurgeChain(sc_cli::PurgeChainCmd), + /// Remove the whole chain. + PurgeChain(sc_cli::PurgeChainCmd), - /// Revert the chain to a previous state. - Revert(sc_cli::RevertCmd), + /// Revert the chain to a previous state. + Revert(sc_cli::RevertCmd), - /// The custom benchmark subcommmand benchmarking runtime pallets. - #[structopt(name = "benchmark", about = "Benchmark runtime pallets.")] - Benchmark(frame_benchmarking_cli::BenchmarkCmd), + /// The custom benchmark subcommmand benchmarking runtime pallets. + #[structopt(name = "benchmark", about = "Benchmark runtime pallets.")] + Benchmark(frame_benchmarking_cli::BenchmarkCmd), } diff --git a/node/src/command.rs b/node/src/command.rs index 0878a79..79c89fb 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -15,145 +15,126 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::cli::{Cli, Subcommand}; -use crate::{chain_spec, service}; -use trackback_node_runtime::Block; +use crate::{ + chain_spec, + cli::{Cli, Subcommand}, + service, +}; use sc_cli::{ChainSpec, Role, RuntimeVersion, SubstrateCli}; use sc_service::PartialComponents; +use trackback_node_runtime::Block; impl SubstrateCli for Cli { - fn impl_name() -> String { - "Substrate Node".into() - } + fn impl_name() -> String { + "Substrate Node".into() + } - fn impl_version() -> String { - env!("SUBSTRATE_CLI_IMPL_VERSION").into() - } + fn impl_version() -> String { + env!("SUBSTRATE_CLI_IMPL_VERSION").into() + } - fn description() -> String { - env!("CARGO_PKG_DESCRIPTION").into() - } + fn description() -> String { + env!("CARGO_PKG_DESCRIPTION").into() + } - fn author() -> String { - env!("CARGO_PKG_AUTHORS").into() - } + fn author() -> String { + env!("CARGO_PKG_AUTHORS").into() + } - fn support_url() -> String { - "support.anonymous.an".into() - } + fn support_url() -> String { + "support.anonymous.an".into() + } - fn copyright_start_year() -> i32 { - 2017 - } + fn copyright_start_year() -> i32 { + 2017 + } - fn load_spec(&self, id: &str) -> Result, String> { - Ok(match id { - | "dev" => Box::new(chain_spec::development_config()?), - | "" | "local" => Box::new(chain_spec::local_testnet_config()?), - | "test-net" => Box::new(chain_spec::test_net_config()), - | path => Box::new(chain_spec::ChainSpec::from_json_file( - std::path::PathBuf::from(path), - )?), - }) - } + fn load_spec(&self, id: &str) -> Result, String> { + Ok(match id { + | "dev" => Box::new(chain_spec::development_config()?), + | "" | "local" => Box::new(chain_spec::local_testnet_config()?), + | "test-net" => Box::new(chain_spec::test_net_config()), + | path => + Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?), + }) + } - fn native_runtime_version(_: &Box) -> &'static RuntimeVersion { - &trackback_node_runtime::VERSION - } + fn native_runtime_version(_: &Box) -> &'static RuntimeVersion { + &trackback_node_runtime::VERSION + } } /// Parse and run command line arguments pub fn run() -> sc_cli::Result<()> { - let cli = Cli::from_args(); + let cli = Cli::from_args(); - match &cli.subcommand { - | Some(Subcommand::Key(cmd)) => cmd.run(&cli), - | Some(Subcommand::BuildSpec(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.sync_run(|config| cmd.run(config.chain_spec, config.network)) - } - | Some(Subcommand::CheckBlock(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|config| { - let PartialComponents { - client, - task_manager, - import_queue, - .. - } = service::new_partial(&config)?; - 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, - .. - } = service::new_partial(&config)?; - 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, - .. - } = service::new_partial(&config)?; - 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, - .. - } = service::new_partial(&config)?; - Ok((cmd.run(client, import_queue), task_manager)) - }) - } - | Some(Subcommand::PurgeChain(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.sync_run(|config| cmd.run(config.database)) - } - | Some(Subcommand::Revert(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|config| { - let PartialComponents { - client, - task_manager, - backend, - .. - } = service::new_partial(&config)?; - Ok((cmd.run(client, backend), task_manager)) - }) - } - | Some(Subcommand::Benchmark(cmd)) => { - if cfg!(feature = "runtime-benchmarks") { - let runner = cli.create_runner(cmd)?; + match &cli.subcommand { + | Some(Subcommand::Key(cmd)) => cmd.run(&cli), + | Some(Subcommand::BuildSpec(cmd)) => { + let runner = cli.create_runner(cmd)?; + runner.sync_run(|config| cmd.run(config.chain_spec, config.network)) + }, + | Some(Subcommand::CheckBlock(cmd)) => { + let runner = cli.create_runner(cmd)?; + runner.async_run(|config| { + let PartialComponents { client, task_manager, import_queue, .. } = + service::new_partial(&config)?; + 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, .. } = service::new_partial(&config)?; + 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, .. } = service::new_partial(&config)?; + 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, .. } = + service::new_partial(&config)?; + Ok((cmd.run(client, import_queue), task_manager)) + }) + }, + | Some(Subcommand::PurgeChain(cmd)) => { + let runner = cli.create_runner(cmd)?; + runner.sync_run(|config| cmd.run(config.database)) + }, + | Some(Subcommand::Revert(cmd)) => { + let runner = cli.create_runner(cmd)?; + runner.async_run(|config| { + let PartialComponents { client, task_manager, backend, .. } = + service::new_partial(&config)?; + Ok((cmd.run(client, backend), task_manager)) + }) + }, + | Some(Subcommand::Benchmark(cmd)) => + if cfg!(feature = "runtime-benchmarks") { + let runner = cli.create_runner(cmd)?; - runner.sync_run(|config| cmd.run::(config)) - } else { - Err("Benchmarking wasn't enabled when building the node. \ + runner.sync_run(|config| cmd.run::(config)) + } else { + Err("Benchmarking wasn't enabled when building the node. \ You can enable it with `--features runtime-benchmarks`." - .into()) - } - } - | None => { - let runner = cli.create_runner(&cli.run)?; - runner.run_node_until_exit(|config| async move { - match config.role { - | Role::Light => service::new_light(config), - | _ => service::new_full(config), - } - .map_err(sc_cli::Error::Service) - }) - } - } + .into()) + }, + | None => { + let runner = cli.create_runner(&cli.run)?; + runner.run_node_until_exit(|config| async move { + match config.role { + | Role::Light => service::new_light(config), + | _ => service::new_full(config), + } + .map_err(sc_cli::Error::Service) + }) + }, + } } diff --git a/node/src/main.rs b/node/src/main.rs index a4182cd..4449d28 100644 --- a/node/src/main.rs +++ b/node/src/main.rs @@ -9,5 +9,5 @@ mod command; mod rpc; fn main() -> sc_cli::Result<()> { - command::run() + command::run() } diff --git a/node/src/rpc.rs b/node/src/rpc.rs index b05e0ab..1f9970f 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -7,58 +7,48 @@ use std::sync::Arc; -use trackback_node_runtime::{opaque::Block, AccountId, Balance, Index}; pub use sc_rpc_api::DenyUnsafe; use sp_api::ProvideRuntimeApi; use sp_block_builder::BlockBuilder; use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; use sp_transaction_pool::TransactionPool; +use trackback_node_runtime::{opaque::Block, AccountId, Balance, Index}; /// Full client dependencies. pub struct FullDeps { - /// The client instance to use. - pub client: Arc, - /// Transaction pool instance. - pub pool: Arc

, - /// Whether to deny unsafe calls - pub deny_unsafe: DenyUnsafe, + /// The client instance to use. + pub client: Arc, + /// Transaction pool instance. + pub pool: Arc

, + /// Whether to deny unsafe calls + pub deny_unsafe: DenyUnsafe, } /// Instantiate all full RPC extensions. pub fn create_full(deps: FullDeps) -> jsonrpc_core::IoHandler where - C: ProvideRuntimeApi, - C: HeaderBackend + HeaderMetadata + 'static, - C: Send + Sync + 'static, - C::Api: substrate_frame_rpc_system::AccountNonceApi, - C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, - C::Api: BlockBuilder, - P: TransactionPool + 'static, + C: ProvideRuntimeApi, + C: HeaderBackend + HeaderMetadata + 'static, + C: Send + Sync + 'static, + C::Api: substrate_frame_rpc_system::AccountNonceApi, + C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, + C::Api: BlockBuilder, + P: TransactionPool + 'static, { - use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; - use substrate_frame_rpc_system::{FullSystem, SystemApi}; + use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; + use substrate_frame_rpc_system::{FullSystem, SystemApi}; - let mut io = jsonrpc_core::IoHandler::default(); - let FullDeps { - client, - pool, - deny_unsafe, - } = deps; + let mut io = jsonrpc_core::IoHandler::default(); + let FullDeps { client, pool, deny_unsafe } = deps; - io.extend_with(SystemApi::to_delegate(FullSystem::new( - client.clone(), - pool, - deny_unsafe, - ))); + io.extend_with(SystemApi::to_delegate(FullSystem::new(client.clone(), pool, deny_unsafe))); - io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new( - client.clone(), - ))); + io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(client.clone()))); - // Extend this RPC with a custom API by using the following syntax. - // `YourRpcStruct` should have a reference to a client, which is needed - // to call into the runtime. - // `io.extend_with(YourRpcTrait::to_delegate(YourRpcStruct::new(ReferenceToClient, ...)));` + // Extend this RPC with a custom API by using the following syntax. + // `YourRpcStruct` should have a reference to a client, which is needed + // to call into the runtime. + // `io.extend_with(YourRpcTrait::to_delegate(YourRpcStruct::new(ReferenceToClient, ...)));` - io + io } diff --git a/node/src/service.rs b/node/src/service.rs index 16f29f3..5e92810 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -1,6 +1,5 @@ //! Service and ServiceFactory implementation. Specialized wrapper over substrate service. -use trackback_node_runtime::{self, opaque::Block, RuntimeApi}; use sc_client_api::{ExecutorProvider, RemoteBackend}; use sc_executor::native_executor_instance; pub use sc_executor::NativeExecutor; @@ -9,15 +8,15 @@ use sc_keystore::LocalKeystore; use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; use sp_inherents::InherentDataProviders; -use std::sync::Arc; -use std::time::Duration; +use std::{sync::Arc, time::Duration}; +use trackback_node_runtime::{self, opaque::Block, RuntimeApi}; // Our native executor instance. native_executor_instance!( - pub Executor, - trackback_node_runtime::api::dispatch, - trackback_node_runtime::native_version, - frame_benchmarking::benchmarking::HostFunctions, + pub Executor, + trackback_node_runtime::api::dispatch, + trackback_node_runtime::native_version, + frame_benchmarking::benchmarking::HostFunctions, ); type FullClient = sc_service::TFullClient; @@ -25,342 +24,325 @@ type FullBackend = sc_service::TFullBackend; type FullSelectChain = sc_consensus::LongestChain; pub fn new_partial( - config: &Configuration, + config: &Configuration, ) -> Result< - sc_service::PartialComponents< - FullClient, - FullBackend, - FullSelectChain, - sp_consensus::DefaultImportQueue, - sc_transaction_pool::FullPool, - ( - sc_consensus_aura::AuraBlockImport< - Block, - FullClient, - sc_finality_grandpa::GrandpaBlockImport< - FullBackend, - Block, - FullClient, - FullSelectChain, - >, - AuraPair, - >, - sc_finality_grandpa::LinkHalf, - ), - >, - ServiceError, + sc_service::PartialComponents< + FullClient, + FullBackend, + FullSelectChain, + sp_consensus::DefaultImportQueue, + sc_transaction_pool::FullPool, + ( + sc_consensus_aura::AuraBlockImport< + Block, + FullClient, + sc_finality_grandpa::GrandpaBlockImport< + FullBackend, + Block, + FullClient, + FullSelectChain, + >, + AuraPair, + >, + sc_finality_grandpa::LinkHalf, + ), + >, + ServiceError, > { - if config.keystore_remote.is_some() { - return Err(ServiceError::Other(format!( - "Remote Keystores are not supported." - ))); - } - let inherent_data_providers = sp_inherents::InherentDataProviders::new(); - - let (client, backend, keystore_container, task_manager) = - sc_service::new_full_parts::(&config)?; - let client = Arc::new(client); - - let select_chain = sc_consensus::LongestChain::new(backend.clone()); - - let transaction_pool = sc_transaction_pool::BasicPool::new_full( - config.transaction_pool.clone(), - config.role.is_authority().into(), - config.prometheus_registry(), - task_manager.spawn_handle(), - client.clone(), - ); - - let (grandpa_block_import, grandpa_link) = sc_finality_grandpa::block_import( - client.clone(), - &(client.clone() as Arc<_>), - select_chain.clone(), - )?; - - let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new( - grandpa_block_import.clone(), - client.clone(), - ); - - let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>( - sc_consensus_aura::slot_duration(&*client)?, - aura_block_import.clone(), - Some(Box::new(grandpa_block_import.clone())), - client.clone(), - inherent_data_providers.clone(), - &task_manager.spawn_handle(), - config.prometheus_registry(), - sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()), - )?; - - Ok(sc_service::PartialComponents { - client, - backend, - task_manager, - import_queue, - keystore_container, - select_chain, - transaction_pool, - inherent_data_providers, - other: (aura_block_import, grandpa_link), - }) + if config.keystore_remote.is_some() { + return Err(ServiceError::Other(format!("Remote Keystores are not supported."))) + } + let inherent_data_providers = sp_inherents::InherentDataProviders::new(); + + let (client, backend, keystore_container, task_manager) = + sc_service::new_full_parts::(&config)?; + let client = Arc::new(client); + + let select_chain = sc_consensus::LongestChain::new(backend.clone()); + + let transaction_pool = sc_transaction_pool::BasicPool::new_full( + config.transaction_pool.clone(), + config.role.is_authority().into(), + config.prometheus_registry(), + task_manager.spawn_handle(), + client.clone(), + ); + + let (grandpa_block_import, grandpa_link) = sc_finality_grandpa::block_import( + client.clone(), + &(client.clone() as Arc<_>), + select_chain.clone(), + )?; + + let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new( + grandpa_block_import.clone(), + client.clone(), + ); + + let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>( + sc_consensus_aura::slot_duration(&*client)?, + aura_block_import.clone(), + Some(Box::new(grandpa_block_import.clone())), + client.clone(), + inherent_data_providers.clone(), + &task_manager.spawn_handle(), + config.prometheus_registry(), + sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()), + )?; + + Ok(sc_service::PartialComponents { + client, + backend, + task_manager, + import_queue, + keystore_container, + select_chain, + transaction_pool, + inherent_data_providers, + other: (aura_block_import, grandpa_link), + }) } fn remote_keystore(_url: &String) -> Result, &'static str> { - // FIXME: here would the concrete keystore be built, - // must return a concrete type (NOT `LocalKeystore`) that - // implements `CryptoStore` and `SyncCryptoStore` - Err("Remote Keystore not supported.") + // FIXME: here would the concrete keystore be built, + // must return a concrete type (NOT `LocalKeystore`) that + // implements `CryptoStore` and `SyncCryptoStore` + Err("Remote Keystore not supported.") } /// Builds a new service for a full client. pub fn new_full(mut config: Configuration) -> Result { - let sc_service::PartialComponents { - client, - backend, - mut task_manager, - import_queue, - mut keystore_container, - select_chain, - transaction_pool, - inherent_data_providers, - other: (block_import, grandpa_link), - } = new_partial(&config)?; - - if let Some(url) = &config.keystore_remote { - match remote_keystore(url) { - | Ok(k) => keystore_container.set_remote_keystore(k), - | Err(e) => { - return Err(ServiceError::Other(format!( - "Error hooking up remote keystore for {}: {}", - url, e - ))) - } - }; - } - - config - .network - .extra_sets - .push(sc_finality_grandpa::grandpa_peers_set_config()); - - let (network, network_status_sinks, system_rpc_tx, network_starter) = - sc_service::build_network(sc_service::BuildNetworkParams { - config: &config, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - spawn_handle: task_manager.spawn_handle(), - import_queue, - on_demand: None, - block_announce_validator_builder: None, - })?; - - if config.offchain_worker.enabled { - sc_service::build_offchain_workers( - &config, - backend.clone(), - task_manager.spawn_handle(), - client.clone(), - network.clone(), - ); - } - - let role = config.role.clone(); - let force_authoring = config.force_authoring; - let backoff_authoring_blocks: Option<()> = None; - let name = config.network.node_name.clone(); - let enable_grandpa = !config.disable_grandpa; - let prometheus_registry = config.prometheus_registry().cloned(); - - let rpc_extensions_builder = { - let client = client.clone(); - let pool = transaction_pool.clone(); - - Box::new(move |deny_unsafe, _| { - let deps = crate::rpc::FullDeps { - client: client.clone(), - pool: pool.clone(), - deny_unsafe, - }; - - crate::rpc::create_full(deps) - }) - }; - - let (_rpc_handlers, telemetry_connection_notifier) = - sc_service::spawn_tasks(sc_service::SpawnTasksParams { - network: network.clone(), - client: client.clone(), - keystore: keystore_container.sync_keystore(), - task_manager: &mut task_manager, - transaction_pool: transaction_pool.clone(), - rpc_extensions_builder, - on_demand: None, - remote_blockchain: None, - backend, - network_status_sinks, - system_rpc_tx, - config, - })?; - - if role.is_authority() { - let proposer = sc_basic_authorship::ProposerFactory::new( - task_manager.spawn_handle(), - client.clone(), - transaction_pool, - prometheus_registry.as_ref(), - ); - - let can_author_with = - sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()); - - let aura = sc_consensus_aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _, _>( - sc_consensus_aura::slot_duration(&*client)?, - client.clone(), - select_chain, - block_import, - proposer, - network.clone(), - inherent_data_providers.clone(), - force_authoring, - backoff_authoring_blocks, - keystore_container.sync_keystore(), - can_author_with, - )?; - - // the AURA authoring task is considered essential, i.e. if it - // fails we take down the service with it. - task_manager - .spawn_essential_handle() - .spawn_blocking("aura", aura); - } - - // if the node isn't actively participating in consensus then it doesn't - // need a keystore, regardless of which protocol we use below. - let keystore = if role.is_authority() { - Some(keystore_container.sync_keystore()) - } else { - None - }; - - let grandpa_config = sc_finality_grandpa::Config { - // FIXME #1578 make this available through chainspec - gossip_duration: Duration::from_millis(333), - justification_period: 512, - name: Some(name), - observer_enabled: false, - keystore, - is_authority: role.is_network_authority(), - }; - - if enable_grandpa { - // start the full GRANDPA voter - // NOTE: non-authorities could run the GRANDPA observer protocol, but at - // this point the full voter should provide better guarantees of block - // and vote data availability than the observer. The observer has not - // been tested extensively yet and having most nodes in a network run it - // could lead to finality stalls. - let grandpa_config = sc_finality_grandpa::GrandpaParams { - config: grandpa_config, - link: grandpa_link, - network, - telemetry_on_connect: telemetry_connection_notifier.map(|x| x.on_connect_stream()), - voting_rule: sc_finality_grandpa::VotingRulesBuilder::default().build(), - prometheus_registry, - shared_voter_state: SharedVoterState::empty(), - }; - - // the GRANDPA voter task is considered infallible, i.e. - // if it fails we take down the service with it. - task_manager.spawn_essential_handle().spawn_blocking( - "grandpa-voter", - sc_finality_grandpa::run_grandpa_voter(grandpa_config)?, - ); - } - - network_starter.start_network(); - Ok(task_manager) + let sc_service::PartialComponents { + client, + backend, + mut task_manager, + import_queue, + mut keystore_container, + select_chain, + transaction_pool, + inherent_data_providers, + other: (block_import, grandpa_link), + } = new_partial(&config)?; + + if let Some(url) = &config.keystore_remote { + match remote_keystore(url) { + | Ok(k) => keystore_container.set_remote_keystore(k), + | Err(e) => + return Err(ServiceError::Other(format!( + "Error hooking up remote keystore for {}: {}", + url, e + ))), + }; + } + + config.network.extra_sets.push(sc_finality_grandpa::grandpa_peers_set_config()); + + let (network, network_status_sinks, system_rpc_tx, network_starter) = + sc_service::build_network(sc_service::BuildNetworkParams { + config: &config, + client: client.clone(), + transaction_pool: transaction_pool.clone(), + spawn_handle: task_manager.spawn_handle(), + import_queue, + on_demand: None, + block_announce_validator_builder: None, + })?; + + if config.offchain_worker.enabled { + sc_service::build_offchain_workers( + &config, + backend.clone(), + task_manager.spawn_handle(), + client.clone(), + network.clone(), + ); + } + + let role = config.role.clone(); + let force_authoring = config.force_authoring; + let backoff_authoring_blocks: Option<()> = None; + let name = config.network.node_name.clone(); + let enable_grandpa = !config.disable_grandpa; + let prometheus_registry = config.prometheus_registry().cloned(); + + let rpc_extensions_builder = { + let client = client.clone(); + let pool = transaction_pool.clone(); + + Box::new(move |deny_unsafe, _| { + let deps = + crate::rpc::FullDeps { client: client.clone(), pool: pool.clone(), deny_unsafe }; + + crate::rpc::create_full(deps) + }) + }; + + let (_rpc_handlers, telemetry_connection_notifier) = + sc_service::spawn_tasks(sc_service::SpawnTasksParams { + network: network.clone(), + client: client.clone(), + keystore: keystore_container.sync_keystore(), + task_manager: &mut task_manager, + transaction_pool: transaction_pool.clone(), + rpc_extensions_builder, + on_demand: None, + remote_blockchain: None, + backend, + network_status_sinks, + system_rpc_tx, + config, + })?; + + if role.is_authority() { + let proposer = sc_basic_authorship::ProposerFactory::new( + task_manager.spawn_handle(), + client.clone(), + transaction_pool, + prometheus_registry.as_ref(), + ); + + let can_author_with = + sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()); + + let aura = sc_consensus_aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _, _>( + sc_consensus_aura::slot_duration(&*client)?, + client.clone(), + select_chain, + block_import, + proposer, + network.clone(), + inherent_data_providers.clone(), + force_authoring, + backoff_authoring_blocks, + keystore_container.sync_keystore(), + can_author_with, + )?; + + // the AURA authoring task is considered essential, i.e. if it + // fails we take down the service with it. + task_manager.spawn_essential_handle().spawn_blocking("aura", aura); + } + + // if the node isn't actively participating in consensus then it doesn't + // need a keystore, regardless of which protocol we use below. + let keystore = + if role.is_authority() { Some(keystore_container.sync_keystore()) } else { None }; + + let grandpa_config = sc_finality_grandpa::Config { + // FIXME #1578 make this available through chainspec + gossip_duration: Duration::from_millis(333), + justification_period: 512, + name: Some(name), + observer_enabled: false, + keystore, + is_authority: role.is_network_authority(), + }; + + if enable_grandpa { + // start the full GRANDPA voter + // NOTE: non-authorities could run the GRANDPA observer protocol, but at + // this point the full voter should provide better guarantees of block + // and vote data availability than the observer. The observer has not + // been tested extensively yet and having most nodes in a network run it + // could lead to finality stalls. + let grandpa_config = sc_finality_grandpa::GrandpaParams { + config: grandpa_config, + link: grandpa_link, + network, + telemetry_on_connect: telemetry_connection_notifier.map(|x| x.on_connect_stream()), + voting_rule: sc_finality_grandpa::VotingRulesBuilder::default().build(), + prometheus_registry, + shared_voter_state: SharedVoterState::empty(), + }; + + // the GRANDPA voter task is considered infallible, i.e. + // if it fails we take down the service with it. + task_manager.spawn_essential_handle().spawn_blocking( + "grandpa-voter", + sc_finality_grandpa::run_grandpa_voter(grandpa_config)?, + ); + } + + network_starter.start_network(); + Ok(task_manager) } /// Builds a new service for a light client. pub fn new_light(mut config: Configuration) -> Result { - let (client, backend, keystore_container, mut task_manager, on_demand) = - sc_service::new_light_parts::(&config)?; - - config - .network - .extra_sets - .push(sc_finality_grandpa::grandpa_peers_set_config()); - - let select_chain = sc_consensus::LongestChain::new(backend.clone()); - - let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light( - config.transaction_pool.clone(), - config.prometheus_registry(), - task_manager.spawn_handle(), - client.clone(), - on_demand.clone(), - )); - - let (grandpa_block_import, _) = sc_finality_grandpa::block_import( - client.clone(), - &(client.clone() as Arc<_>), - select_chain.clone(), - )?; - - let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new( - grandpa_block_import.clone(), - client.clone(), - ); - - let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>( - sc_consensus_aura::slot_duration(&*client)?, - aura_block_import, - Some(Box::new(grandpa_block_import)), - client.clone(), - InherentDataProviders::new(), - &task_manager.spawn_handle(), - config.prometheus_registry(), - sp_consensus::NeverCanAuthor, - )?; - - let (network, network_status_sinks, system_rpc_tx, network_starter) = - sc_service::build_network(sc_service::BuildNetworkParams { - config: &config, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - spawn_handle: task_manager.spawn_handle(), - import_queue, - on_demand: Some(on_demand.clone()), - block_announce_validator_builder: None, - })?; - - if config.offchain_worker.enabled { - sc_service::build_offchain_workers( - &config, - backend.clone(), - task_manager.spawn_handle(), - client.clone(), - network.clone(), - ); - } - - sc_service::spawn_tasks(sc_service::SpawnTasksParams { - remote_blockchain: Some(backend.remote_blockchain()), - transaction_pool, - task_manager: &mut task_manager, - on_demand: Some(on_demand), - rpc_extensions_builder: Box::new(|_, _| ()), - config, - client, - keystore: keystore_container.sync_keystore(), - backend, - network, - network_status_sinks, - system_rpc_tx, - })?; - - network_starter.start_network(); - - Ok(task_manager) + let (client, backend, keystore_container, mut task_manager, on_demand) = + sc_service::new_light_parts::(&config)?; + + config.network.extra_sets.push(sc_finality_grandpa::grandpa_peers_set_config()); + + let select_chain = sc_consensus::LongestChain::new(backend.clone()); + + let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light( + config.transaction_pool.clone(), + config.prometheus_registry(), + task_manager.spawn_handle(), + client.clone(), + on_demand.clone(), + )); + + let (grandpa_block_import, _) = sc_finality_grandpa::block_import( + client.clone(), + &(client.clone() as Arc<_>), + select_chain.clone(), + )?; + + let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new( + grandpa_block_import.clone(), + client.clone(), + ); + + let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>( + sc_consensus_aura::slot_duration(&*client)?, + aura_block_import, + Some(Box::new(grandpa_block_import)), + client.clone(), + InherentDataProviders::new(), + &task_manager.spawn_handle(), + config.prometheus_registry(), + sp_consensus::NeverCanAuthor, + )?; + + let (network, network_status_sinks, system_rpc_tx, network_starter) = + sc_service::build_network(sc_service::BuildNetworkParams { + config: &config, + client: client.clone(), + transaction_pool: transaction_pool.clone(), + spawn_handle: task_manager.spawn_handle(), + import_queue, + on_demand: Some(on_demand.clone()), + block_announce_validator_builder: None, + })?; + + if config.offchain_worker.enabled { + sc_service::build_offchain_workers( + &config, + backend.clone(), + task_manager.spawn_handle(), + client.clone(), + network.clone(), + ); + } + + sc_service::spawn_tasks(sc_service::SpawnTasksParams { + remote_blockchain: Some(backend.remote_blockchain()), + transaction_pool, + task_manager: &mut task_manager, + on_demand: Some(on_demand), + rpc_extensions_builder: Box::new(|_, _| ()), + config, + client, + keystore: keystore_container.sync_keystore(), + backend, + network, + network_status_sinks, + system_rpc_tx, + })?; + + network_starter.start_network(); + + Ok(task_manager) } diff --git a/pallets/dids/LICENSE.md b/pallets/dids/LICENSE.md new file mode 100644 index 0000000..6b111d1 --- /dev/null +++ b/pallets/dids/LICENSE.md @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + +Copyright (C) 2007 Free Software Foundation, Inc. +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. + + Preamble + +The GNU General Public License is a free, copyleft license for +software and other kinds of works. + +The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + +When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + +For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + +Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + +Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + +Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + +0. Definitions. + +"This License" refers to version 3 of the GNU General Public License. + +"Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + +"The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + +To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + +A "covered work" means either the unmodified Program or a work based +on the Program. + +To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + +To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + +An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + +1. Source Code. + +The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + +A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + +The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + +The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + +The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + +The Corresponding Source for a work in source code form is that +same work. + +2. Basic Permissions. + +All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + +3. Protecting Users' Legal Rights From Anti-Circumvention Law. + +No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + +When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + +4. Conveying Verbatim Copies. + +You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + +5. Conveying Modified Source Versions. + +You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + +A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + +6. Conveying Non-Source Forms. + +You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + +A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + +"Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + +If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + +The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + +7. Additional Terms. + +"Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + +All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + +8. Termination. + +You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + +However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + +9. Acceptance Not Required for Having Copies. + +You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + +10. Automatic Licensing of Downstream Recipients. + +Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + +An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + +11. Patents. + +A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + +A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + +In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + +If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + +A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + +12. No Surrender of Others' Freedom. + +If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + +13. Use with the GNU Affero General Public License. + +Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + +14. Revised Versions of this License. + +The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + +If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + +Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + +15. Disclaimer of Warranty. + +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. Limitation of Liability. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + +17. Interpretation of Sections 15 and 16. + +If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 . + +Also add information on how to contact you by electronic and paper mail. + +If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + +You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + +The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/pallets/dids/rpc/Cargo.toml b/pallets/dids/rpc/Cargo.toml deleted file mode 100644 index 912d613..0000000 --- a/pallets/dids/rpc/Cargo.toml +++ /dev/null @@ -1,32 +0,0 @@ -[package] -name = "dids-rpc" -version = "0.1.0" -edition = "2018" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ["derive"] } -serde = { features = ['derive'], optional = true, version = '1.0.119'} - -# local dependencies -pallet-dids = {default-features = false, path = '..'} - -# Custom runrime API -dids-runtime-api = { default-features = false, path = 'runtime-api'} - -# substrate dependencies -sp-api = { default-features = false, version = "3.0.0" } -sp-rpc = { default-features = false, version = "3.0.0"} -sp-runtime = { default-features = false, version = "3.0.0"} -sp-std = { default-features = false, version = "3.0.0"} - -[features] -default = ['std'] -std = [ - 'serde', - 'sp-api/std', - 'sp-std/std', - 'sp-runtime/std', - 'pallet-dids/std' -] diff --git a/pallets/dids/rpc/src/lib.rs b/pallets/dids/rpc/src/lib.rs deleted file mode 100644 index daa945b..0000000 --- a/pallets/dids/rpc/src/lib.rs +++ /dev/null @@ -1,30 +0,0 @@ -#![cfg_attr(not(feature = "std"), no_std)] -use codec::Codec; -use pallet_dids::*; - -sp_api::decl_runrime_apis! { - #[api_version(1)] - pub trait DIDAPI { - fn ping() -> u64 - } -} - - -sp_api::impl_runtime_apis!{ - impl Self::DIDAPI for Runtime{ - fn ping() -> u64 { - 1 - } - } -} - -pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion { - spec_name: create_runtime_str!("node"), - impl_name: create_runtime_str!("test-node"), - authoring_version: 1, - spec_version: 1, - impl_version: 0, - // Here we are exposing the runtime api versions. - apis: RUNTIME_API_VERSIONS, - transaction_version: 1, -}; diff --git a/pallets/dids/src/ipfs_driver.rs b/pallets/dids/src/ipfs_driver.rs deleted file mode 100644 index 8b13789..0000000 --- a/pallets/dids/src/ipfs_driver.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/pallets/dids/src/lib.rs b/pallets/dids/src/lib.rs index 319566b..9387e1a 100644 --- a/pallets/dids/src/lib.rs +++ b/pallets/dids/src/lib.rs @@ -15,25 +15,26 @@ //! //! # Example //! ```no_run -//! use frame_support::pallet_prelude::{StorageMap}; +//! use frame_support::pallet; +//! use frame_support::pallet_prelude::StorageMap; //! use frame_support::Blake2_128Concat; //! use pallet_dids::Config; -//! use frame_support::pallet; //! #[pallet::storage] //! #[pallet::getter(fn get_did_document)] //! pub(super) type DIDDocument = StorageMap<_, Blake2_128Concat, Vec, DID>; //! ``` //! //! ## DIDDocument -//! Keeps trails of DID documents by combination of the Issuer/Controller Account and a unique value +//! Keeps trails of DID documents by combination of the Issuer/Controller Account and a unique +//! value //! * Key 1 -> AccountId + DIDDocumentHash //! * Value -> DID structure //! //! ```no_run +//! use frame_support::pallet; //! use frame_support::pallet_prelude::StorageMap; //! use frame_support::Blake2_128Concat; //! use pallet_dids::Config; -//! use frame_support::pallet; //! #[pallet::storage] //! #[pallet::getter(fn get_did_accounts)] //! pub(super) type DIDs = @@ -43,10 +44,10 @@ //! * Stores a fingerprint of a verifiableCredential //! * TODO: Will move to a separate pallet at MVP stage //! ```no_run +//! use frame_support::pallet; //! use frame_support::pallet_prelude::StorageMap; //! use frame_support::Blake2_128Concat; //! use pallet_dids::Config; -//! use frame_support::pallet; //! #[pallet::storage] //! #[pallet::getter(fn get_verifiable_credential_hash)] //! pub(super) type VC = @@ -55,7 +56,6 @@ #![cfg_attr(not(feature = "std"), no_std)] -mod ipfs_driver; mod structs; mod utils; @@ -70,251 +70,228 @@ pub use pallet::*; #[frame_support::pallet] pub mod pallet { - use frame_support::{dispatch::DispatchResultWithPostInfo, pallet_prelude::*}; - - use frame_system::pallet_prelude::*; - - use crate::structs::{VerifiableCredential, DID}; - use sp_std::str; - use sp_std::vec::Vec; - #[allow(dead_code)] - use frame_support::traits::UnixTime; - - - #[pallet::config] - pub trait Config: frame_system::Config + pallet_timestamp::Config { - type Event: From> + IsType<::Event>; - type TimeProvider: UnixTime; - } - - #[pallet::pallet] - #[pallet::generate_store(pub(super) trait Store)] - pub struct Pallet(_); - - /// Stores a DID document on chain - /// Key 1 -> AccountId + DIDDocumentHash - /// Value -> DID structure - #[pallet::storage] - #[pallet::getter(fn get_did_document)] - pub(super) type DIDDocument = StorageMap< - _, - Blake2_128Concat, - Vec, - DID - >; - - /// Accounts associated with a DID - #[pallet::storage] - #[pallet::getter(fn get_did_accounts)] - pub(super) type DIDs = StorageMap< - _, - Blake2_128Concat, - // public key + Controller Account - (Vec, T::AccountId), - Vec>, - >; - - /// Stores a verifiable credential finger print - #[pallet::storage] - #[pallet::getter(fn get_verifiable_credential_hash)] - pub(super) type VC = - StorageMap<_, Blake2_128Concat, Vec, VerifiableCredential>; - - /// # Pallet Events - /// * DIDDocumentCreated - /// - Returns the created DID hash and the AccountId `(Vec, T::AccountId)` - /// * DIDDocumentRevoked - /// - Triggers when a DID revoked by a controller or a delegated authority `(Vec, T::AccountId)` - /// * VerifiableCredentialFingerprintCreated - /// - Returns Holder's Account, Issuer/Controller's Account and the verifiable credential hash - #[pallet::event] - #[pallet::metadata(T::AccountId = "AccountId")] - #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { - /// Event returns DID Document hash, DID URI, Sender's AccountId - DIDDocumentCreated(Vec, T::AccountId), - - /// DID Document revoked - DIDDocumentRevoked(Vec, T::AccountId), - - /// Verifiable credential fingerprint created - VerifiableCredentialFingerPrintCreated(Vec, T::AccountId, Vec), - - /// DID Document updated - DIDDocumentUpdated(Vec) - } - - #[pallet::error] - pub enum Error { - /// DID Document exists - DIDExists, - - /// DID Document does not exists - DIDDoesNotExists, - - /// Disputed DID Document - DIDDispute, - - /// DID Document locked - DIDLocked, - - /// Verifiable credential exists - VerifiableCredentialExists, - } - - /// Offchain worker to support custom RPC calls to assist verifiable credentials with DIDs - /// TODO: Functionality will be implemented in MVP stage - #[pallet::hooks] - impl Hooks> for Pallet { - fn offchain_worker(block_number: T::BlockNumber) { - log::info!("TrackBack OCW"); - log::info!("{:?}", block_number); - } - } - - #[pallet::call] - impl Pallet { - /// Stores hashes of verifiable credentials issued per issuer's account (aka controller) - /// Does not store any verifiable credential or user centric data on-chain store - #[pallet::weight(0)] - pub fn create_vc_fingerprint( - origin: OriginFor, - public_key: Vec, - vc_hash: Vec, - active: Option, - ) -> DispatchResultWithPostInfo { - let origin_account = ensure_signed(origin)?; - - // Ensures a verifiable credential finger print does not exist - ensure!( - !VC::::contains_key(&vc_hash), - Error::::VerifiableCredentialExists - ); - - let _account = - T::AccountId::decode(&mut &public_key[..]).map_err(|_| "could not convert")?; - let time = T::TimeProvider::now().as_secs(); - - VC::::insert( - vc_hash.clone(), - VerifiableCredential { - account_id: Some(_account), - public_key: public_key.clone(), - block_time_stamp: time, - active, - }, - ); - Self::deposit_event(Event::VerifiableCredentialFingerPrintCreated( - vc_hash, - origin_account, - public_key, - )); - Ok(().into()) - } - - /// DID Revocation - /// Throws DoesNotExists for a non existing DID revocation - #[pallet::weight(0)] - pub fn revoke_did(origin: OriginFor, did_uri: Vec) -> DispatchResultWithPostInfo { - let origin_account = ensure_signed(origin)?; - - ensure!( - DIDDocument::::contains_key(&did_uri), - Error::::DIDDoesNotExists - ); - - DIDDocument::::remove(&did_uri); - - Self::deposit_event(Event::DIDDocumentRevoked(did_uri, origin_account)); - - Ok(().into()) - } - - /// Updates a DID document - #[pallet::weight(0)] - pub fn update_did( - origin: OriginFor, - did_uri: Vec, - did_resolution_metadata: Option>, - did_document_metadata: Option>, - did_ref: Option>, - public_keys: Option>>, - ) -> DispatchResultWithPostInfo { - let _origin_account = ensure_signed(origin)?; - - // Checks the DID document contains the section `Capability Delegation` - // Reference :- https://www.w3.org/TR/did-core/#capability-delegation - - // let doc = str::from_utf8(&did_document).unwrap(); - // let sanitised = doc.replace("\n", "").replace(" ", ""); - - DIDDocument::::mutate(did_uri.clone(), |did| { - match did { - None => { - return Err(Error::::DIDDoesNotExists) - } - Some(d) => { - d.did_resolution_metadata = did_resolution_metadata; - d.did_document_metadata = did_document_metadata; - d.public_keys = public_keys; - d.did_ref = did_ref; - d.updated_timestamp = T::TimeProvider::now().as_secs(); - Ok(()) - } - } - })?; - Self::deposit_event(Event::DIDDocumentUpdated(did_uri)); - - Ok(().into()) - } - - /// Stores a DID document - #[pallet::weight(0)] - pub fn insert_did_document( - origin: OriginFor, - did_document: Vec, - did_document_metadata: Option>, - did_resolution_metadata: Option>, - sender_account_id: Vec, - did_uri: Vec, - did_ref: Option>, - public_keys: Option>> - ) -> DispatchResultWithPostInfo { - let origin_account = ensure_signed(origin)?; - - let block_number = >::block_number(); - - let time = T::TimeProvider::now().as_secs(); - - ensure!( - !DIDDocument::::contains_key(&did_uri), - Error::::DIDExists - ); - - // Checks the DID document contains the section `Capability Delegation` - // Reference :- https://www.w3.org/TR/did-core/#capability-delegation - - let doc = str::from_utf8(&did_document).unwrap(); - let _sanitised = doc.replace("\n", "").replace(" ", ""); - - - DIDDocument::::insert( - did_uri.clone(), - DID { - did_document_metadata, - did_resolution_metadata, - block_number, - block_time_stamp: time.clone(), - updated_timestamp: time, - did_ref, - sender_account_id, - public_keys, - }, - ); - - Self::deposit_event(Event::DIDDocumentCreated(did_uri, origin_account)); - - Ok(().into()) - } - } + use frame_support::{dispatch::DispatchResultWithPostInfo, pallet_prelude::*}; + + use frame_system::pallet_prelude::*; + + use crate::structs::{VerifiableCredential, DID}; + #[allow(dead_code)] + use frame_support::traits::UnixTime; + use sp_std::{str, vec::Vec}; + + #[pallet::config] + pub trait Config: frame_system::Config + pallet_timestamp::Config { + type Event: From> + IsType<::Event>; + type TimeProvider: UnixTime; + } + + #[pallet::pallet] + #[pallet::generate_store(pub(super) trait Store)] + pub struct Pallet(_); + + /// Stores a DID document on chain + /// Key 1 -> AccountId + DIDDocumentHash + /// Value -> DID structure + #[pallet::storage] + #[pallet::getter(fn get_did_document)] + pub(super) type DIDDocument = StorageMap<_, Blake2_128Concat, Vec, DID>; + + /// Accounts associated with a DID + #[pallet::storage] + #[pallet::getter(fn get_did_accounts)] + pub(super) type DIDs = StorageMap< + _, + Blake2_128Concat, + // public key + Controller Account + (Vec, T::AccountId), + Vec>, + >; + + /// Stores a verifiable credential finger print + #[pallet::storage] + #[pallet::getter(fn get_verifiable_credential_hash)] + pub(super) type VC = + StorageMap<_, Blake2_128Concat, Vec, VerifiableCredential>; + + /// # Pallet Events + /// * DIDDocumentCreated + /// - Returns the created DID hash and the AccountId `(Vec, T::AccountId)` + /// * DIDDocumentRevoked + /// - Triggers when a DID revoked by a controller or a delegated authority `(Vec, + /// T::AccountId)` + /// * VerifiableCredentialFingerprintCreated + /// - Returns Holder's Account, Issuer/Controller's Account and the verifiable credential hash + #[pallet::event] + #[pallet::metadata(T::AccountId = "AccountId")] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event { + /// Event returns DID Document hash, DID URI, Sender's AccountId + DIDDocumentCreated(Vec, T::AccountId), + + /// DID Document revoked + DIDDocumentRevoked(Vec, T::AccountId), + + /// Verifiable credential fingerprint created + VerifiableCredentialFingerPrintCreated(Vec, T::AccountId, Vec), + + /// DID Document updated + DIDDocumentUpdated(Vec), + } + + #[pallet::error] + pub enum Error { + /// DID Document exists + DIDExists, + + /// DID Document does not exists + DIDDoesNotExists, + + /// Disputed DID Document + DIDDispute, + + /// DID Document locked + DIDLocked, + + /// Verifiable credential exists + VerifiableCredentialExists, + } + + /// Offchain worker to support custom RPC calls to assist verifiable credentials with DIDs + /// TODO: Functionality will be implemented in MVP stage + #[pallet::hooks] + impl Hooks> for Pallet { + fn offchain_worker(block_number: T::BlockNumber) { + log::info!("TrackBack OCW"); + log::info!("{:?}", block_number); + } + } + + #[pallet::call] + impl Pallet { + /// Stores hashes of verifiable credentials issued per issuer's account (aka controller) + /// Does not store any verifiable credential or user centric data on-chain store + #[pallet::weight(0)] + pub fn create_vc_fingerprint( + origin: OriginFor, + public_key: Vec, + vc_hash: Vec, + active: Option, + ) -> DispatchResultWithPostInfo { + let origin_account = ensure_signed(origin)?; + + // Ensures a verifiable credential finger print does not exist + ensure!(!VC::::contains_key(&vc_hash), Error::::VerifiableCredentialExists); + + let _account = + T::AccountId::decode(&mut &public_key[..]).map_err(|_| "could not convert")?; + let time = T::TimeProvider::now().as_secs(); + + VC::::insert( + vc_hash.clone(), + VerifiableCredential { + account_id: Some(_account), + public_key: public_key.clone(), + block_time_stamp: time, + active, + }, + ); + Self::deposit_event(Event::VerifiableCredentialFingerPrintCreated( + vc_hash, + origin_account, + public_key, + )); + Ok(().into()) + } + + /// DID Revocation + /// Throws DoesNotExists for a non existing DID revocation + #[pallet::weight(0)] + pub fn revoke_did(origin: OriginFor, did_uri: Vec) -> DispatchResultWithPostInfo { + let origin_account = ensure_signed(origin)?; + + ensure!(DIDDocument::::contains_key(&did_uri), Error::::DIDDoesNotExists); + + DIDDocument::::remove(&did_uri); + + Self::deposit_event(Event::DIDDocumentRevoked(did_uri, origin_account)); + + Ok(().into()) + } + + /// Updates a DID document + #[pallet::weight(0)] + pub fn update_did( + origin: OriginFor, + did_uri: Vec, + did_resolution_metadata: Option>, + did_document_metadata: Option>, + did_ref: Option>, + public_keys: Option>>, + ) -> DispatchResultWithPostInfo { + let _origin_account = ensure_signed(origin)?; + + //TODO: Checks the DID document contains the section `Capability Delegation` + // Reference :- https://www.w3.org/TR/did-core/#capability-delegation + + DIDDocument::::mutate(did_uri.clone(), |did| match did { + | None => return Err(Error::::DIDDoesNotExists), + | Some(d) => { + d.did_resolution_metadata = did_resolution_metadata; + d.did_document_metadata = did_document_metadata; + d.public_keys = public_keys; + d.did_ref = did_ref; + d.updated_timestamp = T::TimeProvider::now().as_secs(); + Ok(()) + }, + })?; + Self::deposit_event(Event::DIDDocumentUpdated(did_uri)); + + Ok(().into()) + } + + /// Stores a DID document + #[pallet::weight(0)] + pub fn insert_did_document( + origin: OriginFor, + did_document: Vec, + did_document_metadata: Option>, + did_resolution_metadata: Option>, + sender_account_id: Vec, + did_uri: Vec, + did_ref: Option>, + public_keys: Option>>, + ) -> DispatchResultWithPostInfo { + let origin_account = ensure_signed(origin)?; + + let block_number = >::block_number(); + + let time = T::TimeProvider::now().as_secs(); + + ensure!(!DIDDocument::::contains_key(&did_uri), Error::::DIDExists); + + //TODO: Checks the DID document contains the section `Capability Delegation` + // Reference :- https://www.w3.org/TR/did-core/#capability-delegation + + let doc = str::from_utf8(&did_document).unwrap(); + let _sanitised = doc.replace("\n", "").replace(" ", ""); + + DIDDocument::::insert( + did_uri.clone(), + DID { + did_document_metadata, + did_resolution_metadata, + block_number, + block_time_stamp: time.clone(), + updated_timestamp: time, + did_ref, + sender_account_id, + public_keys, + }, + ); + + Self::deposit_event(Event::DIDDocumentCreated(did_uri, origin_account)); + + Ok(().into()) + } + } } diff --git a/pallets/dids/src/mock.rs b/pallets/dids/src/mock.rs index 0c74765..78149b9 100644 --- a/pallets/dids/src/mock.rs +++ b/pallets/dids/src/mock.rs @@ -3,8 +3,8 @@ use frame_support::parameter_types; use frame_system as system; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + testing::Header, + traits::{BlakeTwo256, IdentityLookup}, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -12,66 +12,63 @@ type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Module, Call, Config, Storage, Event}, - DIDModule: pallet_dids::{Module, Call, Storage, Event}, - Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, - } + pub enum Test where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: frame_system::{Module, Call, Config, Storage, Event}, + DIDModule: pallet_dids::{Module, Call, Storage, Event}, + Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, + } ); parameter_types! { - pub const BlockHashCount: u64 = 250; - pub const SS58Prefix: u8 = 42; + pub const BlockHashCount: u64 = 250; + pub const SS58Prefix: u8 = 42; } impl frame_system::Config for Test { - type BaseCallFilter = (); - type BlockWeights = (); - type BlockLength = (); - type DbWeight = (); - type Origin = Origin; - type Call = Call; - type Index = u64; - type BlockNumber = u64; - type Hash = H256; - type Hashing = BlakeTwo256; - type AccountId = u64; - type Lookup = IdentityLookup; - type Header = Header; - type Event = Event; - type BlockHashCount = BlockHashCount; - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = (); - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = SS58Prefix; + type BaseCallFilter = (); + type BlockWeights = (); + type BlockLength = (); + type DbWeight = (); + type Origin = Origin; + type Call = Call; + type Index = u64; + type BlockNumber = u64; + type Hash = H256; + type Hashing = BlakeTwo256; + type AccountId = u64; + type Lookup = IdentityLookup; + type Header = Header; + type Event = Event; + type BlockHashCount = BlockHashCount; + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = (); + type OnNewAccount = (); + type OnKilledAccount = (); + type SystemWeightInfo = (); + type SS58Prefix = SS58Prefix; } parameter_types! { - pub const MinimumPeriod: u64 = 5; + pub const MinimumPeriod: u64 = 5; } impl pallet_timestamp::Config for Test { - type Moment = u64; - type OnTimestampSet = (); - type MinimumPeriod = (); - type WeightInfo = (); + type Moment = u64; + type OnTimestampSet = (); + type MinimumPeriod = (); + type WeightInfo = (); } impl pallet_dids::Config for Test { - type Event = Event; - type TimeProvider = pallet_timestamp::Pallet; + type Event = Event; + type TimeProvider = pallet_timestamp::Pallet; } // Build genesis storage according to the mock runtime. pub fn new_test_ext() -> sp_io::TestExternalities { - system::GenesisConfig::default() - .build_storage::() - .unwrap() - .into() + system::GenesisConfig::default().build_storage::().unwrap().into() } diff --git a/pallets/dids/src/structs.rs b/pallets/dids/src/structs.rs index 375a526..1eedd23 100644 --- a/pallets/dids/src/structs.rs +++ b/pallets/dids/src/structs.rs @@ -7,61 +7,54 @@ use sp_std::vec::Vec; #[derive(Clone, Decode, Encode, Eq, PartialEq)] pub struct DIDDetail { - // Tracking number of issued DIDs by the controller - public_key: Vec, + // Tracking number of issued DIDs by the controller + public_key: Vec, - // Issued DID documents by the controller - did_documents: Vec>, + // Issued DID documents by the controller + did_documents: Vec>, } #[derive(Clone, Decode, Encode, Eq, PartialEq, Debug)] pub struct DID { + pub did_resolution_metadata: Option>, - pub did_resolution_metadata: Option>, + // DID Document Metadata + pub did_document_metadata: Option>, - // DID Document Metadata - pub did_document_metadata: Option>, + // Block number + pub block_number: ::BlockNumber, + // Created time stamp in ISO 8601 format + pub block_time_stamp: u64, - // Block number - pub block_number: ::BlockNumber, - // Created time stamp in ISO 8601 format - pub block_time_stamp: u64, + // Updated timestamp + pub updated_timestamp: u64, + // IPFS URI of the DID document + pub did_ref: Option>, - // Updated timestamp - pub updated_timestamp: u64, - // IPFS URI of the DID document - pub did_ref: Option>, - - // Sender AccountId - pub sender_account_id: Vec, - - // public keys - pub public_keys: Option>> + // Sender AccountId + pub sender_account_id: Vec, + // public keys + pub public_keys: Option>>, } #[derive(Clone, Decode, Encode, Eq, PartialEq)] pub struct VerifiableCredential { - // Controller's AccountId - pub account_id: Option, + // Controller's AccountId + pub account_id: Option, - // Holder's public key - pub public_key: Vec, + // Holder's public key + pub public_key: Vec, - // Created time - pub block_time_stamp: u64, + // Created time + pub block_time_stamp: u64, - // active - pub active: Option, + // active + pub active: Option, } impl Default for VerifiableCredential { - fn default() -> Self { - Self { - account_id: None, - public_key: Vec::new(), - block_time_stamp: 0, - active: Some(false), - } - } + fn default() -> Self { + Self { account_id: None, public_key: Vec::new(), block_time_stamp: 0, active: Some(false) } + } } diff --git a/pallets/dids/src/tests.rs b/pallets/dids/src/tests.rs index c851d79..48240ee 100644 --- a/pallets/dids/src/tests.rs +++ b/pallets/dids/src/tests.rs @@ -1,56 +1,57 @@ -use crate::mock::new_test_ext; -use crate::mock::Origin; +use crate::mock::{new_test_ext, Origin}; use rstest::*; use crate::mock::DIDModule; -use frame_support::pallet_prelude::DispatchError; -use frame_support::sp_runtime::app_crypto::sp_core::Hasher; -use frame_support::{assert_err, assert_ok}; +use frame_support::{ + assert_err, assert_ok, pallet_prelude::DispatchError, sp_runtime::app_crypto::sp_core::Hasher, +}; +use rand::{distributions::Alphanumeric, thread_rng, Rng}; use sp_core::Blake2Hasher; -use rand::{thread_rng, Rng}; -use rand::distributions::Alphanumeric; - #[fixture] pub fn did_ref() -> Option> { - Some(r#"{QmcNYMJBhvbrH8oTo5QGNUFA5rhKpBVXHBpfiecxso7D8P}"#.as_bytes().to_vec()) + Some(r#"{QmcNYMJBhvbrH8oTo5QGNUFA5rhKpBVXHBpfiecxso7D8P}"#.as_bytes().to_vec()) } #[fixture] pub fn public_keys() -> Option>> { - let mut public_keys = Vec::new(); - for _ in 0..10 { - let pk = thread_rng() - .sample_iter(&Alphanumeric) - .take(60) - .collect::>(); - public_keys.push(pk); - } - Some(public_keys) + let mut public_keys = Vec::new(); + for _ in 0..10 { + let pk = thread_rng().sample_iter(&Alphanumeric).take(60).collect::>(); + public_keys.push(pk); + } + Some(public_keys) } - #[fixture] pub fn did_document_metadata() -> Option> { - Some(r#"{ + Some( + r#"{ "created": "2002-01-01T20:20:20Z", "updated": "2002-02-01T20:20:20Z", "deactivated": "2002-03-01T20:20:20Z", "versionId": "1", - }"#.as_bytes().to_vec()) + }"# + .as_bytes() + .to_vec(), + ) } #[fixture] pub fn did_resolution_metadata() -> Option> { - Some(r#"{ + Some( + r#"{ "accept": "application/did+ld+json" - }"#.as_bytes().to_vec()) + }"# + .as_bytes() + .to_vec(), + ) } #[fixture] pub fn did_document() -> &'static str { - r#"{ + r#"{ "@context": [ "https://www.w3.org/ns/did/v1", "https://w3id.org/security/suites/ed25519-2020/v1" @@ -67,280 +68,250 @@ pub fn did_document() -> &'static str { #[fixture] pub fn did_uri(did_document: &'static str) -> Vec { - Blake2Hasher::hash(did_document.as_ref()).as_bytes().to_vec() + Blake2Hasher::hash(did_document.as_ref()).as_bytes().to_vec() } #[fixture] -pub fn public_key() ->Vec { - vec![ - 0, 1, 217, 200, 51, 244, 152, 125, 173, 92, 30, 224, 60, 141, 221, 44, 65, 132, 45, 94, - 199, 150, 116, 108, 95, 18, 118, 246, 86, 167, 64, 132, 76, - ] +pub fn public_key() -> Vec { + vec![ + 0, 1, 217, 200, 51, 244, 152, 125, 173, 92, 30, 224, 60, 141, 221, 44, 65, 132, 45, 94, + 199, 150, 116, 108, 95, 18, 118, 246, 86, 167, 64, 132, 76, + ] } #[fixture] pub fn vc_hash() -> Vec { - "Hash".as_bytes().to_vec() + "Hash".as_bytes().to_vec() } #[rstest] -fn create_vc(public_key: Vec,vc_hash: Vec) { - - new_test_ext().execute_with(|| { - assert_ok!(DIDModule::create_vc_fingerprint( - Origin::signed(1), - public_key, - vc_hash, - Some(true) - )); - }); +fn create_vc(public_key: Vec, vc_hash: Vec) { + new_test_ext().execute_with(|| { + assert_ok!(DIDModule::create_vc_fingerprint( + Origin::signed(1), + public_key, + vc_hash, + Some(true) + )); + }); } #[rstest] fn create_vc_exists(public_key: Vec, vc_hash: Vec) { - - new_test_ext().execute_with(|| { - DIDModule::create_vc_fingerprint( - Origin::signed(1), - public_key.clone(), - vc_hash.clone(), - Some(true), - ).ok(); - - assert_err!( - DIDModule::create_vc_fingerprint(Origin::signed(1), public_key, vc_hash, Some(true)), - DispatchError::Module { - index: 1, - error: 4, - message: Some("VerifiableCredentialExists") - } - ); - }); + new_test_ext().execute_with(|| { + DIDModule::create_vc_fingerprint( + Origin::signed(1), + public_key.clone(), + vc_hash.clone(), + Some(true), + ) + .ok(); + + assert_err!( + DIDModule::create_vc_fingerprint(Origin::signed(1), public_key, vc_hash, Some(true)), + DispatchError::Module { + index: 1, + error: 4, + message: Some("VerifiableCredentialExists") + } + ); + }); } #[rstest] fn create_did( - did_document_metadata: Option>, - did_resolution_metadata: Option>, - did_document: &'static str, - did_uri: Vec, - did_ref: Option>, - public_key: Vec, - public_keys: Option>> + did_document_metadata: Option>, + did_resolution_metadata: Option>, + did_document: &'static str, + did_uri: Vec, + did_ref: Option>, + public_key: Vec, + public_keys: Option>>, ) { - - new_test_ext().execute_with(|| { - assert_ok!(DIDModule::insert_did_document( - Origin::signed(1), - did_document.as_bytes().to_vec(), - did_document_metadata, - did_resolution_metadata, - public_key, - did_uri, - did_ref, - public_keys - )); - }); + new_test_ext().execute_with(|| { + assert_ok!(DIDModule::insert_did_document( + Origin::signed(1), + did_document.as_bytes().to_vec(), + did_document_metadata, + did_resolution_metadata, + public_key, + did_uri, + did_ref, + public_keys + )); + }); } #[rstest] fn create_an_existing_did( - did_document_metadata: Option>, - did_resolution_metadata: Option>, - did_document: &'static str, - did_uri: Vec, - did_ref: Option>, - public_key: Vec, - public_keys: Option>> + did_document_metadata: Option>, + did_resolution_metadata: Option>, + did_document: &'static str, + did_uri: Vec, + did_ref: Option>, + public_key: Vec, + public_keys: Option>>, ) { - - new_test_ext().execute_with(|| { - DIDModule::insert_did_document( - Origin::signed(1), - did_document.as_bytes().to_vec(), - did_document_metadata.clone(), - did_resolution_metadata.clone(), - public_key.clone(), - did_uri.clone(), - did_ref.clone(), - public_keys.clone() - ).ok(); - - assert_err!( - DIDModule::insert_did_document( - Origin::signed(1), - did_document.as_bytes().to_vec(), - did_document_metadata, - did_resolution_metadata, - public_key, - did_uri.clone(), - did_ref, - public_keys.clone() - ), - DispatchError::Module { - index: 1, - error: 0, - message: Some("DIDExists") - } - ); - }); + new_test_ext().execute_with(|| { + DIDModule::insert_did_document( + Origin::signed(1), + did_document.as_bytes().to_vec(), + did_document_metadata.clone(), + did_resolution_metadata.clone(), + public_key.clone(), + did_uri.clone(), + did_ref.clone(), + public_keys.clone(), + ) + .ok(); + + assert_err!( + DIDModule::insert_did_document( + Origin::signed(1), + did_document.as_bytes().to_vec(), + did_document_metadata, + did_resolution_metadata, + public_key, + did_uri.clone(), + did_ref, + public_keys.clone() + ), + DispatchError::Module { index: 1, error: 0, message: Some("DIDExists") } + ); + }); } #[rstest] fn revoke_a_did( - did_document_metadata: Option>, - did_resolution_metadata: Option>, - did_document: &'static str, - did_uri: Vec, - public_key: Vec, - did_ref: Option>, - public_keys: Option>> + did_document_metadata: Option>, + did_resolution_metadata: Option>, + did_document: &'static str, + did_uri: Vec, + public_key: Vec, + did_ref: Option>, + public_keys: Option>>, ) { - - new_test_ext().execute_with(|| { - DIDModule::insert_did_document( - Origin::signed(1), - did_document.as_bytes().to_vec(), - did_document_metadata.clone(), - did_resolution_metadata.clone(), - public_key, - did_uri.clone(), - did_ref, - public_keys - ).ok(); - - assert_ok!( - DIDModule::revoke_did( - Origin::signed(1), - did_uri - ) - ); - }); + new_test_ext().execute_with(|| { + DIDModule::insert_did_document( + Origin::signed(1), + did_document.as_bytes().to_vec(), + did_document_metadata.clone(), + did_resolution_metadata.clone(), + public_key, + did_uri.clone(), + did_ref, + public_keys, + ) + .ok(); + + assert_ok!(DIDModule::revoke_did(Origin::signed(1), did_uri)); + }); } #[rstest] fn revoke_non_existing_did( - did_document_metadata: Option>, - did_resolution_metadata: Option>, - did_document: &'static str, - did_uri: Vec, - public_key: Vec, - did_ref: Option>, - public_keys: Option>> + did_document_metadata: Option>, + did_resolution_metadata: Option>, + did_document: &'static str, + did_uri: Vec, + public_key: Vec, + did_ref: Option>, + public_keys: Option>>, ) { - - new_test_ext().execute_with(|| { - DIDModule::insert_did_document( - Origin::signed(1), - did_document.as_bytes().to_vec(), - did_document_metadata.clone(), - did_resolution_metadata.clone(), - public_key, - did_uri.clone(), - did_ref, - public_keys - ).ok(); - - DIDModule::revoke_did( - Origin::signed(1), - did_uri.clone() - ).ok(); - - }); + new_test_ext().execute_with(|| { + DIDModule::insert_did_document( + Origin::signed(1), + did_document.as_bytes().to_vec(), + did_document_metadata.clone(), + did_resolution_metadata.clone(), + public_key, + did_uri.clone(), + did_ref, + public_keys, + ) + .ok(); + + DIDModule::revoke_did(Origin::signed(1), did_uri.clone()).ok(); + }); } #[rstest] -fn revoke_a_revoked_did(did_uri: Vec) -{ - new_test_ext().execute_with(|| { - assert_err!( - DIDModule::revoke_did( - Origin::signed(1), - did_uri - ), - DispatchError::Module { - index: 1, - error: 1, - message: Some("DIDDoesNotExists") - } - ); - }); +fn revoke_a_revoked_did(did_uri: Vec) { + new_test_ext().execute_with(|| { + assert_err!( + DIDModule::revoke_did(Origin::signed(1), did_uri), + DispatchError::Module { index: 1, error: 1, message: Some("DIDDoesNotExists") } + ); + }); } #[rstest] fn update_did( - did_document_metadata: Option>, - did_resolution_metadata: Option>, - did_document: &'static str, - did_uri: Vec, - public_key: Vec, - did_ref: Option>, - public_keys: Option>> + did_document_metadata: Option>, + did_resolution_metadata: Option>, + did_document: &'static str, + did_uri: Vec, + public_key: Vec, + did_ref: Option>, + public_keys: Option>>, ) { - - new_test_ext().execute_with(|| { - DIDModule::insert_did_document( - Origin::signed(1), - did_document.as_bytes().to_vec(), - did_document_metadata.clone(), - did_resolution_metadata.clone(), - public_key, - did_uri.clone(), - did_ref.clone(), - public_keys - ).ok(); - assert_ok!( - DIDModule::update_did( - Origin::signed(1), - did_uri.clone(), - did_resolution_metadata, - did_document_metadata, - None, - None - ) - ); - } - ); + new_test_ext().execute_with(|| { + DIDModule::insert_did_document( + Origin::signed(1), + did_document.as_bytes().to_vec(), + did_document_metadata.clone(), + did_resolution_metadata.clone(), + public_key, + did_uri.clone(), + did_ref.clone(), + public_keys, + ) + .ok(); + assert_ok!(DIDModule::update_did( + Origin::signed(1), + did_uri.clone(), + did_resolution_metadata, + did_document_metadata, + None, + None + )); + }); } #[rstest] fn update_non_exsited_did( - did_document_metadata: Option>, - did_resolution_metadata: Option>, - did_document: &'static str, - did_uri: Vec, - public_key: Vec, - did_ref: Option>, - public_keys: Option>> + did_document_metadata: Option>, + did_resolution_metadata: Option>, + did_document: &'static str, + did_uri: Vec, + public_key: Vec, + did_ref: Option>, + public_keys: Option>>, ) { - let non_existed_did_uri =Blake2Hasher::hash("non_existed".as_ref()).as_bytes().to_vec(); - new_test_ext().execute_with(|| { - DIDModule::insert_did_document( - Origin::signed(1), - did_document.as_bytes().to_vec(), - did_document_metadata.clone(), - did_resolution_metadata.clone(), - public_key, - did_uri.clone(), - did_ref, - public_keys - ).ok(); - - assert_err!( - DIDModule::update_did( - Origin::signed(1), - non_existed_did_uri, - did_resolution_metadata, - did_document_metadata, - None, - None, - ), - DispatchError::Module { - index: 1, - error: 1, - message: Some("DIDDoesNotExists") - } - ); - } - ); + let non_existed_did_uri = Blake2Hasher::hash("non_existed".as_ref()).as_bytes().to_vec(); + new_test_ext().execute_with(|| { + DIDModule::insert_did_document( + Origin::signed(1), + did_document.as_bytes().to_vec(), + did_document_metadata.clone(), + did_resolution_metadata.clone(), + public_key, + did_uri.clone(), + did_ref, + public_keys, + ) + .ok(); + + assert_err!( + DIDModule::update_did( + Origin::signed(1), + non_existed_did_uri, + did_resolution_metadata, + did_document_metadata, + None, + None, + ), + DispatchError::Module { index: 1, error: 1, message: Some("DIDDoesNotExists") } + ); + }); } diff --git a/pallets/trackback/Cargo.lock b/pallets/trackback/Cargo.lock deleted file mode 100644 index eb34003..0000000 --- a/pallets/trackback/Cargo.lock +++ /dev/null @@ -1,1944 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "Inflector" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" -dependencies = [ - "lazy_static", - "regex", -] - -[[package]] -name = "addr2line" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" - -[[package]] -name = "ahash" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" - -[[package]] -name = "aho-corasick" -version = "0.7.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b476ce7103678b0c6d3d395dbbae31d48ff910bd28be979ba5d48c6351131d0d" -dependencies = [ - "memchr", -] - -[[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - -[[package]] -name = "arrayvec" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" -dependencies = [ - "nodrop", -] - -[[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" - -[[package]] -name = "autocfg" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" - -[[package]] -name = "backtrace" -version = "0.3.53" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707b586e0e2f247cbde68cdd2c3ce69ea7b7be43e1c5b426e37c9319c4b9838e" -dependencies = [ - "addr2line", - "cfg-if 1.0.0", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - -[[package]] -name = "base58" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" - -[[package]] -name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" - -[[package]] -name = "bitmask" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da9b3d9f6f585199287a473f4f8dfab6566cf827d15c00c219f53c645687ead" - -[[package]] -name = "bitvec" -version = "0.17.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41262f11d771fd4a61aa3ce019fca363b4b6c282fca9da2a31186d3965a47a5c" -dependencies = [ - "either", - "radium", -] - -[[package]] -name = "blake2-rfc" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" -dependencies = [ - "arrayvec 0.4.12", - "constant_time_eq", -] - -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array 0.12.3", -] - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array 0.14.4", -] - -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - -[[package]] -name = "byte-slice-cast" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0a5e3906bcbf133e33c1d4d95afc664ad37fbdb9f6568d8043e7ea8c27d93d3" - -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - -[[package]] -name = "byteorder" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - -[[package]] -name = "cloudabi" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4344512281c643ae7638bbabc3af17a11307803ec8f0fcad9fae512a8bf36467" -dependencies = [ - "bitflags", -] - -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - -[[package]] -name = "cpuid-bool" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" - -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "crypto-mac" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" -dependencies = [ - "generic-array 0.12.3", - "subtle 1.0.0", -] - -[[package]] -name = "curve25519-dalek" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d85653f070353a16313d0046f173f70d1aadd5b42600a14de626f0dfb3473a5" -dependencies = [ - "byteorder", - "digest 0.8.1", - "rand_core", - "subtle 2.3.0", - "zeroize", -] - -[[package]] -name = "curve25519-dalek" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8492de420e9e60bc9a1d66e2dbb91825390b738a388606600663fc529b4b307" -dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core", - "subtle 2.3.0", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cb0e6161ad61ed084a36ba71fbba9e3ac5aee3606fb607fe08da6acbcf3d8c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array 0.12.3", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array 0.14.4", -] - -[[package]] -name = "dyn-clonable" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e9232f0e607a262ceb9bd5141a3dfb3e4db6994b31989bbfd845878cba59fd4" -dependencies = [ - "dyn-clonable-impl", - "dyn-clone", -] - -[[package]] -name = "dyn-clonable-impl" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "558e40ea573c374cf53507fd240b7ee2f5477df7cfebdb97323ec61c719399c5" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "dyn-clone" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d55796afa1b20c2945ca8eabfc421839f2b766619209f1ede813cf2484f31804" - -[[package]] -name = "ed25519" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37c66a534cbb46ab4ea03477eae19d5c22c01da8258030280b7bd9d8433fb6ef" -dependencies = [ - "signature", -] - -[[package]] -name = "ed25519-dalek" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" -dependencies = [ - "curve25519-dalek 3.0.0", - "ed25519", - "rand", - "serde", - "sha2 0.9.1", - "zeroize", -] - -[[package]] -name = "either" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" - -[[package]] -name = "environmental" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6576a1755ddffd988788025e75bce9e74b018f7cc226198fe931d077911c6d7e" - -[[package]] -name = "failure" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" -dependencies = [ - "backtrace", - "failure_derive", -] - -[[package]] -name = "failure_derive" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", -] - -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - -[[package]] -name = "fixed-hash" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11498d382790b7a8f2fd211780bec78619bba81cdad3a283997c0c41f836759c" -dependencies = [ - "byteorder", - "rand", - "rustc-hex", - "static_assertions", -] - -[[package]] -name = "frame-metadata" -version = "11.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "parity-scale-codec", - "serde", - "sp-core", - "sp-std", -] - -[[package]] -name = "frame-support" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "bitmask", - "frame-metadata", - "frame-support-procedural", - "impl-trait-for-tuples", - "log", - "once_cell", - "parity-scale-codec", - "paste", - "serde", - "smallvec", - "sp-arithmetic", - "sp-core", - "sp-inherents", - "sp-io", - "sp-runtime", - "sp-state-machine", - "sp-std", - "sp-tracing", -] - -[[package]] -name = "frame-support-procedural" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "frame-support-procedural-tools", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "frame-support-procedural-tools" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "frame-support-procedural-tools-derive", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "frame-support-procedural-tools-derive" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "frame-system" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "frame-support", - "impl-trait-for-tuples", - "parity-scale-codec", - "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "sp-version", -] - -[[package]] -name = "futures" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95314d38584ffbfda215621d723e0a3906f032e03ae5551e650058dac83d4797" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0448174b01148032eed37ac4aed28963aaaa8cfa93569a08e5b479bbc6c2c151" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18eaa56102984bed2c88ea39026cff3ce3b4c7f508ca970cedf2450ea10d4e46" - -[[package]] -name = "futures-executor" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5f8e0c9258abaea85e78ebdda17ef9666d390e987f006be6080dfe354b708cb" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", - "num_cpus", -] - -[[package]] -name = "futures-io" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e1798854a4727ff944a7b12aa999f58ce7aa81db80d2dfaaf2ba06f065ddd2b" - -[[package]] -name = "futures-macro" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36fccf3fc58563b4a14d265027c627c3b665d7fed489427e88e7cc929559efe" -dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "futures-sink" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e3ca3f17d6e8804ae5d3df7a7d35b2b3a6fe89dac84b31872720fc3060a0b11" - -[[package]] -name = "futures-task" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d502af37186c4fef99453df03e374683f8a1eec9dcc1e66b3b82dc8278ce3c" -dependencies = [ - "once_cell", -] - -[[package]] -name = "futures-util" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abcb44342f62e6f3e8ac427b8aa815f724fd705dfad060b18ac7866c15bb8e34" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project", - "pin-utils", - "proc-macro-hack", - "proc-macro-nested", - "slab", -] - -[[package]] -name = "generic-array" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" -dependencies = [ - "typenum", -] - -[[package]] -name = "generic-array" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "wasi", -] - -[[package]] -name = "gimli" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" - -[[package]] -name = "hash-db" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" - -[[package]] -name = "hash256-std-hasher" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" -dependencies = [ - "crunchy", -] - -[[package]] -name = "hashbrown" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b62f79061a0bc2e046024cb7ba44b08419ed238ecbd9adbd787434b9e8c25" -dependencies = [ - "ahash", - "autocfg", -] - -[[package]] -name = "hermit-abi" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" -dependencies = [ - "libc", -] - -[[package]] -name = "hex" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" - -[[package]] -name = "hmac" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" -dependencies = [ - "crypto-mac", - "digest 0.8.1", -] - -[[package]] -name = "hmac-drbg" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6e570451493f10f6581b48cdd530413b63ea9e780f544bfd3bdcaa0d89d1a7b" -dependencies = [ - "digest 0.8.1", - "generic-array 0.12.3", - "hmac", -] - -[[package]] -name = "impl-codec" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be51a921b067b0eaca2fad532d9400041561aa922221cc65f95a85641c6bf53" -dependencies = [ - "parity-scale-codec", -] - -[[package]] -name = "impl-serde" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e3cae7e99c7ff5a995da2cf78dd0a5383740eda71d98cf7b1910c301ac69b8" -dependencies = [ - "serde", -] - -[[package]] -name = "impl-serde" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b47ca4d2b6931707a55fce5cf66aff80e2178c8b63bbb4ecb5695cbc870ddf6f" -dependencies = [ - "serde", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef5550a42e3740a0e71f909d4c861056a284060af885ae7aa6242820f920d9d" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "instant" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb1fc4429a33e1f80d41dc9fea4d108a88bec1de8053878898ae448a0b52f613" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "integer-sqrt" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" -dependencies = [ - "num-traits", -] - -[[package]] -name = "itertools" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" -dependencies = [ - "either", -] - -[[package]] -name = "keccak" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" - -[[package]] -name = "libsecp256k1" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc1e2c808481a63dc6da2074752fdd4336a3c8fcc68b83db6f1fd5224ae7962" -dependencies = [ - "arrayref", - "crunchy", - "digest 0.8.1", - "hmac-drbg", - "rand", - "sha2 0.8.2", - "subtle 2.3.0", - "typenum", -] - -[[package]] -name = "lock_api" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" -dependencies = [ - "scopeguard", -] - -[[package]] -name = "lock_api" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28247cc5a5be2f05fbcd76dd0cf2c7d3b5400cb978a28042abcd4fa0b3f8261c" -dependencies = [ - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" -dependencies = [ - "cfg-if 0.1.10", -] - -[[package]] -name = "memchr" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" - -[[package]] -name = "memory-db" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36f36ddb0b2cdc25d38babba472108798e3477f02be5165f038c5e393e50c57a" -dependencies = [ - "hash-db", - "hashbrown", - "parity-util-mem", -] - -[[package]] -name = "memory_units" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" - -[[package]] -name = "merlin" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6feca46f4fa3443a01769d768727f10c10a20fdb65e52dc16a81f0c8269bb78" -dependencies = [ - "byteorder", - "keccak", - "rand_core", - "zeroize", -] - -[[package]] -name = "miniz_oxide" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" -dependencies = [ - "adler", - "autocfg", -] - -[[package]] -name = "nodrop" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" - -[[package]] -name = "num-bigint" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" -dependencies = [ - "autocfg", - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" -dependencies = [ - "autocfg", -] - -[[package]] -name = "num_cpus" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "object" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" - -[[package]] -name = "once_cell" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" -dependencies = [ - "parking_lot 0.11.0", -] - -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - -[[package]] -name = "parity-scale-codec" -version = "1.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c740e5fbcb6847058b40ac7e5574766c6388f585e184d769910fe0d3a2ca861" -dependencies = [ - "arrayvec 0.5.2", - "bitvec", - "byte-slice-cast", - "parity-scale-codec-derive", - "serde", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "198db82bb1c18fc00176004462dd809b2a6d851669550aa17af6dacd21ae0c14" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "parity-util-mem" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "297ff91fa36aec49ce183484b102f6b75b46776822bd81525bfc4cc9b0dd0f5c" -dependencies = [ - "cfg-if 0.1.10", - "hashbrown", - "impl-trait-for-tuples", - "parity-util-mem-derive", - "parking_lot 0.10.2", - "primitive-types", - "winapi", -] - -[[package]] -name = "parity-util-mem-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" -dependencies = [ - "proc-macro2", - "syn", - "synstructure", -] - -[[package]] -name = "parity-wasm" -version = "0.41.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc878dac00da22f8f61e7af3157988424567ab01d9920b962ef7dcbd7cd865" - -[[package]] -name = "parking_lot" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" -dependencies = [ - "lock_api 0.3.4", - "parking_lot_core 0.7.2", -] - -[[package]] -name = "parking_lot" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4893845fa2ca272e647da5d0e46660a314ead9c2fdd9a883aabc32e481a8733" -dependencies = [ - "instant", - "lock_api 0.4.1", - "parking_lot_core 0.8.0", -] - -[[package]] -name = "parking_lot_core" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" -dependencies = [ - "cfg-if 0.1.10", - "cloudabi 0.0.3", - "libc", - "redox_syscall", - "smallvec", - "winapi", -] - -[[package]] -name = "parking_lot_core" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c361aa727dd08437f2f1447be8b59a33b0edd15e0fcee698f935613d9efbca9b" -dependencies = [ - "cfg-if 0.1.10", - "cloudabi 0.1.0", - "instant", - "libc", - "redox_syscall", - "smallvec", - "winapi", -] - -[[package]] -name = "paste" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880" -dependencies = [ - "paste-impl", - "proc-macro-hack", -] - -[[package]] -name = "paste-impl" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6" -dependencies = [ - "proc-macro-hack", -] - -[[package]] -name = "pbkdf2" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" -dependencies = [ - "byteorder", - "crypto-mac", -] - -[[package]] -name = "pin-project" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee41d838744f60d959d7074e3afb6b35c7456d0f61cad38a24e35e6553f73841" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81a4ffa594b66bff340084d4081df649a7dc049ac8d7fc458d8e628bfbbb2f86" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pin-project-lite" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "ppv-lite86" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20" - -[[package]] -name = "primitive-types" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55c21c64d0eaa4d7ed885d959ef2d62d9e488c27c0e02d9aa5ce6c877b7d5f8" -dependencies = [ - "fixed-hash", - "impl-codec", - "impl-serde 0.3.1", - "uint", -] - -[[package]] -name = "proc-macro-crate" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" -dependencies = [ - "toml", -] - -[[package]] -name = "proc-macro-hack" -version = "0.5.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99c605b9a0adc77b7211c6b1f722dcb613d68d66859a44f3d485a6da332b0598" - -[[package]] -name = "proc-macro-nested" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" - -[[package]] -name = "proc-macro2" -version = "1.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "quote" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "radium" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom", - "libc", - "rand_chacha", - "rand_core", - "rand_hc", - "rand_pcg", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core", -] - -[[package]] -name = "rand_pcg" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" -dependencies = [ - "rand_core", -] - -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - -[[package]] -name = "ref-cast" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "745c1787167ddae5569661d5ffb8b25ae5fedbf46717eaa92d652221cec72623" -dependencies = [ - "ref-cast-impl", -] - -[[package]] -name = "ref-cast-impl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d21b475ab879ef0e315ad99067fa25778c3b0377f57f1b00207448dac1a3144" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "regex" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8963b85b8ce3074fecffde43b4b0dded83ce2f367dc8d363afc56679f3ee820b" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", - "thread_local", -] - -[[package]] -name = "regex-syntax" -version = "0.6.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cab7a364d15cde1e505267766a2d3c4e22a843e1a601f0fa7564c0f82ced11c" - -[[package]] -name = "rental" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8545debe98b2b139fb04cad8618b530e9b07c152d99a5de83c860b877d67847f" -dependencies = [ - "rental-impl", - "stable_deref_trait", -] - -[[package]] -name = "rental-impl" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "475e68978dc5b743f2f40d8e0a8fdc83f1c5e78cbf4b8fa5e74e73beebc340de" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" - -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - -[[package]] -name = "rustc-hex" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" - -[[package]] -name = "schnorrkel" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862" -dependencies = [ - "arrayref", - "arrayvec 0.5.2", - "curve25519-dalek 2.1.0", - "getrandom", - "merlin", - "rand", - "rand_core", - "sha2 0.8.2", - "subtle 2.3.0", - "zeroize", -] - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "secrecy" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9182278ed645df3477a9c27bfee0621c621aa16f6972635f7f795dae3d81070f" -dependencies = [ - "zeroize", -] - -[[package]] -name = "serde" -version = "1.0.117" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.117" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "sha2" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", -] - -[[package]] -name = "sha2" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2933378ddfeda7ea26f48c555bdad8bb446bf8a3d17832dc83e380d444cfb8c1" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if 0.1.10", - "cpuid-bool", - "digest 0.9.0", - "opaque-debug 0.3.0", -] - -[[package]] -name = "signature" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210" - -[[package]] -name = "slab" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" - -[[package]] -name = "smallvec" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" - -[[package]] -name = "sp-application-crypto" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "parity-scale-codec", - "serde", - "sp-core", - "sp-io", - "sp-std", -] - -[[package]] -name = "sp-arithmetic" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "integer-sqrt", - "num-traits", - "parity-scale-codec", - "serde", - "sp-debug-derive", - "sp-std", -] - -[[package]] -name = "sp-core" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "base58", - "blake2-rfc", - "byteorder", - "derive_more", - "dyn-clonable", - "ed25519-dalek", - "futures", - "hash-db", - "hash256-std-hasher", - "hex", - "impl-serde 0.3.1", - "lazy_static", - "libsecp256k1", - "log", - "merlin", - "num-traits", - "parity-scale-codec", - "parity-util-mem", - "parking_lot 0.10.2", - "primitive-types", - "rand", - "regex", - "schnorrkel", - "secrecy", - "serde", - "sha2 0.8.2", - "sp-debug-derive", - "sp-externalities", - "sp-runtime-interface", - "sp-std", - "sp-storage", - "substrate-bip39", - "tiny-bip39", - "tiny-keccak", - "twox-hash", - "wasmi", - "zeroize", -] - -[[package]] -name = "sp-debug-derive" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "sp-externalities" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "environmental", - "parity-scale-codec", - "sp-std", - "sp-storage", -] - -[[package]] -name = "sp-inherents" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "derive_more", - "parity-scale-codec", - "parking_lot 0.10.2", - "sp-core", - "sp-std", -] - -[[package]] -name = "sp-io" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "futures", - "hash-db", - "libsecp256k1", - "log", - "parity-scale-codec", - "parking_lot 0.10.2", - "sp-core", - "sp-externalities", - "sp-runtime-interface", - "sp-state-machine", - "sp-std", - "sp-tracing", - "sp-trie", - "sp-wasm-interface", -] - -[[package]] -name = "sp-panic-handler" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "backtrace", - "log", -] - -[[package]] -name = "sp-runtime" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "either", - "hash256-std-hasher", - "impl-trait-for-tuples", - "log", - "parity-scale-codec", - "parity-util-mem", - "paste", - "rand", - "serde", - "sp-application-crypto", - "sp-arithmetic", - "sp-core", - "sp-inherents", - "sp-io", - "sp-std", -] - -[[package]] -name = "sp-runtime-interface" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "parity-scale-codec", - "primitive-types", - "sp-externalities", - "sp-runtime-interface-proc-macro", - "sp-std", - "sp-storage", - "sp-tracing", - "sp-wasm-interface", - "static_assertions", -] - -[[package]] -name = "sp-runtime-interface-proc-macro" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "Inflector", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "sp-state-machine" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "hash-db", - "itertools", - "log", - "num-traits", - "parity-scale-codec", - "parking_lot 0.10.2", - "rand", - "smallvec", - "sp-core", - "sp-externalities", - "sp-panic-handler", - "sp-trie", - "trie-db", - "trie-root", -] - -[[package]] -name = "sp-std" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" - -[[package]] -name = "sp-storage" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "impl-serde 0.2.3", - "parity-scale-codec", - "ref-cast", - "serde", - "sp-debug-derive", - "sp-std", -] - -[[package]] -name = "sp-tracing" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "log", - "rental", - "tracing", -] - -[[package]] -name = "sp-trie" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "hash-db", - "memory-db", - "parity-scale-codec", - "sp-core", - "sp-std", - "trie-db", - "trie-root", -] - -[[package]] -name = "sp-version" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "impl-serde 0.2.3", - "parity-scale-codec", - "serde", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "sp-wasm-interface" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186d87b9d2b47a2907c9b51ae1e252362c3" -dependencies = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "sp-std", - "wasmi", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "substrate-bip39" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bed6646a0159b9935b5d045611560eeef842b78d7adc3ba36f5ca325a13a0236" -dependencies = [ - "hmac", - "pbkdf2", - "schnorrkel", - "sha2 0.8.2", - "zeroize", -] - -[[package]] -name = "subtle" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" - -[[package]] -name = "subtle" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd" - -[[package]] -name = "syn" -version = "1.0.48" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "synstructure" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "unicode-xid", -] - -[[package]] -name = "thread_local" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "tiny-bip39" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0165e045cc2ae1660270ca65e1676dbaab60feb0f91b10f7d0665e9b47e31f2" -dependencies = [ - "failure", - "hmac", - "once_cell", - "pbkdf2", - "rand", - "rustc-hash", - "sha2 0.8.2", - "unicode-normalization", -] - -[[package]] -name = "tiny-keccak" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" -dependencies = [ - "crunchy", -] - -[[package]] -name = "tinyvec" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117" - -[[package]] -name = "toml" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75cf45bb0bef80604d001caaec0d09da99611b3c0fd39d3080468875cdb65645" -dependencies = [ - "serde", -] - -[[package]] -name = "tracing" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0987850db3733619253fe60e17cb59b82d37c7e6c0236bb81e4d6b87c879f27" -dependencies = [ - "cfg-if 0.1.10", - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing-core" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "trackback-pallet" -version = "2.0.0-rc6" -dependencies = [ - "frame-support", - "frame-system", - "parity-scale-codec", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "trie-db" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e55f7ace33d6237e14137e386f4e1672e2a5c6bbc97fef9f438581a143971f0" -dependencies = [ - "hash-db", - "hashbrown", - "log", - "rustc-hex", - "smallvec", -] - -[[package]] -name = "trie-root" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "652931506d2c1244d7217a70b99f56718a7b4161b37f04e7cd868072a99f68cd" -dependencies = [ - "hash-db", -] - -[[package]] -name = "twox-hash" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04f8ab788026715fa63b31960869617cba39117e520eb415b0139543e325ab59" -dependencies = [ - "cfg-if 0.1.10", - "rand", - "static_assertions", -] - -[[package]] -name = "typenum" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" - -[[package]] -name = "uint" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9db035e67dfaf7edd9aebfe8676afcd63eed53c8a4044fed514c8cccf1835177" -dependencies = [ - "byteorder", - "crunchy", - "rustc-hex", - "static_assertions", -] - -[[package]] -name = "unicode-normalization" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb19cf769fa8c6a80a162df694621ebeb4dafb606470b2b2fce0be40a98a977" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-xid" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" - -[[package]] -name = "version_check" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "wasmi" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf617d864d25af3587aa745529f7aaa541066c876d57e050c0d0c85c61c92aff" -dependencies = [ - "libc", - "memory_units", - "num-rational", - "num-traits", - "parity-wasm", - "wasmi-validation", -] - -[[package]] -name = "wasmi-validation" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea78c597064ba73596099281e2f4cfc019075122a65cdda3205af94f0b264d93" -dependencies = [ - "parity-wasm", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "zeroize" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f33972566adbd2d3588b0491eb94b98b43695c4ef897903470ede4f3f5a28a" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3f369ddb18862aba61aa49bf31e74d29f0f162dec753063200e1dc084345d16" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", -] diff --git a/pallets/trackback/Cargo.toml b/pallets/trackback/Cargo.toml deleted file mode 100644 index 62fb916..0000000 --- a/pallets/trackback/Cargo.toml +++ /dev/null @@ -1,40 +0,0 @@ -[package] -authors = ['Trackback'] -description = 'Custom Trackback FRAME pallet' -edition = '2018' -homepage = 'https://trackback.co.nz/' -license = 'LGPL-3.0' -name = 'pallet-trackback' -repository = 'https://github.com/trackback-blockchain/trackback-pallet/' -version = '0.0.1' - -[package.metadata.docs.rs] -targets = ['x86_64-unknown-linux-gnu'] - -# alias "parity-scale-code" to "codec" -[dependencies.codec] -default-features = false -features = ['derive'] -package = 'parity-scale-codec' -version = '2.0.0' - -[dependencies] -frame-support = { default-features = false, version = '3.0.0' } -frame-system = { default-features = false, version = '3.0.0' } -sp-std = { default-features = false, version = '3.0.0' } - -[dev-dependencies] -serde = { version = "1.0.119" } -sp-core = { default-features = false, version = '3.0.0' } -sp-io = { default-features = false, version = '3.0.0' } -sp-runtime = { default-features = false, version = '3.0.0' } - -[features] -default = ['std'] -std = [ - 'codec/std', - 'sp-std/std', - 'frame-support/std', - 'frame-system/std', - 'sp-std/std', -] diff --git a/pallets/trackback/HOWTO.md b/pallets/trackback/HOWTO.md deleted file mode 100644 index 23d8a26..0000000 --- a/pallets/trackback/HOWTO.md +++ /dev/null @@ -1,127 +0,0 @@ -# How to Use - -Simply fork this project and start your runtime development in `lib.rs`. - -## Update Your Package Information - -In the `Cargo.toml` file of this template, you should update the name and authors of this pallet: - -```rust -[package] -name = "" -version = "0.1.0" -description = '' -authors = [""] -edition = '2018' -homepage = '' -license = 'LGPL-3.0' -``` - -## Updating Your Dependencies - -For the time being, Substrate does not have any releases on Cargo, which means there is some magic involved with ensuring that all the dependencies of your pallet and the downstream runtime are the same. - -This repository has all Substrate dependencies use: - -``` -rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee' -``` - -> **Note:** Be sure to purge your projects of any `Cargo.lock` files when making changes like this! - -## Adding New Dependencies - -Substrate FRAME can support any Rust libraries that can compile to Wasm. In general, this means that the libraries you use must compile with `no_std` enabled. - -This also means you need to import your dependencies to only use their `std` feature when this pallet uses its `std` dependency. - -The common pattern here look like: - -1. Import your library with `default-features = false` - - ```TOML - [dependencies.codec] - default-features = false - features = ['derive'] - package = 'parity-scale-codec' - version = '1.3.0' - ``` - -2. Add your library to the `std` feature with its `std` feature enabled - - ```TOML - std = [ - 'codec/std', - # --snip-- - ] - ``` - -We won't teach you the details of using Cargo, but feel free to [become a master](https://doc.rust-lang.org/cargo/). - -## Building and Testing - -Before you release your pallet, you should check that it can: - -1. Build to Native: - - ``` - cargo build --release - ``` - -2. Pass your tests: - - ``` - cargo test - ``` - -## Update the README - -Finally, update the [README](README.md) included with this template with the appropriate information for your pallet. - -## Common Issues - -Unfortunately keeping things modular can be a little tricky. Here are some common issues you may face. - -### Developer Dependencies - -When running `cargo build`, everything can compile fine, but when running `cargo test`, you may run into an import error like: - -```rust -error[E0432]: unresolved import `sp_core` - --> src/lib.rs:72:6 - | -72 | use sp_core::H256; - | ^^^^^^^ use of undeclared type or module `sp_core` - -error: aborting due to previous error -``` - -You may need to specify some developer dependency which is needed for your tests: - -``` -[dev-dependencies.sp-core] -default-features = false -git = 'https://github.com/paritytech/substrate.git' -rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee' -``` - -> **Note:** `dev-dependencies` will always use `std`, so you should not set `default-features = false`. - - -### Using Mismatching Substrate Dependencies - -We mentioned above how it is important that your runtime and your module have exactly the same dependency on the Substrate project. If they do not, you will get a lot of `trait bound` errors like this: - -```rust -error[E0277]: the trait bound `Runtime: frame_system::Trait` is not satisfied in `Event` - | -112 | impl system::Trait for Runtime { - | ^^^^^^^^^^^^^ within `Event`, the trait `frame_system::Trait` is not implemented for `Runtime` - | - = note: required because it appears within the type `Event` - -error[E0277]: the trait bound `Runtime: frame_system::Trait` is not satisfied - | -196 | impl test_module::Trait for Runtime { - | ^^^^^^^^^^^^^^^^^^ the trait `frame_system::Trait` is not implemented for `Runtime` -``` diff --git a/pallets/trackback/LICENSE b/pallets/trackback/LICENSE deleted file mode 100644 index cf1ab25..0000000 --- a/pallets/trackback/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -This is free and unencumbered software released into the public domain. - -Anyone is free to copy, modify, publish, use, compile, sell, or -distribute this software, either in source code form or as a compiled -binary, for any purpose, commercial or non-commercial, and by any -means. - -In jurisdictions that recognize copyright laws, the author or authors -of this software dedicate any and all copyright interest in the -software to the public domain. We make this dedication for the benefit -of the public at large and to the detriment of our heirs and -successors. We intend this dedication to be an overt act of -relinquishment in perpetuity of all present and future rights to this -software under copyright law. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -For more information, please refer to diff --git a/pallets/trackback/README.md b/pallets/trackback/README.md deleted file mode 100644 index 7677cac..0000000 --- a/pallets/trackback/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# TANZ Node - -This is a template for a Substrate pallet which lives as its own crate so it can be imported into multiple runtimes. It is based on the ["template" pallet](https://github.com/paritytech/substrate/tree/master/bin/node-template/pallets/template) that is included with the [Substrate node template](https://github.com/paritytech/substrate/tree/master/bin/node-template). - -Check out the [HOWTO](HOWTO.md) to learn how to use this for your own runtime module. - -This README should act as a general template for distributing your pallet to others. - -## Purpose - -This pallet acts as a template for building other pallets. - -It currently allows a user to put a `u32` value into storage, which triggers a runtime event. - -## Dependencies - -### Traits - -This pallet does not depend on any externally defined traits. - -### Pallets - -This pallet does not depend on any other FRAME pallet or externally developed modules. - -## Installation - -### Runtime `Cargo.toml` - -To add this pallet to your runtime, simply include the following to your runtime's `Cargo.toml` file: - -```TOML -[dependencies.substrate-pallet-template] -default_features = false -git = 'https://github.com/substrate-developer-hub/substrate-pallet-template.git' -``` - -and update your runtime's `std` feature to include this pallet: - -```TOML -std = [ - # --snip-- - 'example_pallet/std', -] -``` - -### Runtime `lib.rs` - -You should implement it's trait like so: - -```rust -/// Used for test_module -impl example_pallet::Trait for Runtime { - type Event = Event; -} -``` - -and include it in your `construct_runtime!` macro: - -```rust -ExamplePallet: substrate_pallet_template::{Module, Call, Storage, Event}, -``` - -### Genesis Configuration - -This template pallet does not have any genesis configuration. - -## Reference Docs - -You can view the reference docs for this pallet by running: - -``` -cargo doc --open -``` - -or by visiting this site: diff --git a/pallets/trackback/src/lib.rs b/pallets/trackback/src/lib.rs deleted file mode 100644 index 12e359a..0000000 --- a/pallets/trackback/src/lib.rs +++ /dev/null @@ -1,278 +0,0 @@ -#![cfg_attr(not(feature = "std"), no_std)] - -use frame_support::codec::{Decode, Encode}; -/// Edit this file to define custom logic or remove it if it is not needed. -/// Learn more about FRAME and the core library of Substrate FRAME pallets: -/// https://substrate.dev/docs/en/knowledgebase/runtime/frame -use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure, StorageMap}; -use frame_system::ensure_signed; -use sp_std::collections::btree_set::BTreeSet; -use sp_std::vec::Vec; - -#[cfg(test)] -mod mock; - -#[cfg(test)] -mod tests; - -/// Configure the pallet by specifying the parameters and types on which it depends. -pub trait Config: frame_system::Config { - /// Because this pallet emits events, it depends on the runtime's definition of an event. - type Event: From> + Into<::Event>; -} - -// Represents a crop entry result from BELIS -#[derive(Encode, Decode, Clone, PartialEq)] -pub enum CropEntryResult { - Accepted(Vec), - Rejected, -} - -impl Default for CropEntryResult { - fn default() -> Self { - CropEntryResult::Rejected - } -} - -// Represents a bci line result from BELIS -#[derive(Encode, Decode, Clone, PartialEq)] -pub enum BCILineResult { - Accepted, - Rejected, -} - -impl Default for BCILineResult { - fn default() -> Self { - BCILineResult::Rejected - } -} - -// The pallet's runtime storage items. -// https://substrate.dev/docs/en/knowledgebase/runtime/storage -decl_storage! { - // A unique name is used to ensure that the pallet's storage items are isolated. - // This name may be updated, but each pallet in the runtime must use a unique name. - // ---------------------------------vvvvvvvvvvvvvv - trait Store for Module as TrackbackModule { - // Learn more about declaring storage items: - // https://substrate.dev/docs/en/knowledgebase/runtime/storage#declaring-storage-items - - // crop_entry_id to [grower, event_hash, block_number] - CropEntries get(fn crop_entries): map hasher(blake2_128_concat) Vec => (T::AccountId, Vec, T::BlockNumber); - - // crop_entry_id to [approver, result, event_hash, block_number] - CropEntryResults get(fn crop_entry_results): map hasher(blake2_128_concat) Vec => (T::AccountId, CropEntryResult, Vec, T::BlockNumber); - - // crn to [approver, crop_info_id, event_hash, block_number] - CRNs get(fn crns): map hasher(blake2_128_concat) Vec => (T::AccountId, Vec, Vec, T::BlockNumber); - - // bci_line_id to [submitter, crn, event_hash, block_number] - BCILines get(fn bci_lines): map hasher(blake2_128_concat) Vec => (T::AccountId, Vec, Vec, T::BlockNumber); - - // bci_line_id to [approver, result, event_hash, block_number] - BCILineResults get(fn bci_line_results): map hasher(blake2_128_concat) Vec => (T::AccountId, BCILineResult, Vec, T::BlockNumber); - } -} - -// Pallets use events to inform users when important changes are made. -// https://substrate.dev/docs/en/knowledgebase/runtime/events -decl_event!( - pub enum Event - where - AccountId = ::AccountId, - { - /// Seed application submitted by grower. [event_hash, who] - SeedApplicationSubmitted(Vec, AccountId), - /// Seed application approved by BELIS system. [event_hash, who] - SeedApplicationApproved(Vec, AccountId), - /// Seed application rejected by BELIS system. [event_hash, who] - SeedApplicationRejected(Vec, AccountId), - /// BCI line submitted [event_hash, who] - BCILineSubmitted(Vec, AccountId), - /// BCI line approved by BELIS system. [event_hash, who] - BCILineApproved(Vec, AccountId), - /// BCI line rejected by BELIS system. [event_hash, who] - BCILineRejected(Vec, AccountId), - } -); - -// Errors inform users that something went wrong. -decl_error! { - pub enum Error for Module { - SeedApplicationAlreadyExists, - NoCropEntriesInApplication, - DuplicateCropEntryIdsInApplication, - CropEntryIdAlreadyExists, - CropEntryNotFoundForSeedValidation, - CropEntryAlreadyValidated, - CRNNotFoundForBCILine, - BCILineAlreadyExists, - BCILineIdNotFoundForValidation, - BCILineAlreadyValidated, - } -} - -// Dispatchable functions allows users to interact with the pallet and invoke state changes. -// These functions materialize as "extrinsics", which are often compared to transactions. -// Dispatchable functions must be annotated with a weight and must return a DispatchResult. -decl_module! { - pub struct Module for enum Call where origin: T::Origin { - // Errors must be initialized if they are used by the pallet. - type Error = Error; - - // Events must be initialized if they are used by the pallet. - fn deposit_event() = default; - - /// Stores the crop-entry ids and hashes of submitted crop entries - #[weight = 10_000] - pub fn submit_crop_entries(origin, event_hash: Vec, crop_entries: Vec>) { - // Check that the extrinsic was signed and get the signer. - // This function will return an error if the extrinsic is not signed. - // https://substrate.dev/docs/en/knowledgebase/runtime/origin - let sender = ensure_signed(origin)?; - - ensure!(crop_entries.len() > 0, Error::::NoCropEntriesInApplication); - let mut seen = BTreeSet::new(); - - // Make sure the crop info Ids hasn't been already submitted - for entry in &crop_entries { - let is_unique = seen.insert(entry); - ensure!(is_unique, Error::::DuplicateCropEntryIdsInApplication); - ensure!(!(CropEntries::::get(&entry).1 == event_hash), Error::::SeedApplicationAlreadyExists); - ensure!(!CropEntries::::contains_key(&entry), Error::::CropEntryIdAlreadyExists); - } - - // Get the block number from the FRAME System module. - let current_block = >::block_number(); - - // Store hash of the entire crop info application with each crop info Ids - // We do this after complete validation to avoid any partial inserts to the state. - for entry in crop_entries { - CropEntries::::insert(&entry, (&sender, &event_hash, ¤t_block)) - } - - // Emit an event that the application was created - Self::deposit_event(RawEvent::SeedApplicationSubmitted(event_hash, sender)); - } - - /// Accepts a crop entry if it exists and has no result already. Then store the CRN for the crop entry - #[weight = 10_000] - pub fn accept_crop_entry(origin, crop_entry: Vec, event_hash: Vec, crn: Vec) { - // Check that the extrinsic was signed and get the signer. - // This function will return an error if the extrinsic is not signed. - // https://substrate.dev/docs/en/knowledgebase/runtime/origin - let sender = ensure_signed(origin)?; - - // Make sure the crop entry record exists - ensure!(CropEntries::::contains_key(&crop_entry), Error::::CropEntryNotFoundForSeedValidation); - // Make sure it hasn't been already decided - ensure!(!CropEntryResults::::contains_key(&crop_entry), Error::::CropEntryAlreadyValidated); - - // Get the block number from the FRAME System module. - let current_block = >::block_number(); - - // Store result of crop entry with its event hash - CropEntryResults::::insert(&crop_entry, (&sender, CropEntryResult::Accepted(crn.clone()), &event_hash, ¤t_block)); - - // Store crn submitted with the crop entry approval - CRNs::::insert(&crn, (&sender, &event_hash, &crop_entry, ¤t_block)); - - // Emit an event that the crop entry was approved - Self::deposit_event(RawEvent::SeedApplicationApproved(event_hash, sender)); - } - - /// Rejects a crop entry if it exists and has no result already - #[weight = 10_000] - pub fn reject_crop_entry(origin, crop_entry: Vec, event_hash: Vec) { - // Check that the extrinsic was signed and get the signer. - // This function will return an error if the extrinsic is not signed. - // https://substrate.dev/docs/en/knowledgebase/runtime/origin - let sender = ensure_signed(origin)?; - - // Make sure the crop entry record exists - ensure!(CropEntries::::contains_key(&crop_entry), Error::::CropEntryNotFoundForSeedValidation); - // Make sure it hasn't been already decided - ensure!(!CropEntryResults::::contains_key(&crop_entry), Error::::CropEntryAlreadyValidated); - - // Get the block number from the FRAME System module. - let current_block = >::block_number(); - - // Store result of crop entry with its event hash - CropEntryResults::::insert(&crop_entry, (&sender, CropEntryResult::Rejected, &event_hash, ¤t_block)); - - // Emit an event that the crop entry was approved - Self::deposit_event(RawEvent::SeedApplicationRejected(event_hash, sender)); - } - - /// Submits a BCI line against a CRN and store the event hash - #[weight = 10_000] - pub fn submit_bci_line(origin, crn: Vec, bci_line_id: Vec, event_hash: Vec) { - // Check that the extrinsic was signed and get the signer. - // This function will return an error if the extrinsic is not signed. - // https://substrate.dev/docs/en/knowledgebase/runtime/origin - let sender = ensure_signed(origin)?; - - // Make sure the crn record exists - ensure!(CRNs::::contains_key(&crn), Error::::CRNNotFoundForBCILine); - - // Make sure that the bci line with same Id doesn't already exists - ensure!(!BCILines::::contains_key(&bci_line_id), Error::::BCILineAlreadyExists); - - // Get the block number from the FRAME System module. - let current_block = >::block_number(); - - // Store event_hash of the entire BCI line application - BCILines::::insert(&bci_line_id, (&sender, &crn, &event_hash, ¤t_block)); - - // Emit an event that the BCI line was submitted - Self::deposit_event(RawEvent::BCILineSubmitted(event_hash, sender)); - } - - /// Accept a BCI line if BCI line exists and has not result already - #[weight = 10_000] - pub fn accept_bci_line(origin, bci_line_id: Vec, event_hash: Vec) { - // Check that the extrinsic was signed and get the signer. - // This function will return an error if the extrinsic is not signed. - // https://substrate.dev/docs/en/knowledgebase/runtime/origin - let sender = ensure_signed(origin)?; - - // Make sure the BCI line - ensure!(BCILines::::contains_key(&bci_line_id), Error::::BCILineIdNotFoundForValidation); - // Make sure it hasn't been already decided - ensure!(!BCILineResults::::contains_key(&bci_line_id), Error::::BCILineAlreadyValidated); - - // Get the block number from the FRAME System module. - let current_block = >::block_number(); - - // Store result against the BCI line - BCILineResults::::insert(&bci_line_id, (&sender, BCILineResult::Accepted, &event_hash, ¤t_block)); - - // Emit an event that the BCI line was approved - Self::deposit_event(RawEvent::BCILineApproved(event_hash, sender)); - } - - /// Reject a BCI line if BCI line exists and has not result already - #[weight = 10_000] - pub fn reject_bci_line(origin, bci_line_id: Vec, event_hash: Vec) { - // Check that the extrinsic was signed and get the signer. - // This function will return an error if the extrinsic is not signed. - // https://substrate.dev/docs/en/knowledgebase/runtime/origin - let sender = ensure_signed(origin)?; - - // Make sure the BCI line - ensure!(BCILines::::contains_key(&bci_line_id), Error::::BCILineIdNotFoundForValidation); - // Make sure it hasn't been already decided - ensure!(!BCILineResults::::contains_key(&bci_line_id), Error::::BCILineAlreadyValidated); - - // Get the block number from the FRAME System module. - let current_block = >::block_number(); - - // Store result against the BCI line - BCILineResults::::insert(&bci_line_id, (&sender, BCILineResult::Rejected, &event_hash, ¤t_block)); - - // Emit an event that the BCI line was approved - Self::deposit_event(RawEvent::BCILineRejected(event_hash, sender)); - } - - } -} diff --git a/pallets/trackback/src/mock.rs b/pallets/trackback/src/mock.rs deleted file mode 100644 index 27d3fee..0000000 --- a/pallets/trackback/src/mock.rs +++ /dev/null @@ -1,65 +0,0 @@ -use crate as pallet_trackback; -use frame_support::parameter_types; -use frame_system as system; -use sp_core::H256; -use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, -}; - -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; - -// Configure a mock runtime to test the pallet. -frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Module, Call, Config, Storage, Event}, - TemplateModule: pallet_trackback::{Module, Call, Storage, Event}, - } -); - -parameter_types! { - pub const BlockHashCount: u64 = 250; - pub const SS58Prefix: u8 = 42; -} - -impl system::Config for Test { - type BaseCallFilter = (); - type BlockWeights = (); - type BlockLength = (); - type DbWeight = (); - type Origin = Origin; - type Call = Call; - type Index = u64; - type BlockNumber = u64; - type Hash = H256; - type Hashing = BlakeTwo256; - type AccountId = u64; - type Lookup = IdentityLookup; - type Header = Header; - type Event = Event; - type BlockHashCount = BlockHashCount; - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = (); - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = SS58Prefix; -} - -impl pallet_trackback::Config for Test { - type Event = Event; -} - -// Build genesis storage according to the mock runtime. -pub fn new_test_ext() -> sp_io::TestExternalities { - system::GenesisConfig::default() - .build_storage::() - .unwrap() - .into() -} diff --git a/pallets/trackback/src/tests.rs b/pallets/trackback/src/tests.rs deleted file mode 100644 index 9496eef..0000000 --- a/pallets/trackback/src/tests.rs +++ /dev/null @@ -1,23 +0,0 @@ -use crate::{mock::*, Error}; -use frame_support::{assert_noop, assert_ok}; - -#[test] -fn it_works_for_default_value() { - new_test_ext().execute_with(|| { - // Dispatch a signed extrinsic. - // assert_ok!(TemplateModule::do_something(Origin::signed(1), 42)); - // Read pallet storage and assert an expected result. - // assert_eq!(TemplateModule::something(), Some(42)); - }); -} - -#[test] -fn correct_error_for_none_value() { - new_test_ext().execute_with(|| { - // Ensure the expected error is thrown when no value is present. - // assert_noop!( - // TemplateModule::cause_error(Origin::signed(1)), - // Error::::NoneValue - // ); - }); -} diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index cb49355..b5ec5aa 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -23,7 +23,6 @@ version = '2.0.0' [dependencies] hex-literal = { optional = true, version = '0.3.1' } serde = { features = ['derive'], optional = true, version = '1.0.119' } -pallet-trackback = { path = '../pallets/trackback', default-features = false, version = '0.0.1' } pallet-dids = { path = '../pallets/dids', default-features = false, version = '0.0.1' } # Substrate dependencies @@ -80,7 +79,6 @@ std = [ 'pallet-node-authorization/std', 'pallet-randomness-collective-flip/std', 'pallet-sudo/std', - 'pallet-trackback/std', 'pallet-timestamp/std', 'pallet-transaction-payment/std', 'pallet-transaction-payment-rpc-runtime-api/std', diff --git a/runtime/build.rs b/runtime/build.rs index 9dcfddb..203d775 100644 --- a/runtime/build.rs +++ b/runtime/build.rs @@ -1,9 +1,9 @@ use substrate_wasm_builder::WasmBuilder; fn main() { - WasmBuilder::new() - .with_current_project() - .import_memory() - .export_heap_base() - .build() + WasmBuilder::new() + .with_current_project() + .import_memory() + .export_heap_base() + .build() } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 3105097..ff908c7 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -6,35 +6,33 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); - -use pallet_grandpa::fg_primitives; -use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; +use frame_system::EnsureRoot; +use pallet_grandpa::{ + fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList, +}; use sp_api::impl_runtime_apis; use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; -use sp_runtime::traits::{ - AccountIdLookup, BlakeTwo256, Block as BlockT, IdentifyAccount, NumberFor, Verify, -}; use sp_runtime::{ - create_runtime_str, generic, impl_opaque_keys, - transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, MultiSignature, + create_runtime_str, generic, impl_opaque_keys, + traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, IdentifyAccount, NumberFor, Verify}, + transaction_validity::{TransactionSource, TransactionValidity}, + ApplyExtrinsicResult, MultiSignature, }; use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; -use frame_system::EnsureRoot; // A few exports that help ease life for downstream crates. pub use frame_support::{ - construct_runtime, parameter_types, - traits::{KeyOwnerProofSystem, Randomness}, - weights::{ - constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND}, - IdentityFee, Weight, - }, - StorageValue, + construct_runtime, parameter_types, + traits::{KeyOwnerProofSystem, Randomness}, + weights::{ + constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND}, + IdentityFee, Weight, + }, + StorageValue, }; pub use pallet_balances::Call as BalancesCall; pub use pallet_timestamp::Call as TimestampCall; @@ -43,9 +41,6 @@ use pallet_transaction_payment::CurrencyAdapter; pub use sp_runtime::BuildStorage; pub use sp_runtime::{Perbill, Permill}; -/// Import the template pallet. -pub use pallet_trackback; - /// Decentralised Identifiers pallet. pub use pallet_dids; /// An index to a block. @@ -79,33 +74,33 @@ pub type DigestItem = generic::DigestItem; /// of data like extrinsics, allowing for them to continue syncing the network through upgrades /// to even the core data structures. pub mod opaque { - use super::*; - - pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; - - /// Opaque block header type. - pub type Header = generic::Header; - /// Opaque block type. - pub type Block = generic::Block; - /// Opaque block identifier type. - pub type BlockId = generic::BlockId; - - impl_opaque_keys! { - pub struct SessionKeys { - pub aura: Aura, - pub grandpa: Grandpa, - } - } + use super::*; + + pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; + + /// Opaque block header type. + pub type Header = generic::Header; + /// Opaque block type. + pub type Block = generic::Block; + /// Opaque block identifier type. + pub type BlockId = generic::BlockId; + + impl_opaque_keys! { + pub struct SessionKeys { + pub aura: Aura, + pub grandpa: Grandpa, + } + } } pub const VERSION: RuntimeVersion = RuntimeVersion { - spec_name: create_runtime_str!("trackback-node"), - impl_name: create_runtime_str!("trackback-node"), - authoring_version: 1, - spec_version: 100, - impl_version: 1, - apis: RUNTIME_API_VERSIONS, - transaction_version: 1, + spec_name: create_runtime_str!("trackback-node"), + impl_name: create_runtime_str!("trackback-node"), + authoring_version: 1, + spec_version: 100, + impl_version: 1, + apis: RUNTIME_API_VERSIONS, + transaction_version: 1, }; /// This determines the average expected block time that we are targeting. @@ -127,192 +122,183 @@ pub const DAYS: BlockNumber = HOURS * 24; #[cfg(feature = "std")] pub fn native_version() -> NativeVersion { - NativeVersion { - runtime_version: VERSION, - can_author_with: Default::default(), - } + NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } } const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); parameter_types! { - pub const Version: RuntimeVersion = VERSION; - pub const BlockHashCount: BlockNumber = 2400; - /// We allow for 2 seconds of compute with a 6 second average block time. - pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights - ::with_sensible_defaults(2 * WEIGHT_PER_SECOND, NORMAL_DISPATCH_RATIO); - pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength - ::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); - pub const SS58Prefix: u8 = 42; + pub const Version: RuntimeVersion = VERSION; + pub const BlockHashCount: BlockNumber = 2400; + /// We allow for 2 seconds of compute with a 6 second average block time. + pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights + ::with_sensible_defaults(2 * WEIGHT_PER_SECOND, NORMAL_DISPATCH_RATIO); + pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength + ::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); + pub const SS58Prefix: u8 = 42; } // Configure FRAME pallets to include in runtime. impl frame_system::Config for Runtime { - /// The basic call filter to use in dispatchable. - type BaseCallFilter = (); - /// Block & extrinsics weights: base values and limits. - type BlockWeights = BlockWeights; - /// The maximum length of a block (in bytes). - type BlockLength = BlockLength; - /// The identifier used to distinguish between accounts. - type AccountId = AccountId; - /// The aggregated dispatch type that is available for extrinsics. - type Call = Call; - /// The lookup mechanism to get account ID from whatever is passed in dispatchers. - type Lookup = AccountIdLookup; - /// The index type for storing how many extrinsics an account has signed. - type Index = Index; - /// The index type for blocks. - type BlockNumber = BlockNumber; - /// The type for hashing blocks and tries. - type Hash = Hash; - /// The hashing algorithm used. - type Hashing = BlakeTwo256; - /// The header type. - type Header = generic::Header; - /// The ubiquitous event type. - type Event = Event; - /// The ubiquitous origin type. - type Origin = Origin; - /// Maximum number of block number to block hash mappings to keep (oldest pruned first). - type BlockHashCount = BlockHashCount; - /// The weight of database operations that the runtime can invoke. - type DbWeight = RocksDbWeight; - /// Version of the runtime. - type Version = Version; - /// Converts a module to the index of the module in `construct_runtime!`. - /// - /// This type is being generated by `construct_runtime!`. - type PalletInfo = PalletInfo; - /// What to do if a new account is created. - type OnNewAccount = (); - /// What to do if an account is fully reaped from the system. - type OnKilledAccount = (); - /// The data to be stored in an account. - type AccountData = pallet_balances::AccountData; - /// Weight information for the extrinsics of this pallet. - type SystemWeightInfo = (); - /// This is used as an identifier of the chain. 42 is the generic substrate prefix. - type SS58Prefix = SS58Prefix; + /// The basic call filter to use in dispatchable. + type BaseCallFilter = (); + /// Block & extrinsics weights: base values and limits. + type BlockWeights = BlockWeights; + /// The maximum length of a block (in bytes). + type BlockLength = BlockLength; + /// The identifier used to distinguish between accounts. + type AccountId = AccountId; + /// The aggregated dispatch type that is available for extrinsics. + type Call = Call; + /// The lookup mechanism to get account ID from whatever is passed in dispatchers. + type Lookup = AccountIdLookup; + /// The index type for storing how many extrinsics an account has signed. + type Index = Index; + /// The index type for blocks. + type BlockNumber = BlockNumber; + /// The type for hashing blocks and tries. + type Hash = Hash; + /// The hashing algorithm used. + type Hashing = BlakeTwo256; + /// The header type. + type Header = generic::Header; + /// The ubiquitous event type. + type Event = Event; + /// The ubiquitous origin type. + type Origin = Origin; + /// Maximum number of block number to block hash mappings to keep (oldest pruned first). + type BlockHashCount = BlockHashCount; + /// The weight of database operations that the runtime can invoke. + type DbWeight = RocksDbWeight; + /// Version of the runtime. + type Version = Version; + /// Converts a module to the index of the module in `construct_runtime!`. + /// + /// This type is being generated by `construct_runtime!`. + type PalletInfo = PalletInfo; + /// What to do if a new account is created. + type OnNewAccount = (); + /// What to do if an account is fully reaped from the system. + type OnKilledAccount = (); + /// The data to be stored in an account. + type AccountData = pallet_balances::AccountData; + /// Weight information for the extrinsics of this pallet. + type SystemWeightInfo = (); + /// This is used as an identifier of the chain. 42 is the generic substrate prefix. + type SS58Prefix = SS58Prefix; } impl pallet_aura::Config for Runtime { - type AuthorityId = AuraId; + type AuthorityId = AuraId; } impl pallet_grandpa::Config for Runtime { - type Event = Event; + type Event = Event; - type Call = Call; + type Call = Call; - type KeyOwnerProofSystem = (); + type KeyOwnerProofSystem = (); - type KeyOwnerProof = - >::Proof; + type KeyOwnerProof = + >::Proof; - type KeyOwnerIdentification = >::IdentificationTuple; + type KeyOwnerIdentification = >::IdentificationTuple; - type HandleEquivocation = (); + type HandleEquivocation = (); - type WeightInfo = (); + type WeightInfo = (); } parameter_types! { - pub const MinimumPeriod: u64 = SLOT_DURATION / 2; + pub const MinimumPeriod: u64 = SLOT_DURATION / 2; } impl pallet_timestamp::Config for Runtime { - /// A timestamp: milliseconds since the unix epoch. + /// A timestamp: milliseconds since the unix epoch. - type Moment = u64; - type OnTimestampSet = Aura; - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); + type Moment = u64; + type OnTimestampSet = Aura; + type MinimumPeriod = MinimumPeriod; + type WeightInfo = (); } parameter_types! { - pub const ExistentialDeposit: u128 = 500; - pub const MaxLocks: u32 = 50; + pub const ExistentialDeposit: u128 = 500; + pub const MaxLocks: u32 = 50; } impl pallet_balances::Config for Runtime { - type MaxLocks = MaxLocks; - /// The type for recording an account's balance. - type Balance = Balance; - /// The ubiquitous event type. - type Event = Event; - type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; - type AccountStore = System; - type WeightInfo = pallet_balances::weights::SubstrateWeight; + type MaxLocks = MaxLocks; + /// The type for recording an account's balance. + type Balance = Balance; + /// The ubiquitous event type. + type Event = Event; + type DustRemoval = (); + type ExistentialDeposit = ExistentialDeposit; + type AccountStore = System; + type WeightInfo = pallet_balances::weights::SubstrateWeight; } parameter_types! { - pub const TransactionByteFee: Balance = 1; + pub const TransactionByteFee: Balance = 1; } impl pallet_transaction_payment::Config for Runtime { - type OnChargeTransaction = CurrencyAdapter; - type TransactionByteFee = TransactionByteFee; - type WeightToFee = IdentityFee; - type FeeMultiplierUpdate = (); + type OnChargeTransaction = CurrencyAdapter; + type TransactionByteFee = TransactionByteFee; + type WeightToFee = IdentityFee; + type FeeMultiplierUpdate = (); } impl pallet_sudo::Config for Runtime { - type Event = Event; - type Call = Call; -} - -/// Configure the template pallet in pallets/template. -impl pallet_trackback::Config for Runtime { - type Event = Event; + type Event = Event; + type Call = Call; } impl pallet_dids::Config for Runtime { - type Event = Event; - type TimeProvider = pallet_timestamp::Pallet; + type Event = Event; + type TimeProvider = pallet_timestamp::Pallet; } parameter_types! { - pub const MaxWellKnownNodes: u32 = 2000; - pub const MaxPeerIdLength: u32 = 128; + pub const MaxWellKnownNodes: u32 = 2000; + pub const MaxPeerIdLength: u32 = 128; } impl pallet_node_authorization::Config for Runtime { - type Event = Event; - type MaxWellKnownNodes = MaxWellKnownNodes; - type MaxPeerIdLength = MaxPeerIdLength; - type AddOrigin = EnsureRoot; - type RemoveOrigin = EnsureRoot; - type SwapOrigin = EnsureRoot; - type ResetOrigin = EnsureRoot; - type WeightInfo = (); + type Event = Event; + type MaxWellKnownNodes = MaxWellKnownNodes; + type MaxPeerIdLength = MaxPeerIdLength; + type AddOrigin = EnsureRoot; + type RemoveOrigin = EnsureRoot; + type SwapOrigin = EnsureRoot; + type ResetOrigin = EnsureRoot; + type WeightInfo = (); } // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = opaque::Block, - UncheckedExtrinsic = UncheckedExtrinsic - { - System: frame_system::{Module, Call, Config, Storage, Event}, - RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, - Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, - Aura: pallet_aura::{Module, Config}, - Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - TransactionPayment: pallet_transaction_payment::{Module, Storage}, - Sudo: pallet_sudo::{Module, Call, Config, Storage, Event}, - NodeAuthorization: pallet_node_authorization::{Module, Call, Storage, Event, Config}, - // Include the custom logic from the template pallet in the runtime. - TrackbackModule: pallet_trackback::{Module, Call, Storage, Event}, - DIDModule: pallet_dids::{Module, Call, Storage, Event}, - } + pub enum Runtime where + Block = Block, + NodeBlock = opaque::Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + System: frame_system::{Module, Call, Config, Storage, Event}, + RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, + Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, + Aura: pallet_aura::{Module, Config}, + Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event}, + Balances: pallet_balances::{Module, Call, Storage, Config, Event}, + TransactionPayment: pallet_transaction_payment::{Module, Storage}, + Sudo: pallet_sudo::{Module, Call, Config, Storage, Event}, + NodeAuthorization: pallet_node_authorization::{Module, Call, Storage, Event, Config}, + // Include the custom logic from the template pallet in the runtime. + DIDModule: pallet_dids::{Module, Call, Storage, Event}, + } ); /// The address format for describing accounts. @@ -327,13 +313,13 @@ pub type SignedBlock = generic::SignedBlock; pub type BlockId = generic::BlockId; /// The SignedExtension to the basic transaction logic. pub type SignedExtra = ( - frame_system::CheckSpecVersion, - frame_system::CheckTxVersion, - frame_system::CheckGenesis, - frame_system::CheckEra, - frame_system::CheckNonce, - frame_system::CheckWeight, - pallet_transaction_payment::ChargeTransactionPayment, + frame_system::CheckSpecVersion, + frame_system::CheckTxVersion, + frame_system::CheckGenesis, + frame_system::CheckEra, + frame_system::CheckNonce, + frame_system::CheckWeight, + pallet_transaction_payment::ChargeTransactionPayment, ); /// Unchecked extrinsic type as expected by this runtime. @@ -342,182 +328,182 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< - Runtime, - Block, - frame_system::ChainContext, - Runtime, - AllModules, + Runtime, + Block, + frame_system::ChainContext, + Runtime, + AllModules, >; impl_runtime_apis! { - impl sp_api::Core for Runtime { - fn version() -> RuntimeVersion { - VERSION - } - - fn execute_block(block: Block) { - Executive::execute_block(block) - } - - fn initialize_block(header: &::Header) { - Executive::initialize_block(header) - } - } - - impl sp_api::Metadata for Runtime { - fn metadata() -> OpaqueMetadata { - Runtime::metadata().into() - } - } - - impl sp_block_builder::BlockBuilder for Runtime { - fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { - Executive::apply_extrinsic(extrinsic) - } - - fn finalize_block() -> ::Header { - Executive::finalize_block() - } - - fn inherent_extrinsics(data: sp_inherents::InherentData) -> - Vec<::Extrinsic> { - data.create_extrinsics() - } - - fn check_inherents( - block: Block, - data: sp_inherents::InherentData, - ) -> sp_inherents::CheckInherentsResult { - data.check_extrinsics(&block) - } - - fn random_seed() -> ::Hash { - RandomnessCollectiveFlip::random_seed() - } - } - - impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { - fn validate_transaction( - source: TransactionSource, - tx: ::Extrinsic, - ) -> TransactionValidity { - Executive::validate_transaction(source, tx) - } - } - - impl sp_offchain::OffchainWorkerApi for Runtime { - fn offchain_worker(header: &::Header) { - Executive::offchain_worker(header) - } - } - - impl sp_consensus_aura::AuraApi for Runtime { - fn slot_duration() -> u64 { - Aura::slot_duration() - } - - fn authorities() -> Vec { - Aura::authorities() - } - } - - impl sp_session::SessionKeys for Runtime { - fn generate_session_keys(seed: Option>) -> Vec { - opaque::SessionKeys::generate(seed) - } - - fn decode_session_keys( - encoded: Vec, - ) -> Option, KeyTypeId)>> { - opaque::SessionKeys::decode_into_raw_public_keys(&encoded) - } - } - - impl fg_primitives::GrandpaApi for Runtime { - fn grandpa_authorities() -> GrandpaAuthorityList { - Grandpa::grandpa_authorities() - } - - fn submit_report_equivocation_unsigned_extrinsic( - _equivocation_proof: fg_primitives::EquivocationProof< - ::Hash, - NumberFor, - >, - _key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof, - ) -> Option<()> { - None - } - - fn generate_key_ownership_proof( - _set_id: fg_primitives::SetId, - _authority_id: GrandpaId, - ) -> Option { - // NOTE: this is the only implementation possible since we've - // defined our key owner proof type as a bottom type (i.e. a type - // with no values). - None - } - } - - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: AccountId) -> Index { - System::account_nonce(account) - } - } - - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi - for Runtime { - fn query_info( - uxt: ::Extrinsic, - len: u32, - ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo { - TransactionPayment::query_info(uxt, len) - } - fn query_fee_details( - uxt: ::Extrinsic, - len: u32, - ) -> pallet_transaction_payment::FeeDetails { - TransactionPayment::query_fee_details(uxt, len) - } - } - - #[cfg(feature = "runtime-benchmarks")] - impl frame_benchmarking::Benchmark for Runtime { - fn dispatch_benchmark( - config: frame_benchmarking::BenchmarkConfig - ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; - - use frame_system_benchmarking::Module as SystemBench; - impl frame_system_benchmarking::Config for Runtime {} - - let whitelist: Vec = vec![ - // Block Number - hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac") - .to_vec().into(), - // Total Issuance - hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80") - .to_vec().into(), - // Execution Phase - hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a") - .to_vec().into(), - // Event Count - hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850") - .to_vec().into(), - // System Events - hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7") - .to_vec().into(), - ]; - - let mut batches = Vec::::new(); - let params = (&config, &whitelist); - - add_benchmark!(params, batches, frame_system, SystemBench::); - add_benchmark!(params, batches, pallet_balances, Balances); - add_benchmark!(params, batches, pallet_timestamp, Timestamp); - - if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } - Ok(batches) - } - } + impl sp_api::Core for Runtime { + fn version() -> RuntimeVersion { + VERSION + } + + fn execute_block(block: Block) { + Executive::execute_block(block) + } + + fn initialize_block(header: &::Header) { + Executive::initialize_block(header) + } + } + + impl sp_api::Metadata for Runtime { + fn metadata() -> OpaqueMetadata { + Runtime::metadata().into() + } + } + + impl sp_block_builder::BlockBuilder for Runtime { + fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { + Executive::apply_extrinsic(extrinsic) + } + + fn finalize_block() -> ::Header { + Executive::finalize_block() + } + + fn inherent_extrinsics(data: sp_inherents::InherentData) -> + Vec<::Extrinsic> { + data.create_extrinsics() + } + + fn check_inherents( + block: Block, + data: sp_inherents::InherentData, + ) -> sp_inherents::CheckInherentsResult { + data.check_extrinsics(&block) + } + + fn random_seed() -> ::Hash { + RandomnessCollectiveFlip::random_seed() + } + } + + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { + fn validate_transaction( + source: TransactionSource, + tx: ::Extrinsic, + ) -> TransactionValidity { + Executive::validate_transaction(source, tx) + } + } + + impl sp_offchain::OffchainWorkerApi for Runtime { + fn offchain_worker(header: &::Header) { + Executive::offchain_worker(header) + } + } + + impl sp_consensus_aura::AuraApi for Runtime { + fn slot_duration() -> u64 { + Aura::slot_duration() + } + + fn authorities() -> Vec { + Aura::authorities() + } + } + + impl sp_session::SessionKeys for Runtime { + fn generate_session_keys(seed: Option>) -> Vec { + opaque::SessionKeys::generate(seed) + } + + fn decode_session_keys( + encoded: Vec, + ) -> Option, KeyTypeId)>> { + opaque::SessionKeys::decode_into_raw_public_keys(&encoded) + } + } + + impl fg_primitives::GrandpaApi for Runtime { + fn grandpa_authorities() -> GrandpaAuthorityList { + Grandpa::grandpa_authorities() + } + + fn submit_report_equivocation_unsigned_extrinsic( + _equivocation_proof: fg_primitives::EquivocationProof< + ::Hash, + NumberFor, + >, + _key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof, + ) -> Option<()> { + None + } + + fn generate_key_ownership_proof( + _set_id: fg_primitives::SetId, + _authority_id: GrandpaId, + ) -> Option { + // NOTE: this is the only implementation possible since we've + // defined our key owner proof type as a bottom type (i.e. a type + // with no values). + None + } + } + + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { + fn account_nonce(account: AccountId) -> Index { + System::account_nonce(account) + } + } + + impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi + for Runtime { + fn query_info( + uxt: ::Extrinsic, + len: u32, + ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo { + TransactionPayment::query_info(uxt, len) + } + fn query_fee_details( + uxt: ::Extrinsic, + len: u32, + ) -> pallet_transaction_payment::FeeDetails { + TransactionPayment::query_fee_details(uxt, len) + } + } + + #[cfg(feature = "runtime-benchmarks")] + impl frame_benchmarking::Benchmark for Runtime { + fn dispatch_benchmark( + config: frame_benchmarking::BenchmarkConfig + ) -> Result, sp_runtime::RuntimeString> { + use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; + + use frame_system_benchmarking::Module as SystemBench; + impl frame_system_benchmarking::Config for Runtime {} + + let whitelist: Vec = vec![ + // Block Number + hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac") + .to_vec().into(), + // Total Issuance + hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80") + .to_vec().into(), + // Execution Phase + hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a") + .to_vec().into(), + // Event Count + hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850") + .to_vec().into(), + // System Events + hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7") + .to_vec().into(), + ]; + + let mut batches = Vec::::new(); + let params = (&config, &whitelist); + + add_benchmark!(params, batches, frame_system, SystemBench::); + add_benchmark!(params, batches, pallet_balances, Balances); + add_benchmark!(params, batches, pallet_timestamp, Timestamp); + + if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } + Ok(batches) + } + } }