diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 36e1da8d108da..19f7298ab68ea 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,7 +19,7 @@ # script: # - echo "List of shell commands to run in your job" # - echo "You can also just specify a script here, like so:" -# - ./scripts/gitlab/my_amazing_script.sh +# - ./.maintain/gitlab/my_amazing_script.sh stages: - test @@ -37,6 +37,9 @@ variables: CI_SERVER_NAME: "GitLab CI" DOCKER_OS: "debian:stretch" ARCH: "x86_64" + # FIXME set to release + CARGO_UNLEASH_INSTALL_PARAMS: "--version 1.0.0-alpha.8" + CARGO_UNLEASH_PKG_DEF: "--skip node node-* pallet-template pallet-example pallet-example-* subkey chain-spec-builder" .collect-artifacts: &collect-artifacts @@ -101,6 +104,16 @@ check-runtime: interruptible: true allow_failure: true +check-signed-tag: + stage: test + image: parity/tools:latest + <<: *kubernetes-build + only: + - tags + - /^v[0-9]+\.[0-9]+\.[0-9]+.*$/ + script: + - ./.maintain/gitlab/check_signed.sh + allow_failure: false check-line-width: stage: test @@ -175,6 +188,16 @@ test-dependency-rules: script: - .maintain/ensure-deps.sh +unleash-check: + stage: test + <<: *docker-env + only: + - master + - tags + script: + - cargo install cargo-unleash ${CARGO_UNLEASH_INSTALL_PARAMS} + - cargo unleash check ${CARGO_UNLEASH_PKG_DEF} + test-frame-staking: stage: test <<: *docker-env @@ -546,7 +569,19 @@ publish-draft-release: - tags - /^v[0-9]+\.[0-9]+\.[0-9]+.*$/ script: - - ./scripts/gitlab/publish_draft_release.sh + - ./.maintain/gitlab/publish_draft_release.sh + interruptible: true + allow_failure: true + +publish-to-crates-io: + stage: publish + <<: *docker-env + only: + - tags + - /^v[0-9]+\.[0-9]+\.[0-9]+.*$/ + script: + - cargo install cargo-unleash ${CARGO_UNLEASH_INSTALL_PARAMS} + - cargo unleash em-dragons --no-check ${CARGO_UNLEASH_PKG_DEF} interruptible: true allow_failure: true diff --git a/.maintain/Dockerfile b/.maintain/Dockerfile index 7cba85c544afc..56bfc7a2cc481 100644 --- a/.maintain/Dockerfile +++ b/.maintain/Dockerfile @@ -1,7 +1,7 @@ # Note: We don't use Alpine and its packaged Rust/Cargo because they're too often out of date, # preventing them from being used to build Substrate/Polkadot. -FROM phusion/baseimage:0.10.2 as builder +FROM phusion/baseimage:0.11 as builder LABEL maintainer="chevdor@gmail.com" LABEL description="This is the build stage for Substrate. Here we create the binary." @@ -26,7 +26,7 @@ RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \ # ===== SECOND STAGE ====== -FROM phusion/baseimage:0.10.2 +FROM phusion/baseimage:0.11 LABEL maintainer="chevdor@gmail.com" LABEL description="This is the 2nd stage: a very small image where we copy the Substrate binary." ARG PROFILE=release diff --git a/.maintain/gitlab/check_signed.sh b/.maintain/gitlab/check_signed.sh new file mode 100755 index 0000000000000..7c4cc47baba38 --- /dev/null +++ b/.maintain/gitlab/check_signed.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# shellcheck source=lib.sh +source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh" + +version="$CI_COMMIT_TAG" + +echo '[+] Checking tag has been signed' +check_tag "paritytech/substrate" "$version" +case $? in + 0) echo '[+] Tag found and has been signed'; exit 0 + ;; + 1) echo '[!] Tag found but has not been signed. Aborting release.'; exit 1 + ;; + 2) echo '[!] Tag not found. Aborting release.'; exit 1 +esac diff --git a/scripts/gitlab/lib.sh b/.maintain/gitlab/lib.sh similarity index 90% rename from scripts/gitlab/lib.sh rename to .maintain/gitlab/lib.sh index bc0e06a6d46c4..c8b2d73e6097f 100755 --- a/scripts/gitlab/lib.sh +++ b/.maintain/gitlab/lib.sh @@ -14,6 +14,14 @@ sanitised_git_logs(){ sed 's/^/* /g' } +# Returns the last published release on github +# repo: 'organization/repo' +# Usage: last_github_release "$repo" +last_github_release(){ + curl -H "Authorization: token $GITHUB_RELEASE_TOKEN" \ + -s "$api_base/$1/releases/latest" | jq '.tag_name' +} + # Checks whether a tag on github has been verified # repo: 'organization/repo' # tagver: 'v1.2.3' diff --git a/scripts/gitlab/publish_draft_release.sh b/.maintain/gitlab/publish_draft_release.sh similarity index 82% rename from scripts/gitlab/publish_draft_release.sh rename to .maintain/gitlab/publish_draft_release.sh index 463d8ee6c853d..4f73575f5bbaf 100755 --- a/scripts/gitlab/publish_draft_release.sh +++ b/.maintain/gitlab/publish_draft_release.sh @@ -11,19 +11,10 @@ labels=( ) version="$CI_COMMIT_TAG" -last_version=$(git tag -l | sort -V | grep -B 1 -x "$version" | head -n 1) -echo "[+] Version: $version; Previous version: $last_version" -# Check that a signed tag exists on github for this version -echo '[+] Checking tag has been signed' -#check_tag "paritytech/substrate" "$version" -case $? in - 0) echo '[+] Tag found and has been signed' - ;; - 1) echo '[!] Tag found but has not been signed. Aborting release.'; exit 1 - ;; - 2) echo '[!] Tag not found. Aborting release.'; exit -esac +# Note that this is not the last *tagged* version, but the last *published* version +last_version=$(last_github_release 'paritytech/substrate') +echo "[+] Version: $version; Previous version: $last_version" all_changes="$(sanitised_git_logs "$last_version" "$version")" labelled_changes="" @@ -50,7 +41,7 @@ $labelled_changes" echo "[+] Release text generated: " echo "$release_text" -exit + echo "[+] Pushing release to github" # Create release on github release_name="Substrate $version" @@ -90,6 +81,6 @@ formatted_msg_body=$(cat <, code: WASM_BINARY.to_vec(), changes_trie_config: Default::default(), }), - indices: Some(IndicesConfig { - indices: vec![], - }), balances: Some(BalancesConfig { balances: endowed_accounts.iter().cloned().map(|k|(k, 1 << 60)).collect(), }), - sudo: Some(SudoConfig { - key: root_key, - }), aura: Some(AuraConfig { authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(), }), grandpa: Some(GrandpaConfig { authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(), }), + sudo: Some(SudoConfig { + key: root_key, + }), } } diff --git a/bin/node-template/node/src/service.rs b/bin/node-template/node/src/service.rs index 5b64984c47c99..f87aaf5ec25a8 100644 --- a/bin/node-template/node/src/service.rs +++ b/bin/node-template/node/src/service.rs @@ -37,27 +37,24 @@ macro_rules! new_full_start { let pool_api = sc_transaction_pool::FullChainApi::new(client.clone()); Ok(sc_transaction_pool::BasicPool::new(config, std::sync::Arc::new(pool_api))) })? - .with_import_queue(|_config, client, mut select_chain, transaction_pool| { + .with_import_queue(|_config, client, mut select_chain, _transaction_pool| { let select_chain = select_chain.take() .ok_or_else(|| sc_service::Error::SelectChainRequired)?; let (grandpa_block_import, grandpa_link) = - grandpa::block_import::<_, _, _, node_template_runtime::RuntimeApi, _>( - client.clone(), &*client, select_chain - )?; + grandpa::block_import(client.clone(), &*client, select_chain)?; 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, _>( + let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair>( sc_consensus_aura::slot_duration(&*client)?, aura_block_import, Some(Box::new(grandpa_block_import.clone())), None, client, inherent_data_providers.clone(), - Some(transaction_pool), )?; import_setup = Some((grandpa_block_import, grandpa_link)); @@ -96,10 +93,10 @@ pub fn new_full(config: Configuration) .build()?; if participates_in_consensus { - let proposer = sc_basic_authorship::ProposerFactory { - client: service.client(), - transaction_pool: service.transaction_pool(), - }; + let proposer = sc_basic_authorship::ProposerFactory::new( + service.client(), + service.transaction_pool() + ); let client = service.client(); let select_chain = service.select_chain() @@ -160,6 +157,7 @@ pub fn new_full(config: Configuration) on_exit: service.on_exit(), telemetry_on_connect: Some(service.telemetry_on_connect_stream()), voting_rule: grandpa::VotingRulesBuilder::default().build(), + prometheus_registry: service.prometheus_registry() }; // the GRANDPA voter task is considered infallible, i.e. @@ -203,21 +201,20 @@ pub fn new_light(config: Configuration) let fetch_checker = fetcher .map(|fetcher| fetcher.checker().clone()) .ok_or_else(|| "Trying to start light import queue without active fetch checker")?; - let grandpa_block_import = grandpa::light_block_import::<_, _, _, RuntimeApi>( + let grandpa_block_import = grandpa::light_block_import( client.clone(), backend, &*client.clone(), Arc::new(fetch_checker), )?; let finality_proof_import = grandpa_block_import.clone(); let finality_proof_request_builder = finality_proof_import.create_finality_proof_request_builder(); - let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, ()>( + let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair>( sc_consensus_aura::slot_duration(&*client)?, grandpa_block_import, None, Some(Box::new(finality_proof_import)), client, inherent_data_providers.clone(), - None, )?; Ok((import_queue, finality_proof_request_builder)) diff --git a/bin/node-template/pallets/template/Cargo.toml b/bin/node-template/pallets/template/Cargo.toml index a2abe4c6e2c40..b39fcc1dae4d5 100644 --- a/bin/node-template/pallets/template/Cargo.toml +++ b/bin/node-template/pallets/template/Cargo.toml @@ -2,45 +2,47 @@ authors = ['Anonymous'] edition = '2018' name = 'pallet-template' -version = "2.0.0-dev" +version = "2.0.0-alpha.3" +license = "Unlicense" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME pallet template" [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } safe-mix = { default-features = false, version = '1.0.0' } [dependencies.frame-support] default-features = false -version = "2.0.0-dev" +version = "2.0.0-alpha.2" path = "../../../../frame/support" [dependencies.system] default-features = false package = 'frame-system' -version = "2.0.0-dev" +version = "2.0.0-alpha.2" path = "../../../../frame/system" - [dev-dependencies.sp-core] default-features = false -version = "2.0.0-dev" +version = "2.0.0-alpha.2" path = "../../../../primitives/core" [dev-dependencies.sp-io] default-features = false -version = "2.0.0-dev" +version = "2.0.0-alpha.2" path = "../../../../primitives/io" [dev-dependencies.sp-runtime] default-features = false -version = "2.0.0-dev" +version = "2.0.0-alpha.2" path = "../../../../primitives/runtime" + [features] default = ['std'] std = [ - 'codec/std', - 'frame-support/std', - 'safe-mix/std', - 'system/std' + 'codec/std', + 'frame-support/std', + 'safe-mix/std', + 'system/std' ] diff --git a/bin/node-template/runtime/Cargo.toml b/bin/node-template/runtime/Cargo.toml index b5a89febce08a..9268dd8c05035 100644 --- a/bin/node-template/runtime/Cargo.toml +++ b/bin/node-template/runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "node-template-runtime" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Anonymous"] edition = "2018" license = "Unlicense" @@ -8,34 +8,33 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } -aura = { version = "2.0.0-dev", default-features = false, package = "pallet-aura", path = "../../../frame/aura" } -balances = { version = "2.0.0-dev", default-features = false, package = "pallet-balances", path = "../../../frame/balances" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../../../frame/support" } -grandpa = { version = "2.0.0-dev", default-features = false, package = "pallet-grandpa", path = "../../../frame/grandpa" } -indices = { version = "2.0.0-dev", default-features = false, package = "pallet-indices", path = "../../../frame/indices" } -randomness-collective-flip = { version = "2.0.0-dev", default-features = false, package = "pallet-randomness-collective-flip", path = "../../../frame/randomness-collective-flip" } -sudo = { version = "2.0.0-dev", default-features = false, package = "pallet-sudo", path = "../../../frame/sudo" } -system = { version = "2.0.0-dev", default-features = false, package = "frame-system", path = "../../../frame/system" } -timestamp = { version = "2.0.0-dev", default-features = false, package = "pallet-timestamp", path = "../../../frame/timestamp" } -transaction-payment = { version = "2.0.0-dev", default-features = false, package = "pallet-transaction-payment", path = "../../../frame/transaction-payment" } -frame-executive = { version = "2.0.0-dev", default-features = false, path = "../../../frame/executive" } +aura = { version = "2.0.0-alpha.2", default-features = false, package = "pallet-aura", path = "../../../frame/aura" } +balances = { version = "2.0.0-alpha.2", default-features = false, package = "pallet-balances", path = "../../../frame/balances" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/support" } +grandpa = { version = "2.0.0-alpha.2", default-features = false, package = "pallet-grandpa", path = "../../../frame/grandpa" } +randomness-collective-flip = { version = "2.0.0-alpha.2", default-features = false, package = "pallet-randomness-collective-flip", path = "../../../frame/randomness-collective-flip" } +sudo = { version = "2.0.0-alpha.2", default-features = false, package = "pallet-sudo", path = "../../../frame/sudo" } +system = { version = "2.0.0-alpha.2", default-features = false, package = "frame-system", path = "../../../frame/system" } +timestamp = { version = "2.0.0-alpha.2", default-features = false, package = "pallet-timestamp", path = "../../../frame/timestamp" } +transaction-payment = { version = "2.0.0-alpha.2", default-features = false, package = "pallet-transaction-payment", path = "../../../frame/transaction-payment" } +frame-executive = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/executive" } serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-api = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/api" } -sp-block-builder = { path = "../../../primitives/block-builder", default-features = false, version = "2.0.0-dev"} -sp-consensus-aura = { version = "0.8.0-dev", default-features = false, path = "../../../primitives/consensus/aura" } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/core" } -sp-inherents = { path = "../../../primitives/inherents", default-features = false, version = "2.0.0-dev"} -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/io" } -sp-offchain = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/offchain" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/runtime" } -sp-session = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/session" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/std" } -sp-transaction-pool = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/transaction-pool" } -sp-version = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/version" } +sp-api = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/api" } +sp-block-builder = { path = "../../../primitives/block-builder", default-features = false, version = "2.0.0-alpha.2"} +sp-consensus-aura = { version = "0.8.0-alpha.2", default-features = false, path = "../../../primitives/consensus/aura" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/core" } +sp-inherents = { path = "../../../primitives/inherents", default-features = false, version = "2.0.0-alpha.2"} +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/io" } +sp-offchain = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/offchain" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/runtime" } +sp-session = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/session" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/std" } +sp-transaction-pool = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/transaction-pool" } +sp-version = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/version" } -template = { version = "2.0.0-dev", default-features = false, path = "../pallets/template", package = "pallet-template" } +template = { version = "2.0.0-alpha.2", default-features = false, path = "../pallets/template", package = "pallet-template" } [build-dependencies] wasm-builder-runner = { version = "1.0.5", package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner" } @@ -49,7 +48,6 @@ std = [ "frame-executive/std", "frame-support/std", "grandpa/std", - "indices/std", "randomness-collective-flip/std", "serde", "sp-api/std", diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index afc18177ce078..2bc4c2745007b 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -15,7 +15,7 @@ use sp_runtime::{ impl_opaque_keys, MultiSignature, }; use sp_runtime::traits::{ - BlakeTwo256, Block as BlockT, StaticLookup, Verify, ConvertInto, IdentifyAccount + BlakeTwo256, Block as BlockT, IdentityLookup, Verify, ConvertInto, IdentifyAccount }; use sp_api::impl_runtime_apis; use sp_consensus_aura::sr25519::AuthorityId as AuraId; @@ -132,7 +132,7 @@ impl system::Trait for Runtime { /// 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 = Indices; + type Lookup = IdentityLookup; /// The index type for storing how many extrinsics an account has signed. type Index = Index; /// The index type for blocks. @@ -177,23 +177,6 @@ impl grandpa::Trait for Runtime { type Event = Event; } -parameter_types! { - /// How much an index costs. - pub const IndexDeposit: u128 = 100; -} - -impl indices::Trait for Runtime { - /// The type for recording indexing into the account enumeration. If this ever overflows, there - /// will be problems! - type AccountIndex = AccountIndex; - /// The ubiquitous event type. - type Event = Event; - /// The currency type. - type Currency = Balances; - /// How much an index costs. - type Deposit = IndexDeposit; -} - parameter_types! { pub const MinimumPeriod: u64 = SLOT_DURATION / 2; } @@ -250,21 +233,20 @@ construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic { System: system::{Module, Call, Config, Storage, Event}, + RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage}, Timestamp: timestamp::{Module, Call, Storage, Inherent}, Aura: aura::{Module, Config, Inherent(Timestamp)}, Grandpa: grandpa::{Module, Call, Storage, Config, Event}, - Indices: indices::{Module, Call, Storage, Event, Config}, Balances: balances::{Module, Call, Storage, Config, Event}, TransactionPayment: transaction_payment::{Module, Storage}, Sudo: sudo::{Module, Call, Config, Storage, Event}, // Used for the module template in `./template.rs` TemplateModule: template::{Module, Call, Storage, Event}, - RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage}, } ); /// The address format for describing accounts. -pub type Address = ::Source; +pub type Address = AccountId; /// Block header type as expected by this runtime. pub type Header = generic::Header; /// Block type as expected by this runtime. diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index 7f17f1eaa6f6b..cfb1621b69246 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "node-cli" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] description = "Substrate node implementation in Rust." build = "build.rs" @@ -31,7 +31,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] # third-party dependencies -codec = { package = "parity-scale-codec", version = "1.0.6" } +codec = { package = "parity-scale-codec", version = "1.2.0" } serde = { version = "1.0.102", features = ["derive"] } futures = { version = "0.3.1", features = ["compat"] } hex-literal = "0.2.1" @@ -42,68 +42,68 @@ structopt = { version = "0.3.8", optional = true } tracing = "0.1.10" # primitives -sp-authority-discovery = { version = "2.0.0-dev", path = "../../../primitives/authority-discovery" } -sp-consensus-babe = { version = "0.8.0-dev", path = "../../../primitives/consensus/babe" } -grandpa-primitives = { version = "2.0.0-dev", package = "sp-finality-grandpa", path = "../../../primitives/finality-grandpa" } -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } -sp-timestamp = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/timestamp" } -sp-finality-tracker = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/finality-tracker" } -sp-inherents = { version = "2.0.0-dev", path = "../../../primitives/inherents" } -sp-keyring = { version = "2.0.0-dev", path = "../../../primitives/keyring" } -sp-io = { version = "2.0.0-dev", path = "../../../primitives/io" } -sp-consensus = { version = "0.8.0-dev", path = "../../../primitives/consensus/common" } +sp-authority-discovery = { version = "2.0.0-alpha.2", path = "../../../primitives/authority-discovery" } +sp-consensus-babe = { version = "0.8.0-alpha.2", path = "../../../primitives/consensus/babe" } +grandpa-primitives = { version = "2.0.0-alpha.2", package = "sp-finality-grandpa", path = "../../../primitives/finality-grandpa" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } +sp-timestamp = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/timestamp" } +sp-finality-tracker = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/finality-tracker" } +sp-inherents = { version = "2.0.0-alpha.2", path = "../../../primitives/inherents" } +sp-keyring = { version = "2.0.0-alpha.2", path = "../../../primitives/keyring" } +sp-io = { version = "2.0.0-alpha.2", path = "../../../primitives/io" } +sp-consensus = { version = "0.8.0-alpha.2", path = "../../../primitives/consensus/common" } # client dependencies -sc-client-api = { version = "2.0.0-dev", path = "../../../client/api" } -sc-client = { version = "0.8.0-dev", path = "../../../client/" } -sc-chain-spec = { version = "2.0.0-dev", path = "../../../client/chain-spec" } -sc-transaction-pool = { version = "2.0.0-dev", path = "../../../client/transaction-pool" } -sp-transaction-pool = { version = "2.0.0-dev", path = "../../../primitives/transaction-pool" } -sc-network = { version = "0.8.0-dev", path = "../../../client/network" } -sc-consensus-babe = { version = "0.8.0-dev", path = "../../../client/consensus/babe" } -grandpa = { version = "0.8.0-dev", package = "sc-finality-grandpa", path = "../../../client/finality-grandpa" } -sc-client-db = { version = "0.8.0-dev", default-features = false, path = "../../../client/db" } -sc-offchain = { version = "2.0.0-dev", path = "../../../client/offchain" } -sc-rpc = { version = "2.0.0-dev", path = "../../../client/rpc" } -sc-basic-authorship = { version = "0.8.0-dev", path = "../../../client/basic-authorship" } -sc-service = { version = "0.8.0-dev", default-features = false, path = "../../../client/service" } -sc-tracing = { version = "2.0.0-dev", path = "../../../client/tracing" } -sc-telemetry = { version = "2.0.0-dev", path = "../../../client/telemetry" } -sc-authority-discovery = { version = "0.8.0-dev", path = "../../../client/authority-discovery" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../../../client/api" } +sc-client = { version = "0.8.0-alpha.2", path = "../../../client/" } +sc-chain-spec = { version = "2.0.0-alpha.2", path = "../../../client/chain-spec" } +sc-transaction-pool = { version = "2.0.0-alpha.2", path = "../../../client/transaction-pool" } +sp-transaction-pool = { version = "2.0.0-alpha.2", path = "../../../primitives/transaction-pool" } +sc-network = { version = "0.8.0-alpha.2", path = "../../../client/network" } +sc-consensus-babe = { version = "0.8.0-alpha.2", path = "../../../client/consensus/babe" } +grandpa = { version = "0.8.0-alpha.2", package = "sc-finality-grandpa", path = "../../../client/finality-grandpa" } +sc-client-db = { version = "0.8.0-alpha.2", default-features = false, path = "../../../client/db" } +sc-offchain = { version = "2.0.0-alpha.2", path = "../../../client/offchain" } +sc-rpc = { version = "2.0.0-alpha.2", path = "../../../client/rpc" } +sc-basic-authorship = { version = "0.8.0-alpha.2", path = "../../../client/basic-authorship" } +sc-service = { version = "0.8.0-alpha.2", default-features = false, path = "../../../client/service" } +sc-tracing = { version = "2.0.0-alpha.2", path = "../../../client/tracing" } +sc-telemetry = { version = "2.0.0-alpha.2", path = "../../../client/telemetry" } +sc-authority-discovery = { version = "0.8.0-alpha.2", path = "../../../client/authority-discovery" } # frame dependencies -pallet-indices = { version = "2.0.0-dev", path = "../../../frame/indices" } -pallet-timestamp = { version = "2.0.0-dev", default-features = false, path = "../../../frame/timestamp" } -pallet-contracts = { version = "2.0.0-dev", path = "../../../frame/contracts" } -frame-system = { version = "2.0.0-dev", path = "../../../frame/system" } -pallet-balances = { version = "2.0.0-dev", path = "../../../frame/balances" } -pallet-transaction-payment = { version = "2.0.0-dev", path = "../../../frame/transaction-payment" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../../../frame/support" } -pallet-im-online = { version = "2.0.0-dev", default-features = false, path = "../../../frame/im-online" } -pallet-authority-discovery = { version = "2.0.0-dev", path = "../../../frame/authority-discovery" } +pallet-indices = { version = "2.0.0-alpha.2", path = "../../../frame/indices" } +pallet-timestamp = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/timestamp" } +pallet-contracts = { version = "2.0.0-alpha.2", path = "../../../frame/contracts" } +frame-system = { version = "2.0.0-alpha.2", path = "../../../frame/system" } +pallet-balances = { version = "2.0.0-alpha.2", path = "../../../frame/balances" } +pallet-transaction-payment = { version = "2.0.0-alpha.2", path = "../../../frame/transaction-payment" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/support" } +pallet-im-online = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/im-online" } +pallet-authority-discovery = { version = "2.0.0-alpha.2", path = "../../../frame/authority-discovery" } # node-specific dependencies -node-runtime = { version = "2.0.0-dev", path = "../runtime" } -node-rpc = { version = "2.0.0-dev", path = "../rpc" } -node-primitives = { version = "2.0.0-dev", path = "../primitives" } -node-executor = { version = "2.0.0-dev", path = "../executor" } +node-runtime = { version = "2.0.0-alpha.2", path = "../runtime" } +node-rpc = { version = "2.0.0-alpha.2", path = "../rpc" } +node-primitives = { version = "2.0.0-alpha.2", path = "../primitives" } +node-executor = { version = "2.0.0-alpha.2", path = "../executor" } # CLI-specific dependencies -sc-cli = { version = "0.8.0-dev", optional = true, path = "../../../client/cli" } -frame-benchmarking-cli = { version = "2.0.0-dev", optional = true, path = "../../../utils/frame/benchmarking-cli" } -node-transaction-factory = { version = "0.8.0-dev", optional = true, path = "../transaction-factory" } -node-inspect = { version = "0.8.0-dev", optional = true, path = "../inspect" } +sc-cli = { version = "0.8.0-alpha.2", optional = true, path = "../../../client/cli" } +frame-benchmarking-cli = { version = "2.0.0-alpha.2", optional = true, path = "../../../utils/frame/benchmarking-cli" } +node-transaction-factory = { version = "0.8.0-alpha.2", optional = true, path = "../transaction-factory" } +node-inspect = { version = "0.8.0-alpha.2", optional = true, path = "../inspect" } # WASM-specific dependencies wasm-bindgen = { version = "0.2.57", optional = true } wasm-bindgen-futures = { version = "0.4.7", optional = true } -browser-utils = { path = "../../../utils/browser", optional = true , version = "0.8.0-dev"} +browser-utils = { package = "substrate-browser-utils", path = "../../../utils/browser", optional = true, version = "0.8.0-alpha.2" } [dev-dependencies] -sc-keystore = { version = "2.0.0-dev", path = "../../../client/keystore" } -sc-consensus-babe = { version = "0.8.0-dev", features = ["test-helpers"], path = "../../../client/consensus/babe" } -sc-consensus-epochs = { version = "0.8.0-dev", path = "../../../client/consensus/epochs" } +sc-keystore = { version = "2.0.0-alpha.2", path = "../../../client/keystore" } +sc-consensus-babe = { version = "0.8.0-alpha.2", features = ["test-helpers"], path = "../../../client/consensus/babe" } +sc-consensus-epochs = { version = "0.8.0-alpha.2", path = "../../../client/consensus/epochs" } sc-service-test = { version = "2.0.0-dev", path = "../../../client/service/test" } futures = "0.3.1" tempfile = "3.1.0" @@ -112,14 +112,14 @@ nix = "0.17" serde_json = "1.0" [build-dependencies] -build-script-utils = { version = "2.0.0-dev", package = "substrate-build-script-utils", path = "../../../utils/build-script-utils" } +build-script-utils = { version = "2.0.0-alpha.2", package = "substrate-build-script-utils", path = "../../../utils/build-script-utils" } structopt = { version = "0.3.8", optional = true } -node-transaction-factory = { version = "0.8.0-dev", optional = true, path = "../transaction-factory" } -node-inspect = { version = "0.8.0-dev", optional = true, path = "../inspect" } -frame-benchmarking-cli = { version = "2.0.0-dev", optional = true, path = "../../../utils/frame/benchmarking-cli" } +node-transaction-factory = { version = "0.8.0-alpha.2", optional = true, path = "../transaction-factory" } +node-inspect = { version = "0.8.0-alpha.2", optional = true, path = "../inspect" } +frame-benchmarking-cli = { version = "2.0.0-alpha.2", optional = true, path = "../../../utils/frame/benchmarking-cli" } [build-dependencies.sc-cli] -version = "0.8.0-dev" +version = "0.8.0-alpha.2" package = "sc-cli" path = "../../../client/cli" optional = true diff --git a/bin/node/cli/src/chain_spec.rs b/bin/node/cli/src/chain_spec.rs index d163cdf3918a2..af24db704c379 100644 --- a/bin/node/cli/src/chain_spec.rs +++ b/bin/node/cli/src/chain_spec.rs @@ -247,7 +247,6 @@ pub fn testnet_genesis( }).collect::>(), }), pallet_staking: Some(StakingConfig { - current_era: 0, validator_count: initial_authorities.len() as u32 * 2, minimum_validator_count: initial_authorities.len() as u32, stakers: initial_authorities.iter().map(|x| { diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index 70dd0521dece3..f31fa0b9730b0 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -150,10 +150,10 @@ macro_rules! new_full { ($with_startup_data)(&block_import, &babe_link); if participates_in_consensus { - let proposer = sc_basic_authorship::ProposerFactory { - client: service.client(), - transaction_pool: service.transaction_pool(), - }; + let proposer = sc_basic_authorship::ProposerFactory::new( + service.client(), + service.transaction_pool() + ); let client = service.client(); let select_chain = service.select_chain() @@ -228,6 +228,7 @@ macro_rules! new_full { on_exit: service.on_exit(), telemetry_on_connect: Some(service.telemetry_on_connect_stream()), voting_rule: grandpa::VotingRulesBuilder::default().build(), + prometheus_registry: service.prometheus_registry(), }; // the GRANDPA voter task is considered infallible, i.e. @@ -314,7 +315,7 @@ pub fn new_light(config: NodeConfiguration) let fetch_checker = fetcher .map(|fetcher| fetcher.checker().clone()) .ok_or_else(|| "Trying to start light import queue without active fetch checker")?; - let grandpa_block_import = grandpa::light_block_import::<_, _, _, RuntimeApi>( + let grandpa_block_import = grandpa::light_block_import( client.clone(), backend, &*client, @@ -501,10 +502,10 @@ mod tests { let parent_header = service.client().header(&parent_id).unwrap().unwrap(); let parent_hash = parent_header.hash(); let parent_number = *parent_header.number(); - let mut proposer_factory = sc_basic_authorship::ProposerFactory { - client: service.client(), - transaction_pool: service.transaction_pool(), - }; + let mut proposer_factory = sc_basic_authorship::ProposerFactory::new( + service.client(), + service.transaction_pool() + ); let epoch = babe_link.epoch_changes().lock().epoch_for_child_of( descendent_query(&*service.client()), diff --git a/bin/node/cli/tests/check_block_works.rs b/bin/node/cli/tests/check_block_works.rs index e4c93c9e88528..6bfb82a8bfafb 100644 --- a/bin/node/cli/tests/check_block_works.rs +++ b/bin/node/cli/tests/check_block_works.rs @@ -26,10 +26,10 @@ mod common; fn check_block_works() { let base_path = tempdir().expect("could not create a temp dir"); - common::run_command_for_a_while(base_path.path(), false); + common::run_dev_node_for_a_while(base_path.path()); let status = Command::new(cargo_bin("substrate")) - .args(&["check-block", "-d"]) + .args(&["check-block", "--dev", "--pruning", "archive", "-d"]) .arg(base_path.path()) .arg("1") .status() diff --git a/bin/node/cli/tests/common.rs b/bin/node/cli/tests/common.rs index 682a30bcc0178..34e371195c16b 100644 --- a/bin/node/cli/tests/common.rs +++ b/bin/node/cli/tests/common.rs @@ -27,13 +27,18 @@ use nix::unistd::Pid; /// /// Returns the `Some(exit status)` or `None` if the process did not finish in the given time. pub fn wait_for(child: &mut Child, secs: usize) -> Option { - for _ in 0..secs { + for i in 0..secs { match child.try_wait().unwrap() { - Some(status) => return Some(status), + Some(status) => { + if i > 5 { + eprintln!("Child process took {} seconds to exit gracefully", i); + } + return Some(status) + }, None => thread::sleep(Duration::from_secs(1)), } } - eprintln!("Took to long to exit. Killing..."); + eprintln!("Took too long to exit (> {} seconds). Killing...", secs); let _ = child.kill(); child.wait().unwrap(); @@ -41,14 +46,11 @@ pub fn wait_for(child: &mut Child, secs: usize) -> Option { } /// Run the node for a while (30 seconds) -pub fn run_command_for_a_while(base_path: &Path, dev: bool) { +pub fn run_dev_node_for_a_while(base_path: &Path) { let mut cmd = Command::new(cargo_bin("substrate")); - if dev { - cmd.arg("--dev"); - } - let mut cmd = cmd + .args(&["--dev"]) .arg("-d") .arg(base_path) .spawn() diff --git a/bin/node/cli/tests/import_export_and_revert_work.rs b/bin/node/cli/tests/import_export_and_revert_work.rs index e109aa279eb88..131265e3b4ab9 100644 --- a/bin/node/cli/tests/import_export_and_revert_work.rs +++ b/bin/node/cli/tests/import_export_and_revert_work.rs @@ -27,10 +27,10 @@ fn import_export_and_revert_work() { let base_path = tempdir().expect("could not create a temp dir"); let exported_blocks = base_path.path().join("exported_blocks"); - common::run_command_for_a_while(base_path.path(), false); + common::run_dev_node_for_a_while(base_path.path()); let status = Command::new(cargo_bin("substrate")) - .args(&["export-blocks", "-d"]) + .args(&["export-blocks", "--dev", "--pruning", "archive", "-d"]) .arg(base_path.path()) .arg(&exported_blocks) .status() @@ -43,7 +43,7 @@ fn import_export_and_revert_work() { let _ = fs::remove_dir_all(base_path.path().join("db")); let status = Command::new(cargo_bin("substrate")) - .args(&["import-blocks", "-d"]) + .args(&["import-blocks", "--dev", "--pruning", "archive", "-d"]) .arg(base_path.path()) .arg(&exported_blocks) .status() @@ -51,7 +51,7 @@ fn import_export_and_revert_work() { assert!(status.success()); let status = Command::new(cargo_bin("substrate")) - .args(&["revert", "-d"]) + .args(&["revert", "--dev", "--pruning", "archive", "-d"]) .arg(base_path.path()) .status() .unwrap(); diff --git a/bin/node/cli/tests/inspect_works.rs b/bin/node/cli/tests/inspect_works.rs index 0bd48c3693802..441b08ccf46da 100644 --- a/bin/node/cli/tests/inspect_works.rs +++ b/bin/node/cli/tests/inspect_works.rs @@ -26,10 +26,10 @@ mod common; fn inspect_works() { let base_path = tempdir().expect("could not create a temp dir"); - common::run_command_for_a_while(base_path.path(), false); + common::run_dev_node_for_a_while(base_path.path()); let status = Command::new(cargo_bin("substrate")) - .args(&["inspect", "-d"]) + .args(&["inspect", "--dev", "--pruning", "archive", "-d"]) .arg(base_path.path()) .args(&["block", "1"]) .status() diff --git a/bin/node/cli/tests/purge_chain_works.rs b/bin/node/cli/tests/purge_chain_works.rs index 42a5bc3ce143e..020259d0c595a 100644 --- a/bin/node/cli/tests/purge_chain_works.rs +++ b/bin/node/cli/tests/purge_chain_works.rs @@ -25,7 +25,7 @@ mod common; fn purge_chain_works() { let base_path = tempdir().expect("could not create a temp dir"); - common::run_command_for_a_while(base_path.path(), true); + common::run_dev_node_for_a_while(base_path.path()); let status = Command::new(cargo_bin("substrate")) .args(&["purge-chain", "--dev", "-d"]) diff --git a/bin/node/executor/Cargo.toml b/bin/node/executor/Cargo.toml index 321ef3bec0bc9..c8ef75a5a2a9a 100644 --- a/bin/node/executor/Cargo.toml +++ b/bin/node/executor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "node-executor" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] description = "Substrate node implementation in Rust." edition = "2018" @@ -9,33 +9,33 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0" } -node-primitives = { version = "2.0.0-dev", path = "../primitives" } -node-runtime = { version = "2.0.0-dev", path = "../runtime" } -sc-executor = { version = "0.8.0-dev", path = "../../../client/executor" } -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } -sp-io = { version = "2.0.0-dev", path = "../../../primitives/io" } -sp-state-machine = { version = "0.8.0-dev", path = "../../../primitives/state-machine" } -sp-trie = { version = "2.0.0-dev", path = "../../../primitives/trie" } +codec = { package = "parity-scale-codec", version = "1.2.0" } +node-primitives = { version = "2.0.0-alpha.2", path = "../primitives" } +node-runtime = { version = "2.0.0-alpha.2", path = "../runtime" } +sc-executor = { version = "0.8.0-alpha.2", path = "../../../client/executor" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } +sp-io = { version = "2.0.0-alpha.2", path = "../../../primitives/io" } +sp-state-machine = { version = "0.8.0-alpha.2", path = "../../../primitives/state-machine" } +sp-trie = { version = "2.0.0-alpha.2", path = "../../../primitives/trie" } trie-root = "0.16.0" -frame-benchmarking = { version = "2.0.0-dev", path = "../../../frame/benchmarking" } +frame-benchmarking = { version = "2.0.0-alpha.2", path = "../../../frame/benchmarking" } [dev-dependencies] criterion = "0.3.0" -frame-support = { version = "2.0.0-dev", path = "../../../frame/support" } -frame-system = { version = "2.0.0-dev", path = "../../../frame/system" } -node-testing = { version = "2.0.0-dev", path = "../testing" } -pallet-balances = { version = "2.0.0-dev", path = "../../../frame/balances" } -pallet-contracts = { version = "2.0.0-dev", path = "../../../frame/contracts" } -pallet-grandpa = { version = "2.0.0-dev", path = "../../../frame/grandpa" } -pallet-im-online = { version = "2.0.0-dev", path = "../../../frame/im-online" } -pallet-indices = { version = "2.0.0-dev", path = "../../../frame/indices" } -pallet-session = { version = "2.0.0-dev", path = "../../../frame/session" } -pallet-timestamp = { version = "2.0.0-dev", path = "../../../frame/timestamp" } -pallet-transaction-payment = { version = "2.0.0-dev", path = "../../../frame/transaction-payment" } -pallet-treasury = { version = "2.0.0-dev", path = "../../../frame/treasury" } -sp-application-crypto = { version = "2.0.0-dev", path = "../../../primitives/application-crypto" } -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } +frame-support = { version = "2.0.0-alpha.2", path = "../../../frame/support" } +frame-system = { version = "2.0.0-alpha.2", path = "../../../frame/system" } +node-testing = { version = "2.0.0-alpha.2", path = "../testing" } +pallet-balances = { version = "2.0.0-alpha.2", path = "../../../frame/balances" } +pallet-contracts = { version = "2.0.0-alpha.2", path = "../../../frame/contracts" } +pallet-grandpa = { version = "2.0.0-alpha.2", path = "../../../frame/grandpa" } +pallet-im-online = { version = "2.0.0-alpha.2", path = "../../../frame/im-online" } +pallet-indices = { version = "2.0.0-alpha.2", path = "../../../frame/indices" } +pallet-session = { version = "2.0.0-alpha.2", path = "../../../frame/session" } +pallet-timestamp = { version = "2.0.0-alpha.2", path = "../../../frame/timestamp" } +pallet-transaction-payment = { version = "2.0.0-alpha.2", path = "../../../frame/transaction-payment" } +pallet-treasury = { version = "2.0.0-alpha.2", path = "../../../frame/treasury" } +sp-application-crypto = { version = "2.0.0-alpha.2", path = "../../../primitives/application-crypto" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } substrate-test-client = { version = "2.0.0-dev", path = "../../../test-utils/client" } wabt = "0.9.2" diff --git a/bin/node/inspect/Cargo.toml b/bin/node/inspect/Cargo.toml index b512c458d804b..022f4d0ca49f5 100644 --- a/bin/node/inspect/Cargo.toml +++ b/bin/node/inspect/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "node-inspect" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" @@ -8,13 +8,13 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0" } +codec = { package = "parity-scale-codec", version = "1.2.0" } derive_more = "0.99" log = "0.4.8" -sc-cli = { version = "0.8.0-dev", path = "../../../client/cli" } -sc-client-api = { version = "2.0.0-dev", path = "../../../client/api" } -sc-service = { version = "0.8.0-dev", default-features = false, path = "../../../client/service" } -sp-blockchain = { version = "2.0.0-dev", path = "../../../primitives/blockchain" } -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } +sc-cli = { version = "0.8.0-alpha.2", path = "../../../client/cli" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../../../client/api" } +sc-service = { version = "0.8.0-alpha.2", default-features = false, path = "../../../client/service" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../../primitives/blockchain" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } structopt = "0.3.8" diff --git a/bin/node/primitives/Cargo.toml b/bin/node/primitives/Cargo.toml index 79819614b3f52..cb271b987dba2 100644 --- a/bin/node/primitives/Cargo.toml +++ b/bin/node/primitives/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "node-primitives" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" @@ -8,11 +8,11 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/core" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/runtime" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/core" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/runtime" } [dev-dependencies] -sp-serializer = { version = "2.0.0-dev", path = "../../../primitives/serializer" } +sp-serializer = { version = "2.0.0-alpha.2", path = "../../../primitives/serializer" } pretty_assertions = "0.6.1" [features] diff --git a/bin/node/rpc-client/Cargo.toml b/bin/node/rpc-client/Cargo.toml index d9f35829a1239..8b37aff291341 100644 --- a/bin/node/rpc-client/Cargo.toml +++ b/bin/node/rpc-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "node-rpc-client" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" @@ -13,5 +13,5 @@ futures = "0.1.29" hyper = "0.12.35" jsonrpc-core-client = { version = "14.0.3", features = ["http", "ws"] } log = "0.4.8" -node-primitives = { version = "2.0.0-dev", path = "../primitives" } -sc-rpc = { version = "2.0.0-dev", path = "../../../client/rpc" } +node-primitives = { version = "2.0.0-alpha.2", path = "../primitives" } +sc-rpc = { version = "2.0.0-alpha.2", path = "../../../client/rpc" } diff --git a/bin/node/rpc/Cargo.toml b/bin/node/rpc/Cargo.toml index a714c8a1725f1..1155eab304f8a 100644 --- a/bin/node/rpc/Cargo.toml +++ b/bin/node/rpc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "node-rpc" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" @@ -8,20 +8,20 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -sc-client = { version = "0.8.0-dev", path = "../../../client/" } +sc-client = { version = "0.8.0-alpha.2", path = "../../../client/" } jsonrpc-core = "14.0.3" -node-primitives = { version = "2.0.0-dev", path = "../primitives" } -node-runtime = { version = "2.0.0-dev", path = "../runtime" } -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } -sp-api = { version = "2.0.0-dev", path = "../../../primitives/api" } -pallet-contracts-rpc = { version = "0.8.0-dev", path = "../../../frame/contracts/rpc/" } -pallet-transaction-payment-rpc = { version = "2.0.0-dev", path = "../../../frame/transaction-payment/rpc/" } -substrate-frame-rpc-system = { version = "2.0.0-dev", path = "../../../utils/frame/rpc/system" } -sp-transaction-pool = { version = "2.0.0-dev", path = "../../../primitives/transaction-pool" } -sc-consensus-babe = { version = "0.8.0-dev", path = "../../../client/consensus/babe" } -sc-consensus-babe-rpc = { version = "0.8.0-dev", path = "../../../client/consensus/babe/rpc" } -sp-consensus-babe = { version = "0.8.0-dev", path = "../../../primitives/consensus/babe" } -sc-keystore = { version = "2.0.0-dev", path = "../../../client/keystore" } -sc-consensus-epochs = { version = "0.8.0-dev", path = "../../../client/consensus/epochs" } -sp-consensus = { version = "0.8.0-dev", path = "../../../primitives/consensus/common" } -sp-blockchain = { version = "2.0.0-dev", path = "../../../primitives/blockchain" } +node-primitives = { version = "2.0.0-alpha.2", path = "../primitives" } +node-runtime = { version = "2.0.0-alpha.2", path = "../runtime" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } +sp-api = { version = "2.0.0-alpha.2", path = "../../../primitives/api" } +pallet-contracts-rpc = { version = "0.8.0-alpha.2", path = "../../../frame/contracts/rpc/" } +pallet-transaction-payment-rpc = { version = "2.0.0-alpha.2", path = "../../../frame/transaction-payment/rpc/" } +substrate-frame-rpc-system = { version = "2.0.0-alpha.2", path = "../../../utils/frame/rpc/system" } +sp-transaction-pool = { version = "2.0.0-alpha.2", path = "../../../primitives/transaction-pool" } +sc-consensus-babe = { version = "0.8.0-alpha.2", path = "../../../client/consensus/babe" } +sc-consensus-babe-rpc = { version = "0.8.0-alpha.2", path = "../../../client/consensus/babe/rpc" } +sp-consensus-babe = { version = "0.8.0-alpha.2", path = "../../../primitives/consensus/babe" } +sc-keystore = { version = "2.0.0-alpha.2", path = "../../../client/keystore" } +sc-consensus-epochs = { version = "0.8.0-alpha.2", path = "../../../client/consensus/epochs" } +sp-consensus = { version = "0.8.0-alpha.2", path = "../../../primitives/consensus/common" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../../primitives/blockchain" } diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index ddb1f16898509..8a901660ce975 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "node-runtime" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" build = "build.rs" @@ -11,70 +11,70 @@ repository = "https://github.com/paritytech/substrate/" [dependencies] # third-party dependencies -codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } integer-sqrt = { version = "0.1.2" } rustc-hex = { version = "2.0", optional = true } serde = { version = "1.0.102", optional = true } # primitives -sp-authority-discovery = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/authority-discovery" } -sp-consensus-babe = { version = "0.8.0-dev", default-features = false, path = "../../../primitives/consensus/babe" } -sp-block-builder = { path = "../../../primitives/block-builder", default-features = false, version = "2.0.0-dev"} -sp-inherents = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/inherents" } -node-primitives = { version = "2.0.0-dev", default-features = false, path = "../primitives" } -sp-offchain = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/offchain" } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/core" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/std" } -sp-api = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/api" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/runtime" } -sp-staking = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/staking" } -sp-keyring = { version = "2.0.0-dev", optional = true, path = "../../../primitives/keyring" } -sp-session = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/session" } -sp-transaction-pool = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/transaction-pool" } -sp-version = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/version" } +sp-authority-discovery = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/authority-discovery" } +sp-consensus-babe = { version = "0.8.0-alpha.2", default-features = false, path = "../../../primitives/consensus/babe" } +sp-block-builder = { path = "../../../primitives/block-builder", default-features = false, version = "2.0.0-alpha.2"} +sp-inherents = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/inherents" } +node-primitives = { version = "2.0.0-alpha.2", default-features = false, path = "../primitives" } +sp-offchain = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/offchain" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/core" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/std" } +sp-api = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/api" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/runtime" } +sp-staking = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/staking" } +sp-keyring = { version = "2.0.0-alpha.2", optional = true, path = "../../../primitives/keyring" } +sp-session = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/session" } +sp-transaction-pool = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/transaction-pool" } +sp-version = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/version" } # frame dependencies -frame-executive = { version = "2.0.0-dev", default-features = false, path = "../../../frame/executive" } -frame-benchmarking = { version = "2.0.0-dev", default-features = false, path = "../../../frame/benchmarking" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../../../frame/support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../../../frame/system" } -frame-system-rpc-runtime-api = { version = "2.0.0-dev", default-features = false, path = "../../../frame/system/rpc/runtime-api/" } -pallet-authority-discovery = { version = "2.0.0-dev", default-features = false, path = "../../../frame/authority-discovery" } -pallet-authorship = { version = "2.0.0-dev", default-features = false, path = "../../../frame/authorship" } -pallet-babe = { version = "2.0.0-dev", default-features = false, path = "../../../frame/babe" } -pallet-balances = { version = "2.0.0-dev", default-features = false, path = "../../../frame/balances" } -pallet-collective = { version = "2.0.0-dev", default-features = false, path = "../../../frame/collective" } -pallet-contracts = { version = "2.0.0-dev", default-features = false, path = "../../../frame/contracts" } -pallet-contracts-primitives = { version = "2.0.0-dev", default-features = false, path = "../../../frame/contracts/common/" } -pallet-contracts-rpc-runtime-api = { version = "0.8.0-dev", default-features = false, path = "../../../frame/contracts/rpc/runtime-api/" } -pallet-democracy = { version = "2.0.0-dev", default-features = false, path = "../../../frame/democracy" } -pallet-elections-phragmen = { version = "2.0.0-dev", default-features = false, path = "../../../frame/elections-phragmen" } -pallet-finality-tracker = { version = "2.0.0-dev", default-features = false, path = "../../../frame/finality-tracker" } -pallet-grandpa = { version = "2.0.0-dev", default-features = false, path = "../../../frame/grandpa" } -pallet-im-online = { version = "2.0.0-dev", default-features = false, path = "../../../frame/im-online" } -pallet-indices = { version = "2.0.0-dev", default-features = false, path = "../../../frame/indices" } -pallet-identity = { version = "2.0.0-dev", default-features = false, path = "../../../frame/identity" } -pallet-membership = { version = "2.0.0-dev", default-features = false, path = "../../../frame/membership" } -pallet-offences = { version = "2.0.0-dev", default-features = false, path = "../../../frame/offences" } -pallet-randomness-collective-flip = { version = "2.0.0-dev", default-features = false, path = "../../../frame/randomness-collective-flip" } -pallet-recovery = { version = "2.0.0-dev", default-features = false, path = "../../../frame/recovery" } -pallet-session = { version = "2.0.0-dev", features = ["historical"], path = "../../../frame/session", default-features = false } -pallet-staking = { version = "2.0.0-dev", features = ["migrate"], path = "../../../frame/staking", default-features = false } -pallet-staking-reward-curve = { version = "2.0.0-dev", path = "../../../frame/staking/reward-curve" } -pallet-sudo = { version = "2.0.0-dev", default-features = false, path = "../../../frame/sudo" } -pallet-society = { version = "2.0.0-dev", default-features = false, path = "../../../frame/society" } -pallet-timestamp = { version = "2.0.0-dev", default-features = false, path = "../../../frame/timestamp" } -pallet-treasury = { version = "2.0.0-dev", default-features = false, path = "../../../frame/treasury" } -pallet-utility = { version = "2.0.0-dev", default-features = false, path = "../../../frame/utility" } -pallet-transaction-payment = { version = "2.0.0-dev", default-features = false, path = "../../../frame/transaction-payment" } -pallet-transaction-payment-rpc-runtime-api = { version = "2.0.0-dev", default-features = false, path = "../../../frame/transaction-payment/rpc/runtime-api/" } -pallet-vesting = { version = "2.0.0-dev", default-features = false, path = "../../../frame/vesting" } +frame-executive = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/executive" } +frame-benchmarking = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/benchmarking" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/system" } +frame-system-rpc-runtime-api = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/system/rpc/runtime-api/" } +pallet-authority-discovery = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/authority-discovery" } +pallet-authorship = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/authorship" } +pallet-babe = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/babe" } +pallet-balances = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/balances" } +pallet-collective = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/collective" } +pallet-contracts = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/contracts" } +pallet-contracts-primitives = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/contracts/common/" } +pallet-contracts-rpc-runtime-api = { version = "0.8.0-alpha.2", default-features = false, path = "../../../frame/contracts/rpc/runtime-api/" } +pallet-democracy = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/democracy" } +pallet-elections-phragmen = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/elections-phragmen" } +pallet-finality-tracker = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/finality-tracker" } +pallet-grandpa = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/grandpa" } +pallet-im-online = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/im-online" } +pallet-indices = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/indices" } +pallet-identity = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/identity" } +pallet-membership = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/membership" } +pallet-offences = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/offences" } +pallet-randomness-collective-flip = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/randomness-collective-flip" } +pallet-recovery = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/recovery" } +pallet-session = { version = "2.0.0-alpha.2", features = ["historical"], path = "../../../frame/session", default-features = false } +pallet-staking = { version = "2.0.0-alpha.2", features = ["migrate"], path = "../../../frame/staking", default-features = false } +pallet-staking-reward-curve = { version = "2.0.0-alpha.2", path = "../../../frame/staking/reward-curve" } +pallet-sudo = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/sudo" } +pallet-society = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/society" } +pallet-timestamp = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/timestamp" } +pallet-treasury = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/treasury" } +pallet-utility = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/utility" } +pallet-transaction-payment = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/transaction-payment" } +pallet-transaction-payment-rpc-runtime-api = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/transaction-payment/rpc/runtime-api/" } +pallet-vesting = { version = "2.0.0-alpha.2", default-features = false, path = "../../../frame/vesting" } [build-dependencies] wasm-builder-runner = { version = "1.0.5", package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner" } [dev-dependencies] -sp-io = { version = "2.0.0-dev", path = "../../../primitives/io" } +sp-io = { version = "2.0.0-alpha.2", path = "../../../primitives/io" } [features] default = ["std"] diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index e91eca4e400cd..be5ca25630d4a 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -31,7 +31,8 @@ pub use node_primitives::{AccountId, Signature}; use node_primitives::{AccountIndex, Balance, BlockNumber, Hash, Index, Moment}; use sp_api::impl_runtime_apis; use sp_runtime::{ - Permill, Perbill, Percent, ApplyExtrinsicResult, impl_opaque_keys, generic, create_runtime_str, + Permill, Perbill, Percent, ApplyExtrinsicResult, RuntimeString, + impl_opaque_keys, generic, create_runtime_str, }; use sp_runtime::curve::PiecewiseLinear; use sp_runtime::transaction_validity::TransactionValidity; @@ -81,7 +82,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 225, + spec_version: 227, impl_version: 0, apis: RUNTIME_API_VERSIONS, }; @@ -268,6 +269,7 @@ parameter_types! { pub const BondingDuration: pallet_staking::EraIndex = 24 * 28; pub const SlashDeferDuration: pallet_staking::EraIndex = 24 * 7; // 1/4 the bonding duration. pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; + pub const MaxNominatorRewardedPerValidator: u32 = 64; } impl pallet_staking::Trait for Runtime { @@ -285,6 +287,7 @@ impl pallet_staking::Trait for Runtime { type SlashCancelOrigin = pallet_collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>; type SessionInterface = Self; type RewardCurve = RewardCurve; + type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; } parameter_types! { @@ -819,17 +822,39 @@ impl_runtime_apis! { fn dispatch_benchmark( module: Vec, extrinsic: Vec, - steps: u32, + lowest_range_values: Vec, + highest_range_values: Vec, + steps: Vec, repeat: u32, - ) -> Option> { + ) -> Result, RuntimeString> { use frame_benchmarking::Benchmarking; - match module.as_slice() { - b"pallet-balances" | b"balances" => Balances::run_benchmark(extrinsic, steps, repeat).ok(), - b"pallet-identity" | b"identity" => Identity::run_benchmark(extrinsic, steps, repeat).ok(), - b"pallet-timestamp" | b"timestamp" => Timestamp::run_benchmark(extrinsic, steps, repeat).ok(), - _ => None, - } + let result = match module.as_slice() { + b"pallet-balances" | b"balances" => Balances::run_benchmark( + extrinsic, + lowest_range_values, + highest_range_values, + steps, + repeat, + ), + b"pallet-identity" | b"identity" => Identity::run_benchmark( + extrinsic, + lowest_range_values, + highest_range_values, + steps, + repeat, + ), + b"pallet-timestamp" | b"timestamp" => Timestamp::run_benchmark( + extrinsic, + lowest_range_values, + highest_range_values, + steps, + repeat, + ), + _ => Err("Benchmark not found for this pallet."), + }; + + result.map_err(|e| e.into()) } } } diff --git a/bin/node/testing/Cargo.toml b/bin/node/testing/Cargo.toml index 4530c9576086e..4496047b50cff 100644 --- a/bin/node/testing/Cargo.toml +++ b/bin/node/testing/Cargo.toml @@ -1,55 +1,56 @@ [package] name = "node-testing" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] description = "Test utilities for Substrate node." edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +publish = true [dependencies] -pallet-balances = { version = "2.0.0-dev", path = "../../../frame/balances" } -sc-client = { version = "0.8.0-dev", path = "../../../client/" } -sc-client-db = { version = "0.8.0-dev", path = "../../../client/db/", features = ["kvdb-rocksdb"] } -sc-client-api = { version = "2.0.0-dev", path = "../../../client/api/" } -codec = { package = "parity-scale-codec", version = "1.0.0" } -pallet-contracts = { version = "2.0.0-dev", path = "../../../frame/contracts" } -pallet-grandpa = { version = "2.0.0-dev", path = "../../../frame/grandpa" } -pallet-indices = { version = "2.0.0-dev", path = "../../../frame/indices" } -sp-keyring = { version = "2.0.0-dev", path = "../../../primitives/keyring" } -node-executor = { version = "2.0.0-dev", path = "../executor" } -node-primitives = { version = "2.0.0-dev", path = "../primitives" } -node-runtime = { version = "2.0.0-dev", path = "../runtime" } -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } -sp-io = { version = "2.0.0-dev", path = "../../../primitives/io" } -frame-support = { version = "2.0.0-dev", path = "../../../frame/support" } -pallet-session = { version = "2.0.0-dev", path = "../../../frame/session" } -pallet-society = { version = "2.0.0-dev", path = "../../../frame/society" } -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } -pallet-staking = { version = "2.0.0-dev", path = "../../../frame/staking" } -sc-executor = { version = "0.8.0-dev", path = "../../../client/executor", features = ["wasmtime"] } -sp-consensus = { version = "0.8.0-dev", path = "../../../primitives/consensus/common" } -frame-system = { version = "2.0.0-dev", path = "../../../frame/system" } +pallet-balances = { version = "2.0.0-alpha.2", path = "../../../frame/balances" } +sc-client = { version = "0.8.0-alpha.2", path = "../../../client/" } +sc-client-db = { version = "0.8.0-alpha.2", path = "../../../client/db/", features = ["kvdb-rocksdb"] } +sc-client-api = { version = "2.0.0-alpha.2", path = "../../../client/api/" } +codec = { package = "parity-scale-codec", version = "1.2.0" } +pallet-contracts = { version = "2.0.0-alpha.2", path = "../../../frame/contracts" } +pallet-grandpa = { version = "2.0.0-alpha.2", path = "../../../frame/grandpa" } +pallet-indices = { version = "2.0.0-alpha.2", path = "../../../frame/indices" } +sp-keyring = { version = "2.0.0-alpha.2", path = "../../../primitives/keyring" } +node-executor = { version = "2.0.0-alpha.2", path = "../executor" } +node-primitives = { version = "2.0.0-alpha.2", path = "../primitives" } +node-runtime = { version = "2.0.0-alpha.2", path = "../runtime" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } +sp-io = { version = "2.0.0-alpha.2", path = "../../../primitives/io" } +frame-support = { version = "2.0.0-alpha.2", path = "../../../frame/support" } +pallet-session = { version = "2.0.0-alpha.2", path = "../../../frame/session" } +pallet-society = { version = "2.0.0-alpha.2", path = "../../../frame/society" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } +pallet-staking = { version = "2.0.0-alpha.2", path = "../../../frame/staking" } +sc-executor = { version = "0.8.0-alpha.2", path = "../../../client/executor", features = ["wasmtime"] } +sp-consensus = { version = "0.8.0-alpha.2", path = "../../../primitives/consensus/common" } +frame-system = { version = "2.0.0-alpha.2", path = "../../../frame/system" } substrate-test-client = { version = "2.0.0-dev", path = "../../../test-utils/client" } -pallet-timestamp = { version = "2.0.0-dev", path = "../../../frame/timestamp" } -pallet-transaction-payment = { version = "2.0.0-dev", path = "../../../frame/transaction-payment" } -pallet-treasury = { version = "2.0.0-dev", path = "../../../frame/treasury" } +pallet-timestamp = { version = "2.0.0-alpha.2", path = "../../../frame/timestamp" } +pallet-transaction-payment = { version = "2.0.0-alpha.2", path = "../../../frame/transaction-payment" } +pallet-treasury = { version = "2.0.0-alpha.2", path = "../../../frame/treasury" } wabt = "0.9.2" -sp-api = { version = "2.0.0-dev", path = "../../../primitives/api" } -sp-finality-tracker = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/finality-tracker" } -sp-timestamp = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/timestamp" } -sp-block-builder = { version = "2.0.0-dev", path = "../../../primitives/block-builder" } -sp-inherents = { version = "2.0.0-dev", path = "../../../primitives/inherents" } -sp-blockchain = { version = "2.0.0-dev", path = "../../../primitives/blockchain" } +sp-api = { version = "2.0.0-alpha.2", path = "../../../primitives/api" } +sp-finality-tracker = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/finality-tracker" } +sp-timestamp = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/timestamp" } +sp-block-builder = { version = "2.0.0-alpha.2", path = "../../../primitives/block-builder" } +sp-inherents = { version = "2.0.0-alpha.2", path = "../../../primitives/inherents" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../../primitives/blockchain" } log = "0.4.8" -tempdir = "0.3" +tempfile = "3.1.0" fs_extra = "1" [dev-dependencies] criterion = "0.3.0" -sc-cli = { version = "0.8.0-dev", path = "../../../client/cli" } -sc-service = { version = "0.8.0-dev", path = "../../../client/service", features = ["rocksdb"] } +sc-cli = { version = "0.8.0-alpha.2", path = "../../../client/cli" } +sc-service = { version = "0.8.0-alpha.2", path = "../../../client/service", features = ["rocksdb"] } [[bench]] name = "import" diff --git a/bin/node/testing/src/bench.rs b/bin/node/testing/src/bench.rs index 5653ba7701646..58a7ab933eeb9 100644 --- a/bin/node/testing/src/bench.rs +++ b/bin/node/testing/src/bench.rs @@ -81,7 +81,7 @@ pub struct BenchDb { impl Clone for BenchDb { fn clone(&self) -> Self { let keyring = self.keyring.clone(); - let dir = tempdir::TempDir::new("sub-bench").expect("temp dir creation failed"); + let dir = tempfile::tempdir().expect("temp dir creation failed"); let seed_dir = self.directory_guard.0.path(); @@ -120,7 +120,7 @@ impl BenchDb { pub fn new(keyring_length: usize) -> Self { let keyring = BenchKeyring::new(keyring_length); - let dir = tempdir::TempDir::new("sub-bench").expect("temp dir creation failed"); + let dir = tempfile::tempdir().expect("temp dir creation failed"); log::trace!( target: "bench-logistics", "Created seed db at {}", @@ -357,7 +357,7 @@ impl Profile { } } -struct Guard(tempdir::TempDir); +struct Guard(tempfile::TempDir); impl Guard { fn path(&self) -> &Path { diff --git a/bin/node/testing/src/genesis.rs b/bin/node/testing/src/genesis.rs index 6aa7290a641bf..e35059e0c6ffd 100644 --- a/bin/node/testing/src/genesis.rs +++ b/bin/node/testing/src/genesis.rs @@ -84,7 +84,6 @@ pub fn config_endowed( ] }), pallet_staking: Some(StakingConfig { - current_era: 0, stakers: vec![ (dave(), alice(), 111 * DOLLARS, pallet_staking::StakerStatus::Validator), (eve(), bob(), 100 * DOLLARS, pallet_staking::StakerStatus::Validator), diff --git a/bin/node/transaction-factory/Cargo.toml b/bin/node/transaction-factory/Cargo.toml index 5d44c3a86a79d..8de968baa64f5 100644 --- a/bin/node/transaction-factory/Cargo.toml +++ b/bin/node/transaction-factory/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "node-transaction-factory" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" @@ -8,15 +8,15 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -sp-block-builder = { version = "2.0.0-dev", path = "../../../primitives/block-builder" } -sc-cli = { version = "0.8.0-dev", path = "../../../client/cli" } -sc-client-api = { version = "2.0.0-dev", path = "../../../client/api" } -sc-client = { version = "0.8.0-dev", path = "../../../client" } -codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -sp-consensus = { version = "0.8.0-dev", path = "../../../primitives/consensus/common" } +sp-block-builder = { version = "2.0.0-alpha.2", path = "../../../primitives/block-builder" } +sc-cli = { version = "0.8.0-alpha.2", path = "../../../client/cli" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../../../client/api" } +sc-client = { version = "0.8.0-alpha.2", path = "../../../client" } +codec = { package = "parity-scale-codec", version = "1.2.0", features = ["derive"] } +sp-consensus = { version = "0.8.0-alpha.2", path = "../../../primitives/consensus/common" } log = "0.4.8" -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } -sp-api = { version = "2.0.0-dev", path = "../../../primitives/api" } -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } -sc-service = { version = "0.8.0-dev", path = "../../../client/service" } -sp-blockchain = { version = "2.0.0-dev", path = "../../../primitives/blockchain" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } +sp-api = { version = "2.0.0-alpha.2", path = "../../../primitives/api" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } +sc-service = { version = "0.8.0-alpha.2", path = "../../../client/service" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../../primitives/blockchain" } diff --git a/bin/utils/chain-spec-builder/Cargo.toml b/bin/utils/chain-spec-builder/Cargo.toml index b211b308e18d6..5e51c4358e513 100644 --- a/bin/utils/chain-spec-builder/Cargo.toml +++ b/bin/utils/chain-spec-builder/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chain-spec-builder" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" build = "build.rs" @@ -10,8 +10,8 @@ repository = "https://github.com/paritytech/substrate/" [dependencies] ansi_term = "0.12.1" -sc-keystore = { version = "2.0.0-dev", path = "../../../client/keystore" } -node-cli = { version = "2.0.0-dev", path = "../../node/cli" } -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } +sc-keystore = { version = "2.0.0-alpha.2", path = "../../../client/keystore" } +node-cli = { version = "2.0.0-alpha.2", path = "../../node/cli" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } rand = "0.7.2" structopt = "0.3.8" diff --git a/bin/utils/subkey/Cargo.toml b/bin/utils/subkey/Cargo.toml index 14e5cb4be0b4d..252978a3a98cb 100644 --- a/bin/utils/subkey/Cargo.toml +++ b/bin/utils/subkey/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subkey" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" @@ -9,10 +9,10 @@ repository = "https://github.com/paritytech/substrate/" [dependencies] futures = "0.1.29" -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } -node-runtime = { version = "2.0.0-dev", path = "../../node/runtime" } -node-primitives = { version = "2.0.0-dev", path = "../../node/primitives" } -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } +node-runtime = { version = "2.0.0-alpha.2", path = "../../node/runtime" } +node-primitives = { version = "2.0.0-alpha.2", path = "../../node/primitives" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } rand = "0.7.2" clap = "2.33.0" tiny-bip39 = "0.7" @@ -20,17 +20,17 @@ rustc-hex = "2.0.1" substrate-bip39 = "0.3.1" hex = "0.4.0" hex-literal = "0.2.1" -codec = { package = "parity-scale-codec", version = "1.0.0" } -frame-system = { version = "2.0.0-dev", path = "../../../frame/system" } -pallet-balances = { version = "2.0.0-dev", path = "../../../frame/balances" } -pallet-transaction-payment = { version = "2.0.0-dev", path = "../../../frame/transaction-payment" } +codec = { package = "parity-scale-codec", version = "1.2.0" } +frame-system = { version = "2.0.0-alpha.2", path = "../../../frame/system" } +pallet-balances = { version = "2.0.0-alpha.2", path = "../../../frame/balances" } +pallet-transaction-payment = { version = "2.0.0-alpha.2", path = "../../../frame/transaction-payment" } rpassword = "4.0.1" itertools = "0.8.2" derive_more = { version = "0.99.2" } -sc-rpc = { version = "2.0.0-dev", path = "../../../client/rpc" } +sc-rpc = { version = "2.0.0-alpha.2", path = "../../../client/rpc" } jsonrpc-core-client = { version = "14.0.3", features = ["http"] } hyper = "0.12.35" -libp2p = "0.16.1" +libp2p = "0.16.2" serde_json = "1.0" [features] diff --git a/client/Cargo.toml b/client/Cargo.toml index b8a6efd05d8ee..710cdbd128f94 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -1,38 +1,39 @@ [package] name = "sc-client" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Substrate Client and associated logic." [dependencies] -sc-block-builder = { version = "0.8.0-dev", path = "block-builder" } -sc-client-api = { version = "2.0.0-dev", path = "api" } -codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -sp-consensus = { version = "0.8.0-dev", path = "../primitives/consensus/common" } +sc-block-builder = { version = "0.8.0-alpha.2", path = "block-builder" } +sc-client-api = { version = "2.0.0-alpha.2", path = "api" } +codec = { package = "parity-scale-codec", version = "1.2.0", features = ["derive"] } +sp-consensus = { version = "0.8.0-alpha.2", path = "../primitives/consensus/common" } derive_more = { version = "0.99.2" } -sc-executor = { version = "0.8.0-dev", path = "executor" } -sp-externalities = { version = "0.8.0-dev", path = "../primitives/externalities" } +sc-executor = { version = "0.8.0-alpha.2", path = "executor" } +sp-externalities = { version = "0.8.0-alpha.2", path = "../primitives/externalities" } fnv = { version = "1.0.6" } futures = { version = "0.3.1", features = ["compat"] } hash-db = { version = "0.15.2" } hex-literal = { version = "0.2.1" } -sp-inherents = { version = "2.0.0-dev", path = "../primitives/inherents" } -sp-keyring = { version = "2.0.0-dev", path = "../primitives/keyring" } +sp-inherents = { version = "2.0.0-alpha.2", path = "../primitives/inherents" } +sp-keyring = { version = "2.0.0-alpha.2", path = "../primitives/keyring" } kvdb = "0.4.0" log = { version = "0.4.8" } parking_lot = "0.10.0" -sp-core = { version = "2.0.0-dev", path = "../primitives/core" } -sp-std = { version = "2.0.0-dev", path = "../primitives/std" } -sp-version = { version = "2.0.0-dev", path = "../primitives/version" } -sp-api = { version = "2.0.0-dev", path = "../primitives/api" } -sp-runtime = { version = "2.0.0-dev", path = "../primitives/runtime" } -sp-blockchain = { version = "2.0.0-dev", path = "../primitives/blockchain" } -sp-state-machine = { version = "0.8.0-dev", path = "../primitives/state-machine" } -sc-telemetry = { version = "2.0.0-dev", path = "telemetry" } -sp-trie = { version = "2.0.0-dev", path = "../primitives/trie" } +sp-core = { version = "2.0.0-alpha.2", path = "../primitives/core" } +sp-std = { version = "2.0.0-alpha.2", path = "../primitives/std" } +sp-version = { version = "2.0.0-alpha.2", path = "../primitives/version" } +sp-api = { version = "2.0.0-alpha.2", path = "../primitives/api" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../primitives/runtime" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../primitives/blockchain" } +sp-state-machine = { version = "0.8.0-alpha.2", path = "../primitives/state-machine" } +sc-telemetry = { version = "2.0.0-alpha.2", path = "telemetry" } +sp-trie = { version = "2.0.0-alpha.2", path = "../primitives/trie" } tracing = "0.1.10" [dev-dependencies] @@ -40,4 +41,4 @@ env_logger = "0.7.0" tempfile = "3.1.0" substrate-test-runtime-client = { version = "2.0.0-dev", path = "../test-utils/runtime/client" } kvdb-memorydb = "0.4.0" -sp-panic-handler = { version = "2.0.0-dev", path = "../primitives/panic-handler" } +sp-panic-handler = { version = "2.0.0-alpha.2", path = "../primitives/panic-handler" } diff --git a/client/api/Cargo.toml b/client/api/Cargo.toml index a848875029f0c..025689105473f 100644 --- a/client/api/Cargo.toml +++ b/client/api/Cargo.toml @@ -1,37 +1,40 @@ [package] name = "sc-client-api" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Substrate client interfaces." +documentation = "https://docs.rs/sc-client-api" + [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-consensus = { version = "0.8.0-dev", path = "../../primitives/consensus/common" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-consensus = { version = "0.8.0-alpha.2", path = "../../primitives/consensus/common" } derive_more = { version = "0.99.2" } -sc-executor = { version = "0.8.0-dev", path = "../executor" } -sp-externalities = { version = "0.8.0-dev", path = "../../primitives/externalities" } +sc-executor = { version = "0.8.0-alpha.2", path = "../executor" } +sp-externalities = { version = "0.8.0-alpha.2", path = "../../primitives/externalities" } fnv = { version = "1.0.6" } futures = { version = "0.3.1" } hash-db = { version = "0.15.2", default-features = false } -sp-blockchain = { version = "2.0.0-dev", path = "../../primitives/blockchain" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../primitives/blockchain" } hex-literal = { version = "0.2.1" } -sp-inherents = { version = "2.0.0-dev", default-features = false, path = "../../primitives/inherents" } -sp-keyring = { version = "2.0.0-dev", path = "../../primitives/keyring" } +sp-inherents = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/inherents" } +sp-keyring = { version = "2.0.0-alpha.2", path = "../../primitives/keyring" } kvdb = "0.4.0" log = { version = "0.4.8" } parking_lot = "0.10.0" -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../primitives/core" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-version = { version = "2.0.0-dev", default-features = false, path = "../../primitives/version" } -sp-api = { version = "2.0.0-dev", path = "../../primitives/api" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-state-machine = { version = "0.8.0-dev", path = "../../primitives/state-machine" } -sc-telemetry = { version = "2.0.0-dev", path = "../telemetry" } -sp-trie = { version = "2.0.0-dev", path = "../../primitives/trie" } -sp-transaction-pool = { version = "2.0.0-dev", path = "../../primitives/transaction-pool" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/core" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-version = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/version" } +sp-api = { version = "2.0.0-alpha.2", path = "../../primitives/api" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-state-machine = { version = "0.8.0-alpha.2", path = "../../primitives/state-machine" } +sc-telemetry = { version = "2.0.0-alpha.2", path = "../telemetry" } +sp-trie = { version = "2.0.0-alpha.2", path = "../../primitives/trie" } +sp-transaction-pool = { version = "2.0.0-alpha.2", path = "../../primitives/transaction-pool" } [dev-dependencies] sp-test-primitives = { version = "2.0.0-dev", path = "../../primitives/test-primitives" } diff --git a/client/api/src/backend.rs b/client/api/src/backend.rs index a389af5671b32..c3e56e7f8b216 100644 --- a/client/api/src/backend.rs +++ b/client/api/src/backend.rs @@ -169,6 +169,15 @@ pub trait BlockImportOperation { fn mark_head(&mut self, id: BlockId) -> sp_blockchain::Result<()>; } +/// Interface for performing operations on the backend. +pub trait LockImportRun> { + /// Lock the import lock, and run operations inside. + fn lock_import_and_run(&self, f: F) -> Result + where + F: FnOnce(&mut ClientImportOperation) -> Result, + Err: From; +} + /// Finalize Facilities pub trait Finalizer> { /// Mark all blocks up to given as finalized in operation. diff --git a/client/api/src/client.rs b/client/api/src/client.rs index 7503ce4a79e46..4980015568be9 100644 --- a/client/api/src/client.rs +++ b/client/api/src/client.rs @@ -97,13 +97,56 @@ pub struct ClientInfo { pub usage: Option, } +/// A wrapper to store the size of some memory. +#[derive(Default, Clone, Debug, Copy)] +pub struct MemorySize(usize); + +impl MemorySize { + /// Creates `Self` from the given `bytes` size. + pub fn from_bytes(bytes: usize) -> Self { + Self(bytes) + } + + /// Returns the memory size as bytes. + pub fn as_bytes(self) -> usize { + self.0 + } +} + +impl fmt::Display for MemorySize { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if self.0 < 1024 { + write!(f, "{} bytes", self.0) + } else if self.0 < 1024 * 1024 { + write!(f, "{:.2} KiB", self.0 as f64 / 1024f64) + } else if self.0 < 1024 * 1024 * 1024 { + write!(f, "{:.2} MiB", self.0 as f64 / (1024f64 * 1024f64)) + } else { + write!(f, "{:.2} GiB", self.0 as f64 / (1024f64 * 1024f64 * 1024f64)) + } + } +} + +/// Memory statistics for state db. +#[derive(Default, Clone, Debug)] +pub struct StateDbMemoryInfo { + /// Memory usage of the non-canonical overlay + pub non_canonical: MemorySize, + /// Memory usage of the pruning window. + pub pruning: Option, + /// Memory usage of the pinned blocks. + pub pinned: MemorySize, +} + /// Memory statistics for client instance. #[derive(Default, Clone, Debug)] pub struct MemoryInfo { /// Size of state cache. - pub state_cache: usize, + pub state_cache: MemorySize, /// Size of backend database cache. - pub database_cache: usize, + pub database_cache: MemorySize, + /// Size of the state db. + pub state_db: StateDbMemoryInfo, } /// I/O statistics for client instance. @@ -144,10 +187,16 @@ pub struct UsageInfo { impl fmt::Display for UsageInfo { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, - "caches: ({} state, {} db overlay), i/o: ({} tx, {} write, {} read, {} avg tx, {}/{} key cache reads/total, {} key writes)", + write!( + f, + "caches: ({} state, {} db overlay), \ + state db: ({} non-canonical, {} pruning, {} pinned), \ + i/o: ({} tx, {} write, {} read, {} avg tx, {}/{} key cache reads/total, {} key writes)", self.memory.state_cache, self.memory.database_cache, + self.memory.state_db.non_canonical, + self.memory.state_db.pruning.unwrap_or_default(), + self.memory.state_db.pinned, self.io.transactions, self.io.bytes_written, self.io.bytes_read, diff --git a/client/authority-discovery/Cargo.toml b/client/authority-discovery/Cargo.toml index a87a0fee9795d..0c3b739bb9deb 100644 --- a/client/authority-discovery/Cargo.toml +++ b/client/authority-discovery/Cargo.toml @@ -1,38 +1,39 @@ [package] name = "sc-authority-discovery" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" build = "build.rs" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Substrate authority discovery." [build-dependencies] prost-build = "0.6.1" [dependencies] -bytes = "0.4.12" -codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" } +bytes = "0.5.0" +codec = { package = "parity-scale-codec", default-features = false, version = "1.2.0" } derive_more = "0.99.2" futures = "0.3.1" futures-timer = "3.0.1" -libp2p = { version = "0.16.1", default-features = false, features = ["secp256k1", "libp2p-websocket"] } +libp2p = { version = "0.16.2", default-features = false, features = ["secp256k1", "libp2p-websocket"] } log = "0.4.8" prost = "0.6.1" rand = "0.7.2" -sc-client-api = { version = "2.0.0-dev", path = "../api" } -sc-keystore = { version = "2.0.0-dev", path = "../keystore" } -sc-network = { version = "0.8.0-dev", path = "../network" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../api" } +sc-keystore = { version = "2.0.0-alpha.2", path = "../keystore" } +sc-network = { version = "0.8.0-alpha.2", path = "../network" } serde_json = "1.0.41" -sp-authority-discovery = { version = "2.0.0-dev", path = "../../primitives/authority-discovery" } -sp-blockchain = { version = "2.0.0-dev", path = "../../primitives/blockchain" } -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -sp-runtime = { version = "2.0.0-dev", path = "../../primitives/runtime" } -sp-api = { version = "2.0.0-dev", path = "../../primitives/api" } +sp-authority-discovery = { version = "2.0.0-alpha.2", path = "../../primitives/authority-discovery" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../primitives/blockchain" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../primitives/runtime" } +sp-api = { version = "2.0.0-alpha.2", path = "../../primitives/api" } [dev-dependencies] env_logger = "0.7.0" quickcheck = "0.9.0" -sc-peerset = { version = "2.0.0-dev", path = "../peerset" } +sc-peerset = { version = "2.0.0-alpha.2", path = "../peerset" } substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../test-utils/runtime/client"} diff --git a/client/basic-authorship/Cargo.toml b/client/basic-authorship/Cargo.toml index 15a94def5f35e..7503221f65560 100644 --- a/client/basic-authorship/Cargo.toml +++ b/client/basic-authorship/Cargo.toml @@ -1,30 +1,30 @@ [package] name = "sc-basic-authorship" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Basic implementation of block-authoring logic." [dependencies] log = "0.4.8" futures = "0.3.1" -codec = { package = "parity-scale-codec", version = "1.0.0" } -sp-api = { version = "2.0.0-dev", path = "../../primitives/api" } -sp-runtime = { version = "2.0.0-dev", path = "../../primitives/runtime" } -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -sp-blockchain = { version = "2.0.0-dev", path = "../../primitives/blockchain" } -sc-client = { version = "0.8.0-dev", path = "../" } -sc-client-api = { version = "2.0.0-dev", path = "../api" } -sp-consensus = { version = "0.8.0-dev", path = "../../primitives/consensus/common" } -sp-inherents = { version = "2.0.0-dev", path = "../../primitives/inherents" } -sc-telemetry = { version = "2.0.0-dev", path = "../telemetry" } -sp-transaction-pool = { version = "2.0.0-dev", path = "../../primitives/transaction-pool" } -sc-block-builder = { version = "0.8.0-dev", path = "../block-builder" } +codec = { package = "parity-scale-codec", version = "1.2.0" } +sp-api = { version = "2.0.0-alpha.2", path = "../../primitives/api" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../primitives/runtime" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../primitives/blockchain" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../api" } +sp-consensus = { version = "0.8.0-alpha.2", path = "../../primitives/consensus/common" } +sp-inherents = { version = "2.0.0-alpha.2", path = "../../primitives/inherents" } +sc-telemetry = { version = "2.0.0-alpha.2", path = "../telemetry" } +sp-transaction-pool = { version = "2.0.0-alpha.2", path = "../../primitives/transaction-pool" } +sc-block-builder = { version = "0.8.0-alpha.2", path = "../block-builder" } tokio-executor = { version = "0.2.0-alpha.6", features = ["blocking"] } [dev-dependencies] -sc-transaction-pool = { version = "2.0.0-dev", path = "../../client/transaction-pool" } +sc-transaction-pool = { version = "2.0.0-alpha.2", path = "../../client/transaction-pool" } substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../test-utils/runtime/client" } parking_lot = "0.10.0" diff --git a/client/basic-authorship/src/basic_authorship.rs b/client/basic-authorship/src/basic_authorship.rs index a99453544e5f6..231d0255919b4 100644 --- a/client/basic-authorship/src/basic_authorship.rs +++ b/client/basic-authorship/src/basic_authorship.rs @@ -19,8 +19,7 @@ // FIXME #1021 move this into sp-consensus use std::{time, sync::Arc}; -use sc_client_api::{CallExecutor, backend}; -use sc_client::Client as SubstrateClient; +use sc_client_api::backend; use codec::Decode; use sp_consensus::{evaluation, Proposal, RecordProof}; use sp_inherents::InherentData; @@ -32,35 +31,47 @@ use sp_runtime::{ }; use sp_transaction_pool::{TransactionPool, InPoolTransaction}; use sc_telemetry::{telemetry, CONSENSUS_INFO}; -use sc_block_builder::BlockBuilderApi; +use sc_block_builder::{BlockBuilderApi, BlockBuilderProvider}; use sp_api::{ProvideRuntimeApi, ApiExt}; use futures::prelude::*; +use sp_blockchain::HeaderBackend; +use std::marker::PhantomData; /// Proposer factory. -pub struct ProposerFactory where A: TransactionPool { +pub struct ProposerFactory { /// The client instance. - pub client: Arc, + client: Arc, /// The transaction pool. - pub transaction_pool: Arc, + transaction_pool: Arc, + /// phantom member to pin the `Backend` type. + _phantom: PhantomData, +} + +impl ProposerFactory { + pub fn new(client: Arc, transaction_pool: Arc) -> Self { + ProposerFactory { + client, + transaction_pool, + _phantom: PhantomData, + } + } } -impl ProposerFactory, A> +impl ProposerFactory where A: TransactionPool + 'static, B: backend::Backend + Send + Sync + 'static, - E: CallExecutor + Send + Sync + Clone + 'static, Block: BlockT, - RA: Send + Sync + 'static, - SubstrateClient: ProvideRuntimeApi, - as ProvideRuntimeApi>::Api: - BlockBuilderApi + - ApiExt>, + C: BlockBuilderProvider + HeaderBackend + ProvideRuntimeApi + + Send + Sync + 'static, + C::Api: ApiExt> + + BlockBuilderApi, { pub fn init_with_now( &mut self, parent_header: &::Header, now: Box time::Instant + Send + Sync>, - ) -> Proposer, A> { + ) -> Proposer { let parent_hash = parent_header.hash(); let id = BlockId::hash(parent_hash); @@ -75,6 +86,7 @@ impl ProposerFactory, A> parent_number: *parent_header.number(), transaction_pool: self.transaction_pool.clone(), now, + _phantom: PhantomData, }), }; @@ -82,21 +94,19 @@ impl ProposerFactory, A> } } -impl sp_consensus::Environment for - ProposerFactory, A> +impl sp_consensus::Environment for + ProposerFactory where A: TransactionPool + 'static, B: backend::Backend + Send + Sync + 'static, - E: CallExecutor + Send + Sync + Clone + 'static, Block: BlockT, - RA: Send + Sync + 'static, - SubstrateClient: ProvideRuntimeApi, - as ProvideRuntimeApi>::Api: - BlockBuilderApi + - ApiExt>, + C: BlockBuilderProvider + HeaderBackend + ProvideRuntimeApi + + Send + Sync + 'static, + C::Api: ApiExt> + + BlockBuilderApi, { type CreateProposer = future::Ready>; - type Proposer = Proposer, A>; + type Proposer = Proposer; type Error = sp_blockchain::Error; fn init( @@ -108,32 +118,31 @@ impl sp_consensus::Environment for } /// The proposer logic. -pub struct Proposer { - inner: Arc>, +pub struct Proposer { + inner: Arc>, } /// Proposer inner, to wrap parameters under Arc. -struct ProposerInner { +struct ProposerInner { client: Arc, parent_hash: ::Hash, parent_id: BlockId, parent_number: <::Header as HeaderT>::Number, transaction_pool: Arc, now: Box time::Instant + Send + Sync>, + _phantom: PhantomData, } -impl sp_consensus::Proposer for - Proposer, A> +impl sp_consensus::Proposer for + Proposer where A: TransactionPool + 'static, B: backend::Backend + Send + Sync + 'static, - E: CallExecutor + Send + Sync + Clone + 'static, Block: BlockT, - RA: Send + Sync + 'static, - SubstrateClient: ProvideRuntimeApi, - as ProvideRuntimeApi>::Api: - BlockBuilderApi + - ApiExt>, + C: BlockBuilderProvider + HeaderBackend + ProvideRuntimeApi + + Send + Sync + 'static, + C::Api: ApiExt> + + BlockBuilderApi, { type Transaction = backend::TransactionFor; type Proposal = tokio_executor::blocking::Blocking< @@ -157,16 +166,15 @@ impl sp_consensus::Proposer for } } -impl ProposerInner, A> where - A: TransactionPool, - B: sc_client_api::backend::Backend + Send + Sync + 'static, - E: CallExecutor + Send + Sync + Clone + 'static, - Block: BlockT, - RA: Send + Sync + 'static, - SubstrateClient: ProvideRuntimeApi, - as ProvideRuntimeApi>::Api: - BlockBuilderApi + - ApiExt>, +impl ProposerInner + where + A: TransactionPool, + B: backend::Backend + Send + Sync + 'static, + Block: BlockT, + C: BlockBuilderProvider + HeaderBackend + ProvideRuntimeApi + + Send + Sync + 'static, + C::Api: ApiExt> + + BlockBuilderApi, { fn propose_with( &self, @@ -315,10 +323,7 @@ mod tests { txpool.submit_at(&BlockId::number(0), vec![extrinsic(0), extrinsic(1)]) ).unwrap(); - let mut proposer_factory = ProposerFactory { - client: client.clone(), - transaction_pool: txpool.clone(), - }; + let mut proposer_factory = ProposerFactory::new(client.clone(), txpool.clone()); let cell = Mutex::new(time::Instant::now()); let mut proposer = proposer_factory.init_with_now( @@ -359,10 +364,7 @@ mod tests { txpool.submit_at(&BlockId::number(0), vec![extrinsic(0)]), ).unwrap(); - let mut proposer_factory = ProposerFactory { - client: client.clone(), - transaction_pool: txpool.clone(), - }; + let mut proposer_factory = ProposerFactory::new(client.clone(), txpool.clone()); let mut proposer = proposer_factory.init_with_now( &client.header(&block_id).unwrap().unwrap(), diff --git a/client/basic-authorship/src/lib.rs b/client/basic-authorship/src/lib.rs index e9087c89e07ed..5ec0bc6f9a520 100644 --- a/client/basic-authorship/src/lib.rs +++ b/client/basic-authorship/src/lib.rs @@ -28,10 +28,7 @@ //! # let client = Arc::new(substrate_test_runtime_client::new()); //! # let txpool = Arc::new(BasicPool::new(Default::default(), Arc::new(FullChainApi::new(client.clone()))).0); //! // The first step is to create a `ProposerFactory`. -//! let mut proposer_factory = ProposerFactory { -//! client: client.clone(), -//! transaction_pool: txpool.clone(), -//! }; +//! let mut proposer_factory = ProposerFactory::new(client.clone(), txpool.clone()); //! //! // From this factory, we create a `Proposer`. //! let proposer = proposer_factory.init( diff --git a/client/block-builder/Cargo.toml b/client/block-builder/Cargo.toml index f706265cabfb8..745669c033e38 100644 --- a/client/block-builder/Cargo.toml +++ b/client/block-builder/Cargo.toml @@ -1,19 +1,21 @@ [package] name = "sc-block-builder" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Substrate block builder" + [dependencies] -sp-state-machine = { version = "0.8.0-dev", path = "../../primitives/state-machine" } -sp-runtime = { version = "2.0.0-dev", path = "../../primitives/runtime" } -sp-api = { version = "2.0.0-dev", path = "../../primitives/api" } -sp-consensus = { version = "0.8.0-dev", path = "../../primitives/consensus/common" } -sp-blockchain = { version = "2.0.0-dev", path = "../../primitives/blockchain" } -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -sp-block-builder = { version = "2.0.0-dev", path = "../../primitives/block-builder" } -sc-client-api = { version = "2.0.0-dev", path = "../api" } -codec = { package = "parity-scale-codec", version = "1.0.6", features = ["derive"] } +sp-state-machine = { version = "0.8.0-alpha.2", path = "../../primitives/state-machine" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../primitives/runtime" } +sp-api = { version = "2.0.0-alpha.2", path = "../../primitives/api" } +sp-consensus = { version = "0.8.0-alpha.2", path = "../../primitives/consensus/common" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../primitives/blockchain" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +sp-block-builder = { version = "2.0.0-alpha.2", path = "../../primitives/block-builder" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../api" } +codec = { package = "parity-scale-codec", version = "1.2.0", features = ["derive"] } diff --git a/client/block-builder/src/lib.rs b/client/block-builder/src/lib.rs index 9bc14cb6e9e1a..4c14f3716f210 100644 --- a/client/block-builder/src/lib.rs +++ b/client/block-builder/src/lib.rs @@ -63,6 +63,27 @@ impl>> Built } } +/// Block builder provider +pub trait BlockBuilderProvider + where + Block: BlockT, + B: backend::Backend, + Self: Sized, + RA: ProvideRuntimeApi, +{ + /// Create a new block, built on top of `parent`. + /// + /// When proof recording is enabled, all accessed trie nodes are saved. + /// These recorded trie nodes can be used by a third party to proof the + /// output of this block builder without having access to the full storage. + fn new_block_at>( + &self, + parent: &BlockId, + inherent_digests: DigestFor, + record_proof: R, + ) -> sp_blockchain::Result>; +} + /// Utility for building new (valid) blocks from a stream of extrinsics. pub struct BlockBuilder<'a, Block: BlockT, A: ProvideRuntimeApi, B> { extrinsics: Vec, @@ -131,8 +152,7 @@ where /// Push onto the block's list of extrinsics. /// - /// This will treat incoming extrinsic `xt` as untrusted and perform additional checks - /// (currenty checking signature). + /// This will treat incoming extrinsic `xt` as trusted and skip signature check (for signed transactions). pub fn push_trusted(&mut self, xt: ::Extrinsic) -> Result<(), ApiErrorFor> { self.push_internal(xt, true) } diff --git a/client/chain-spec/Cargo.toml b/client/chain-spec/Cargo.toml index b2dee23ac5ec1..10d4fc2622480 100644 --- a/client/chain-spec/Cargo.toml +++ b/client/chain-spec/Cargo.toml @@ -1,18 +1,19 @@ [package] name = "sc-chain-spec" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Substrate chain configurations." [dependencies] -sc-chain-spec-derive = { version = "2.0.0-dev", path = "./derive" } +sc-chain-spec-derive = { version = "2.0.0-alpha.2", path = "./derive" } impl-trait-for-tuples = "0.1.3" -sc-network = { version = "0.8.0-dev", path = "../network" } -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } +sc-network = { version = "0.8.0-alpha.2", path = "../network" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" -sp-runtime = { version = "2.0.0-dev", path = "../../primitives/runtime" } -sc-telemetry = { version = "2.0.0-dev", path = "../telemetry" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../primitives/runtime" } +sc-telemetry = { version = "2.0.0-alpha.2", path = "../telemetry" } diff --git a/client/chain-spec/derive/Cargo.toml b/client/chain-spec/derive/Cargo.toml index 9b23b71ab5217..c76949011aa09 100644 --- a/client/chain-spec/derive/Cargo.toml +++ b/client/chain-spec/derive/Cargo.toml @@ -1,11 +1,12 @@ [package] name = "sc-chain-spec-derive" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Macros to derive chain spec extension traits implementation." [lib] proc-macro = true diff --git a/client/chain-spec/src/chain_spec.rs b/client/chain-spec/src/chain_spec.rs index ab9c851bdde5f..a7e5738fc4bd8 100644 --- a/client/chain-spec/src/chain_spec.rs +++ b/client/chain-spec/src/chain_spec.rs @@ -117,8 +117,8 @@ struct ChildRawStorage { #[serde(deny_unknown_fields)] /// Storage content for genesis block. struct RawGenesis { - pub top: GenesisStorage, - pub children: HashMap, + top: GenesisStorage, + children: HashMap, } #[derive(Serialize, Deserialize)] @@ -134,14 +134,14 @@ enum Genesis { #[serde(rename_all = "camelCase")] #[serde(deny_unknown_fields)] struct ClientSpec { - pub name: String, - pub id: String, - pub boot_nodes: Vec, - pub telemetry_endpoints: Option, - pub protocol_id: Option, - pub properties: Option, + name: String, + id: String, + boot_nodes: Vec, + telemetry_endpoints: Option, + protocol_id: Option, + properties: Option, #[serde(flatten)] - pub extensions: E, + extensions: E, // Never used, left only for backward compatibility. consensus_engine: (), #[serde(skip_serializing)] diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index 30c749ff85e95..588aa134ab172 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sc-cli" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] description = "Substrate CLI interface." edition = "2018" @@ -23,21 +23,21 @@ tokio = { version = "0.2.9", features = [ "signal", "rt-core", "rt-threaded" ] } futures = "0.3.1" fdlimit = "0.1.1" serde_json = "1.0.41" -sc-informant = { version = "0.8.0-dev", path = "../informant" } -sp-panic-handler = { version = "2.0.0-dev", path = "../../primitives/panic-handler" } -sc-client-api = { version = "2.0.0-dev", path = "../api" } -sp-blockchain = { version = "2.0.0-dev", path = "../../primitives/blockchain" } -sc-network = { version = "0.8.0-dev", path = "../network" } -sp-runtime = { version = "2.0.0-dev", path = "../../primitives/runtime" } -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -sc-service = { version = "0.8.0-dev", default-features = false, path = "../service" } -sp-state-machine = { version = "0.8.0-dev", path = "../../primitives/state-machine" } -sc-telemetry = { version = "2.0.0-dev", path = "../telemetry" } -prometheus-exporter = { path = "../../utils/prometheus" , version = "0.8.0-dev"} -sp-keyring = { version = "2.0.0-dev", path = "../../primitives/keyring" } +sc-informant = { version = "0.8.0-alpha.2", path = "../informant" } +sp-panic-handler = { version = "2.0.0-alpha.2", path = "../../primitives/panic-handler" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../api" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../primitives/blockchain" } +sc-network = { version = "0.8.0-alpha.2", path = "../network" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../primitives/runtime" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +sc-service = { version = "0.8.0-alpha.2", default-features = false, path = "../service" } +sp-state-machine = { version = "0.8.0-alpha.2", path = "../../primitives/state-machine" } +sc-telemetry = { version = "2.0.0-alpha.2", path = "../telemetry" } +substrate-prometheus-endpoint = { path = "../../utils/prometheus" , version = "0.8.0-alpha.2"} +sp-keyring = { version = "2.0.0-alpha.2", path = "../../primitives/keyring" } names = "0.11.0" structopt = "0.3.8" -sc-tracing = { version = "2.0.0-dev", path = "../tracing" } +sc-tracing = { version = "2.0.0-alpha.2", path = "../tracing" } chrono = "0.4.10" parity-util-mem = { version = "0.5.1", default-features = false, features = ["primitive-types"] } diff --git a/client/cli/src/commands/export_blocks_cmd.rs b/client/cli/src/commands/export_blocks_cmd.rs index 8db650ae8c88c..21195cccd4664 100644 --- a/client/cli/src/commands/export_blocks_cmd.rs +++ b/client/cli/src/commands/export_blocks_cmd.rs @@ -22,15 +22,14 @@ use log::info; use structopt::StructOpt; use sc_service::{ Configuration, ChainSpecExtension, RuntimeGenesis, ServiceBuilderCommand, ChainSpec, - config::DatabaseConfig, + config::DatabaseConfig, Roles, }; use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; use crate::error; use crate::VersionInfo; use crate::runtime::run_until_exit; -use crate::params::SharedParams; -use crate::params::BlockNumber; +use crate::params::{SharedParams, BlockNumber, PruningParams}; /// The `export-blocks` command used to export blocks. #[derive(Debug, StructOpt, Clone)] @@ -51,13 +50,17 @@ pub struct ExportBlocksCmd { #[structopt(long = "to", value_name = "BLOCK")] pub to: Option, - /// Use JSON output rather than binary. - #[structopt(long = "json")] - pub json: bool, + /// Use binary output rather than JSON. + #[structopt(long = "binary", value_name = "BOOL", parse(try_from_str), default_value("false"))] + pub binary: bool, #[allow(missing_docs)] #[structopt(flatten)] pub shared_params: SharedParams, + + #[allow(missing_docs)] + #[structopt(flatten)] + pub pruning_params: PruningParams, } impl ExportBlocksCmd { @@ -82,7 +85,7 @@ impl ExportBlocksCmd { let from = self.from.as_ref().and_then(|f| f.parse().ok()).unwrap_or(1); let to = self.to.as_ref().and_then(|t| t.parse().ok()); - let json = self.json; + let binary = self.binary; let file: Box = match &self.output { Some(filename) => Box::new(fs::File::create(filename)?), @@ -90,7 +93,7 @@ impl ExportBlocksCmd { }; run_until_exit(config, |config| { - Ok(builder(config)?.export_blocks(file, from.into(), to, json)) + Ok(builder(config)?.export_blocks(file, from.into(), to, binary)) }) } @@ -106,6 +109,7 @@ impl ExportBlocksCmd { F: FnOnce(&str) -> Result>, String>, { self.shared_params.update_config(&mut config, spec_factory, version)?; + self.pruning_params.update_config(&mut config, Roles::FULL, true)?; config.use_in_memory_keystore()?; Ok(()) diff --git a/client/cli/src/commands/revert_cmd.rs b/client/cli/src/commands/revert_cmd.rs index 9ab86986cdd07..f0c534898effd 100644 --- a/client/cli/src/commands/revert_cmd.rs +++ b/client/cli/src/commands/revert_cmd.rs @@ -17,14 +17,13 @@ use std::fmt::Debug; use structopt::StructOpt; use sc_service::{ - Configuration, ChainSpecExtension, RuntimeGenesis, ServiceBuilderCommand, ChainSpec, + Configuration, ChainSpecExtension, RuntimeGenesis, ServiceBuilderCommand, ChainSpec, Roles, }; use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; use crate::error; use crate::VersionInfo; -use crate::params::BlockNumber; -use crate::params::SharedParams; +use crate::params::{BlockNumber, SharedParams, PruningParams}; /// The `revert` command used revert the chain to a previous state. #[derive(Debug, StructOpt, Clone)] @@ -36,6 +35,10 @@ pub struct RevertCmd { #[allow(missing_docs)] #[structopt(flatten)] pub shared_params: SharedParams, + + #[allow(missing_docs)] + #[structopt(flatten)] + pub pruning_params: PruningParams, } impl RevertCmd { @@ -72,6 +75,7 @@ impl RevertCmd { F: FnOnce(&str) -> Result>, String>, { self.shared_params.update_config(&mut config, spec_factory, version)?; + self.pruning_params.update_config(&mut config, Roles::FULL, true)?; config.use_in_memory_keystore()?; Ok(()) diff --git a/client/cli/src/params/import_params.rs b/client/cli/src/params/import_params.rs index 98809a38ae446..36c62bc979c5c 100644 --- a/client/cli/src/params/import_params.rs +++ b/client/cli/src/params/import_params.rs @@ -15,10 +15,7 @@ // along with Substrate. If not, see . use structopt::StructOpt; -use sc_service::{ - Configuration, RuntimeGenesis, - config::DatabaseConfig, PruningMode, -}; +use sc_service::{Configuration, RuntimeGenesis, config::DatabaseConfig}; use crate::error; use crate::arg_enums::{ @@ -26,17 +23,14 @@ use crate::arg_enums::{ DEFAULT_EXECUTION_IMPORT_BLOCK, DEFAULT_EXECUTION_OFFCHAIN_WORKER, DEFAULT_EXECUTION_OTHER, DEFAULT_EXECUTION_SYNCING }; +use crate::params::PruningParams; /// Parameters for block import. #[derive(Debug, StructOpt, Clone)] pub struct ImportParams { - /// Specify the state pruning mode, a number of blocks to keep or 'archive'. - /// - /// Default is to keep all block states if the node is running as a - /// validator (i.e. 'archive'), otherwise state is only kept for the last - /// 256 blocks. - #[structopt(long = "pruning", value_name = "PRUNING_MODE")] - pub pruning: Option, + #[allow(missing_docs)] + #[structopt(flatten)] + pub pruning_params: PruningParams, /// Force start with unsafe pruning settings. /// @@ -87,7 +81,7 @@ impl ImportParams { /// Put block import CLI params into `config` object. pub fn update_config( &self, - config: &mut Configuration, + mut config: &mut Configuration, role: sc_service::Roles, is_dev: bool, ) -> error::Result<()> @@ -102,27 +96,7 @@ impl ImportParams { config.state_cache_size = self.state_cache_size; - // by default we disable pruning if the node is an authority (i.e. - // `ArchiveAll`), otherwise we keep state for the last 256 blocks. if the - // node is an authority and pruning is enabled explicitly, then we error - // unless `unsafe_pruning` is set. - config.pruning = match &self.pruning { - Some(ref s) if s == "archive" => PruningMode::ArchiveAll, - None if role == sc_service::Roles::AUTHORITY => PruningMode::ArchiveAll, - None => PruningMode::default(), - Some(s) => { - if role == sc_service::Roles::AUTHORITY && !self.unsafe_pruning { - return Err(error::Error::Input( - "Validators should run with state pruning disabled (i.e. archive). \ - You can ignore this check with `--unsafe-pruning`.".to_string() - )); - } - - PruningMode::keep_blocks(s.parse() - .map_err(|_| error::Error::Input("Invalid pruning mode specified".to_string()))? - ) - }, - }; + self.pruning_params.update_config(&mut config, role, self.unsafe_pruning)?; config.wasm_method = self.wasm_method.into(); @@ -144,6 +118,7 @@ impl ImportParams { exec_all_or(exec.execution_offchain_worker, DEFAULT_EXECUTION_OFFCHAIN_WORKER), other: exec_all_or(exec.execution_other, DEFAULT_EXECUTION_OTHER), }; + Ok(()) } } diff --git a/client/cli/src/params/mod.rs b/client/cli/src/params/mod.rs index 75509afa42558..f684cab336423 100644 --- a/client/cli/src/params/mod.rs +++ b/client/cli/src/params/mod.rs @@ -19,6 +19,7 @@ mod transaction_pool_params; mod shared_params; mod node_key_params; mod network_configuration_params; +mod pruning_params; use std::str::FromStr; use std::fmt::Debug; @@ -28,6 +29,7 @@ pub use crate::params::transaction_pool_params::*; pub use crate::params::shared_params::*; pub use crate::params::node_key_params::*; pub use crate::params::network_configuration_params::*; +pub use crate::params::pruning_params::*; /// Wrapper type of `String` that holds an unsigned integer of arbitrary size, formatted as a decimal. #[derive(Debug, Clone)] diff --git a/client/cli/src/params/pruning_params.rs b/client/cli/src/params/pruning_params.rs new file mode 100644 index 0000000000000..ad64d757dcb61 --- /dev/null +++ b/client/cli/src/params/pruning_params.rs @@ -0,0 +1,69 @@ +// Copyright 2020 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate 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. + +// Substrate 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 Substrate. If not, see . + +use structopt::StructOpt; +use sc_service::{Configuration, RuntimeGenesis, PruningMode}; + +use crate::error; + +/// Parameters to define the pruning mode +#[derive(Debug, StructOpt, Clone)] +pub struct PruningParams { + /// Specify the state pruning mode, a number of blocks to keep or 'archive'. + /// + /// Default is to keep all block states if the node is running as a + /// validator (i.e. 'archive'), otherwise state is only kept for the last + /// 256 blocks. + #[structopt(long = "pruning", value_name = "PRUNING_MODE")] + pub pruning: Option, +} + +impl PruningParams { + /// Put block pruning CLI params into `config` object. + pub fn update_config( + &self, + mut config: &mut Configuration, + role: sc_service::Roles, + unsafe_pruning: bool, + ) -> error::Result<()> + where + G: RuntimeGenesis, + { + // by default we disable pruning if the node is an authority (i.e. + // `ArchiveAll`), otherwise we keep state for the last 256 blocks. if the + // node is an authority and pruning is enabled explicitly, then we error + // unless `unsafe_pruning` is set. + config.pruning = match &self.pruning { + Some(ref s) if s == "archive" => PruningMode::ArchiveAll, + None if role == sc_service::Roles::AUTHORITY => PruningMode::ArchiveAll, + None => PruningMode::default(), + Some(s) => { + if role == sc_service::Roles::AUTHORITY && !unsafe_pruning { + return Err(error::Error::Input( + "Validators should run with state pruning disabled (i.e. archive). \ + You can ignore this check with `--unsafe-pruning`.".to_string() + )); + } + + PruningMode::keep_blocks(s.parse() + .map_err(|_| error::Error::Input("Invalid pruning mode specified".to_string()))? + ) + }, + }; + + Ok(()) + } +} diff --git a/client/consensus/aura/Cargo.toml b/client/consensus/aura/Cargo.toml index 24c42fe0fc15a..be610c16d99b5 100644 --- a/client/consensus/aura/Cargo.toml +++ b/client/consensus/aura/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sc-consensus-aura" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] description = "Aura consensus algorithm for substrate" edition = "2018" @@ -9,38 +9,36 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -sp-application-crypto = { version = "2.0.0-dev", path = "../../../primitives/application-crypto" } -sp-consensus-aura = { version = "0.8.0-dev", path = "../../../primitives/consensus/aura" } -sp-block-builder = { version = "2.0.0-dev", path = "../../../primitives/block-builder" } -sc-client = { version = "0.8.0-dev", path = "../../" } -sc-client-api = { version = "2.0.0-dev", path = "../../api" } -codec = { package = "parity-scale-codec", version = "1.0.0" } -sp-consensus = { version = "0.8.0-dev", path = "../../../primitives/consensus/common" } +sp-application-crypto = { version = "2.0.0-alpha.2", path = "../../../primitives/application-crypto" } +sp-consensus-aura = { version = "0.8.0-alpha.2", path = "../../../primitives/consensus/aura" } +sp-block-builder = { version = "2.0.0-alpha.2", path = "../../../primitives/block-builder" } +sc-client = { version = "0.8.0-alpha.2", path = "../../" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../../api" } +codec = { package = "parity-scale-codec", version = "1.2.0" } +sp-consensus = { version = "0.8.0-alpha.2", path = "../../../primitives/consensus/common" } derive_more = "0.99.2" futures = "0.3.1" futures-timer = "3.0.1" -sp-inherents = { version = "2.0.0-dev", path = "../../../primitives/inherents" } -sc-keystore = { version = "2.0.0-dev", path = "../../keystore" } +sp-inherents = { version = "2.0.0-alpha.2", path = "../../../primitives/inherents" } +sc-keystore = { version = "2.0.0-alpha.2", path = "../../keystore" } log = "0.4.8" parking_lot = "0.10.0" -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } -sp-blockchain = { version = "2.0.0-dev", path = "../../../primitives/blockchain" } -sp-io = { version = "2.0.0-dev", path = "../../../primitives/io" } -sp-version = { version = "2.0.0-dev", path = "../../../primitives/version" } -sc-consensus-slots = { version = "0.8.0-dev", path = "../slots" } -sp-api = { version = "2.0.0-dev", path = "../../../primitives/api" } -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } -sp-timestamp = { version = "2.0.0-dev", path = "../../../primitives/timestamp" } -sc-telemetry = { version = "2.0.0-dev", path = "../../telemetry" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../../primitives/blockchain" } +sp-io = { version = "2.0.0-alpha.2", path = "../../../primitives/io" } +sp-version = { version = "2.0.0-alpha.2", path = "../../../primitives/version" } +sc-consensus-slots = { version = "0.8.0-alpha.2", path = "../slots" } +sp-api = { version = "2.0.0-alpha.2", path = "../../../primitives/api" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } +sp-timestamp = { version = "2.0.0-alpha.2", path = "../../../primitives/timestamp" } +sc-telemetry = { version = "2.0.0-alpha.2", path = "../../telemetry" } [dev-dependencies] -sp-keyring = { version = "2.0.0-dev", path = "../../../primitives/keyring" } -sc-executor = { version = "0.8.0-dev", path = "../../executor" } -sc-network = { version = "0.8.0-dev", path = "../../network" } +sp-keyring = { version = "2.0.0-alpha.2", path = "../../../primitives/keyring" } +sc-executor = { version = "0.8.0-alpha.2", path = "../../executor" } +sc-network = { version = "0.8.0-alpha.2", path = "../../network" } sc-network-test = { version = "0.8.0-dev", path = "../../network/test" } -sc-service = { version = "0.8.0-dev", path = "../../service" } +sc-service = { version = "0.8.0-alpha.2", path = "../../service" } substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../../test-utils/runtime/client" } -tokio = "0.1.22" env_logger = "0.7.0" tempfile = "3.1.0" -futures01 = { package = "futures", version = "0.1" } diff --git a/client/consensus/aura/src/lib.rs b/client/consensus/aura/src/lib.rs index 13dd81c1989fb..5850228628547 100644 --- a/client/consensus/aura/src/lib.rs +++ b/client/consensus/aura/src/lib.rs @@ -405,21 +405,17 @@ fn find_pre_digest(header: &B::Header) -> Result( +fn check_header( client: &C, slot_now: u64, mut header: B::Header, hash: B::Hash, authorities: &[AuthorityId

], - _transaction_pool: Option<&T>, ) -> Result)>, Error> where DigestItemFor: CompatibleDigestItem

, P::Signature: Decode, C: sc_client_api::backend::AuxStore, P::Public: Encode + Decode + PartialEq + Clone, - T: Send + Sync + 'static, { let seal = match header.digest_mut().pop() { Some(x) => x, @@ -469,14 +465,13 @@ fn check_header( } /// A verifier for Aura blocks. -pub struct AuraVerifier { +pub struct AuraVerifier { client: Arc, phantom: PhantomData

, inherent_data_providers: sp_inherents::InherentDataProviders, - transaction_pool: Option>, } -impl AuraVerifier +impl AuraVerifier where P: Send + Sync + 'static { fn check_inherents( @@ -531,7 +526,7 @@ impl AuraVerifier } #[forbid(deprecated)] -impl Verifier for AuraVerifier where +impl Verifier for AuraVerifier where C: ProvideRuntimeApi + Send + Sync + @@ -543,7 +538,6 @@ impl Verifier for AuraVerifier where P: Pair + Send + Sync + 'static, P::Public: Send + Sync + Hash + Eq + Clone + Decode + Encode + Debug + 'static, P::Signature: Encode + Decode, - T: Send + Sync + 'static, { fn verify( &mut self, @@ -565,13 +559,12 @@ impl Verifier for AuraVerifier where // we add one to allow for some small drift. // FIXME #1019 in the future, alter this queue to allow deferring of // headers - let checked_header = check_header::( + let checked_header = check_header::( &self.client, slot_now + 1, header, hash, &authorities[..], - self.transaction_pool.as_ref().map(|x| &**x), ).map_err(|e| e.to_string())?; match checked_header { CheckedHeader::Checked(pre_header, (slot_num, seal)) => { @@ -795,14 +788,13 @@ impl BlockImport for AuraBlockImport( +pub fn import_queue( slot_duration: SlotDuration, block_import: I, justification_import: Option>, finality_proof_import: Option>, client: Arc, inherent_data_providers: InherentDataProviders, - transaction_pool: Option>, ) -> Result>, sp_consensus::Error> where B: BlockT, C::Api: BlockBuilderApi + AuraApi> + ApiExt, @@ -812,7 +804,6 @@ pub fn import_queue( P: Pair + Send + Sync + 'static, P::Public: Clone + Eq + Send + Sync + Hash + Debug + Encode + Decode, P::Signature: Encode + Decode, - T: Send + Sync + 'static, { register_aura_inherent_data_provider(&inherent_data_providers, slot_duration.get())?; initialize_authorities_cache(&*client)?; @@ -821,7 +812,6 @@ pub fn import_queue( client: client.clone(), inherent_data_providers, phantom: PhantomData, - transaction_pool, }; Ok(BasicQueue::new( verifier, @@ -839,10 +829,10 @@ mod tests { use sp_runtime::traits::{Block as BlockT, DigestFor}; use sc_network::config::ProtocolConfig; use parking_lot::Mutex; - use tokio::runtime::current_thread; use sp_keyring::sr25519::Keyring; use sc_client::BlockchainEvents; use sp_consensus_aura::sr25519::AuthorityPair; + use std::task::Poll; type Error = sp_blockchain::Error; @@ -900,7 +890,7 @@ mod tests { } impl TestNetFactory for AuraTestNet { - type Verifier = AuraVerifier; + type Verifier = AuraVerifier; type PeerData = (); /// Create new test network with peers and given config. @@ -926,7 +916,6 @@ mod tests { AuraVerifier { client, inherent_data_providers, - transaction_pool: Default::default(), phantom: Default::default(), } }, @@ -961,8 +950,8 @@ mod tests { let net = Arc::new(Mutex::new(net)); let mut import_notifications = Vec::new(); + let mut aura_futures = Vec::new(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut keystore_paths = Vec::new(); for (peer_id, key) in peers { let mut net = net.lock(); @@ -990,7 +979,7 @@ mod tests { &inherent_data_providers, slot_duration.get() ).expect("Registers aura inherent data provider"); - let aura = start_aura::<_, _, _, _, _, AuthorityPair, _, _, _>( + aura_futures.push(start_aura::<_, _, _, _, _, AuthorityPair, _, _, _>( slot_duration, client.clone(), select_chain, @@ -1001,21 +990,19 @@ mod tests { false, keystore, sp_consensus::AlwaysCanAuthor, - ) - .expect("Starts aura") - .unit_error() - .compat(); - - runtime.spawn(aura); + ).expect("Starts aura")); } - runtime.spawn(futures01::future::poll_fn(move || { - net.lock().poll(); - Ok::<_, ()>(futures01::Async::NotReady::<()>) - })); - - runtime.block_on(future::join_all(import_notifications) - .unit_error().compat()).unwrap(); + futures::executor::block_on(future::select( + future::poll_fn(move |cx| { + net.lock().poll(cx); + Poll::<()>::Pending + }), + future::select( + future::join_all(aura_futures), + future::join_all(import_notifications) + ) + )); } #[test] diff --git a/client/consensus/babe/Cargo.toml b/client/consensus/babe/Cargo.toml index 2e11d741dcb8d..66455adbdf828 100644 --- a/client/consensus/babe/Cargo.toml +++ b/client/consensus/babe/Cargo.toml @@ -1,39 +1,41 @@ [package] name = "sc-consensus-babe" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] description = "BABE consensus algorithm for substrate" edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +documentation = "https://docs.rs/sc-consensus-babe" + [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -sp-consensus-babe = { version = "0.8.0-dev", path = "../../../primitives/consensus/babe" } -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } -sp-application-crypto = { version = "2.0.0-dev", path = "../../../primitives/application-crypto" } +codec = { package = "parity-scale-codec", version = "1.2.0", features = ["derive"] } +sp-consensus-babe = { version = "0.8.0-alpha.2", path = "../../../primitives/consensus/babe" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } +sp-application-crypto = { version = "2.0.0-alpha.2", path = "../../../primitives/application-crypto" } num-bigint = "0.2.3" num-rational = "0.2.2" num-traits = "0.2.8" serde = { version = "1.0.104", features = ["derive"] } -sp-version = { version = "2.0.0-dev", path = "../../../primitives/version" } -sp-io = { version = "2.0.0-dev", path = "../../../primitives/io" } -sp-inherents = { version = "2.0.0-dev", path = "../../../primitives/inherents" } -sp-timestamp = { version = "2.0.0-dev", path = "../../../primitives/timestamp" } -sc-telemetry = { version = "2.0.0-dev", path = "../../telemetry" } -sc-keystore = { version = "2.0.0-dev", path = "../../keystore" } -sc-client-api = { version = "2.0.0-dev", path = "../../api" } -sc-client = { version = "0.8.0-dev", path = "../../" } -sc-consensus-epochs = { version = "0.8.0-dev", path = "../epochs" } -sp-api = { version = "2.0.0-dev", path = "../../../primitives/api" } -sp-block-builder = { version = "2.0.0-dev", path = "../../../primitives/block-builder" } -sp-blockchain = { version = "2.0.0-dev", path = "../../../primitives/blockchain" } -sp-consensus = { version = "0.8.0-dev", path = "../../../primitives/consensus/common" } -sc-consensus-uncles = { version = "0.8.0-dev", path = "../uncles" } -sc-consensus-slots = { version = "0.8.0-dev", path = "../slots" } -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } -fork-tree = { version = "2.0.0-dev", path = "../../../utils/fork-tree" } +sp-version = { version = "2.0.0-alpha.2", path = "../../../primitives/version" } +sp-io = { version = "2.0.0-alpha.2", path = "../../../primitives/io" } +sp-inherents = { version = "2.0.0-alpha.2", path = "../../../primitives/inherents" } +sp-timestamp = { version = "2.0.0-alpha.2", path = "../../../primitives/timestamp" } +sc-telemetry = { version = "2.0.0-alpha.2", path = "../../telemetry" } +sc-keystore = { version = "2.0.0-alpha.2", path = "../../keystore" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../../api" } +sc-client = { version = "0.8.0-alpha.2", path = "../../" } +sc-consensus-epochs = { version = "0.8.0-alpha.2", path = "../epochs" } +sp-api = { version = "2.0.0-alpha.2", path = "../../../primitives/api" } +sp-block-builder = { version = "2.0.0-alpha.2", path = "../../../primitives/block-builder" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../../primitives/blockchain" } +sp-consensus = { version = "0.8.0-alpha.2", path = "../../../primitives/consensus/common" } +sc-consensus-uncles = { version = "0.8.0-alpha.2", path = "../uncles" } +sc-consensus-slots = { version = "0.8.0-alpha.2", path = "../slots" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } +fork-tree = { version = "2.0.0-alpha.2", path = "../../../utils/fork-tree" } futures = "0.3.1" futures-timer = "3.0.1" parking_lot = "0.10.0" @@ -45,17 +47,15 @@ pdqselect = "0.1.0" derive_more = "0.99.2" [dev-dependencies] -sp-keyring = { version = "2.0.0-dev", path = "../../../primitives/keyring" } -sc-executor = { version = "0.8.0-dev", path = "../../executor" } -sc-network = { version = "0.8.0-dev", path = "../../network" } +sp-keyring = { version = "2.0.0-alpha.2", path = "../../../primitives/keyring" } +sc-executor = { version = "0.8.0-alpha.2", path = "../../executor" } +sc-network = { version = "0.8.0-alpha.2", path = "../../network" } sc-network-test = { version = "0.8.0-dev", path = "../../network/test" } -sc-service = { version = "0.8.0-dev", path = "../../service" } +sc-service = { version = "0.8.0-alpha.2", path = "../../service" } substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../../test-utils/runtime/client" } -sc-block-builder = { version = "0.8.0-dev", path = "../../block-builder" } -tokio = "0.1.22" +sc-block-builder = { version = "0.8.0-alpha.2", path = "../../block-builder" } env_logger = "0.7.0" tempfile = "3.1.0" -futures01 = { package = "futures", version = "0.1" } [features] test-helpers = [] diff --git a/client/consensus/babe/rpc/Cargo.toml b/client/consensus/babe/rpc/Cargo.toml index 524b90046d687..3f2cc4f0bcbce 100644 --- a/client/consensus/babe/rpc/Cargo.toml +++ b/client/consensus/babe/rpc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sc-consensus-babe-rpc" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] description = "RPC extensions for the BABE consensus algorithm" edition = "2018" @@ -9,24 +9,24 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -sc-consensus-babe = { version = "0.8.0-dev", path = "../" } +sc-consensus-babe = { version = "0.8.0-alpha.2", path = "../" } jsonrpc-core = "14.0.3" jsonrpc-core-client = "14.0.3" jsonrpc-derive = "14.0.3" -sp-consensus-babe = { version = "0.8.0-dev", path = "../../../../primitives/consensus/babe" } +sp-consensus-babe = { version = "0.8.0-alpha.2", path = "../../../../primitives/consensus/babe" } serde = { version = "1.0.104", features=["derive"] } -sp-blockchain = { version = "2.0.0-dev", path = "../../../../primitives/blockchain" } -sp-runtime = { version = "2.0.0-dev", path = "../../../../primitives/runtime" } -sc-consensus-epochs = { version = "0.8.0-dev", path = "../../epochs" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../../../primitives/blockchain" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../../primitives/runtime" } +sc-consensus-epochs = { version = "0.8.0-alpha.2", path = "../../epochs" } futures = "0.3.1" derive_more = "0.99.2" -sp-api = { version = "2.0.0-dev", path = "../../../../primitives/api" } -sp-consensus = { version = "0.8.0-dev", path = "../../../../primitives/consensus/common" } -sp-core = { version = "2.0.0-dev", path = "../../../../primitives/core" } -sc-keystore = { version = "2.0.0-dev", path = "../../../keystore" } +sp-api = { version = "2.0.0-alpha.2", path = "../../../../primitives/api" } +sp-consensus = { version = "0.8.0-alpha.2", path = "../../../../primitives/consensus/common" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../../primitives/core" } +sc-keystore = { version = "2.0.0-alpha.2", path = "../../../keystore" } [dev-dependencies] substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../../../test-utils/runtime/client" } -sp-application-crypto = { version = "2.0.0-dev", path = "../../../../primitives/application-crypto" } -sp-keyring = { version = "2.0.0-dev", path = "../../../../primitives/keyring" } +sp-application-crypto = { version = "2.0.0-alpha.2", path = "../../../../primitives/application-crypto" } +sp-keyring = { version = "2.0.0-alpha.2", path = "../../../../primitives/keyring" } tempfile = "3.1.0" diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index 000642fec4a26..967a78e7bfc88 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -318,7 +318,7 @@ pub struct BabeParams { pub can_author_with: CAW, } -/// Start the babe worker. The returned future should be run in a tokio runtime. +/// Start the babe worker. pub fn start_babe(BabeParams { keystore, client, diff --git a/client/consensus/babe/src/tests.rs b/client/consensus/babe/src/tests.rs index 4045e18b5c3fb..a5493918f001d 100644 --- a/client/consensus/babe/src/tests.rs +++ b/client/consensus/babe/src/tests.rs @@ -23,7 +23,7 @@ use super::*; use authorship::claim_slot; use sp_consensus_babe::{AuthorityPair, SlotNumber}; -use sc_block_builder::BlockBuilder; +use sc_block_builder::{BlockBuilder, BlockBuilderProvider}; use sp_consensus::{ NoNetwork as DummyOracle, Proposal, RecordProof, import_queue::{BoxBlockImport, BoxJustificationImport, BoxFinalityProofImport}, @@ -32,10 +32,9 @@ use sc_network_test::*; use sc_network_test::{Block as TestBlock, PeersClient}; use sc_network::config::{BoxFinalityProofRequestBuilder, ProtocolConfig}; use sp_runtime::{generic::DigestItem, traits::{Block as BlockT, DigestFor}}; -use tokio::runtime::current_thread; use sc_client_api::{BlockchainEvents, backend::TransactionFor}; use log::debug; -use std::{time::Duration, cell::RefCell}; +use std::{time::Duration, cell::RefCell, task::Poll}; type Item = DigestItem; @@ -354,7 +353,7 @@ fn run_one_test( let net = Arc::new(Mutex::new(net)); let mut import_notifications = Vec::new(); - let mut runtime = current_thread::Runtime::new().unwrap(); + let mut babe_futures = Vec::new(); let mut keystore_paths = Vec::new(); for (peer_id, seed) in peers { @@ -399,7 +398,7 @@ fn run_one_test( ); - runtime.spawn(start_babe(BabeParams { + babe_futures.push(start_babe(BabeParams { block_import: data.block_import.lock().take().expect("import set up during init"), select_chain, client, @@ -410,23 +409,23 @@ fn run_one_test( babe_link: data.link.clone(), keystore, can_author_with: sp_consensus::AlwaysCanAuthor, - }).expect("Starts babe").unit_error().compat()); + }).expect("Starts babe")); } - runtime.spawn(futures01::future::poll_fn(move || { - let mut net = net.lock(); - net.poll(); - for p in net.peers() { - for (h, e) in p.failed_verifications() { - panic!("Verification failed for {:?}: {}", h, e); + futures::executor::block_on(future::select( + futures::future::poll_fn(move |cx| { + let mut net = net.lock(); + net.poll(cx); + for p in net.peers() { + for (h, e) in p.failed_verifications() { + panic!("Verification failed for {:?}: {}", h, e); + } } - } - - Ok::<_, ()>(futures01::Async::NotReady::<()>) - })); - - runtime.block_on(future::join_all(import_notifications) - .unit_error().compat()).unwrap(); + + Poll::<()>::Pending + }), + future::select(future::join_all(import_notifications), future::join_all(babe_futures)) + )); } #[test] diff --git a/client/consensus/epochs/Cargo.toml b/client/consensus/epochs/Cargo.toml index 26dc2062b878a..fe23654298921 100644 --- a/client/consensus/epochs/Cargo.toml +++ b/client/consensus/epochs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sc-consensus-epochs" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] description = "Generic epochs-based utilities for consensus" edition = "2018" @@ -9,9 +9,9 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "1.2.0", features = ["derive"] } parking_lot = "0.10.0" -fork-tree = { version = "2.0.0-dev", path = "../../../utils/fork-tree" } -sp-runtime = { path = "../../../primitives/runtime" , version = "2.0.0-dev"} -sp-blockchain = { version = "2.0.0-dev", path = "../../../primitives/blockchain" } -sc-client-api = { path = "../../api" , version = "2.0.0-dev"} +fork-tree = { version = "2.0.0-alpha.2", path = "../../../utils/fork-tree" } +sp-runtime = { path = "../../../primitives/runtime" , version = "2.0.0-alpha.2"} +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../../primitives/blockchain" } +sc-client-api = { path = "../../api" , version = "2.0.0-alpha.2"} diff --git a/client/consensus/manual-seal/Cargo.toml b/client/consensus/manual-seal/Cargo.toml index 25650f3300d89..11fee0e3f9e60 100644 --- a/client/consensus/manual-seal/Cargo.toml +++ b/client/consensus/manual-seal/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sc-consensus-manual-seal" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] description = "Manual sealing engine for Substrate" edition = "2018" @@ -18,17 +18,17 @@ log = "0.4.8" parking_lot = "0.10.0" serde = { version = "1.0", features=["derive"] } -sc-client = { path = "../../../client" , version = "0.8.0-dev"} -sc-client-api = { path = "../../../client/api" , version = "2.0.0-dev"} -sc-transaction-pool = { path = "../../transaction-pool" , version = "2.0.0-dev"} -sp-blockchain = { path = "../../../primitives/blockchain" , version = "2.0.0-dev"} -sp-consensus = { package = "sp-consensus", path = "../../../primitives/consensus/common" , version = "0.8.0-dev"} -sp-inherents = { path = "../../../primitives/inherents" , version = "2.0.0-dev"} -sp-runtime = { path = "../../../primitives/runtime" , version = "2.0.0-dev"} -sp-transaction-pool = { path = "../../../primitives/transaction-pool" , version = "2.0.0-dev"} +sc-client = { path = "../../../client" , version = "0.8.0-alpha.2"} +sc-client-api = { path = "../../../client/api" , version = "2.0.0-alpha.2"} +sc-transaction-pool = { path = "../../transaction-pool" , version = "2.0.0-alpha.2"} +sp-blockchain = { path = "../../../primitives/blockchain" , version = "2.0.0-alpha.2"} +sp-consensus = { package = "sp-consensus", path = "../../../primitives/consensus/common" , version = "0.8.0-alpha.2"} +sp-inherents = { path = "../../../primitives/inherents" , version = "2.0.0-alpha.2"} +sp-runtime = { path = "../../../primitives/runtime" , version = "2.0.0-alpha.2"} +sp-transaction-pool = { path = "../../../primitives/transaction-pool" , version = "2.0.0-alpha.2"} [dev-dependencies] -sc-basic-authorship = { path = "../../basic-authorship" , version = "0.8.0-dev"} +sc-basic-authorship = { path = "../../basic-authorship" , version = "0.8.0-alpha.2"} substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" , version = "2.0.0-dev"} substrate-test-runtime-transaction-pool = { path = "../../../test-utils/runtime/transaction-pool" , version = "2.0.0-dev"} tokio = { version = "0.2", features = ["rt-core", "macros"] } diff --git a/client/consensus/manual-seal/src/lib.rs b/client/consensus/manual-seal/src/lib.rs index c4336485a14ac..18dc91ad34d62 100644 --- a/client/consensus/manual-seal/src/lib.rs +++ b/client/consensus/manual-seal/src/lib.rs @@ -244,10 +244,10 @@ mod tests { let select_chain = LongestChain::new(backend.clone()); let inherent_data_providers = InherentDataProviders::new(); let pool = Arc::new(BasicPool::new(Options::default(), api()).0); - let env = ProposerFactory { - transaction_pool: pool.clone(), - client: client.clone(), - }; + let env = ProposerFactory::new( + client.clone(), + pool.clone() + ); // this test checks that blocks are created as soon as transactions are imported into the pool. let (sender, receiver) = futures::channel::oneshot::channel(); let mut sender = Arc::new(Some(sender)); @@ -309,10 +309,10 @@ mod tests { let select_chain = LongestChain::new(backend.clone()); let inherent_data_providers = InherentDataProviders::new(); let pool = Arc::new(BasicPool::new(Options::default(), api()).0); - let env = ProposerFactory { - transaction_pool: pool.clone(), - client: client.clone(), - }; + let env = ProposerFactory::new( + client.clone(), + pool.clone() + ); // this test checks that blocks are created as soon as an engine command is sent over the stream. let (mut sink, stream) = futures::channel::mpsc::channel(1024); let future = run_manual_seal( @@ -378,10 +378,10 @@ mod tests { let inherent_data_providers = InherentDataProviders::new(); let pool_api = api(); let pool = Arc::new(BasicPool::new(Options::default(), pool_api.clone()).0); - let env = ProposerFactory { - transaction_pool: pool.clone(), - client: client.clone(), - }; + let env = ProposerFactory::new( + client.clone(), + pool.clone(), + ); // this test checks that blocks are created as soon as an engine command is sent over the stream. let (mut sink, stream) = futures::channel::mpsc::channel(1024); let future = run_manual_seal( diff --git a/client/consensus/pow/Cargo.toml b/client/consensus/pow/Cargo.toml index b700b52ab09f4..f95d196b62f7a 100644 --- a/client/consensus/pow/Cargo.toml +++ b/client/consensus/pow/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sc-consensus-pow" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] description = "PoW consensus algorithm for substrate" edition = "2018" @@ -9,17 +9,17 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } -sp-blockchain = { version = "2.0.0-dev", path = "../../../primitives/blockchain" } -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } -sp-api = { version = "2.0.0-dev", path = "../../../primitives/api" } -sc-client-api = { version = "2.0.0-dev", path = "../../api" } -sp-block-builder = { version = "2.0.0-dev", path = "../../../primitives/block-builder" } -sp-inherents = { version = "2.0.0-dev", path = "../../../primitives/inherents" } -sp-consensus-pow = { version = "0.8.0-dev", path = "../../../primitives/consensus/pow" } -sp-consensus = { version = "0.8.0-dev", path = "../../../primitives/consensus/common" } +codec = { package = "parity-scale-codec", version = "1.2.0", features = ["derive"] } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../../primitives/blockchain" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } +sp-api = { version = "2.0.0-alpha.2", path = "../../../primitives/api" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../../api" } +sp-block-builder = { version = "2.0.0-alpha.2", path = "../../../primitives/block-builder" } +sp-inherents = { version = "2.0.0-alpha.2", path = "../../../primitives/inherents" } +sp-consensus-pow = { version = "0.8.0-alpha.2", path = "../../../primitives/consensus/pow" } +sp-consensus = { version = "0.8.0-alpha.2", path = "../../../primitives/consensus/common" } log = "0.4.8" futures = { version = "0.3.1", features = ["compat"] } -sp-timestamp = { version = "2.0.0-dev", path = "../../../primitives/timestamp" } +sp-timestamp = { version = "2.0.0-alpha.2", path = "../../../primitives/timestamp" } derive_more = "0.99.2" diff --git a/client/consensus/slots/Cargo.toml b/client/consensus/slots/Cargo.toml index 9a75972f588a7..fe7958b257203 100644 --- a/client/consensus/slots/Cargo.toml +++ b/client/consensus/slots/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sc-consensus-slots" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] description = "Generic slots-based utilities for consensus" edition = "2018" @@ -10,16 +10,16 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0" } -sc-client-api = { version = "2.0.0-dev", path = "../../api" } -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } -sp-blockchain = { version = "2.0.0-dev", path = "../../../primitives/blockchain" } -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } -sp-state-machine = { version = "0.8.0-dev", path = "../../../primitives/state-machine" } -sp-api = { version = "2.0.0-dev", path = "../../../primitives/api" } -sc-telemetry = { version = "2.0.0-dev", path = "../../telemetry" } -sp-consensus = { version = "0.8.0-dev", path = "../../../primitives/consensus/common" } -sp-inherents = { version = "2.0.0-dev", path = "../../../primitives/inherents" } +codec = { package = "parity-scale-codec", version = "1.2.0" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../../api" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../../primitives/blockchain" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } +sp-state-machine = { version = "0.8.0-alpha.2", path = "../../../primitives/state-machine" } +sp-api = { version = "2.0.0-alpha.2", path = "../../../primitives/api" } +sc-telemetry = { version = "2.0.0-alpha.2", path = "../../telemetry" } +sp-consensus = { version = "0.8.0-alpha.2", path = "../../../primitives/consensus/common" } +sp-inherents = { version = "2.0.0-alpha.2", path = "../../../primitives/inherents" } futures = "0.3.1" futures-timer = "3.0.1" parking_lot = "0.10.0" diff --git a/client/consensus/uncles/Cargo.toml b/client/consensus/uncles/Cargo.toml index ad9ac538425d7..ad325ed79f7a5 100644 --- a/client/consensus/uncles/Cargo.toml +++ b/client/consensus/uncles/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sc-consensus-uncles" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] description = "Generic uncle inclusion utilities for consensus" edition = "2018" @@ -9,10 +9,10 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -sc-client-api = { version = "2.0.0-dev", path = "../../api" } -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } -sp-authorship = { version = "2.0.0-dev", path = "../../../primitives/authorship" } -sp-consensus = { version = "0.8.0-dev", path = "../../../primitives/consensus/common" } -sp-inherents = { version = "2.0.0-dev", path = "../../../primitives/inherents" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../../api" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } +sp-authorship = { version = "2.0.0-alpha.2", path = "../../../primitives/authorship" } +sp-consensus = { version = "0.8.0-alpha.2", path = "../../../primitives/consensus/common" } +sp-inherents = { version = "2.0.0-alpha.2", path = "../../../primitives/inherents" } log = "0.4.8" diff --git a/client/db/Cargo.toml b/client/db/Cargo.toml index c2e27ae7e632e..f92a5c48e28ef 100644 --- a/client/db/Cargo.toml +++ b/client/db/Cargo.toml @@ -1,11 +1,12 @@ [package] name = "sc-client-db" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Client backend that uses RocksDB database as storage." [dependencies] parking_lot = "0.10.0" @@ -17,21 +18,21 @@ kvdb-memorydb = "0.4.0" linked-hash-map = "0.5.2" hash-db = "0.15.2" parity-util-mem = { version = "0.5.1", default-features = false, features = ["std"] } -codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "1.2.0", features = ["derive"] } -sc-client-api = { version = "2.0.0-dev", path = "../api" } -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -sp-runtime = { version = "2.0.0-dev", path = "../../primitives/runtime" } -sc-client = { version = "0.8.0-dev", path = "../" } -sp-state-machine = { version = "0.8.0-dev", path = "../../primitives/state-machine" } -sc-executor = { version = "0.8.0-dev", path = "../executor" } -sc-state-db = { version = "0.8.0-dev", path = "../state-db" } -sp-trie = { version = "2.0.0-dev", path = "../../primitives/trie" } -sp-consensus = { version = "0.8.0-dev", path = "../../primitives/consensus/common" } -sp-blockchain = { version = "2.0.0-dev", path = "../../primitives/blockchain" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../api" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../primitives/runtime" } +sc-client = { version = "0.8.0-alpha.2", path = "../" } +sp-state-machine = { version = "0.8.0-alpha.2", path = "../../primitives/state-machine" } +sc-executor = { version = "0.8.0-alpha.2", path = "../executor" } +sc-state-db = { version = "0.8.0-alpha.2", path = "../state-db" } +sp-trie = { version = "2.0.0-alpha.2", path = "../../primitives/trie" } +sp-consensus = { version = "0.8.0-alpha.2", path = "../../primitives/consensus/common" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../primitives/blockchain" } [dev-dependencies] -sp-keyring = { version = "2.0.0-dev", path = "../../primitives/keyring" } +sp-keyring = { version = "2.0.0-alpha.2", path = "../../primitives/keyring" } substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../test-utils/runtime/client" } env_logger = "0.7.0" quickcheck = "0.9" diff --git a/client/db/src/lib.rs b/client/db/src/lib.rs index 5173497509cf9..b4dd98457d4f8 100644 --- a/client/db/src/lib.rs +++ b/client/db/src/lib.rs @@ -46,9 +46,11 @@ use std::path::PathBuf; use std::io; use std::collections::HashMap; -use sc_client_api::{execution_extensions::ExecutionExtensions, ForkBlocks, UsageInfo, MemoryInfo, BadBlocks, IoInfo}; -use sc_client_api::backend::NewBlockState; -use sc_client_api::backend::PrunableStateChangesTrieStorage; +use sc_client_api::{ + ForkBlocks, UsageInfo, MemoryInfo, BadBlocks, IoInfo, MemorySize, + execution_extensions::ExecutionExtensions, + backend::{NewBlockState, PrunableStateChangesTrieStorage}, +}; use sp_blockchain::{ Result as ClientResult, Error as ClientError, well_known_cache_keys, HeaderBackend, @@ -1455,13 +1457,17 @@ impl sc_client_api::backend::Backend for Backend { self.state_usage.take(), ) ); - let database_cache = parity_util_mem::malloc_size(&*self.storage.db); - let state_cache = (*&self.shared_cache).lock().used_storage_cache_size(); + let database_cache = MemorySize::from_bytes(parity_util_mem::malloc_size(&*self.storage.db)); + let state_cache = MemorySize::from_bytes( + (*&self.shared_cache).lock().used_storage_cache_size(), + ); + let state_db = self.storage.state_db.memory_info(); Some(UsageInfo { memory: MemoryInfo { state_cache, database_cache, + state_db, }, io: IoInfo { transactions: io_stats.transactions, diff --git a/client/db/src/light.rs b/client/db/src/light.rs index 14ce6ac0f9a05..3d30598b19e89 100644 --- a/client/db/src/light.rs +++ b/client/db/src/light.rs @@ -317,7 +317,7 @@ impl LightStorage { // if the header includes changes trie root, let's build a changes tries roots CHT if header.digest().log(DigestItem::as_changes_trie_root).is_some() { let mut current_num = new_cht_start; - let cht_range = ::std::iter::from_fn(|| { + let cht_range = std::iter::from_fn(|| { let old_current_num = current_num; current_num = current_num + One::one(); Some(old_current_num) @@ -572,15 +572,16 @@ impl LightBlockchainStorage for LightStorage #[cfg(not(target_os = "unknown"))] fn usage_info(&self) -> Option { - use sc_client_api::{MemoryInfo, IoInfo}; + use sc_client_api::{MemoryInfo, IoInfo, MemorySize}; - let database_cache = parity_util_mem::malloc_size(&*self.db); + let database_cache = MemorySize::from_bytes(parity_util_mem::malloc_size(&*self.db)); let io_stats = self.io_stats.take_or_else(|| self.db.io_stats(kvdb::IoStatsKind::SincePrevious)); Some(UsageInfo { memory: MemoryInfo { database_cache, - state_cache: 0, + state_cache: Default::default(), + state_db: Default::default(), }, io: IoInfo { transactions: io_stats.transactions, diff --git a/client/executor/Cargo.toml b/client/executor/Cargo.toml index f98cbf97e0598..46e4bb04bb985 100644 --- a/client/executor/Cargo.toml +++ b/client/executor/Cargo.toml @@ -1,30 +1,32 @@ [package] name = "sc-executor" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "A crate that provides means of executing/dispatching calls into the runtime." +documentation = "https://docs.rs/sc-executor" [dependencies] derive_more = "0.99.2" -codec = { package = "parity-scale-codec", version = "1.0.0" } -sp-io = { version = "2.0.0-dev", path = "../../primitives/io" } -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -sp-trie = { version = "2.0.0-dev", path = "../../primitives/trie" } -sp-serializer = { version = "2.0.0-dev", path = "../../primitives/serializer" } -sp-version = { version = "2.0.0-dev", path = "../../primitives/version" } -sp-panic-handler = { version = "2.0.0-dev", path = "../../primitives/panic-handler" } +codec = { package = "parity-scale-codec", version = "1.2.0" } +sp-io = { version = "2.0.0-alpha.2", path = "../../primitives/io" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +sp-trie = { version = "2.0.0-alpha.2", path = "../../primitives/trie" } +sp-serializer = { version = "2.0.0-alpha.2", path = "../../primitives/serializer" } +sp-version = { version = "2.0.0-alpha.2", path = "../../primitives/version" } +sp-panic-handler = { version = "2.0.0-alpha.2", path = "../../primitives/panic-handler" } wasmi = "0.6.2" parity-wasm = "0.41.0" lazy_static = "1.4.0" -sp-wasm-interface = { version = "2.0.0-dev", path = "../../primitives/wasm-interface" } -sp-runtime-interface = { version = "2.0.0-dev", path = "../../primitives/runtime-interface" } -sp-externalities = { version = "0.8.0-dev", path = "../../primitives/externalities" } -sc-executor-common = { version = "0.8.0-dev", path = "common" } -sc-executor-wasmi = { version = "0.8.0-dev", path = "wasmi" } -sc-executor-wasmtime = { version = "0.8.0-dev", path = "wasmtime", optional = true } +sp-wasm-interface = { version = "2.0.0-alpha.2", path = "../../primitives/wasm-interface" } +sp-runtime-interface = { version = "2.0.0-alpha.2", path = "../../primitives/runtime-interface" } +sp-externalities = { version = "0.8.0-alpha.2", path = "../../primitives/externalities" } +sc-executor-common = { version = "0.8.0-alpha.2", path = "common" } +sc-executor-wasmi = { version = "0.8.0-alpha.2", path = "wasmi" } +sc-executor-wasmtime = { version = "0.8.0-alpha.2", path = "wasmtime", optional = true } parking_lot = "0.10.0" log = "0.4.8" libsecp256k1 = "0.3.4" @@ -35,7 +37,7 @@ wabt = "0.9.2" hex-literal = "0.2.1" sc-runtime-test = { version = "2.0.0-dev", path = "runtime-test" } substrate-test-runtime = { version = "2.0.0-dev", path = "../../test-utils/runtime" } -sp-state-machine = { version = "0.8.0-dev", path = "../../primitives/state-machine" } +sp-state-machine = { version = "0.8.0-alpha.2", path = "../../primitives/state-machine" } test-case = "0.3.3" [features] diff --git a/client/executor/common/Cargo.toml b/client/executor/common/Cargo.toml index fd3645719c2a8..04db56938a4bc 100644 --- a/client/executor/common/Cargo.toml +++ b/client/executor/common/Cargo.toml @@ -1,22 +1,24 @@ [package] name = "sc-executor-common" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "A set of common definitions that are needed for defining execution engines." +documentation = "https://docs.rs/sc-executor-common/" [dependencies] log = "0.4.8" derive_more = "0.99.2" -codec = { package = "parity-scale-codec", version = "1.0.0" } +codec = { package = "parity-scale-codec", version = "1.2.0" } wasmi = "0.6.2" -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } -sp-allocator = { version = "2.0.0-dev", path = "../../../primitives/allocator" } -sp-wasm-interface = { version = "2.0.0-dev", path = "../../../primitives/wasm-interface" } -sp-runtime-interface = { version = "2.0.0-dev", path = "../../../primitives/runtime-interface" } -sp-serializer = { version = "2.0.0-dev", path = "../../../primitives/serializer" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } +sp-allocator = { version = "2.0.0-alpha.2", path = "../../../primitives/allocator" } +sp-wasm-interface = { version = "2.0.0-alpha.2", path = "../../../primitives/wasm-interface" } +sp-runtime-interface = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime-interface" } +sp-serializer = { version = "2.0.0-alpha.2", path = "../../../primitives/serializer" } [features] default = [] diff --git a/client/executor/runtime-test/Cargo.toml b/client/executor/runtime-test/Cargo.toml index b677dcd07d65a..ad7c44718d243 100644 --- a/client/executor/runtime-test/Cargo.toml +++ b/client/executor/runtime-test/Cargo.toml @@ -10,12 +10,12 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/std" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/io" } -sp-sandbox = { version = "0.8.0-dev", default-features = false, path = "../../../primitives/sandbox" } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/core" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/runtime" } -sp-allocator = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/allocator" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/std" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/io" } +sp-sandbox = { version = "0.8.0-alpha.2", default-features = false, path = "../../../primitives/sandbox" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/core" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/runtime" } +sp-allocator = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/allocator" } [build-dependencies] wasm-builder-runner = { version = "1.0.5", package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner" } diff --git a/client/executor/src/deprecated_host_interface.rs b/client/executor/src/deprecated_host_interface.rs deleted file mode 100644 index 6ea0b11f5a909..0000000000000 --- a/client/executor/src/deprecated_host_interface.rs +++ /dev/null @@ -1,941 +0,0 @@ -// Copyright 2017-2020 Parity Technologies (UK) Ltd. -// This file is part of Substrate. - -// Substrate 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. - -// Substrate 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 Substrate. If not, see . - -//! Definition and implementation of the old and deprecated Substrate runtime interface for the host. - -use codec::Encode; -use std::{convert::TryFrom, str}; -use sp_core::{ - blake2_128, blake2_256, twox_64, twox_128, twox_256, ed25519, sr25519, keccak_256, Blake2Hasher, Pair, - crypto::KeyTypeId, offchain, -}; -use sp_trie::{TrieConfiguration, trie_types::Layout}; -use sp_wasm_interface::{ - Pointer, WordSize, WritePrimitive, ReadPrimitive, FunctionContext, Result as WResult, -}; - -#[cfg(feature="wasm-extern-trace")] -macro_rules! debug_trace { - ( $( $x:tt )* ) => ( trace!( $( $x )* ) ) -} - -#[cfg(not(feature="wasm-extern-trace"))] -macro_rules! debug_trace { - ( $( $x:tt )* ) => () -} - -/// The old and deprecated Substrate externals. These are still required for backwards compatibility -/// reasons. -pub struct SubstrateExternals; - -enum RecoverResult { - Invalid(u32), - Valid(secp256k1::PublicKey), -} - -fn secp256k1_recover( - context: &mut dyn FunctionContext, - msg_data: Pointer, - sig_data: Pointer, -) -> WResult { - let mut sig = [0u8; 65]; - context.read_memory_into(sig_data, &mut sig[..]) - .map_err(|_| "Invalid attempt to get signature in ext_secp256k1_ecdsa_recover")?; - let rs = match secp256k1::Signature::parse_slice(&sig[0..64]) { - Ok(rs) => rs, - _ => return Ok(RecoverResult::Invalid(1)), - }; - - let recovery_id = if sig[64] > 26 { sig[64] - 27 } else { sig[64] } as u8; - let v = match secp256k1::RecoveryId::parse(recovery_id) { - Ok(v) => v, - _ => return Ok(RecoverResult::Invalid(2)), - }; - - let mut msg = [0u8; 32]; - context.read_memory_into(msg_data, &mut msg[..]) - .map_err(|_| "Invalid attempt to get message in ext_secp256k1_ecdsa_recover")?; - - Ok(match secp256k1::recover(&secp256k1::Message::parse(&msg), &rs, &v) { - Ok(pubkey) => RecoverResult::Valid(pubkey), - Err(_) => RecoverResult::Invalid(3), - }) -} - -impl_wasm_host_interface! { - impl SubstrateExternals where context { - ext_malloc(size: WordSize) -> Pointer { - let r = context.allocate_memory(size)?; - debug_trace!(target: "sp-io", "malloc {} bytes at {:?}", size, r); - Ok(r) - } - - ext_free(addr: Pointer) { - context.deallocate_memory(addr)?; - debug_trace!(target: "sp-io", "free {:?}", addr); - Ok(()) - } - - ext_sandbox_instantiate( - dispatch_thunk_idx: u32, - wasm_ptr: Pointer, - wasm_len: WordSize, - imports_ptr: Pointer, - imports_len: WordSize, - state: u32, - ) -> u32 { - let wasm = context.read_memory(wasm_ptr, wasm_len) - .map_err(|_| "OOB while ext_sandbox_instantiate: wasm")?; - let raw_env_def = context.read_memory(imports_ptr, imports_len) - .map_err(|_| "OOB while ext_sandbox_instantiate: imports")?; - - context.sandbox().instance_new(dispatch_thunk_idx, &wasm, &raw_env_def, state) - } - - ext_sandbox_instance_teardown(instance_idx: u32) { - context.sandbox().instance_teardown(instance_idx) - } - - ext_sandbox_invoke( - instance_idx: u32, - export_ptr: Pointer, - export_len: WordSize, - args_ptr: Pointer, - args_len: WordSize, - return_val_ptr: Pointer, - return_val_len: WordSize, - state: u32, - ) -> u32 { - let export = context.read_memory(export_ptr, export_len) - .map_err(|_| "OOB while ext_sandbox_invoke: export") - .and_then(|b| - String::from_utf8(b) - .map_err(|_| "Export name should be a valid utf-8 sequence") - )?; - - // Deserialize arguments and convert them into wasmi types. - let serialized_args = context.read_memory(args_ptr, args_len) - .map_err(|_| "OOB while ext_sandbox_invoke: args")?; - - context.sandbox().invoke( - instance_idx, - &export, - &serialized_args, - return_val_ptr, - return_val_len, - state, - ) - } - - ext_sandbox_memory_new(initial: WordSize, maximum: WordSize) -> u32 { - context.sandbox().memory_new(initial, maximum) - } - - ext_sandbox_memory_get( - memory_idx: u32, - offset: WordSize, - buf_ptr: Pointer, - buf_len: WordSize, - ) -> u32 { - context.sandbox().memory_get(memory_idx, offset, buf_ptr, buf_len) - } - - ext_sandbox_memory_set( - memory_idx: u32, - offset: WordSize, - val_ptr: Pointer, - val_len: WordSize, - ) -> u32 { - context.sandbox().memory_set(memory_idx, offset, val_ptr, val_len) - } - - ext_sandbox_memory_teardown(memory_idx: u32) { - context.sandbox().memory_teardown(memory_idx) - } - - ext_print_utf8(utf8_data: Pointer, utf8_len: WordSize) { - if let Ok(utf8) = context.read_memory(utf8_data, utf8_len) { - sp_io::misc::print_utf8(&utf8); - } - Ok(()) - } - - ext_print_hex(data: Pointer, len: WordSize) { - if let Ok(hex) = context.read_memory(data, len) { - sp_io::misc::print_hex(&hex); - } - Ok(()) - } - - ext_print_num(number: u64) { - sp_io::misc::print_num(number); - Ok(()) - } - - ext_log( - level: u32, - target_data: Pointer, - target_len: WordSize, - message_data: Pointer, - message_len: WordSize, - ) { - let target = context.read_memory(target_data, target_len) - .map_err(|_| "Invalid attempt to determine target in ext_log")?; - let message = context.read_memory(message_data, message_len) - .map_err(|_| "Invalid attempt to determine message in ext_log")?; - - let target_str = std::str::from_utf8(&target) - .map_err(|_| "Target invalid utf8 in ext_log")?; - - sp_io::logging::log(level.into(), &target_str, &message); - Ok(()) - } - - ext_set_storage( - key_data: Pointer, - key_len: WordSize, - value_data: Pointer, - value_len: WordSize, - ) { - let key = context.read_memory(key_data, key_len) - .map_err(|_| "Invalid attempt to determine key in ext_set_storage")?; - let value = context.read_memory(value_data, value_len) - .map_err(|_| "Invalid attempt to determine value in ext_set_storage")?; - Ok(sp_io::storage::set(&key, &value)) - } - - ext_clear_storage(key_data: Pointer, key_len: WordSize) { - let key = context.read_memory(key_data, key_len) - .map_err(|_| "Invalid attempt to determine key in ext_clear_storage")?; - Ok(sp_io::storage::clear(&key)) - } - - ext_exists_storage(key_data: Pointer, key_len: WordSize) -> u32 { - let key = context.read_memory(key_data, key_len) - .map_err(|_| "Invalid attempt to determine key in ext_exists_storage")?; - Ok(if sp_io::storage::exists(&key) { 1 } else { 0 }) - } - - ext_clear_prefix(prefix_data: Pointer, prefix_len: WordSize) { - let prefix = context.read_memory(prefix_data, prefix_len) - .map_err(|_| "Invalid attempt to determine prefix in ext_clear_prefix")?; - Ok(sp_io::storage::clear_prefix(&prefix)) - } - - ext_get_allocated_storage( - key_data: Pointer, - key_len: WordSize, - written_out: Pointer, - ) -> Pointer { - let key = context.read_memory(key_data, key_len) - .map_err(|_| "Invalid attempt to determine key in ext_get_allocated_storage")?; - - if let Some(value) = sp_io::storage::get(&key) { - let offset = context.allocate_memory(value.len() as u32)?; - context.write_memory(offset, &value) - .map_err(|_| "Invalid attempt to set memory in ext_get_allocated_storage")?; - context.write_primitive(written_out, value.len() as u32) - .map_err(|_| "Invalid attempt to write written_out in ext_get_allocated_storage")?; - Ok(offset) - } else { - context.write_primitive(written_out, u32::max_value()) - .map_err(|_| "Invalid attempt to write failed written_out in ext_get_allocated_storage")?; - Ok(Pointer::null()) - } - } - - ext_get_storage_into( - key_data: Pointer, - key_len: WordSize, - value_data: Pointer, - value_len: WordSize, - value_offset: WordSize, - ) -> WordSize { - let key = context.read_memory(key_data, key_len) - .map_err(|_| "Invalid attempt to get key in ext_get_storage_into")?; - - if let Some(value) = sp_io::storage::get(&key) { - let data = &value[value.len().min(value_offset as usize)..]; - let written = std::cmp::min(value_len as usize, data.len()); - context.write_memory(value_data, &data[..written]) - .map_err(|_| "Invalid attempt to set value in ext_get_storage_into")?; - Ok(value.len() as u32) - } else { - Ok(u32::max_value()) - } - } - - ext_storage_root(result: Pointer) { - context.write_memory(result, sp_io::storage::root().as_ref()) - .map_err(|_| "Invalid attempt to set memory in ext_storage_root".into()) - } - - ext_storage_changes_root( - parent_hash_data: Pointer, - _len: WordSize, - result: Pointer, - ) -> u32 { - let mut parent_hash = [0u8; 32]; - context.read_memory_into(parent_hash_data, &mut parent_hash[..]) - .map_err(|_| "Invalid attempt to get parent_hash in ext_storage_changes_root")?; - - if let Some(r) = sp_io::storage::changes_root(&parent_hash) { - context.write_memory(result, &r[..]) - .map_err(|_| "Invalid attempt to set memory in ext_storage_changes_root")?; - Ok(1) - } else { - Ok(0) - } - } - - ext_blake2_256_enumerated_trie_root( - values_data: Pointer, - lens_data: Pointer, - lens_len: WordSize, - result: Pointer, - ) { - let values = (0..lens_len) - .map(|i| context.read_primitive(lens_data.offset(i).ok_or("Pointer overflow")?)) - .collect::, _>>()? - .into_iter() - .scan(0u32, |acc, v| { let o = *acc; *acc += v; Some((o, v)) }) - .map(|(offset, len)| - context.read_memory(values_data.offset(offset).ok_or("Pointer overflow")?, len) - .map_err(|_| - "Invalid attempt to get memory in ext_blake2_256_enumerated_trie_root" - ) - ) - .collect::, _>>()?; - let r = Layout::::ordered_trie_root(values.into_iter()); - context.write_memory(result, &r[..]) - .map_err(|_| "Invalid attempt to set memory in ext_blake2_256_enumerated_trie_root")?; - Ok(()) - } - - ext_chain_id() -> u64 { - Ok(sp_io::misc::chain_id()) - } - - ext_twox_64(data: Pointer, len: WordSize, out: Pointer) { - let result: [u8; 8] = if len == 0 { - let hashed = twox_64(&[0u8; 0]); - hashed - } else { - let key = context.read_memory(data, len) - .map_err(|_| "Invalid attempt to get key in ext_twox_64")?; - let hashed_key = twox_64(&key); - hashed_key - }; - - context.write_memory(out, &result) - .map_err(|_| "Invalid attempt to set result in ext_twox_64")?; - Ok(()) - } - - ext_twox_128(data: Pointer, len: WordSize, out: Pointer) { - let result: [u8; 16] = if len == 0 { - let hashed = twox_128(&[0u8; 0]); - hashed - } else { - let key = context.read_memory(data, len) - .map_err(|_| "Invalid attempt to get key in ext_twox_128")?; - let hashed_key = twox_128(&key); - hashed_key - }; - - context.write_memory(out, &result) - .map_err(|_| "Invalid attempt to set result in ext_twox_128")?; - Ok(()) - } - - ext_twox_256(data: Pointer, len: WordSize, out: Pointer) { - let result: [u8; 32] = if len == 0 { - twox_256(&[0u8; 0]) - } else { - let mem = context.read_memory(data, len) - .map_err(|_| "Invalid attempt to get data in ext_twox_256")?; - twox_256(&mem) - }; - context.write_memory(out, &result) - .map_err(|_| "Invalid attempt to set result in ext_twox_256")?; - Ok(()) - } - - ext_blake2_128(data: Pointer, len: WordSize, out: Pointer) { - let result: [u8; 16] = if len == 0 { - let hashed = blake2_128(&[0u8; 0]); - hashed - } else { - let key = context.read_memory(data, len) - .map_err(|_| "Invalid attempt to get key in ext_blake2_128")?; - let hashed_key = blake2_128(&key); - hashed_key - }; - - context.write_memory(out, &result) - .map_err(|_| "Invalid attempt to set result in ext_blake2_128")?; - Ok(()) - } - - ext_blake2_256(data: Pointer, len: WordSize, out: Pointer) { - let result: [u8; 32] = if len == 0 { - blake2_256(&[0u8; 0]) - } else { - let mem = context.read_memory(data, len) - .map_err(|_| "Invalid attempt to get data in ext_blake2_256")?; - blake2_256(&mem) - }; - context.write_memory(out, &result) - .map_err(|_| "Invalid attempt to set result in ext_blake2_256")?; - Ok(()) - } - - ext_keccak_256(data: Pointer, len: WordSize, out: Pointer) { - let result: [u8; 32] = if len == 0 { - keccak_256(&[0u8; 0]) - } else { - let mem = context.read_memory(data, len) - .map_err(|_| "Invalid attempt to get data in ext_keccak_256")?; - keccak_256(&mem) - }; - context.write_memory(out, &result) - .map_err(|_| "Invalid attempt to set result in ext_keccak_256")?; - Ok(()) - } - - ext_ed25519_public_keys(id_data: Pointer, result_len: Pointer) -> Pointer { - let mut id = [0u8; 4]; - context.read_memory_into(id_data, &mut id[..]) - .map_err(|_| "Invalid attempt to get id in ext_ed25519_public_keys")?; - let key_type = KeyTypeId(id); - - let keys = sp_io::crypto::ed25519_public_keys(key_type).encode(); - - let len = keys.len() as u32; - let offset = context.allocate_memory(len)?; - - context.write_memory(offset, keys.as_ref()) - .map_err(|_| "Invalid attempt to set memory in ext_ed25519_public_keys")?; - context.write_primitive(result_len, len) - .map_err(|_| "Invalid attempt to write result_len in ext_ed25519_public_keys")?; - - Ok(offset) - } - - ext_ed25519_verify( - msg_data: Pointer, - msg_len: WordSize, - sig_data: Pointer, - pubkey_data: Pointer, - ) -> u32 { - let mut sig = [0u8; 64]; - context.read_memory_into(sig_data, &mut sig[..]) - .map_err(|_| "Invalid attempt to get signature in ext_ed25519_verify")?; - let mut pubkey = [0u8; 32]; - context.read_memory_into(pubkey_data, &mut pubkey[..]) - .map_err(|_| "Invalid attempt to get pubkey in ext_ed25519_verify")?; - let msg = context.read_memory(msg_data, msg_len) - .map_err(|_| "Invalid attempt to get message in ext_ed25519_verify")?; - - Ok(if ed25519::Pair::verify_weak(&sig, &msg, &pubkey) { - 0 - } else { - 1 - }) - } - - ext_ed25519_generate( - id_data: Pointer, - seed: Pointer, - seed_len: WordSize, - out: Pointer, - ) { - let mut id = [0u8; 4]; - context.read_memory_into(id_data, &mut id[..]) - .map_err(|_| "Invalid attempt to get id in ext_ed25519_generate")?; - let key_type = KeyTypeId(id); - - let seed = if seed_len == 0 { - None - } else { - Some( - context.read_memory(seed, seed_len) - .map_err(|_| "Invalid attempt to get seed in ext_ed25519_generate")? - ) - }; - - let pubkey = sp_io::crypto::ed25519_generate(key_type, seed); - - context.write_memory(out, pubkey.as_ref()) - .map_err(|_| "Invalid attempt to set out in ext_ed25519_generate".into()) - } - - ext_ed25519_sign( - id_data: Pointer, - pubkey_data: Pointer, - msg_data: Pointer, - msg_len: WordSize, - out: Pointer, - ) -> u32 { - let mut id = [0u8; 4]; - context.read_memory_into(id_data, &mut id[..]) - .map_err(|_| "Invalid attempt to get id in ext_ed25519_sign")?; - let key_type = KeyTypeId(id); - - let mut pubkey = [0u8; 32]; - context.read_memory_into(pubkey_data, &mut pubkey[..]) - .map_err(|_| "Invalid attempt to get pubkey in ext_ed25519_sign")?; - - let msg = context.read_memory(msg_data, msg_len) - .map_err(|_| "Invalid attempt to get message in ext_ed25519_sign")?; - - let pub_key = ed25519::Public::try_from(pubkey.as_ref()) - .map_err(|_| "Invalid `ed25519` public key")?; - - let signature = sp_io::crypto::ed25519_sign(key_type, &pub_key, &msg); - - match signature { - Some(signature) => { - context.write_memory(out, signature.as_ref()) - .map_err(|_| "Invalid attempt to set out in ext_ed25519_sign")?; - Ok(0) - }, - None => Ok(1), - } - } - - ext_sr25519_public_keys(id_data: Pointer, result_len: Pointer) -> Pointer { - let mut id = [0u8; 4]; - context.read_memory_into(id_data, &mut id[..]) - .map_err(|_| "Invalid attempt to get id in ext_sr25519_public_keys")?; - let key_type = KeyTypeId(id); - - let keys = sp_io::crypto::sr25519_public_keys(key_type).encode(); - - let len = keys.len() as u32; - let offset = context.allocate_memory(len)?; - - context.write_memory(offset, keys.as_ref()) - .map_err(|_| "Invalid attempt to set memory in ext_sr25519_public_keys")?; - context.write_primitive(result_len, len) - .map_err(|_| "Invalid attempt to write result_len in ext_sr25519_public_keys")?; - - Ok(offset) - } - - ext_sr25519_verify( - msg_data: Pointer, - msg_len: WordSize, - sig_data: Pointer, - pubkey_data: Pointer, - ) -> u32 { - let mut sig = [0u8; 64]; - context.read_memory_into(sig_data, &mut sig[..]) - .map_err(|_| "Invalid attempt to get signature in ext_sr25519_verify")?; - let mut pubkey = [0u8; 32]; - context.read_memory_into(pubkey_data, &mut pubkey[..]) - .map_err(|_| "Invalid attempt to get pubkey in ext_sr25519_verify")?; - let msg = context.read_memory(msg_data, msg_len) - .map_err(|_| "Invalid attempt to get message in ext_sr25519_verify")?; - - Ok(if sr25519::Pair::verify_weak(&sig, &msg, &pubkey) { - 0 - } else { - 1 - }) - } - - ext_sr25519_generate( - id_data: Pointer, - seed: Pointer, - seed_len: WordSize, - out: Pointer, - ) { - let mut id = [0u8; 4]; - context.read_memory_into(id_data, &mut id[..]) - .map_err(|_| "Invalid attempt to get id in ext_sr25519_generate")?; - let key_type = KeyTypeId(id); - let seed = if seed_len == 0 { - None - } else { - Some( - context.read_memory(seed, seed_len) - .map_err(|_| "Invalid attempt to get seed in ext_sr25519_generate")? - ) - }; - - let pubkey = sp_io::crypto::sr25519_generate(key_type, seed); - - context.write_memory(out, pubkey.as_ref()) - .map_err(|_| "Invalid attempt to set out in ext_sr25519_generate".into()) - } - - ext_sr25519_sign( - id_data: Pointer, - pubkey_data: Pointer, - msg_data: Pointer, - msg_len: WordSize, - out: Pointer, - ) -> u32 { - let mut id = [0u8; 4]; - context.read_memory_into(id_data, &mut id[..]) - .map_err(|_| "Invalid attempt to get id in ext_sr25519_sign")?; - let key_type = KeyTypeId(id); - - let mut pubkey = [0u8; 32]; - context.read_memory_into(pubkey_data, &mut pubkey[..]) - .map_err(|_| "Invalid attempt to get pubkey in ext_sr25519_sign")?; - - let msg = context.read_memory(msg_data, msg_len) - .map_err(|_| "Invalid attempt to get message in ext_sr25519_sign")?; - - let pub_key = sr25519::Public::try_from(pubkey.as_ref()) - .map_err(|_| "Invalid `sr25519` public key")?; - - let signature = sp_io::crypto::sr25519_sign(key_type, &pub_key, &msg); - - match signature { - Some(signature) => { - context.write_memory(out, signature.as_ref()) - .map_err(|_| "Invalid attempt to set out in ext_sr25519_sign")?; - Ok(0) - }, - None => Ok(1), - } - } - - ext_secp256k1_ecdsa_recover( - msg_data: Pointer, - sig_data: Pointer, - pubkey_data: Pointer, - ) -> u32 { - match secp256k1_recover(context, msg_data, sig_data)? { - RecoverResult::Invalid(c) => Ok(c), - RecoverResult::Valid(pubkey) => { - context.write_memory(pubkey_data, &pubkey.serialize()[1..65]) - .map_err(|_| "Invalid attempt to set pubkey in ext_secp256k1_ecdsa_recover")?; - Ok(0) - } - } - } - - ext_secp256k1_ecdsa_recover_compressed( - msg_data: Pointer, - sig_data: Pointer, - pubkey_data: Pointer, - ) -> u32 { - match secp256k1_recover(context, msg_data, sig_data)? { - RecoverResult::Invalid(c) => Ok(c), - RecoverResult::Valid(pubkey) => { - context.write_memory(pubkey_data, &pubkey.serialize_compressed()[..]) - .map_err(|_| "Invalid attempt to set pubkey in ext_secp256k1_ecdsa_recover")?; - Ok(0) - } - } - } - - ext_is_validator() -> u32 { - if sp_io::offchain::is_validator() { Ok(1) } else { Ok(0) } - } - - ext_submit_transaction(msg_data: Pointer, len: WordSize) -> u32 { - let extrinsic = context.read_memory(msg_data, len) - .map_err(|_| "OOB while ext_submit_transaction: wasm")?; - - let res = sp_io::offchain::submit_transaction(extrinsic); - - Ok(if res.is_ok() { 0 } else { 1 }) - } - - ext_network_state(written_out: Pointer) -> Pointer { - let res = sp_io::offchain::network_state(); - - let encoded = res.encode(); - let len = encoded.len() as u32; - let offset = context.allocate_memory(len)?; - context.write_memory(offset, &encoded) - .map_err(|_| "Invalid attempt to set memory in ext_network_state")?; - - context.write_primitive(written_out, len) - .map_err(|_| "Invalid attempt to write written_out in ext_network_state")?; - - Ok(offset) - } - - ext_timestamp() -> u64 { - Ok(sp_io::offchain::timestamp().unix_millis()) - } - - ext_sleep_until(deadline: u64) { - sp_io::offchain::sleep_until(offchain::Timestamp::from_unix_millis(deadline)); - Ok(()) - } - - ext_random_seed(seed_data: Pointer) { - // NOTE the runtime as assumptions about seed size. - let seed = sp_io::offchain::random_seed(); - - context.write_memory(seed_data, &seed) - .map_err(|_| "Invalid attempt to set value in ext_random_seed")?; - Ok(()) - } - - ext_local_storage_set( - kind: u32, - key: Pointer, - key_len: WordSize, - value: Pointer, - value_len: WordSize, - ) { - let kind = offchain::StorageKind::try_from(kind) - .map_err(|_| "storage kind OOB while ext_local_storage_set: wasm")?; - let key = context.read_memory(key, key_len) - .map_err(|_| "OOB while ext_local_storage_set: wasm")?; - let value = context.read_memory(value, value_len) - .map_err(|_| "OOB while ext_local_storage_set: wasm")?; - - sp_io::offchain::local_storage_set(kind, &key, &value); - - Ok(()) - } - - ext_local_storage_get( - kind: u32, - key: Pointer, - key_len: WordSize, - value_len: Pointer, - ) -> Pointer { - let kind = offchain::StorageKind::try_from(kind) - .map_err(|_| "storage kind OOB while ext_local_storage_get: wasm")?; - let key = context.read_memory(key, key_len) - .map_err(|_| "OOB while ext_local_storage_get: wasm")?; - - let maybe_value = sp_io::offchain::local_storage_get(kind, &key); - - let (offset, len) = if let Some(value) = maybe_value { - let offset = context.allocate_memory(value.len() as u32)?; - context.write_memory(offset, &value) - .map_err(|_| "Invalid attempt to set memory in ext_local_storage_get")?; - (offset, value.len() as u32) - } else { - (Pointer::null(), u32::max_value()) - }; - - context.write_primitive(value_len, len) - .map_err(|_| "Invalid attempt to write value_len in ext_local_storage_get")?; - - Ok(offset) - } - - ext_local_storage_compare_and_set( - kind: u32, - key: Pointer, - key_len: WordSize, - old_value: Pointer, - old_value_len: WordSize, - new_value: Pointer, - new_value_len: WordSize, - ) -> u32 { - let kind = offchain::StorageKind::try_from(kind) - .map_err(|_| "storage kind OOB while ext_local_storage_compare_and_set: wasm")?; - let key = context.read_memory(key, key_len) - .map_err(|_| "OOB while ext_local_storage_compare_and_set: wasm")?; - let new_value = context.read_memory(new_value, new_value_len) - .map_err(|_| "OOB while ext_local_storage_compare_and_set: wasm")?; - - let old_value = if old_value_len == u32::max_value() { - None - } else { - Some( - context.read_memory(old_value, old_value_len) - .map_err(|_| "OOB while ext_local_storage_compare_and_set: wasm")? - ) - }; - - let res = sp_io::offchain::local_storage_compare_and_set( - kind, - &key, - old_value, - &new_value, - ); - - Ok(if res { 0 } else { 1 }) - } - - ext_http_request_start( - method: Pointer, - method_len: WordSize, - url: Pointer, - url_len: WordSize, - meta: Pointer, - meta_len: WordSize, - ) -> u32 { - let method = context.read_memory(method, method_len) - .map_err(|_| "OOB while ext_http_request_start: wasm")?; - let url = context.read_memory(url, url_len) - .map_err(|_| "OOB while ext_http_request_start: wasm")?; - let meta = context.read_memory(meta, meta_len) - .map_err(|_| "OOB while ext_http_request_start: wasm")?; - - let method_str = str::from_utf8(&method) - .map_err(|_| "invalid str while ext_http_request_start: wasm")?; - let url_str = str::from_utf8(&url) - .map_err(|_| "invalid str while ext_http_request_start: wasm")?; - - let id = sp_io::offchain::http_request_start(method_str, url_str, &meta); - - if let Ok(id) = id { - Ok(id.into()) - } else { - Ok(u32::max_value()) - } - } - - ext_http_request_add_header( - request_id: u32, - name: Pointer, - name_len: WordSize, - value: Pointer, - value_len: WordSize, - ) -> u32 { - let name = context.read_memory(name, name_len) - .map_err(|_| "OOB while ext_http_request_add_header: wasm")?; - let value = context.read_memory(value, value_len) - .map_err(|_| "OOB while ext_http_request_add_header: wasm")?; - - let name_str = str::from_utf8(&name) - .map_err(|_| "Invalid str while ext_http_request_add_header: wasm")?; - let value_str = str::from_utf8(&value) - .map_err(|_| "Invalid str while ext_http_request_add_header: wasm")?; - - let res = sp_io::offchain::http_request_add_header( - offchain::HttpRequestId(request_id as u16), - name_str, - value_str, - ); - - Ok(if res.is_ok() { 0 } else { 1 }) - } - - ext_http_request_write_body( - request_id: u32, - chunk: Pointer, - chunk_len: WordSize, - deadline: u64, - ) -> u32 { - let chunk = context.read_memory(chunk, chunk_len) - .map_err(|_| "OOB while ext_http_request_write_body: wasm")?; - - let res = sp_io::offchain::http_request_write_body( - offchain::HttpRequestId(request_id as u16), - &chunk, - deadline_to_timestamp(deadline), - ); - - Ok(match res { - Ok(()) => 0, - Err(e) => e.into(), - }) - } - - ext_http_response_wait( - ids: Pointer, - ids_len: WordSize, - statuses: Pointer, - deadline: u64, - ) { - let ids = (0..ids_len) - .map(|i| - context.read_primitive(ids.offset(i).ok_or("Point overflow")?) - .map(|id: u32| offchain::HttpRequestId(id as u16)) - .map_err(|_| "OOB while ext_http_response_wait: wasm") - ) - .collect::, _>>()?; - - let res = sp_io::offchain::http_response_wait(&ids, deadline_to_timestamp(deadline)) - .into_iter() - .map(|status| u32::from(status)) - .enumerate() - // make sure to take up to `ids_len` to avoid exceeding the mem. - .take(ids_len as usize); - - for (i, status) in res { - context.write_primitive(statuses.offset(i as u32).ok_or("Point overflow")?, status) - .map_err(|_| "Invalid attempt to set memory in ext_http_response_wait")?; - } - - Ok(()) - } - - ext_http_response_headers( - request_id: u32, - written_out: Pointer, - ) -> Pointer { - use codec::Encode; - - let headers = sp_io::offchain::http_response_headers( - offchain::HttpRequestId(request_id as u16), - ); - - let encoded = headers.encode(); - let len = encoded.len() as u32; - let offset = context.allocate_memory(len)?; - - context.write_memory(offset, &encoded) - .map_err(|_| "Invalid attempt to set memory in ext_http_response_headers")?; - context.write_primitive(written_out, len) - .map_err(|_| "Invalid attempt to write written_out in ext_http_response_headers")?; - - Ok(offset) - } - - ext_http_response_read_body( - request_id: u32, - buffer: Pointer, - buffer_len: WordSize, - deadline: u64, - ) -> WordSize { - let mut internal_buffer = Vec::with_capacity(buffer_len as usize); - internal_buffer.resize(buffer_len as usize, 0); - - let res = sp_io::offchain::http_response_read_body( - offchain::HttpRequestId(request_id as u16), - &mut internal_buffer, - deadline_to_timestamp(deadline), - ); - - Ok(match res { - Ok(read) => { - context.write_memory(buffer, &internal_buffer[..read as usize]) - .map_err(|_| "Invalid attempt to set memory in ext_http_response_read_body")?; - - read as u32 - }, - Err(err) => { - u32::max_value() - u32::from(err) + 1 - } - }) - } - } -} - -fn deadline_to_timestamp(deadline: u64) -> Option { - if deadline == 0 { - None - } else { - Some(offchain::Timestamp::from_unix_millis(deadline)) - } -} diff --git a/client/executor/src/lib.rs b/client/executor/src/lib.rs index 152e3a498485d..af53ed91838cc 100644 --- a/client/executor/src/lib.rs +++ b/client/executor/src/lib.rs @@ -29,11 +29,8 @@ #![warn(missing_docs)] #![recursion_limit="128"] -#[macro_use] -mod wasm_utils; #[macro_use] mod native_executor; -pub mod deprecated_host_interface; mod wasm_runtime; #[cfg(test)] mod integration_tests; diff --git a/client/executor/src/native_executor.rs b/client/executor/src/native_executor.rs index 4fe7a205f53f9..1364b753dbeeb 100644 --- a/client/executor/src/native_executor.rs +++ b/client/executor/src/native_executor.rs @@ -101,10 +101,6 @@ impl NativeExecutor { /// Defaults to `DEFAULT_HEAP_PAGES` if `None` is provided. pub fn new(fallback_method: WasmExecutionMethod, default_heap_pages: Option) -> Self { let mut host_functions = sp_io::SubstrateHostFunctions::host_functions(); - // Add the old and deprecated host functions as well, so that we support old wasm runtimes. - host_functions.extend( - crate::deprecated_host_interface::SubstrateExternals::host_functions(), - ); // Add the custom host functions provided by the user. host_functions.extend(D::ExtendHostFunctions::host_functions()); diff --git a/client/executor/src/wasm_utils.rs b/client/executor/src/wasm_utils.rs deleted file mode 100644 index 539e210a9467e..0000000000000 --- a/client/executor/src/wasm_utils.rs +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright 2017-2020 Parity Technologies (UK) Ltd. -// This file is part of Substrate. - -// Substrate 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. - -// Substrate 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 Substrate. If not, see . - -//! Utilities for defining the wasm host environment. - -/// Converts arguments into respective WASM types. -#[macro_export] -macro_rules! convert_args { - () => ([]); - ( $( $t:ty ),* ) => ( [ $( <$t as $crate::sp_wasm_interface::IntoValue>::VALUE_TYPE, )* ] ); -} - -/// Generates a WASM signature for given list of parameters. -#[macro_export] -macro_rules! gen_signature { - ( ( $( $params: ty ),* ) ) => ( - $crate::sp_wasm_interface::Signature { - args: std::borrow::Cow::Borrowed(&convert_args!( $( $params ),* )[..]), - return_value: None, - } - ); - ( ( $( $params: ty ),* ) -> $returns:ty ) => ( - $crate::sp_wasm_interface::Signature { - args: std::borrow::Cow::Borrowed(&convert_args!( $( $params ),* )[..]), - return_value: Some(<$returns as $crate::sp_wasm_interface::IntoValue>::VALUE_TYPE), - } - ); -} - -macro_rules! gen_functions { - (@INTERNAL - { $( $generated:tt )* } - $context:ident, - ) => ( - vec![ $( $generated )* ] - ); - (@INTERNAL - { $( $generated:tt )* } - $context:ident, - $name:ident ( $( $names:ident: $params:ty ),* ) $( -> $returns:ty )? { $( $body:tt )* } - $( $tail:tt )* - ) => ( - gen_functions! { - @INTERNAL - { - $( $generated )* - { - struct $name; - - #[allow(unused)] - impl $crate::sp_wasm_interface::Function for $name { - fn name(&self) -> &str { - stringify!($name) - } - fn signature(&self) -> $crate::sp_wasm_interface::Signature { - gen_signature!( ( $( $params ),* ) $( -> $returns )? ) - } - fn execute( - &self, - context: &mut dyn $crate::sp_wasm_interface::FunctionContext, - args: &mut dyn Iterator, - ) -> ::std::result::Result, String> { - let mut $context = context; - marshall! { - args, - ( $( $names : $params ),* ) $( -> $returns )? => { $( $body )* } - } - } - } - - &$name as &dyn $crate::sp_wasm_interface::Function - }, - } - $context, - $( $tail )* - } - ); - - ( $context:ident, $( $tail:tt )* ) => ( - gen_functions!(@INTERNAL {} $context, $($tail)*); - ); -} - -/// Converts the list of arguments coming from WASM into their native types. -#[macro_export] -macro_rules! unmarshall_args { - ( $body:tt, $args_iter:ident, $( $names:ident : $params:ty ),*) => ({ - $( - let $names : $params = - $args_iter.next() - .and_then(|val| <$params as $crate::sp_wasm_interface::TryFromValue>::try_from_value(val)) - .expect( - "`$args_iter` comes from an argument of Externals::execute_function; - args to an external call always matches the signature of the external; - external signatures are built with count and types and in order defined by `$params`; - here, we iterating on `$params`; - qed; - " - ); - )* - $body - }) -} - -/// Since we can't specify the type of closure directly at binding site: -/// -/// ```nocompile -/// let f: FnOnce() -> Result<::NativeType, _> = || { /* ... */ }; -/// ``` -/// -/// we use this function to constrain the type of the closure. -#[inline(always)] -pub fn constrain_closure(f: F) -> F -where - F: FnOnce() -> Result -{ - f -} - -/// Pass the list of parameters by converting them to respective WASM types. -#[macro_export] -macro_rules! marshall { - ( $args_iter:ident, ( $( $names:ident : $params:ty ),* ) -> $returns:ty => $body:tt ) => ({ - let body = $crate::wasm_utils::constrain_closure::<$returns, _>(|| { - unmarshall_args!($body, $args_iter, $( $names : $params ),*) - }); - let r = body()?; - return Ok(Some($crate::sp_wasm_interface::IntoValue::into_value(r))) - }); - ( $args_iter:ident, ( $( $names:ident : $params:ty ),* ) => $body:tt ) => ({ - let body = $crate::wasm_utils::constrain_closure::<(), _>(|| { - unmarshall_args!($body, $args_iter, $( $names : $params ),*) - }); - body()?; - return Ok(None) - }) -} - -/// Implements the wasm host interface for the given type. -#[macro_export] -macro_rules! impl_wasm_host_interface { - ( - impl $interface_name:ident where $context:ident { - $( - $name:ident($( $names:ident : $params:ty ),* $(,)? ) $( -> $returns:ty )? - { $( $body:tt )* } - )* - } - ) => ( - impl $crate::sp_wasm_interface::HostFunctions for $interface_name { - #[allow(non_camel_case_types)] - fn host_functions() -> Vec<&'static dyn $crate::sp_wasm_interface::Function> { - gen_functions!( - $context, - $( $name( $( $names: $params ),* ) $( -> $returns )? { $( $body )* } )* - ) - } - } - ); -} diff --git a/client/executor/wasmi/Cargo.toml b/client/executor/wasmi/Cargo.toml index 6c8ba4c747d12..aa259e29f8dfb 100644 --- a/client/executor/wasmi/Cargo.toml +++ b/client/executor/wasmi/Cargo.toml @@ -1,19 +1,21 @@ [package] name = "sc-executor-wasmi" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "This crate provides an implementation of `WasmRuntime` that is baked by wasmi." +documentation = "https://docs.rs/sc-execturo-wasmi" [dependencies] log = "0.4.8" wasmi = "0.6.2" parity-wasm = "0.41.0" -codec = { package = "parity-scale-codec", version = "1.0.0" } -sc-executor-common = { version = "0.8.0-dev", path = "../common" } -sp-wasm-interface = { version = "2.0.0-dev", path = "../../../primitives/wasm-interface" } -sp-runtime-interface = { version = "2.0.0-dev", path = "../../../primitives/runtime-interface" } -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } -sp-allocator = { version = "2.0.0-dev", path = "../../../primitives/allocator" } +codec = { package = "parity-scale-codec", version = "1.2.0" } +sc-executor-common = { version = "0.8.0-alpha.2", path = "../common" } +sp-wasm-interface = { version = "2.0.0-alpha.2", path = "../../../primitives/wasm-interface" } +sp-runtime-interface = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime-interface" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } +sp-allocator = { version = "2.0.0-alpha.2", path = "../../../primitives/allocator" } diff --git a/client/executor/wasmtime/Cargo.toml b/client/executor/wasmtime/Cargo.toml index cd7e5dead9fe6..57f4c2a84231f 100644 --- a/client/executor/wasmtime/Cargo.toml +++ b/client/executor/wasmtime/Cargo.toml @@ -1,22 +1,23 @@ [package] name = "sc-executor-wasmtime" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Defines a `WasmRuntime` that uses the Wasmtime JIT to execute." [dependencies] log = "0.4.8" wasmi = "0.6.2" parity-wasm = "0.41.0" -codec = { package = "parity-scale-codec", version = "1.0.0" } -sc-executor-common = { version = "0.8.0-dev", path = "../common" } -sp-wasm-interface = { version = "2.0.0-dev", path = "../../../primitives/wasm-interface" } -sp-runtime-interface = { version = "2.0.0-dev", path = "../../../primitives/runtime-interface" } -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } -sp-allocator = { version = "2.0.0-dev", path = "../../../primitives/allocator" } +codec = { package = "parity-scale-codec", version = "1.2.0" } +sc-executor-common = { version = "0.8.0-alpha.2", path = "../common" } +sp-wasm-interface = { version = "2.0.0-alpha.2", path = "../../../primitives/wasm-interface" } +sp-runtime-interface = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime-interface" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } +sp-allocator = { version = "2.0.0-alpha.2", path = "../../../primitives/allocator" } wasmtime = "0.11" diff --git a/client/finality-grandpa/Cargo.toml b/client/finality-grandpa/Cargo.toml index 46dd444cdfc13..6cee0cd8526f6 100644 --- a/client/finality-grandpa/Cargo.toml +++ b/client/finality-grandpa/Cargo.toml @@ -1,49 +1,54 @@ [package] name = "sc-finality-grandpa" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Integration of the GRANDPA finality gadget into substrate." +documentation = "https://docs.rs/sc-finality-grandpa" + [dependencies] -fork-tree = { version = "2.0.0-dev", path = "../../utils/fork-tree" } +fork-tree = { version = "2.0.0-alpha.2", path = "../../utils/fork-tree" } futures = "0.3.1" futures-timer = "3.0.1" log = "0.4.8" parking_lot = "0.10.0" rand = "0.7.2" assert_matches = "1.3.0" -parity-scale-codec = { version = "1.0.0", features = ["derive"] } -sp-arithmetic = { version = "2.0.0-dev", path = "../../primitives/arithmetic" } -sp-runtime = { version = "2.0.0-dev", path = "../../primitives/runtime" } -sp-consensus = { version = "0.8.0-dev", path = "../../primitives/consensus/common" } -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -sc-telemetry = { version = "2.0.0-dev", path = "../telemetry" } -sc-keystore = { version = "2.0.0-dev", path = "../keystore" } +parity-scale-codec = { version = "1.2.0", features = ["derive"] } +sp-arithmetic = { version = "2.0.0-alpha.2", path = "../../primitives/arithmetic" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../primitives/runtime" } +sp-consensus = { version = "0.8.0-alpha.1", path = "../../primitives/consensus/common" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +sp-api = { version = "2.0.0-alpha.2", path = "../../primitives/api" } +sc-telemetry = { version = "2.0.0-alpha.2", path = "../telemetry" } +sc-keystore = { version = "2.0.0-alpha.2", path = "../keystore" } serde_json = "1.0.41" -sc-client-api = { version = "2.0.0-dev", path = "../api" } -sc-client = { version = "0.8.0-dev", path = "../" } -sp-inherents = { version = "2.0.0-dev", path = "../../primitives/inherents" } -sp-blockchain = { version = "2.0.0-dev", path = "../../primitives/blockchain" } -sc-network = { version = "0.8.0-dev", path = "../network" } -sc-network-gossip = { version = "0.8.0-dev", path = "../network-gossip" } -sp-finality-tracker = { version = "2.0.0-dev", path = "../../primitives/finality-tracker" } -sp-finality-grandpa = { version = "2.0.0-dev", path = "../../primitives/finality-grandpa" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../api" } +sc-client = { version = "0.8.0-alpha.2", path = "../" } +sp-inherents = { version = "2.0.0-alpha.2", path = "../../primitives/inherents" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../primitives/blockchain" } +sc-network = { version = "0.8.0-alpha.2", path = "../network" } +sc-network-gossip = { version = "0.8.0-alpha.2", path = "../network-gossip" } +sp-finality-tracker = { version = "2.0.0-alpha.2", path = "../../primitives/finality-tracker" } +sp-finality-grandpa = { version = "2.0.0-alpha.2", path = "../../primitives/finality-grandpa" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../utils/prometheus", version = "0.8.0-alpha.2" } +sc-block-builder = { version = "0.8.0-alpha.2", path = "../block-builder" } finality-grandpa = { version = "0.11.1", features = ["derive-codec"] } pin-project = "0.4.6" [dev-dependencies] finality-grandpa = { version = "0.11.1", features = ["derive-codec", "test-helpers"] } -sc-network = { version = "0.8.0-dev", path = "../network" } +sc-network = { version = "0.8.0-alpha.2", path = "../network" } sc-network-test = { version = "0.8.0-dev", path = "../network/test" } -sp-keyring = { version = "2.0.0-dev", path = "../../primitives/keyring" } +sp-keyring = { version = "2.0.0-alpha.2", path = "../../primitives/keyring" } substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../test-utils/runtime/client" } -sp-consensus-babe = { version = "0.8.0-dev", path = "../../primitives/consensus/babe" } -sp-state-machine = { version = "0.8.0-dev", path = "../../primitives/state-machine" } +sp-consensus-babe = { version = "0.8.0-alpha.2", path = "../../primitives/consensus/babe" } +sp-state-machine = { version = "0.8.0-alpha.2", path = "../../primitives/state-machine" } env_logger = "0.7.0" -tokio = "0.1.22" +tokio = { version = "0.2", features = ["rt-core"] } tempfile = "3.1.0" -sp-api = { version = "2.0.0-dev", path = "../../primitives/api" } -futures01 = { package = "futures", version = "0.1.29" } +sp-api = { version = "2.0.0-alpha.2", path = "../../primitives/api" } diff --git a/client/finality-grandpa/src/environment.rs b/client/finality-grandpa/src/environment.rs index fd88113776c9c..21a44c32dc9ea 100644 --- a/client/finality-grandpa/src/environment.rs +++ b/client/finality-grandpa/src/environment.rs @@ -25,18 +25,14 @@ use parity_scale_codec::{Decode, Encode}; use futures::prelude::*; use futures_timer::Delay; use parking_lot::RwLock; -use sp_blockchain::{HeaderBackend, Error as ClientError}; +use sp_blockchain::{HeaderBackend, Error as ClientError, HeaderMetadata}; +use std::marker::PhantomData; use sc_client_api::{ - BlockchainEvents, - backend::{AuxStore, Backend}, - Finalizer, - call_executor::CallExecutor, + backend::Backend, utils::is_descendent_of, }; -use sc_client::{ - apply_aux, Client, -}; +use sc_client::apply_aux; use finality_grandpa::{ BlockNumberOps, Equivocation, Error as GrandpaError, round::State as RoundState, voter, voter_set::VoterSet, @@ -62,6 +58,7 @@ use crate::justification::GrandpaJustification; use crate::until_imported::UntilVoteTargetImported; use crate::voting_rule::VotingRule; use sp_finality_grandpa::{AuthorityId, AuthoritySignature, SetId, RoundNumber}; +use prometheus_endpoint::{Gauge, U64, register, PrometheusError}; type HistoricalVotes = finality_grandpa::HistoricalVotes< ::Hash, @@ -376,9 +373,27 @@ impl SharedVoterSetState { } } +/// Prometheus metrics for GRANDPA. +#[derive(Clone)] +pub(crate) struct Metrics { + finality_grandpa_round: Gauge, +} + +impl Metrics { + pub(crate) fn register(registry: &prometheus_endpoint::Registry) -> Result { + Ok(Self { + finality_grandpa_round: register( + Gauge::new("finality_grandpa_round", "Highest completed GRANDPA round.")?, + registry + )?, + }) + } +} + + /// The environment we run GRANDPA in. -pub(crate) struct Environment, RA, SC, VR> { - pub(crate) client: Arc>, +pub(crate) struct Environment, SC, VR> { + pub(crate) client: Arc, pub(crate) select_chain: SC, pub(crate) voters: Arc>, pub(crate) config: Config, @@ -388,9 +403,11 @@ pub(crate) struct Environment, RA, SC, V pub(crate) set_id: SetId, pub(crate) voter_set_state: SharedVoterSetState, pub(crate) voting_rule: VR, + pub(crate) metrics: Option, + pub(crate) _phantom: PhantomData, } -impl, RA, SC, VR> Environment { +impl, SC, VR> Environment { /// Updates the voter set state using the given closure. The write lock is /// held during evaluation of the closure and the environment's voter set /// state is set to its result if successful. @@ -400,23 +417,33 @@ impl, RA, SC, VR> Environment +impl finality_grandpa::Chain> -for Environment +for Environment where Block: 'static, - B: Backend + 'static, - E: CallExecutor + Send + Sync, + BE: Backend, + C: crate::ClientForGrandpa, N: NetworkT + 'static + Send, SC: SelectChain + 'static, - VR: VotingRule>, - RA: Send + Sync, + VR: VotingRule, NumberFor: BlockNumberOps, { fn ancestry(&self, base: Block::Hash, block: Block::Hash) -> Result, GrandpaError> { @@ -432,7 +459,7 @@ where return None; } - let base_header = match self.client.header(&BlockId::Hash(block)).ok()? { + let base_header = match self.client.header(BlockId::Hash(block)).ok()? { Some(h) => h, None => { debug!(target: "afg", "Encountered error finding best chain containing {:?}: couldn't find base block", block); @@ -450,7 +477,7 @@ where match self.select_chain.finality_target(block, None) { Ok(Some(best_hash)) => { - let best_header = self.client.header(&BlockId::Hash(best_hash)).ok()? + let best_header = self.client.header(BlockId::Hash(best_hash)).ok()? .expect("Header known to exist after `finality_target` call; qed"); // check if our vote is currently being limited due to a pending change @@ -474,7 +501,7 @@ where break; } - target_header = self.client.header(&BlockId::Hash(*target_header.parent_hash())).ok()? + target_header = self.client.header(BlockId::Hash(*target_header.parent_hash())).ok()? .expect("Header known to exist after `finality_target` call; qed"); } @@ -519,17 +546,16 @@ where } -pub(crate) fn ancestry( - client: &Client, +pub(crate) fn ancestry( + client: &Arc, base: Block::Hash, block: Block::Hash, ) -> Result, GrandpaError> where - B: Backend, - E: CallExecutor, + Client: HeaderMetadata, { if base == block { return Err(GrandpaError::NotDescendent) } - let tree_route_res = sp_blockchain::tree_route(client, block, base); + let tree_route_res = sp_blockchain::tree_route(&**client, block, base); let tree_route = match tree_route_res { Ok(tree_route) => tree_route, @@ -550,19 +576,17 @@ pub(crate) fn ancestry( Ok(tree_route.retracted().iter().skip(1).map(|e| e.hash).collect()) } -impl +impl voter::Environment> -for Environment +for Environment where Block: 'static, - B: Backend + 'static, - E: CallExecutor + 'static + Send + Sync, + B: Backend, + C: crate::ClientForGrandpa + 'static, N: NetworkT + 'static + Send, - RA: 'static + Send + Sync, SC: SelectChain + 'static, - VR: VotingRule>, + VR: VotingRule, NumberFor: BlockNumberOps, - Client: AuxStore, { type Timer = Pin> + Send>>; type Id = AuthorityId; @@ -882,7 +906,7 @@ where commit: Commit, ) -> Result<(), Self::Error> { finalize_block( - &*self.client, + self.client.clone(), &self.authority_set, &self.consensus_changes, Some(self.config.justification_period.into()), @@ -940,8 +964,8 @@ impl From> for JustificationOrCommit< /// authority set change is enacted then a justification is created (if not /// given) and stored with the block when finalizing it. /// This method assumes that the block being finalized has already been imported. -pub(crate) fn finalize_block( - client: &Client, +pub(crate) fn finalize_block( + client: Arc, authority_set: &SharedAuthoritySet>, consensus_changes: &SharedConsensusChanges>, justification_period: Option>, @@ -949,16 +973,16 @@ pub(crate) fn finalize_block( number: NumberFor, justification_or_commit: JustificationOrCommit, ) -> Result<(), CommandOrError>> where - B: Backend, - E: CallExecutor + Send + Sync, - RA: Send + Sync, + Block: BlockT, + BE: Backend, + Client: crate::ClientForGrandpa, { // NOTE: lock must be held through writing to DB to avoid race. this lock // also implicitly synchronizes the check for last finalized number // below. let mut authority_set = authority_set.inner().write(); - let status = client.chain_info(); + let status = client.info(); if number <= status.finalized_number && client.hash(number)? == Some(hash) { // This can happen after a forced change (triggered by the finality tracker when finality is stalled), since // the voter will be restarted at the median last finalized block, which can be lower than the local best @@ -981,14 +1005,14 @@ pub(crate) fn finalize_block( let mut consensus_changes = consensus_changes.lock(); let canon_at_height = |canon_number| { // "true" because the block is finalized - canonical_at_height(client, (hash, number), true, canon_number) + canonical_at_height(&*client, (hash, number), true, canon_number) }; let update_res: Result<_, Error> = client.lock_import_and_run(|import_op| { let status = authority_set.apply_standard_changes( hash, number, - &is_descendent_of::(client, None), + &is_descendent_of::(&*client, None), ).map_err(|e| Error::Safety(e.to_string()))?; // check if this is this is the first finalization of some consensus changes @@ -1031,7 +1055,7 @@ pub(crate) fn finalize_block( // finalization to remote nodes if !justification_required { if let Some(justification_period) = justification_period { - let last_finalized_number = client.chain_info().finalized_number; + let last_finalized_number = client.info().finalized_number; justification_required = (!last_finalized_number.is_zero() || number - last_finalized_number == justification_period) && (last_finalized_number / justification_period != number / justification_period); @@ -1040,7 +1064,7 @@ pub(crate) fn finalize_block( if justification_required { let justification = GrandpaJustification::from_commit( - client, + &client, round_number, commit, )?; diff --git a/client/finality-grandpa/src/import.rs b/client/finality-grandpa/src/import.rs index 2eb1b4a7c889c..28a08339dcb36 100644 --- a/client/finality-grandpa/src/import.rs +++ b/client/finality-grandpa/src/import.rs @@ -21,9 +21,10 @@ use parity_scale_codec::Encode; use futures::channel::mpsc; use parking_lot::RwLockWriteGuard; -use sp_blockchain::{HeaderBackend, BlockStatus, well_known_cache_keys}; -use sc_client_api::{backend::{TransactionFor, Backend}, CallExecutor, utils::is_descendent_of}; -use sc_client::Client; +use sp_blockchain::{BlockStatus, well_known_cache_keys}; +use sc_client_api::{backend::Backend, utils::is_descendent_of}; +use sp_api::{TransactionFor}; + use sp_consensus::{ BlockImport, Error as ConsensusError, BlockCheckParams, BlockImportParams, ImportResult, JustificationImport, @@ -41,6 +42,7 @@ use crate::authorities::{AuthoritySet, SharedAuthoritySet, DelayKind, PendingCha use crate::consensus_changes::SharedConsensusChanges; use crate::environment::finalize_block; use crate::justification::GrandpaJustification; +use std::marker::PhantomData; /// A block-import handler for GRANDPA. /// @@ -51,16 +53,17 @@ use crate::justification::GrandpaJustification; /// /// When using GRANDPA, the block import worker should be using this block import /// object. -pub struct GrandpaBlockImport { - inner: Arc>, +pub struct GrandpaBlockImport { + inner: Arc, select_chain: SC, authority_set: SharedAuthoritySet>, send_voter_commands: mpsc::UnboundedSender>>, consensus_changes: SharedConsensusChanges>, + _phantom: PhantomData, } -impl Clone for - GrandpaBlockImport +impl Clone for + GrandpaBlockImport { fn clone(&self) -> Self { GrandpaBlockImport { @@ -69,24 +72,24 @@ impl Clone for authority_set: self.authority_set.clone(), send_voter_commands: self.send_voter_commands.clone(), consensus_changes: self.consensus_changes.clone(), + _phantom: PhantomData, } } } -impl JustificationImport - for GrandpaBlockImport where +impl JustificationImport + for GrandpaBlockImport where NumberFor: finality_grandpa::BlockNumberOps, - B: Backend + 'static, - E: CallExecutor + 'static + Clone + Send + Sync, DigestFor: Encode, - RA: Send + Sync, + BE: Backend, + Client: crate::ClientForGrandpa, SC: SelectChain, { type Error = ConsensusError; fn on_start(&mut self) -> Vec<(Block::Hash, NumberFor)> { let mut out = Vec::new(); - let chain_info = self.inner.chain_info(); + let chain_info = self.inner.info(); // request justifications for all pending changes for which change blocks have already been imported let authorities = self.authority_set.inner().read(); @@ -105,7 +108,7 @@ impl JustificationImport }; if let Ok(Some(hash)) = effective_block_hash { - if let Ok(Some(header)) = self.inner.header(&BlockId::Hash(hash)) { + if let Ok(Some(header)) = self.inner.header(BlockId::Hash(hash)) { if *header.number() == pending_change.effective_number() { out.push((header.hash(), *header.number())); } @@ -123,7 +126,7 @@ impl JustificationImport number: NumberFor, justification: Justification, ) -> Result<(), Self::Error> { - self.import_justification(hash, number, justification, false) + GrandpaBlockImport::import_justification(self, hash, number, justification, false) } } @@ -200,14 +203,13 @@ fn find_forced_change(header: &B::Header) header.digest().convert_first(|l| l.try_to(id).and_then(filter_log)) } -impl - GrandpaBlockImport +impl + GrandpaBlockImport where NumberFor: finality_grandpa::BlockNumberOps, - B: Backend + 'static, - E: CallExecutor + 'static + Clone + Send + Sync, DigestFor: Encode, - RA: Send + Sync, + BE: Backend, + Client: crate::ClientForGrandpa, { // check for a new authority set change. fn check_new_change(&self, header: &Block::Header, hash: Block::Hash) @@ -235,11 +237,11 @@ where }) } - fn make_authorities_changes<'a>( - &'a self, - block: &mut BlockImportParams>, + fn make_authorities_changes( + &self, + block: &mut BlockImportParams>, hash: Block::Hash, - ) -> Result, ConsensusError> { + ) -> Result, ConsensusError> { // when we update the authorities, we need to hold the lock // until the block is written to prevent a race if we need to restore // the old authority set on error or panic. @@ -325,10 +327,10 @@ where // for the canon block the new authority set should start // with. we use the minimum between the median and the local // best finalized block. - let best_finalized_number = self.inner.chain_info().finalized_number; + let best_finalized_number = self.inner.info().finalized_number; let canon_number = best_finalized_number.min(median_last_finalized_number); let canon_hash = - self.inner.header(&BlockId::Number(canon_number)) + self.inner.header(BlockId::Number(canon_number)) .map_err(|e| ConsensusError::ClientImport(e.to_string()))? .expect("the given block number is less or equal than the current best finalized number; \ current best finalized number must exist in chain; qed.") @@ -380,18 +382,17 @@ where } } -impl BlockImport - for GrandpaBlockImport where +impl BlockImport + for GrandpaBlockImport where NumberFor: finality_grandpa::BlockNumberOps, - B: Backend + 'static, - E: CallExecutor + 'static + Clone + Send + Sync, DigestFor: Encode, - RA: Send + Sync, - for<'a> &'a Client: - BlockImport>, + BE: Backend, + Client: crate::ClientForGrandpa, + for<'a> &'a Client: + BlockImport>, { type Error = ConsensusError; - type Transaction = TransactionFor; + type Transaction = TransactionFor; fn import_block( &mut self, @@ -521,31 +522,31 @@ impl BlockImport } } -impl GrandpaBlockImport { +impl GrandpaBlockImport { pub(crate) fn new( - inner: Arc>, + inner: Arc, select_chain: SC, authority_set: SharedAuthoritySet>, send_voter_commands: mpsc::UnboundedSender>>, consensus_changes: SharedConsensusChanges>, - ) -> GrandpaBlockImport { + ) -> GrandpaBlockImport { GrandpaBlockImport { inner, select_chain, authority_set, send_voter_commands, consensus_changes, + _phantom: PhantomData, } } } -impl - GrandpaBlockImport +impl + GrandpaBlockImport where + BE: Backend, + Client: crate::ClientForGrandpa, NumberFor: finality_grandpa::BlockNumberOps, - B: Backend + 'static, - E: CallExecutor + 'static + Clone + Send + Sync, - RA: Send + Sync, { /// Import a block justification and finalize the block. @@ -572,7 +573,7 @@ where }; let result = finalize_block( - &*self.inner, + self.inner.clone(), &self.authority_set, &self.consensus_changes, None, diff --git a/client/finality-grandpa/src/justification.rs b/client/finality-grandpa/src/justification.rs index ad96956454fd7..084c0042ab19a 100644 --- a/client/finality-grandpa/src/justification.rs +++ b/client/finality-grandpa/src/justification.rs @@ -15,10 +15,9 @@ // along with Substrate. If not, see . use std::collections::{HashMap, HashSet}; +use std::sync::Arc; -use sc_client::Client; -use sc_client_api::{CallExecutor, backend::Backend}; -use sp_blockchain::Error as ClientError; +use sp_blockchain::{Error as ClientError, HeaderBackend}; use parity_scale_codec::{Encode, Decode}; use finality_grandpa::voter_set::VoterSet; use finality_grandpa::{Error as GrandpaError}; @@ -47,14 +46,12 @@ pub struct GrandpaJustification { impl GrandpaJustification { /// Create a GRANDPA justification from the given commit. This method /// assumes the commit is valid and well-formed. - pub(crate) fn from_commit( - client: &Client, + pub(crate) fn from_commit( + client: &Arc, round: u64, commit: Commit, ) -> Result, Error> where - B: Backend, - E: CallExecutor + Send + Sync, - RA: Send + Sync, + C: HeaderBackend, { let mut votes_ancestries_hashes = HashSet::new(); let mut votes_ancestries = Vec::new(); @@ -69,7 +66,7 @@ impl GrandpaJustification { loop { if current_hash == commit.target_hash { break; } - match client.header(&BlockId::Hash(current_hash))? { + match client.header(BlockId::Hash(current_hash))? { Some(current_header) => { if *current_header.number() <= commit.target_number { return error(); diff --git a/client/finality-grandpa/src/lib.rs b/client/finality-grandpa/src/lib.rs index 650b59dfff662..e9ea244a7247c 100644 --- a/client/finality-grandpa/src/lib.rs +++ b/client/finality-grandpa/src/lib.rs @@ -56,15 +56,18 @@ use futures::prelude::*; use futures::StreamExt; use log::{debug, info}; use futures::channel::mpsc; -use sc_client_api::{BlockchainEvents, CallExecutor, backend::{AuxStore, Backend}, ExecutionStrategy}; -use sp_blockchain::{HeaderBackend, Error as ClientError}; +use sc_client_api::{ + LockImportRun, BlockchainEvents, CallExecutor, + backend::{AuxStore, Backend}, ExecutionStrategy, Finalizer, TransactionFor, +}; +use sp_blockchain::{HeaderBackend, Error as ClientError, HeaderMetadata}; use sc_client::Client; use parity_scale_codec::{Decode, Encode}; use sp_runtime::generic::BlockId; use sp_runtime::traits::{NumberFor, Block as BlockT, DigestFor, Zero}; use sc_keystore::KeyStorePtr; use sp_inherents::InherentDataProviders; -use sp_consensus::SelectChain; +use sp_consensus::{SelectChain, BlockImport}; use sp_core::Pair; use sc_telemetry::{telemetry, CONSENSUS_INFO, CONSENSUS_DEBUG}; use serde_json; @@ -101,7 +104,7 @@ pub use voting_rule::{ }; use aux_schema::PersistentData; -use environment::{Environment, VoterSetState}; +use environment::{Environment, VoterSetState, Metrics}; use import::GrandpaBlockImport; use until_imported::UntilGlobalMessageBlocksImported; use communication::{NetworkBridge, Network as NetworkT}; @@ -109,6 +112,8 @@ use sp_finality_grandpa::{AuthorityList, AuthorityPair, AuthoritySignature, SetI // Re-export these two because it's just so damn convenient. pub use sp_finality_grandpa::{AuthorityId, ScheduledChange}; +use sp_api::ProvideRuntimeApi; +use std::marker::PhantomData; #[cfg(test)] mod tests; @@ -245,10 +250,8 @@ pub(crate) trait BlockStatus { fn block_number(&self, hash: Block::Hash) -> Result>, Error>; } -impl BlockStatus for Arc> where - B: Backend, - E: CallExecutor + Send + Sync, - RA: Send + Sync, +impl BlockStatus for Arc where + Client: HeaderBackend, NumberFor: BlockNumberOps, { fn block_number(&self, hash: Block::Hash) -> Result>, Error> { @@ -257,6 +260,29 @@ impl BlockStatus for Arc } } +/// A trait that includes all the client functionalities grandpa requires. +/// Ideally this would be a trait alias, we're not there yet. +/// tracking issue https://github.com/rust-lang/rust/issues/41517 +pub trait ClientForGrandpa: + LockImportRun + Finalizer + AuxStore + + HeaderMetadata + HeaderBackend + + BlockchainEvents + ProvideRuntimeApi + + BlockImport, Error = sp_consensus::Error> + where + BE: Backend, + Block: BlockT, +{} + +impl ClientForGrandpa for T + where + BE: Backend, + Block: BlockT, + T: LockImportRun + Finalizer + AuxStore + + HeaderMetadata + HeaderBackend + + BlockchainEvents + ProvideRuntimeApi + + BlockImport, Error = sp_consensus::Error>, +{} + /// Something that one can ask to do a block sync request. pub(crate) trait BlockSyncRequester { /// Notifies the sync service to try and sync the given block from the given @@ -348,8 +374,8 @@ impl fmt::Display for CommandOrError { } } -pub struct LinkHalf { - client: Arc>, +pub struct LinkHalf { + client: Arc, select_chain: SC, persistent_data: PersistentData, voter_commands_rx: mpsc::UnboundedReceiver>>, @@ -390,22 +416,20 @@ impl GenesisAuthoritySetProvider for Client( - client: Arc>, +pub fn block_import( + client: Arc, genesis_authorities_provider: &dyn GenesisAuthoritySetProvider, select_chain: SC, ) -> Result<( - GrandpaBlockImport, - LinkHalf + GrandpaBlockImport, + LinkHalf, ), ClientError> where - B: Backend + 'static, - E: CallExecutor + Send + Sync, - RA: Send + Sync, SC: SelectChain, - Client: AuxStore, + BE: Backend + 'static, + Client: ClientForGrandpa + 'static, { - let chain_info = client.chain_info(); + let chain_info = client.info(); let genesis_hash = chain_info.genesis_hash; let persistent_data = aux_schema::load_persistent( @@ -440,10 +464,10 @@ where )) } -fn global_communication( +fn global_communication( set_id: SetId, voters: &Arc>, - client: &Arc>, + client: Arc, network: &NetworkBridge, keystore: &Option, ) -> ( @@ -455,10 +479,9 @@ fn global_communication( Error = CommandOrError>, > + Unpin, ) where - B: Backend, - E: CallExecutor + Send + Sync, + BE: Backend + 'static, + C: ClientForGrandpa + 'static, N: NetworkT, - RA: Send + Sync, NumberFor: BlockNumberOps, { let is_voter = is_voter(voters, keystore).is_some(); @@ -487,20 +510,18 @@ fn global_communication( /// Register the finality tracker inherent data provider (which is used by /// GRANDPA), if not registered already. -fn register_finality_tracker_inherent_data_provider( - client: Arc>, +fn register_finality_tracker_inherent_data_provider( + client: Arc, inherent_data_providers: &InherentDataProviders, ) -> Result<(), sp_consensus::Error> where - B: Backend + 'static, - E: CallExecutor + Send + Sync + 'static, - RA: Send + Sync + 'static, + Client: HeaderBackend + 'static, { if !inherent_data_providers.has_provider(&sp_finality_tracker::INHERENT_IDENTIFIER) { inherent_data_providers .register_provider(sp_finality_tracker::InherentDataProvider::new(move || { #[allow(deprecated)] { - let info = client.chain_info(); + let info = client.info(); telemetry!(CONSENSUS_INFO; "afg.finalized"; "finalized_number" => ?info.finalized_number, "finalized_hash" => ?info.finalized_hash, @@ -515,11 +536,11 @@ fn register_finality_tracker_inherent_data_provider( } /// Parameters used to run Grandpa. -pub struct GrandpaParams { +pub struct GrandpaParams { /// Configuration for the GRANDPA service. pub config: Config, /// A link to the block import worker. - pub link: LinkHalf, + pub link: LinkHalf, /// The Network instance. pub network: N, /// The inherent data providers. @@ -530,24 +551,24 @@ pub struct GrandpaParams { pub telemetry_on_connect: Option>, /// A voting rule used to potentially restrict target votes. pub voting_rule: VR, + /// The prometheus metrics registry. + pub prometheus_registry: Option, } /// Run a GRANDPA voter as a task. Provide configuration and a link to a /// block import worker that has already been instantiated with `block_import`. -pub fn run_grandpa_voter( - grandpa_params: GrandpaParams, +pub fn run_grandpa_voter( + grandpa_params: GrandpaParams, ) -> sp_blockchain::Result + Unpin + Send + 'static> where Block::Hash: Ord, - B: Backend + 'static, - E: CallExecutor + Send + Sync + 'static, + BE: Backend + 'static, N: NetworkT + Send + Sync + Clone + 'static, SC: SelectChain + 'static, - VR: VotingRule> + Clone + 'static, + VR: VotingRule + Clone + 'static, NumberFor: BlockNumberOps, DigestFor: Encode, - RA: Send + Sync + 'static, X: futures::Future + Clone + Send + Unpin + 'static, - Client: AuxStore, + C: ClientForGrandpa + 'static, { let GrandpaParams { mut config, @@ -557,6 +578,7 @@ pub fn run_grandpa_voter( on_exit, telemetry_on_connect, voting_rule, + prometheus_registry, } = grandpa_params; // NOTE: we have recently removed `run_grandpa_observer` from the public @@ -615,6 +637,7 @@ pub fn run_grandpa_voter( voting_rule, persistent_data, voter_commands_rx, + prometheus_registry, ); let voter_work = voter_work @@ -629,33 +652,32 @@ pub fn run_grandpa_voter( /// Future that powers the voter. #[must_use] -struct VoterWork, RA, SC, VR> { +struct VoterWork, SC, VR> { voter: Pin>>> + Send>>, - env: Arc>, + env: Arc>, voter_commands_rx: mpsc::UnboundedReceiver>>, network: NetworkBridge, } -impl VoterWork +impl VoterWork where Block: BlockT, + B: Backend + 'static, + C: ClientForGrandpa + 'static, N: NetworkT + Sync, NumberFor: BlockNumberOps, - RA: 'static + Send + Sync, - E: CallExecutor + Send + Sync + 'static, - B: Backend + 'static, SC: SelectChain + 'static, - VR: VotingRule> + Clone + 'static, - Client: AuxStore, + VR: VotingRule + Clone + 'static, { fn new( - client: Arc>, + client: Arc, config: Config, network: NetworkBridge, select_chain: SC, voting_rule: VR, persistent_data: PersistentData, voter_commands_rx: mpsc::UnboundedReceiver>>, + prometheus_registry: Option, ) -> Self { let voters = persistent_data.authority_set.current_authorities(); @@ -670,6 +692,11 @@ where authority_set: persistent_data.authority_set.clone(), consensus_changes: persistent_data.consensus_changes.clone(), voter_set_state: persistent_data.set_state.clone(), + metrics: prometheus_registry.map(|registry| { + Metrics::register(®istry) + .expect("Other metrics would have failed to register before these; qed") + }), + _phantom: PhantomData, }); let mut work = VoterWork { @@ -700,7 +727,7 @@ where "authority_id" => authority_id.to_string(), ); - let chain_info = self.env.client.chain_info(); + let chain_info = self.env.client.info(); telemetry!(CONSENSUS_INFO; "afg.authority_set"; "number" => ?chain_info.finalized_number, "hash" => ?chain_info.finalized_hash, @@ -724,7 +751,7 @@ where let global_comms = global_communication( self.env.set_id, &self.env.voters, - &self.env.client, + self.env.client.clone(), &self.env.network, &self.env.config.keystore, ); @@ -789,6 +816,8 @@ where consensus_changes: self.env.consensus_changes.clone(), network: self.env.network.clone(), voting_rule: self.env.voting_rule.clone(), + metrics: self.env.metrics.clone(), + _phantom: PhantomData, }); self.rebuild_voter(); @@ -813,17 +842,15 @@ where } } -impl Future for VoterWork +impl Future for VoterWork where Block: BlockT, + B: Backend + 'static, N: NetworkT + Sync, NumberFor: BlockNumberOps, - RA: 'static + Send + Sync, - E: CallExecutor + Send + Sync + 'static, - B: Backend + 'static, SC: SelectChain + 'static, - VR: VotingRule> + Clone + 'static, - Client: AuxStore, + C: ClientForGrandpa + 'static, + VR: VotingRule + Clone + 'static, { type Output = Result<(), Error>; @@ -868,15 +895,13 @@ where /// discards all GRANDPA messages (otherwise, we end up banning nodes that send /// us a `Neighbor` message, since there is no registered gossip validator for /// the engine id defined in the message.) -pub fn setup_disabled_grandpa( - client: Arc>, +pub fn setup_disabled_grandpa( + client: Arc, inherent_data_providers: &InherentDataProviders, network: N, ) -> Result<(), sp_consensus::Error> where - B: Backend + 'static, - E: CallExecutor + Send + Sync + 'static, - RA: Send + Sync + 'static, N: NetworkT + Send + Clone + 'static, + Client: HeaderBackend + 'static, { register_finality_tracker_inherent_data_provider( client, diff --git a/client/finality-grandpa/src/light_import.rs b/client/finality-grandpa/src/light_import.rs index 0181a93f1088c..258ea81bd5197 100644 --- a/client/finality-grandpa/src/light_import.rs +++ b/client/finality-grandpa/src/light_import.rs @@ -18,8 +18,7 @@ use std::collections::HashMap; use std::sync::Arc; use log::{info, trace, warn}; use parking_lot::RwLock; -use sc_client::Client; -use sc_client_api::{CallExecutor, backend::{AuxStore, Backend, Finalizer, TransactionFor}}; +use sc_client_api::backend::{AuxStore, Backend, Finalizer, TransactionFor}; use sp_blockchain::{HeaderBackend, Error as ClientError, well_known_cache_keys}; use parity_scale_codec::{Encode, Decode}; use sp_consensus::{ @@ -48,17 +47,15 @@ const LIGHT_AUTHORITY_SET_KEY: &[u8] = b"grandpa_voters"; const LIGHT_CONSENSUS_CHANGES_KEY: &[u8] = b"grandpa_consensus_changes"; /// Create light block importer. -pub fn light_block_import( - client: Arc>, - backend: Arc, +pub fn light_block_import( + client: Arc, + backend: Arc, genesis_authorities_provider: &dyn GenesisAuthoritySetProvider, authority_set_provider: Arc>, -) -> Result, ClientError> +) -> Result, ClientError> where - B: Backend + 'static, - E: CallExecutor + 'static + Clone + Send + Sync, - RA: Send + Sync, - Client: AuxStore, + BE: Backend, + Client: crate::ClientForGrandpa, { let info = client.info(); let import_data = load_aux_import_data( @@ -79,14 +76,14 @@ pub fn light_block_import( /// It is responsible for: /// - checking GRANDPA justifications; /// - fetching finality proofs for blocks that are enacting consensus changes. -pub struct GrandpaLightBlockImport { - client: Arc>, - backend: Arc, +pub struct GrandpaLightBlockImport { + client: Arc, + backend: Arc, authority_set_provider: Arc>, data: Arc>>, } -impl Clone for GrandpaLightBlockImport { +impl Clone for GrandpaLightBlockImport { fn clone(&self) -> Self { GrandpaLightBlockImport { client: self.client.clone(), @@ -111,27 +108,26 @@ struct LightAuthoritySet { authorities: AuthorityList, } -impl GrandpaLightBlockImport { +impl GrandpaLightBlockImport { /// Create finality proof request builder. pub fn create_finality_proof_request_builder(&self) -> BoxFinalityProofRequestBuilder { Box::new(GrandpaFinalityProofRequestBuilder(self.data.clone())) as _ } } -impl BlockImport - for GrandpaLightBlockImport where +impl BlockImport + for GrandpaLightBlockImport where NumberFor: finality_grandpa::BlockNumberOps, - B: Backend + 'static, - E: CallExecutor + 'static + Clone + Send + Sync, DigestFor: Encode, - RA: Send + Sync, - for<'a> &'a Client: - BlockImport> - + Finalizer + BE: Backend + 'static, + for<'a> &'a Client: + HeaderBackend + + BlockImport> + + Finalizer + AuxStore, { type Error = ConsensusError; - type Transaction = TransactionFor; + type Transaction = TransactionFor; fn import_block( &mut self, @@ -151,23 +147,22 @@ impl BlockImport } } -impl FinalityProofImport - for GrandpaLightBlockImport where +impl FinalityProofImport + for GrandpaLightBlockImport where NumberFor: finality_grandpa::BlockNumberOps, - B: Backend + 'static, - E: CallExecutor + 'static + Clone + Send + Sync, DigestFor: Encode, - RA: Send + Sync, - for<'a> &'a Client: - BlockImport> - + Finalizer + BE: Backend + 'static, + for<'a> &'a Client: + HeaderBackend + + BlockImport> + + Finalizer + AuxStore, { type Error = ConsensusError; fn on_start(&mut self) -> Vec<(Block::Hash, NumberFor)> { let mut out = Vec::new(); - let chain_info = self.client.chain_info(); + let chain_info = (&*self.client).info(); let data = self.data.read(); for (pending_number, pending_hash) in data.consensus_changes.pending_changes() { @@ -567,7 +562,7 @@ fn on_post_finalization_error(error: ClientError, value_type: &str) -> Consensus #[cfg(test)] pub mod tests { use super::*; - use sp_consensus::ForkChoiceStrategy; + use sp_consensus::{ForkChoiceStrategy, BlockImport}; use sp_finality_grandpa::AuthorityId; use sp_core::{H256, crypto::Public}; use substrate_test_runtime_client::sc_client::in_mem::Blockchain as InMemoryAuxStore; @@ -575,37 +570,36 @@ pub mod tests { use crate::tests::TestApi; use crate::finality_proof::tests::TestJustification; - pub struct NoJustificationsImport( - pub GrandpaLightBlockImport + pub struct NoJustificationsImport( + pub GrandpaLightBlockImport ); - impl Clone - for NoJustificationsImport where + impl Clone + for NoJustificationsImport where NumberFor: finality_grandpa::BlockNumberOps, - B: Backend + 'static, - E: CallExecutor + 'static + Clone + Send + Sync, DigestFor: Encode, - RA: Send + Sync, + BE: Backend + 'static, { fn clone(&self) -> Self { NoJustificationsImport(self.0.clone()) } } - impl BlockImport - for NoJustificationsImport where + impl BlockImport + for NoJustificationsImport where NumberFor: finality_grandpa::BlockNumberOps, - B: Backend + 'static, - E: CallExecutor + 'static + Clone + Send + Sync, DigestFor: Encode, - RA: Send + Sync, - for<'a> &'a Client: - BlockImport> - + Finalizer + BE: Backend + 'static, + for <'a > &'a Client: + HeaderBackend + + BlockImport> + + Finalizer + AuxStore, + GrandpaLightBlockImport: + BlockImport, Error = ConsensusError> { type Error = ConsensusError; - type Transaction = TransactionFor; + type Transaction = TransactionFor; fn import_block( &mut self, @@ -624,16 +618,15 @@ pub mod tests { } } - impl FinalityProofImport - for NoJustificationsImport where + impl FinalityProofImport + for NoJustificationsImport where NumberFor: finality_grandpa::BlockNumberOps, - B: Backend + 'static, - E: CallExecutor + 'static + Clone + Send + Sync, + BE: Backend + 'static, DigestFor: Encode, - RA: Send + Sync, - for<'a> &'a Client: - BlockImport> - + Finalizer + for <'a > &'a Client: + HeaderBackend + + BlockImport> + + Finalizer + AuxStore, { type Error = ConsensusError; @@ -654,19 +647,15 @@ pub mod tests { } /// Creates light block import that ignores justifications that came outside of finality proofs. - pub fn light_block_import_without_justifications( - client: Arc>, - backend: Arc, + pub fn light_block_import_without_justifications( + client: Arc, + backend: Arc, genesis_authorities_provider: &dyn GenesisAuthoritySetProvider, authority_set_provider: Arc>, - ) -> Result, ClientError> + ) -> Result, ClientError> where - B: Backend + 'static, - E: CallExecutor + 'static + Clone + Send + Sync, - RA: Send + Sync, - Client: BlockImport - + Finalizer - + AuxStore, + BE: Backend + 'static, + Client: crate::ClientForGrandpa, { light_block_import(client, backend, genesis_authorities_provider, authority_set_provider) .map(NoJustificationsImport) @@ -677,6 +666,7 @@ pub mod tests { justification: Option, ) -> ImportResult { let (client, _backend) = substrate_test_runtime_client::new_light(); + let client = Arc::new(client); let mut import_data = LightImportData { last_finalized: Default::default(), authority_set: LightAuthoritySet::genesis(vec![(AuthorityId::from_slice(&[1; 32]), 1)]), @@ -696,7 +686,7 @@ pub mod tests { block.fork_choice = Some(ForkChoiceStrategy::LongestChain); do_import_block::<_, _, _, TestJustification>( - &client, + &*client, &mut import_data, block, new_cache, diff --git a/client/finality-grandpa/src/observer.rs b/client/finality-grandpa/src/observer.rs index 8345a3420998e..f6cf1a8aa1478 100644 --- a/client/finality-grandpa/src/observer.rs +++ b/client/finality-grandpa/src/observer.rs @@ -26,10 +26,9 @@ use finality_grandpa::{ use log::{debug, info, warn}; use sp_consensus::SelectChain; -use sc_client_api::{CallExecutor, backend::{Backend, AuxStore}}; -use sc_client::Client; +use sc_client_api::backend::Backend; use sp_runtime::traits::{NumberFor, Block as BlockT}; - +use sp_blockchain::HeaderMetadata; use crate::{ global_communication, CommandOrError, CommunicationIn, Config, environment, LinkHalf, Error, aux_schema::PersistentData, VoterCommand, VoterSetState, @@ -38,17 +37,21 @@ use crate::authorities::SharedAuthoritySet; use crate::communication::{Network as NetworkT, NetworkBridge}; use crate::consensus_changes::SharedConsensusChanges; use sp_finality_grandpa::AuthorityId; +use std::marker::{PhantomData, Unpin}; -struct ObserverChain<'a, Block: BlockT, B, E, RA>(&'a Client); +struct ObserverChain<'a, Block: BlockT, Client> { + client: &'a Arc, + _phantom: PhantomData, +} -impl<'a, Block: BlockT, B, E, RA> finality_grandpa::Chain> - for ObserverChain<'a, Block, B, E, RA> where - B: Backend, - E: CallExecutor, +impl<'a, Block, Client> finality_grandpa::Chain> + for ObserverChain<'a, Block, Client> where + Block: BlockT, + Client: HeaderMetadata, NumberFor: BlockNumberOps, { fn ancestry(&self, base: Block::Hash, block: Block::Hash) -> Result, GrandpaError> { - environment::ancestry(&self.0, base, block) + environment::ancestry(&self.client, base, block) } fn best_chain_containing(&self, _block: Block::Hash) -> Option<(Block::Hash, NumberFor)> { @@ -57,8 +60,8 @@ impl<'a, Block: BlockT, B, E, RA> finality_grandpa::Chain( - client: &Arc>, +fn grandpa_observer( + client: &Arc, authority_set: &SharedAuthoritySet>, consensus_changes: &SharedConsensusChanges>, voters: &Arc>, @@ -67,13 +70,12 @@ fn grandpa_observer( note_round: F, ) -> impl Future>>> where NumberFor: BlockNumberOps, - B: Backend, - E: CallExecutor + Send + Sync + 'static, - RA: Send + Sync, S: Stream< Item = Result, CommandOrError>>, >, F: Fn(u64), + BE: Backend, + Client: crate::ClientForGrandpa, { let authority_set = authority_set.clone(); let consensus_changes = consensus_changes.clone(); @@ -101,7 +103,7 @@ fn grandpa_observer( let validation_result = match finality_grandpa::validate_commit( &commit, &voters, - &ObserverChain(&*client), + &ObserverChain { client: &client, _phantom: PhantomData }, ) { Ok(r) => r, Err(e) => return future::err(e.into()), @@ -113,7 +115,7 @@ fn grandpa_observer( // commit is valid, finalize the block it targets match environment::finalize_block( - &client, + client.clone(), &authority_set, &consensus_changes, None, @@ -153,19 +155,17 @@ fn grandpa_observer( /// NOTE: this is currently not part of the crate's public API since we don't consider /// it stable enough to use on a live network. #[allow(unused)] -pub fn run_grandpa_observer( +pub fn run_grandpa_observer( config: Config, - link: LinkHalf, + link: LinkHalf, network: N, on_exit: impl futures::Future + Clone + Send + Unpin + 'static, ) -> sp_blockchain::Result + Unpin + Send + 'static> where - B: Backend + 'static, - E: CallExecutor + Send + Sync + 'static, + BE: Backend + Unpin + 'static, N: NetworkT + Send + Clone + 'static, SC: SelectChain + 'static, NumberFor: BlockNumberOps, - RA: Send + Sync + 'static, - Client: AuxStore, + Client: crate::ClientForGrandpa + 'static, { let LinkHalf { client, @@ -199,28 +199,27 @@ pub fn run_grandpa_observer( /// Future that powers the observer. #[must_use] -struct ObserverWork, E, Backend, RA> { +struct ObserverWork> { observer: Pin>>> + Send>>, - client: Arc>, + client: Arc, network: NetworkBridge, persistent_data: PersistentData, keystore: Option, voter_commands_rx: mpsc::UnboundedReceiver>>, + _phantom: PhantomData, } -impl ObserverWork +impl ObserverWork where B: BlockT, - N: NetworkT, + BE: Backend + 'static, + Client: crate::ClientForGrandpa + 'static, + Network: NetworkT, NumberFor: BlockNumberOps, - RA: 'static + Send + Sync, - E: CallExecutor + Send + Sync + 'static, - Bk: Backend + 'static, - Client: AuxStore, { fn new( - client: Arc>, - network: NetworkBridge, + client: Arc, + network: NetworkBridge, persistent_data: PersistentData, keystore: Option, voter_commands_rx: mpsc::UnboundedReceiver>>, @@ -235,6 +234,7 @@ where persistent_data, keystore, voter_commands_rx, + _phantom: PhantomData, }; work.rebuild_observer(); work @@ -251,12 +251,12 @@ where let (global_in, _) = global_communication( set_id, &voters, - &self.client, + self.client.clone(), &self.network, &self.keystore, ); - let last_finalized_number = self.client.chain_info().finalized_number; + let last_finalized_number = self.client.info().finalized_number; // NOTE: since we are not using `round_communication` we have to // manually note the round with the gossip validator, otherwise we won't @@ -324,15 +324,13 @@ where } } -impl Future for ObserverWork +impl Future for ObserverWork where B: BlockT, + BE: Backend + Unpin + 'static, + C: crate::ClientForGrandpa+ 'static, N: NetworkT, NumberFor: BlockNumberOps, - RA: 'static + Send + Sync, - E: CallExecutor + Send + Sync + 'static, - Bk: Backend + 'static, - Client: AuxStore, { type Output = Result<(), Error>; @@ -379,6 +377,7 @@ mod tests { use crate::{aux_schema, communication::tests::{Event, make_test_network}}; use substrate_test_runtime_client::{TestClientBuilder, TestClientBuilderExt}; use sc_network::PeerId; + use sp_blockchain::HeaderBackend as _; use futures::executor; @@ -406,7 +405,7 @@ mod tests { let persistent_data = aux_schema::load_persistent( &*backend, - client.chain_info().genesis_hash, + client.info().genesis_hash, 0, || Ok(vec![]), ).unwrap(); diff --git a/client/finality-grandpa/src/tests.rs b/client/finality-grandpa/src/tests.rs index 16b50ccb9f226..7b5880f7ee5eb 100644 --- a/client/finality-grandpa/src/tests.rs +++ b/client/finality-grandpa/src/tests.rs @@ -20,12 +20,12 @@ use super::*; use environment::HasVoted; use sc_network_test::{ Block, Hash, TestNetFactory, BlockImportAdapter, Peer, - PeersClient, PassThroughVerifier, + PeersClient, PassThroughVerifier, PeersFullClient, }; use sc_network::config::{ProtocolConfig, Roles, BoxFinalityProofRequestBuilder}; use parking_lot::Mutex; use futures_timer::Delay; -use tokio::runtime::current_thread; +use tokio::runtime::{Runtime, Handle}; use sp_keyring::Ed25519Keyring; use sc_client::LongestChain; use sc_client_api::backend::TransactionFor; @@ -47,23 +47,20 @@ use sp_runtime::generic::{BlockId, DigestItem}; use sp_core::{H256, NativeOrEncoded, ExecutionContext, crypto::Public}; use sp_finality_grandpa::{GRANDPA_ENGINE_ID, AuthorityList, GrandpaApi}; use sp_state_machine::{InMemoryBackend, prove_read, read_proof_check}; -use futures01::Async; -use futures::compat::Future01CompatExt; use authorities::AuthoritySet; use finality_proof::{ FinalityProofProvider, AuthoritySetForFinalityProver, AuthoritySetForFinalityChecker, }; use consensus_changes::ConsensusChanges; +use sc_block_builder::BlockBuilderProvider; type PeerData = Mutex< Option< LinkHalf< - substrate_test_runtime_client::Backend, - substrate_test_runtime_client::Executor, Block, - substrate_test_runtime_client::runtime::RuntimeApi, + PeersFullClient, LongestChain > > @@ -371,27 +368,25 @@ fn create_keystore(authority: Ed25519Keyring) -> (KeyStorePtr, tempfile::TempDir (keystore, keystore_path) } -fn block_until_complete(future: impl Future + Unpin, net: &Arc>, runtime: &mut current_thread::Runtime) { - let drive_to_completion = futures01::future::poll_fn(|| { - net.lock().poll(); Ok::, ()>(Async::NotReady) +fn block_until_complete(future: impl Future + Unpin, net: &Arc>, runtime: &mut Runtime) { + let drive_to_completion = futures::future::poll_fn(|cx| { + net.lock().poll(cx); Poll::<()>::Pending }); runtime.block_on( - future::select(future, drive_to_completion.compat()) - .map(|_| Ok::<(), ()>(())) - .compat() - ).unwrap(); + future::select(future, drive_to_completion) + ); } // run the voters to completion. provide a closure to be invoked after // the voters are spawned but before blocking on them. fn run_to_completion_with( - runtime: &mut current_thread::Runtime, + runtime: &mut Runtime, blocks: u64, net: Arc>, peers: &[Ed25519Keyring], with: F, ) -> u64 where - F: FnOnce(current_thread::Handle) -> Option>>> + F: FnOnce(Handle) -> Option>>> { use parking_lot::RwLock; @@ -399,7 +394,7 @@ fn run_to_completion_with( let highest_finalized = Arc::new(RwLock::new(0)); - if let Some(f) = (with)(runtime.handle()) { + if let Some(f) = (with)(runtime.handle().clone()) { wait_for.push(f); }; @@ -452,12 +447,13 @@ fn run_to_completion_with( on_exit: Exit, telemetry_on_connect: None, voting_rule: (), + prometheus_registry: None, }; let voter = run_grandpa_voter(grandpa_params).expect("all in order with client and network"); assert_send(&voter); - runtime.spawn(voter.unit_error().compat()); + runtime.spawn(voter); } // wait for all finalized on each. @@ -469,7 +465,7 @@ fn run_to_completion_with( } fn run_to_completion( - runtime: &mut current_thread::Runtime, + runtime: &mut Runtime, blocks: u64, net: Arc>, peers: &[Ed25519Keyring] @@ -498,13 +494,13 @@ fn add_forced_change( #[test] fn finalize_3_voters_no_observers() { let _ = env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); + let mut runtime = Runtime::new().unwrap(); let peers = &[Ed25519Keyring::Alice, Ed25519Keyring::Bob, Ed25519Keyring::Charlie]; let voters = make_ids(peers); let mut net = GrandpaTestNet::new(TestApi::new(voters), 3); net.peer(0).push_blocks(20, false); - net.block_until_sync(&mut runtime); + net.block_until_sync(); for i in 0..3 { assert_eq!(net.peer(i).client().info().best_number, 20, @@ -523,14 +519,14 @@ fn finalize_3_voters_no_observers() { #[test] fn finalize_3_voters_1_full_observer() { - let mut runtime = current_thread::Runtime::new().unwrap(); + let mut runtime = Runtime::new().unwrap(); let peers = &[Ed25519Keyring::Alice, Ed25519Keyring::Bob, Ed25519Keyring::Charlie]; let voters = make_ids(peers); let mut net = GrandpaTestNet::new(TestApi::new(voters), 4); net.peer(0).push_blocks(20, false); - net.block_until_sync(&mut runtime); + net.block_until_sync(); let net = Arc::new(Mutex::new(net)); let mut finality_notifications = Vec::new(); @@ -583,13 +579,14 @@ fn finalize_3_voters_1_full_observer() { on_exit: Exit, telemetry_on_connect: None, voting_rule: (), + prometheus_registry: None, }; voters.push(run_grandpa_voter(grandpa_params).expect("all in order with client and network")); } for voter in voters { - runtime.spawn(voter.unit_error().compat()); + runtime.spawn(voter); } // wait for all finalized on each. @@ -627,10 +624,10 @@ fn transition_3_voters_twice_1_full_observer() { let api = TestApi::new(genesis_voters); let net = Arc::new(Mutex::new(GrandpaTestNet::new(api, 8))); - let mut runtime = current_thread::Runtime::new().unwrap(); + let mut runtime = Runtime::new().unwrap(); net.lock().peer(0).push_blocks(1, false); - net.lock().block_until_sync(&mut runtime); + net.lock().block_until_sync(); for (i, peer) in net.lock().peers().iter().enumerate() { let full_client = peer.client().as_full().expect("only full clients are used in test"); @@ -690,7 +687,7 @@ fn transition_3_voters_twice_1_full_observer() { future::ready(()) }); - runtime.spawn(block_production.unit_error().compat()); + runtime.spawn(block_production); } let mut finality_notifications = Vec::new(); @@ -746,10 +743,11 @@ fn transition_3_voters_twice_1_full_observer() { on_exit: Exit, telemetry_on_connect: None, voting_rule: (), + prometheus_registry: None, }; let voter = run_grandpa_voter(grandpa_params).expect("all in order with client and network"); - runtime.spawn(voter.unit_error().compat()); + runtime.spawn(voter); } // wait for all finalized on each. @@ -760,14 +758,14 @@ fn transition_3_voters_twice_1_full_observer() { #[test] fn justification_is_emitted_when_consensus_data_changes() { - let mut runtime = current_thread::Runtime::new().unwrap(); + let mut runtime = Runtime::new().unwrap(); let peers = &[Ed25519Keyring::Alice, Ed25519Keyring::Bob, Ed25519Keyring::Charlie]; let mut net = GrandpaTestNet::new(TestApi::new(make_ids(peers)), 3); // import block#1 WITH consensus data change let new_authorities = vec![sp_consensus_babe::AuthorityId::from_slice(&[42; 32])]; net.peer(0).push_authorities_change_block(new_authorities); - net.block_until_sync(&mut runtime); + net.block_until_sync(); let net = Arc::new(Mutex::new(net)); run_to_completion(&mut runtime, 1, net.clone(), peers); @@ -778,13 +776,13 @@ fn justification_is_emitted_when_consensus_data_changes() { #[test] fn justification_is_generated_periodically() { - let mut runtime = current_thread::Runtime::new().unwrap(); + let mut runtime = Runtime::new().unwrap(); let peers = &[Ed25519Keyring::Alice, Ed25519Keyring::Bob, Ed25519Keyring::Charlie]; let voters = make_ids(peers); let mut net = GrandpaTestNet::new(TestApi::new(voters), 3); net.peer(0).push_blocks(32, false); - net.block_until_sync(&mut runtime); + net.block_until_sync(); let net = Arc::new(Mutex::new(net)); run_to_completion(&mut runtime, 32, net.clone(), peers); @@ -817,7 +815,7 @@ fn consensus_changes_works() { #[test] fn sync_justifications_on_change_blocks() { - let mut runtime = current_thread::Runtime::new().unwrap(); + let mut runtime = Runtime::new().unwrap(); let peers_a = &[Ed25519Keyring::Alice, Ed25519Keyring::Bob, Ed25519Keyring::Charlie]; let peers_b = &[Ed25519Keyring::Alice, Ed25519Keyring::Bob]; let voters = make_ids(peers_b); @@ -841,7 +839,7 @@ fn sync_justifications_on_change_blocks() { // add more blocks on top of it (until we have 25) net.peer(0).push_blocks(4, false); - net.block_until_sync(&mut runtime); + net.block_until_sync(); for i in 0..4 { assert_eq!(net.peer(i).client().info().best_number, 25, @@ -858,9 +856,9 @@ fn sync_justifications_on_change_blocks() { } // the last peer should get the justification by syncing from other peers - futures::executor::block_on(futures::future::poll_fn(move |_| { + futures::executor::block_on(futures::future::poll_fn(move |cx| { if net.lock().peer(3).client().justification(&BlockId::Number(21)).unwrap().is_none() { - net.lock().poll(); + net.lock().poll(cx); Poll::Pending } else { Poll::Ready(()) @@ -871,7 +869,7 @@ fn sync_justifications_on_change_blocks() { #[test] fn finalizes_multiple_pending_changes_in_order() { let _ = env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); + let mut runtime = Runtime::new().unwrap(); let peers_a = &[Ed25519Keyring::Alice, Ed25519Keyring::Bob, Ed25519Keyring::Charlie]; let peers_b = &[Ed25519Keyring::Dave, Ed25519Keyring::Eve, Ed25519Keyring::Ferdie]; @@ -916,7 +914,7 @@ fn finalizes_multiple_pending_changes_in_order() { // add more blocks on top of it (until we have 30) net.peer(0).push_blocks(4, false); - net.block_until_sync(&mut runtime); + net.block_until_sync(); // all peers imported both change blocks for i in 0..6 { @@ -931,7 +929,7 @@ fn finalizes_multiple_pending_changes_in_order() { #[test] fn force_change_to_new_set() { let _ = env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); + let mut runtime = Runtime::new().unwrap(); // two of these guys are offline. let genesis_authorities = &[ Ed25519Keyring::Alice, @@ -966,7 +964,7 @@ fn force_change_to_new_set() { }); net.lock().peer(0).push_blocks(25, false); - net.lock().block_until_sync(&mut runtime); + net.lock().block_until_sync(); for (i, peer) in net.lock().peers().iter().enumerate() { assert_eq!(peer.client().info().best_number, 26, @@ -1094,7 +1092,7 @@ fn voter_persists_its_votes() { use futures::channel::mpsc; let _ = env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); + let mut runtime = Runtime::new().unwrap(); // we have two authorities but we'll only be running the voter for alice // we are going to be listening for the prevotes it casts @@ -1104,7 +1102,7 @@ fn voter_persists_its_votes() { // alice has a chain with 20 blocks let mut net = GrandpaTestNet::new(TestApi::new(voters.clone()), 2); net.peer(0).push_blocks(20, false); - net.block_until_sync(&mut runtime); + net.block_until_sync(); assert_eq!(net.peer(0).client().info().best_number, 20, "Peer #{} failed to sync", 0); @@ -1171,6 +1169,7 @@ fn voter_persists_its_votes() { on_exit: Exit, telemetry_on_connect: None, voting_rule: VotingRulesBuilder::default().build(), + prometheus_registry: None, }; let voter = run_grandpa_voter(grandpa_params) @@ -1202,7 +1201,7 @@ fn voter_persists_its_votes() { net: net.clone(), client: client.clone(), keystore, - }.unit_error().compat()); + }); } let (exit_tx, exit_rx) = futures::channel::oneshot::channel::<()>(); @@ -1247,10 +1246,7 @@ fn voter_persists_its_votes() { HasVoted::No, ); - runtime.spawn( - network.map_err(|e| panic!("network bridge should not error: {:?}", e)) - .compat(), - ); + runtime.spawn(network); let round_tx = Arc::new(Mutex::new(round_tx)); let exit_tx = Arc::new(Mutex::new(Some(exit_tx))); @@ -1342,7 +1338,7 @@ fn voter_persists_its_votes() { panic!() } } - }).map(Ok).boxed().compat()); + })); } block_until_complete(exit_rx.into_future(), &net, &mut runtime); @@ -1351,13 +1347,13 @@ fn voter_persists_its_votes() { #[test] fn finalize_3_voters_1_light_observer() { let _ = env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); + let mut runtime = Runtime::new().unwrap(); let authorities = &[Ed25519Keyring::Alice, Ed25519Keyring::Bob, Ed25519Keyring::Charlie]; let voters = make_ids(authorities); let mut net = GrandpaTestNet::new(TestApi::new(voters), 4); net.peer(0).push_blocks(20, false); - net.block_until_sync(&mut runtime); + net.block_until_sync(); for i in 0..4 { assert_eq!(net.peer(i).client().info().best_number, 20, @@ -1387,8 +1383,8 @@ fn finalize_3_voters_1_light_observer() { link, net.lock().peers[3].network_service().clone(), Exit, - ).unwrap().unit_error().compat() - ).unwrap(); + ).unwrap() + ); Some(Box::pin(finality_notifications.map(|_| ()))) }); @@ -1397,7 +1393,7 @@ fn finalize_3_voters_1_light_observer() { #[test] fn finality_proof_is_fetched_by_light_client_when_consensus_data_changes() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); + let mut runtime = Runtime::new().unwrap(); let peers = &[Ed25519Keyring::Alice]; let mut net = GrandpaTestNet::new(TestApi::new(make_ids(peers)), 1); @@ -1408,18 +1404,17 @@ fn finality_proof_is_fetched_by_light_client_when_consensus_data_changes() { net.peer(0).push_authorities_change_block(vec![sp_consensus_babe::AuthorityId::from_slice(&[42; 32])]); let net = Arc::new(Mutex::new(net)); run_to_completion(&mut runtime, 1, net.clone(), peers); - net.lock().block_until_sync(&mut runtime); + net.lock().block_until_sync(); // check that the block#1 is finalized on light client - let mut runtime = current_thread::Runtime::new().unwrap(); - let _ = runtime.block_on(futures::future::poll_fn(move |_| { + runtime.block_on(futures::future::poll_fn(move |cx| { if net.lock().peer(1).client().info().finalized_number == 1 { Poll::Ready(()) } else { - net.lock().poll(); + net.lock().poll(cx); Poll::Pending } - }).unit_error().compat()); + })); } #[test] @@ -1428,7 +1423,7 @@ fn empty_finality_proof_is_returned_to_light_client_when_authority_set_is_differ const FORCE_CHANGE: bool = true; let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); + let mut runtime = Runtime::new().unwrap(); // two of these guys are offline. let genesis_authorities = if FORCE_CHANGE { @@ -1473,14 +1468,14 @@ fn empty_finality_proof_is_returned_to_light_client_when_authority_set_is_differ vec![sp_consensus_babe::AuthorityId::from_slice(&[42; 32])] ); // #10 net.lock().peer(0).push_blocks(1, false); // best is #11 - net.lock().block_until_sync(&mut runtime); + net.lock().block_until_sync(); // finalize block #11 on full clients run_to_completion(&mut runtime, 11, net.clone(), peers_a); // request finalization by light client net.lock().add_light_peer(&GrandpaTestNet::default_config()); - net.lock().block_until_sync(&mut runtime); + net.lock().block_until_sync(); // check block, finalized on light client assert_eq!( @@ -1492,14 +1487,14 @@ fn empty_finality_proof_is_returned_to_light_client_when_authority_set_is_differ #[test] fn voter_catches_up_to_latest_round_when_behind() { let _ = env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); + let mut runtime = Runtime::new().unwrap(); let peers = &[Ed25519Keyring::Alice, Ed25519Keyring::Bob]; let voters = make_ids(peers); let mut net = GrandpaTestNet::new(TestApi::new(voters), 3); net.peer(0).push_blocks(50, false); - net.block_until_sync(&mut runtime); + net.block_until_sync(); let net = Arc::new(Mutex::new(net)); let mut finality_notifications = Vec::new(); @@ -1520,6 +1515,7 @@ fn voter_catches_up_to_latest_round_when_behind() { on_exit: Exit, telemetry_on_connect: None, voting_rule: (), + prometheus_registry: None, }; Box::pin(run_grandpa_voter(grandpa_params).expect("all in order with client and network")) @@ -1549,19 +1545,18 @@ fn voter_catches_up_to_latest_round_when_behind() { let voter = voter(Some(keystore), peer_id, link, net.clone()); - runtime.spawn(voter.unit_error().compat()); + runtime.spawn(voter); } // wait for them to finalize block 50. since they'll vote on 3/4 of the // unfinalized chain it will take at least 4 rounds to do it. - let wait_for_finality = ::futures::future::join_all(finality_notifications) - .map(|_| ()); + let wait_for_finality = ::futures::future::join_all(finality_notifications); // spawn a new voter, it should be behind by at least 4 rounds and should be // able to catch up to the latest round let test = { let net = net.clone(); - let runtime = runtime.handle(); + let runtime = runtime.handle().clone(); wait_for_finality.then(move |_| { let peer_id = 2; @@ -1575,7 +1570,7 @@ fn voter_catches_up_to_latest_round_when_behind() { let voter = voter(None, peer_id, link, net); - runtime.spawn(voter.unit_error().compat()).unwrap(); + runtime.spawn(voter); let start_time = std::time::Instant::now(); let timeout = Duration::from_secs(5 * 60); @@ -1596,14 +1591,12 @@ fn voter_catches_up_to_latest_round_when_behind() { }) }; - let drive_to_completion = futures01::future::poll_fn(|| { - net.lock().poll(); Ok::, ()>(Async::NotReady) + let drive_to_completion = futures::future::poll_fn(|cx| { + net.lock().poll(cx); Poll::<()>::Pending }); runtime.block_on( - future::select(test, drive_to_completion.compat()) - .map(|_| Ok::<(), ()>(())) - .compat() - ).unwrap(); + future::select(test, drive_to_completion) + ); } #[test] @@ -1654,6 +1647,8 @@ fn grandpa_environment_respects_voting_rules() { voters: Arc::new(authority_set.current_authorities()), network, voting_rule, + metrics: None, + _phantom: PhantomData, } }; diff --git a/client/informant/Cargo.toml b/client/informant/Cargo.toml index f60abeee349fa..a29d793c3601b 100644 --- a/client/informant/Cargo.toml +++ b/client/informant/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sc-informant" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] description = "Substrate informant." edition = "2018" @@ -14,8 +14,8 @@ futures = "0.3.1" log = "0.4.8" parity-util-mem = { version = "0.5.1", default-features = false, features = ["primitive-types"] } wasm-timer = "0.2" -sc-client-api = { version = "2.0.0-dev", path = "../api" } -sc-network = { version = "0.8.0-dev", path = "../network" } -sc-service = { version = "0.8.0-dev", default-features = false, path = "../service" } -sp-blockchain = { version = "2.0.0-dev", path = "../../primitives/blockchain" } -sp-runtime = { version = "2.0.0-dev", path = "../../primitives/runtime" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../api" } +sc-network = { version = "0.8.0-alpha.2", path = "../network" } +sc-service = { version = "0.8.0-alpha.2", default-features = false, path = "../service" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../primitives/blockchain" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../primitives/runtime" } diff --git a/client/informant/src/lib.rs b/client/informant/src/lib.rs index 699dcfdd7425e..d104a64a2dbd1 100644 --- a/client/informant/src/lib.rs +++ b/client/informant/src/lib.rs @@ -46,7 +46,10 @@ pub fn build(service: &impl AbstractService, format: OutputFormat) -> impl futur if let Some(ref usage) = info.usage { trace!(target: "usage", "Usage statistics: {}", usage); } else { - trace!(target: "usage", "Usage statistics not displayed as backend does not provide it") + trace!( + target: "usage", + "Usage statistics not displayed as backend does not provide it", + ) } #[cfg(not(target_os = "unknown"))] trace!( diff --git a/client/keystore/Cargo.toml b/client/keystore/Cargo.toml index 221449d34ef9a..247376bc46e17 100644 --- a/client/keystore/Cargo.toml +++ b/client/keystore/Cargo.toml @@ -1,16 +1,19 @@ [package] name = "sc-keystore" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Keystore (and session key management) for ed25519 based chains like Polkadot." +documentation = "https://docs.rs/sc-keystore" + [dependencies] derive_more = "0.99.2" -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -sp-application-crypto = { version = "2.0.0-dev", path = "../../primitives/application-crypto" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +sp-application-crypto = { version = "2.0.0-alpha.2", path = "../../primitives/application-crypto" } hex = "0.4.0" rand = "0.7.2" serde_json = "1.0.41" diff --git a/client/network-gossip/Cargo.toml b/client/network-gossip/Cargo.toml index 25b0548c840c7..08c304c6e0614 100644 --- a/client/network-gossip/Cargo.toml +++ b/client/network-gossip/Cargo.toml @@ -1,20 +1,22 @@ [package] description = "Gossiping for the Substrate network protocol" name = "sc-network-gossip" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" license = "GPL-3.0" authors = ["Parity Technologies "] edition = "2018" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +documentation = "https://docs.rs/sc-network-gossip" + [dependencies] futures = "0.3.1" futures-timer = "3.0.1" -libp2p = { version = "0.16.1", default-features = false, features = ["libp2p-websocket"] } +libp2p = { version = "0.16.2", default-features = false, features = ["libp2p-websocket"] } log = "0.4.8" -lru = "0.1.2" +lru = "0.4.3" parking_lot = "0.10.0" -sc-network = { version = "0.8.0-dev", path = "../network" } -sp-runtime = { version = "2.0.0-dev", path = "../../primitives/runtime" } +sc-network = { version = "0.8.0-alpha.2", path = "../network" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../primitives/runtime" } wasm-timer = "0.2" diff --git a/client/network-gossip/src/state_machine.rs b/client/network-gossip/src/state_machine.rs index 26433e63ec3ea..db5ea3603dcac 100644 --- a/client/network-gossip/src/state_machine.rs +++ b/client/network-gossip/src/state_machine.rs @@ -258,6 +258,7 @@ impl ConsensusGossip { let mut context = NetworkContext { gossip: self, network, engine_id: engine_id.clone() }; v.peer_disconnected(&mut context, &who); } + self.peers.remove(&who); } /// Perform periodic maintenance @@ -644,4 +645,52 @@ mod tests { let _ = consensus.live_message_sinks.remove(&([0, 0, 0, 0], topic)); assert_eq!(stream.next(), None); } + + #[test] + fn peer_is_removed_on_disconnect() { + struct TestNetwork; + impl Network for TestNetwork { + fn event_stream( + &self, + ) -> std::pin::Pin + Send>> { + unimplemented!("Not required in tests") + } + + fn report_peer(&self, _: PeerId, _: crate::ReputationChange) { + unimplemented!("Not required in tests") + } + + fn disconnect_peer(&self, _: PeerId) { + unimplemented!("Not required in tests") + } + + fn write_notification(&self, _: PeerId, _: crate::ConsensusEngineId, _: Vec) { + unimplemented!("Not required in tests") + } + + fn register_notifications_protocol( + &self, + _: ConsensusEngineId, + _: std::borrow::Cow<'static, [u8]>, + ) { + unimplemented!("Not required in tests") + } + + fn announce(&self, _: H256, _: Vec) { + unimplemented!("Not required in tests") + } + } + + let mut consensus = ConsensusGossip::::new(); + consensus.register_validator_internal([0, 0, 0, 0], Arc::new(AllowAll)); + + let mut network = TestNetwork; + + let peer_id = PeerId::random(); + consensus.new_peer(&mut network, peer_id.clone(), Roles::FULL); + assert!(consensus.peers.contains_key(&peer_id)); + + consensus.peer_disconnected(&mut network, peer_id.clone()); + assert!(!consensus.peers.contains_key(&peer_id)); + } } diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index 48a6fee638a87..d99dce2fd2cdd 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -1,12 +1,14 @@ [package] description = "Substrate network protocol" name = "sc-network" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" license = "GPL-3.0" authors = ["Parity Technologies "] edition = "2018" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +documentation = "https://docs.rs/sc-network" + [build-dependencies] prost-build = "0.6.1" @@ -14,17 +16,17 @@ prost-build = "0.6.1" [dependencies] bitflags = "1.2.0" bytes = "0.5.0" -codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "1.2.0", features = ["derive"] } derive_more = "0.99.2" either = "1.5.3" erased-serde = "0.3.9" fnv = "1.0.6" -fork-tree = { version = "2.0.0-dev", path = "../../utils/fork-tree" } +fork-tree = { version = "2.0.0-alpha.2", path = "../../utils/fork-tree" } futures = "0.3.1" futures_codec = "0.3.3" futures-timer = "3.0.1" wasm-timer = "0.2" -libp2p = { version = "0.16.1", default-features = false, features = ["libp2p-websocket"] } +libp2p = { version = "0.16.2", default-features = false, features = ["libp2p-websocket"] } linked-hash-map = "0.5.2" linked_hash_set = "0.1.3" log = "0.4.8" @@ -34,25 +36,23 @@ parking_lot = "0.10.0" prost = "0.6.1" rand = "0.7.2" rustc-hex = "2.0.1" -sc-block-builder = { version = "0.8.0-dev", path = "../block-builder" } -sc-client = { version = "0.8.0-dev", path = "../" } -sc-client-api = { version = "2.0.0-dev", path = "../api" } -sc-peerset = { version = "2.0.0-dev", path = "../peerset" } +sc-block-builder = { version = "0.8.0-alpha.2", path = "../block-builder" } +sc-client = { version = "0.8.0-alpha.2", path = "../" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../api" } +sc-peerset = { version = "2.0.0-alpha.2", path = "../peerset" } pin-project = "0.4.6" serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" slog = { version = "2.5.2", features = ["nested-values"] } slog_derive = "0.2.0" smallvec = "0.6.10" -sp-arithmetic = { version = "2.0.0-dev", path = "../../primitives/arithmetic" } -sp-blockchain = { version = "2.0.0-dev", path = "../../primitives/blockchain" } -sp-consensus = { version = "0.8.0-dev", path = "../../primitives/consensus/common" } -sp-consensus-babe = { version = "0.8.0-dev", path = "../../primitives/consensus/babe" } -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -sp-keyring = { version = "2.0.0-dev", optional = true, path = "../../primitives/keyring" } -sp-runtime = { version = "2.0.0-dev", path = "../../primitives/runtime" } -substrate-test-client = { version = "2.0.0-dev", optional = true, path = "../../test-utils/client" } -substrate-test-runtime-client = { version = "2.0.0-dev", optional = true, path = "../../test-utils/runtime/client" } +sp-arithmetic = { version = "2.0.0-alpha.2", path = "../../primitives/arithmetic" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../primitives/blockchain" } +sp-consensus = { version = "0.8.0-alpha.2", path = "../../primitives/consensus/common" } +sp-consensus-babe = { version = "0.8.0-alpha.2", path = "../../primitives/consensus/babe" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../primitives/runtime" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.8.0-alpha.2", path = "../../utils/prometheus" } thiserror = "1" unsigned-varint = { version = "0.3.1", features = ["futures", "futures-codec"] } void = "1.0.2" @@ -64,7 +64,7 @@ assert_matches = "1.3" env_logger = "0.7.0" quickcheck = "0.9.0" rand = "0.7.2" -sp-keyring = { version = "2.0.0-dev", path = "../../primitives/keyring" } +sp-keyring = { version = "2.0.0-alpha.2", path = "../../primitives/keyring" } sp-test-primitives = { version = "2.0.0-dev", path = "../../primitives/test-primitives" } substrate-test-runtime = { version = "2.0.0-dev", path = "../../test-utils/runtime" } substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../test-utils/runtime/client" } @@ -72,4 +72,4 @@ tempfile = "3.1.0" [features] default = [] -test-helpers = ["sp-keyring", "substrate-test-runtime-client"] + diff --git a/client/network/src/config.rs b/client/network/src/config.rs index f5cad5977fc47..76c0c9b5440f7 100644 --- a/client/network/src/config.rs +++ b/client/network/src/config.rs @@ -41,6 +41,7 @@ use core::{fmt, iter}; use std::{future::Future, pin::Pin}; use std::{error::Error, fs, io::{self, Write}, net::Ipv4Addr, path::{Path, PathBuf}, sync::Arc}; use zeroize::Zeroize; +use prometheus_endpoint::Registry; /// Network initialization parameters. pub struct Params { @@ -90,6 +91,9 @@ pub struct Params { /// Type to check incoming block announcements. pub block_announce_validator: Box + Send>, + + /// Registry for recording prometheus metrics to. + pub metrics_registry: Option, } bitflags! { diff --git a/client/network/src/error.rs b/client/network/src/error.rs index ba5d5c2d0d2b5..158e75fcf1d72 100644 --- a/client/network/src/error.rs +++ b/client/network/src/error.rs @@ -45,6 +45,8 @@ pub enum Error { /// The second peer id that was found for the bootnode. second_id: PeerId, }, + /// Prometheus metrics error. + Prometheus(prometheus_endpoint::PrometheusError) } // Make `Debug` use the `Display` implementation. @@ -60,6 +62,7 @@ impl std::error::Error for Error { Error::Io(ref err) => Some(err), Error::Client(ref err) => Some(err), Error::DuplicateBootnode { .. } => None, + Error::Prometheus(ref err) => Some(err), } } } diff --git a/client/network/src/protocol.rs b/client/network/src/protocol.rs index dd8b5e6c28ee4..d344321e68dd0 100644 --- a/client/network/src/protocol.rs +++ b/client/network/src/protocol.rs @@ -131,6 +131,8 @@ mod rep { pub const BAD_PROTOCOL: Rep = Rep::new_fatal("Unsupported protocol"); /// Peer role does not match (e.g. light peer connecting to another light peer). pub const BAD_ROLE: Rep = Rep::new_fatal("Unsupported role"); + /// Peer response data does not have requested bits. + pub const BAD_RESPONSE: Rep = Rep::new(-(1 << 12), "Incomplete response"); } // Lock must always be taken in order declared here. @@ -701,12 +703,14 @@ impl Protocol { peer: PeerId, request: message::BlockRequest ) { - trace!(target: "sync", "BlockRequest {} from {}: from {:?} to {:?} max {:?}", + trace!(target: "sync", "BlockRequest {} from {}: from {:?} to {:?} max {:?} for {:?}", request.id, peer, request.from, request.to, - request.max); + request.max, + request.fields, + ); // sending block requests to the node that is unable to serve it is considered a bad behavior if !self.config.roles.is_full() { @@ -754,6 +758,11 @@ impl Protocol { message_queue: None, justification, }; + // Stop if we don't have requested block body + if get_body && block_data.body.is_none() { + trace!(target: "sync", "Missing data for block request."); + break; + } blocks.push(block_data); match request.direction { message::Direction::Ascending => id = BlockId::Number(number + One::one()), @@ -784,7 +793,7 @@ impl Protocol { request: message::BlockRequest, response: message::BlockResponse, ) -> CustomMessageOutcome { - let blocks_range = match ( + let blocks_range = || match ( response.blocks.first().and_then(|b| b.header.as_ref().map(|h| h.number())), response.blocks.last().and_then(|b| b.header.as_ref().map(|h| h.number())), ) { @@ -796,7 +805,7 @@ impl Protocol { response.id, peer, response.blocks.len(), - blocks_range + blocks_range(), ); if request.fields == message::BlockAttributes::JUSTIFICATION { @@ -811,6 +820,20 @@ impl Protocol { } } } else { + // Validate fields against the request. + if request.fields.contains(message::BlockAttributes::HEADER) && response.blocks.iter().any(|b| b.header.is_none()) { + self.behaviour.disconnect_peer(&peer); + self.peerset_handle.report_peer(peer, rep::BAD_RESPONSE); + trace!(target: "sync", "Missing header for a block"); + return CustomMessageOutcome::None + } + if request.fields.contains(message::BlockAttributes::BODY) && response.blocks.iter().any(|b| b.body.is_none()) { + self.behaviour.disconnect_peer(&peer); + self.peerset_handle.report_peer(peer, rep::BAD_RESPONSE); + trace!(target: "sync", "Missing body for a block"); + return CustomMessageOutcome::None + } + match self.sync.on_block_data(peer, Some(request), response) { Ok(sync::OnBlockData::Import(origin, blocks)) => CustomMessageOutcome::BlockImport(origin, blocks), diff --git a/client/network/src/protocol/block_requests.rs b/client/network/src/protocol/block_requests.rs index ef970657c5ff9..20a99378b16c9 100644 --- a/client/network/src/protocol/block_requests.rs +++ b/client/network/src/protocol/block_requests.rs @@ -111,7 +111,7 @@ impl Config { let mut v = Vec::new(); v.extend_from_slice(b"/"); v.extend_from_slice(id.as_bytes()); - v.extend_from_slice(b"/sync/1"); + v.extend_from_slice(b"/sync/2"); self.protocol = v.into(); self } @@ -146,8 +146,7 @@ where , request: &api::v1::BlockRequest ) -> Result { - log::trace!("block request {} from peer {}: from block {:?} to block {:?}, max blocks {:?}", - request.id, + log::trace!("block request from peer {}: from block {:?} to block {:?}, max blocks {:?}", peer, request.from_block, request.to_block, @@ -242,7 +241,7 @@ where } } - Ok(api::v1::BlockResponse { id: request.id, blocks }) + Ok(api::v1::BlockResponse { blocks }) } } @@ -274,10 +273,10 @@ where fn inject_node_event(&mut self, peer: PeerId, Request(request, mut stream): Request) { match self.on_block_request(&peer, &request) { Ok(res) => { - log::trace!("enqueueing block response {} for peer {} with {} blocks", res.id, peer, res.blocks.len()); + log::trace!("enqueueing block response for peer {} with {} blocks", peer, res.blocks.len()); let mut data = Vec::with_capacity(res.encoded_len()); if let Err(e) = res.encode(&mut data) { - log::debug!("error encoding block response {} for peer {}: {}", res.id, peer, e) + log::debug!("error encoding block response for peer {}: {}", peer, e) } else { let future = async move { if let Err(e) = write_one(&mut stream, data).await { @@ -287,7 +286,7 @@ where self.outgoing.push(future.boxed()) } } - Err(e) => log::debug!("error handling block request {} from peer {}: {}", request.id, peer, e) + Err(e) => log::debug!("error handling block request from peer {}: {}", peer, e) } } diff --git a/client/network/src/protocol/light_client_handler.rs b/client/network/src/protocol/light_client_handler.rs index 77cf71408d6c4..b531f3515a6ec 100644 --- a/client/network/src/protocol/light_client_handler.rs +++ b/client/network/src/protocol/light_client_handler.rs @@ -127,7 +127,7 @@ impl Config { let mut v = Vec::new(); v.extend_from_slice(b"/"); v.extend_from_slice(id.as_bytes()); - v.extend_from_slice(b"/light/1"); + v.extend_from_slice(b"/light/2"); self.protocol = v.into(); self } @@ -350,7 +350,7 @@ where , response: api::v1::light::Response ) -> Result, Error> { - log::trace!("response {} from {}", response.id, peer); + log::trace!("response from {}", peer); use api::v1::light::response::Response; match response.response { Some(Response::RemoteCallResponse(response)) => @@ -419,12 +419,10 @@ where fn on_remote_call_request ( &mut self , peer: &PeerId - , request_id: u64 , request: &api::v1::light::RemoteCallRequest ) -> Result { - log::trace!("remote call request {} from {} ({} at {:?})", - request_id, + log::trace!("remote call request from {} ({} at {:?})", peer, request.method, request.block); @@ -434,8 +432,7 @@ where let proof = match self.chain.execution_proof(&block, &request.method, &request.data) { Ok((_, proof)) => proof, Err(e) => { - log::trace!("remote call request {} from {} ({} at {:?}) failed with: {}", - request_id, + log::trace!("remote call request from {} ({} at {:?}) failed with: {}", peer, request.method, request.block, @@ -449,13 +446,12 @@ where api::v1::light::response::Response::RemoteCallResponse(r) }; - Ok(api::v1::light::Response { id: request_id, response: Some(response) }) + Ok(api::v1::light::Response { response: Some(response) }) } fn on_remote_read_request ( &mut self , peer: &PeerId - , request_id: u64 , request: &api::v1::light::RemoteReadRequest ) -> Result { @@ -464,8 +460,7 @@ where return Err(Error::BadRequest("remote read request without keys")) } - log::trace!("remote read request {} from {} ({} at {:?})", - request_id, + log::trace!("remote read request from {} ({} at {:?})", peer, fmt_keys(request.keys.first(), request.keys.last()), request.block); @@ -475,8 +470,7 @@ where let proof = match self.chain.read_proof(&block, &request.keys) { Ok(proof) => proof, Err(error) => { - log::trace!("remote read request {} from {} ({} at {:?}) failed with: {}", - request_id, + log::trace!("remote read request from {} ({} at {:?}) failed with: {}", peer, fmt_keys(request.keys.first(), request.keys.last()), request.block, @@ -490,13 +484,12 @@ where api::v1::light::response::Response::RemoteReadResponse(r) }; - Ok(api::v1::light::Response { id: request_id, response: Some(response) }) + Ok(api::v1::light::Response { response: Some(response) }) } fn on_remote_read_child_request ( &mut self , peer: &PeerId - , request_id: u64 , request: &api::v1::light::RemoteReadChildRequest ) -> Result { @@ -505,8 +498,7 @@ where return Err(Error::BadRequest("remove read child request without keys")) } - log::trace!("remote read child request {} from {} ({} {} at {:?})", - request_id, + log::trace!("remote read child request from {} ({} {} at {:?})", peer, request.storage_key.to_hex::(), fmt_keys(request.keys.first(), request.keys.last()), @@ -519,8 +511,7 @@ where match self.chain.read_child_proof(&block, &request.storage_key, info, &request.keys) { Ok(proof) => proof, Err(error) => { - log::trace!("remote read child request {} from {} ({} {} at {:?}) failed with: {}", - request_id, + log::trace!("remote read child request from {} ({} {} at {:?}) failed with: {}", peer, request.storage_key.to_hex::(), fmt_keys(request.keys.first(), request.keys.last()), @@ -530,8 +521,7 @@ where } } } else { - log::trace!("remote read child request {} from {} ({} {} at {:?}) failed with: {}", - request_id, + log::trace!("remote read child request from {} ({} {} at {:?}) failed with: {}", peer, request.storage_key.to_hex::(), fmt_keys(request.keys.first(), request.keys.last()), @@ -546,25 +536,23 @@ where api::v1::light::response::Response::RemoteReadResponse(r) }; - Ok(api::v1::light::Response { id: request_id, response: Some(response) }) + Ok(api::v1::light::Response { response: Some(response) }) } fn on_remote_header_request ( &mut self , peer: &PeerId - , request_id: u64 , request: &api::v1::light::RemoteHeaderRequest ) -> Result { - log::trace!("remote header proof request {} from {} ({:?})", request_id, peer, request.block); + log::trace!("remote header proof request from {} ({:?})", peer, request.block); let block = Decode::decode(&mut request.block.as_ref())?; let (header, proof) = match self.chain.header_proof(block) { Ok((header, proof)) => (header.encode(), proof), Err(error) => { - log::trace!("remote header proof request {} from {} ({:?}) failed with: {}", - request_id, + log::trace!("remote header proof request from {} ({:?}) failed with: {}", peer, request.block, error); @@ -577,18 +565,16 @@ where api::v1::light::response::Response::RemoteHeaderResponse(r) }; - Ok(api::v1::light::Response { id: request_id, response: Some(response) }) + Ok(api::v1::light::Response { response: Some(response) }) } fn on_remote_changes_request ( &mut self , peer: &PeerId - , request_id: u64 , request: &api::v1::light::RemoteChangesRequest ) -> Result { - log::trace!("remote changes proof request {} from {} for key {} ({:?}..{:?})", - request_id, + log::trace!("remote changes proof request from {} for key {} ({:?}..{:?})", peer, if !request.storage_key.is_empty() { format!("{} : {}", request.storage_key.to_hex::(), request.key.to_hex::()) @@ -613,8 +599,7 @@ where let proof = match self.chain.key_changes_proof(first, last, min, max, storage_key.as_ref(), &key) { Ok(proof) => proof, Err(error) => { - log::trace!("remote changes proof request {} from {} for key {} ({:?}..{:?}) failed with: {}", - request_id, + log::trace!("remote changes proof request from {} for key {} ({:?}..{:?}) failed with: {}", peer, if let Some(sk) = storage_key { format!("{} : {}", sk.0.to_hex::(), key.0.to_hex::()) @@ -646,7 +631,7 @@ where api::v1::light::response::Response::RemoteChangesResponse(r) }; - Ok(api::v1::light::Response { id: request_id, response: Some(response) }) + Ok(api::v1::light::Response { response: Some(response) }) } } @@ -697,29 +682,29 @@ where match event { // An incoming request from remote has been received. Event::Request(request, mut stream) => { - log::trace!("incoming request {} from {}", peer, request.id); + log::trace!("incoming request from {}", peer); let result = match &request.request { Some(api::v1::light::request::Request::RemoteCallRequest(r)) => - self.on_remote_call_request(&peer, request.id, r), + self.on_remote_call_request(&peer, r), Some(api::v1::light::request::Request::RemoteReadRequest(r)) => - self.on_remote_read_request(&peer, request.id, r), + self.on_remote_read_request(&peer, r), Some(api::v1::light::request::Request::RemoteHeaderRequest(r)) => - self.on_remote_header_request(&peer, request.id, r), + self.on_remote_header_request(&peer, r), Some(api::v1::light::request::Request::RemoteReadChildRequest(r)) => - self.on_remote_read_child_request(&peer, request.id, r), + self.on_remote_read_child_request(&peer, r), Some(api::v1::light::request::Request::RemoteChangesRequest(r)) => - self.on_remote_changes_request(&peer, request.id, r), + self.on_remote_changes_request(&peer, r), None => { - log::debug!("ignoring request {} without request data from peer {}", request.id, peer); + log::debug!("ignoring request without request data from peer {}", peer); return } }; match result { Ok(response) => { - log::trace!("enqueueing response {} for peer {}", response.id, peer); + log::trace!("enqueueing response for peer {}", peer); let mut data = Vec::new(); if let Err(e) = response.encode(&mut data) { - log::debug!("error encoding response {} for peer {}: {}", response.id, peer, e) + log::debug!("error encoding response for peer {}: {}", peer, e) } else { let future = async move { if let Err(e) = write_one(&mut stream, data).await { @@ -733,16 +718,15 @@ where self.remove_peer(&peer); self.peerset.report_peer(peer, ReputationChange::new(-(1 << 12), "bad request")) } - Err(e) => log::debug!("error handling request {} from peer {}: {}", request.id, peer, e) + Err(e) => log::debug!("error handling request from peer {}: {}", peer, e) } } // A response to one of our own requests has been received. - Event::Response(response) => { - let id = response.id; + Event::Response(id, response) => { if let Some(request) = self.outstanding.remove(&id) { // We first just check if the response originates from the expected peer. if request.peer != peer { - log::debug!("was expecting response {} from {} instead of {}", id, request.peer, peer); + log::debug!("was expecting response from {} instead of {}", request.peer, peer); self.outstanding.insert(id, request); self.remove_peer(&peer); self.peerset.report_peer(peer, ReputationChange::new_fatal("response from unexpected peer")); @@ -836,16 +820,17 @@ where } }; if let Some(peer) = available_peer { - let id = self.next_request_id(); - let rq = serialize_request(id, &request.request); + let rq = serialize_request(&request.request); let mut buf = Vec::with_capacity(rq.encoded_len()); if let Err(e) = rq.encode(&mut buf) { - log::debug!("failed to serialize request {}: {}", id, e); + log::debug!("failed to serialize request: {}", e); send_reply(Err(ClientError::RemoteFetchFailed), request.request) } else { + let id = self.next_request_id(); log::trace!("sending request {} to peer {}", id, peer); let protocol = OutboundProtocol { request: buf, + request_id: id, max_data_size: self.config.max_data_size, protocol: self.config.protocol.clone(), }; @@ -918,7 +903,7 @@ fn retries(request: &Request) -> usize { rc.unwrap_or(0) } -fn serialize_request(id: u64, request: &Request) -> api::v1::light::Request { +fn serialize_request(request: &Request) -> api::v1::light::Request { let request = match request { Request::Header { request, .. } => { let r = api::v1::light::RemoteHeaderRequest { block: request.block.encode() }; @@ -962,7 +947,7 @@ fn serialize_request(id: u64, request: &Request) -> api::v1::light: } }; - api::v1::light::Request { id, request: Some(request) } + api::v1::light::Request { request: Some(request) } } fn send_reply(result: Result, ClientError>, request: Request) { @@ -1004,7 +989,7 @@ pub enum Event { /// Incoming request from remote and substream to use for the response. Request(api::v1::light::Request, T), /// Incoming response from remote. - Response(api::v1::light::Response), + Response(u64, api::v1::light::Response), } /// Substream upgrade protocol. @@ -1054,6 +1039,8 @@ where pub struct OutboundProtocol { /// The serialized protobuf request. request: Vec, + /// Local identifier for the request. Used to associate it with a response. + request_id: u64, /// The max. request length in bytes. max_data_size: usize, /// The protocol to use for upgrade negotiation. @@ -1082,7 +1069,7 @@ where write_one(&mut s, &self.request).await?; let vec = read_one(&mut s, self.max_data_size).await?; api::v1::light::Response::decode(&vec[..]) - .map(Event::Response) + .map(|r| Event::Response(self.request_id, r)) .map_err(|e| { ReadOneError::Io(io::Error::new(io::ErrorKind::Other, e)) }) @@ -1308,53 +1295,6 @@ mod tests { assert_eq!(0, behaviour.outstanding.len()); } - #[test] - fn disconnects_from_peer_on_response_with_wrong_id() { - let peer = PeerId::random(); - let pset = peerset(); - let mut behaviour = make_behaviour(true, pset.1, make_config()); - - behaviour.inject_connected(peer.clone(), empty_dialer()); - assert_eq!(1, behaviour.peers.len()); - - let chan = oneshot::channel(); - let request = fetcher::RemoteCallRequest { - block: Default::default(), - header: dummy_header(), - method: "test".into(), - call_data: vec![], - retry_count: Some(1), - }; - behaviour.request(Request::Call { request, sender: chan.0 }).unwrap(); - - assert_eq!(1, behaviour.pending_requests.len()); - assert_eq!(0, behaviour.outstanding.len()); - poll(&mut behaviour); // Make progress - assert_eq!(0, behaviour.pending_requests.len()); - assert_eq!(1, behaviour.outstanding.len()); - - // Construct response with bogus ID - let response = { - let r = api::v1::light::RemoteCallResponse { proof: empty_proof() }; - api::v1::light::Response { - id: 2365789, - response: Some(api::v1::light::response::Response::RemoteCallResponse(r)), - } - }; - - // Make sure our bogus ID is really not used. - assert!(!behaviour.outstanding.keys().any(|id| id == &response.id)); - - behaviour.inject_node_event(peer.clone(), Event::Response(response)); - assert!(behaviour.peers.is_empty()); - - poll(&mut behaviour); // More progress - - // The request should be back in the pending queue - assert_eq!(1, behaviour.pending_requests.len()); - assert_eq!(0, behaviour.outstanding.len()); - } - #[test] fn disconnects_from_peer_on_incorrect_response() { let peer = PeerId::random(); @@ -1386,12 +1326,11 @@ mod tests { let response = { let r = api::v1::light::RemoteCallResponse { proof: empty_proof() }; api::v1::light::Response { - id: request_id, response: Some(api::v1::light::response::Response::RemoteCallResponse(r)), } }; - behaviour.inject_node_event(peer.clone(), Event::Response(response)); + behaviour.inject_node_event(peer.clone(), Event::Response(request_id, response)); assert!(behaviour.peers.is_empty()); poll(&mut behaviour); // More progress @@ -1416,12 +1355,11 @@ mod tests { let response = { let r = api::v1::light::RemoteCallResponse { proof: empty_proof() }; api::v1::light::Response { - id: 2347895932, response: Some(api::v1::light::response::Response::RemoteCallResponse(r)), } }; - behaviour.inject_node_event(peer.clone(), Event::Response(response)); + behaviour.inject_node_event(peer.clone(), Event::Response(2347895932, response)); assert!(behaviour.peers.is_empty()); poll(&mut behaviour); @@ -1459,12 +1397,11 @@ mod tests { let response = { let r = api::v1::light::RemoteReadResponse { proof: empty_proof() }; // Not a RemoteCallResponse! api::v1::light::Response { - id: request_id, response: Some(api::v1::light::response::Response::RemoteReadResponse(r)), } }; - behaviour.inject_node_event(peer.clone(), Event::Response(response)); + behaviour.inject_node_event(peer.clone(), Event::Response(request_id, response)); assert!(behaviour.peers.is_empty()); poll(&mut behaviour); // More progress @@ -1513,11 +1450,10 @@ mod tests { let response = { let r = api::v1::light::RemoteCallResponse { proof: empty_proof() }; api::v1::light::Response { - id: request_id, response: Some(api::v1::light::response::Response::RemoteCallResponse(r)) } }; - behaviour.inject_node_event(responding_peer, Event::Response(response.clone())); + behaviour.inject_node_event(responding_peer, Event::Response(request_id, response.clone())); assert_matches!(poll(&mut behaviour), Poll::Ready(NetworkBehaviourAction::SendEvent { .. })); assert_matches!(chan.1.try_recv(), Ok(None)) } @@ -1527,11 +1463,10 @@ mod tests { let response = { let r = api::v1::light::RemoteCallResponse { proof: empty_proof() }; api::v1::light::Response { - id: request_id, response: Some(api::v1::light::response::Response::RemoteCallResponse(r)), } }; - behaviour.inject_node_event(responding_peer, Event::Response(response)); + behaviour.inject_node_event(responding_peer, Event::Response(request_id, response)); assert_matches!(poll(&mut behaviour), Poll::Pending); assert_matches!(chan.1.try_recv(), Ok(Some(Err(ClientError::RemoteFetchFailed)))) } @@ -1551,28 +1486,24 @@ mod tests { proof: empty_proof() }; api::v1::light::Response { - id: 1, response: Some(api::v1::light::response::Response::RemoteHeaderResponse(r)), } } Request::Read{..} => { let r = api::v1::light::RemoteReadResponse { proof: empty_proof() }; api::v1::light::Response { - id: 1, response: Some(api::v1::light::response::Response::RemoteReadResponse(r)), } } Request::ReadChild{..} => { let r = api::v1::light::RemoteReadResponse { proof: empty_proof() }; api::v1::light::Response { - id: 1, response: Some(api::v1::light::response::Response::RemoteReadResponse(r)), } } Request::Call{..} => { let r = api::v1::light::RemoteCallResponse { proof: empty_proof() }; api::v1::light::Response { - id: 1, response: Some(api::v1::light::response::Response::RemoteCallResponse(r)), } } @@ -1584,7 +1515,6 @@ mod tests { roots_proof: empty_proof() }; api::v1::light::Response { - id: 1, response: Some(api::v1::light::response::Response::RemoteChangesResponse(r)), } } @@ -1599,7 +1529,7 @@ mod tests { assert_eq!(1, behaviour.outstanding.len()); assert_eq!(1, *behaviour.outstanding.keys().next().unwrap()); - behaviour.inject_node_event(peer.clone(), Event::Response(response)); + behaviour.inject_node_event(peer.clone(), Event::Response(1, response)); poll(&mut behaviour); diff --git a/client/network/src/protocol/schema/api.v1.proto b/client/network/src/protocol/schema/api.v1.proto index 73128c53de466..ccbf49d666115 100644 --- a/client/network/src/protocol/schema/api.v1.proto +++ b/client/network/src/protocol/schema/api.v1.proto @@ -14,31 +14,27 @@ enum Direction { // Request block data from a peer. message BlockRequest { - // Unique request id. - uint64 id = 1; // Bits of block data to request. - uint32 fields = 2; + uint32 fields = 1; // Start from this block. oneof from_block { // Start with given hash. - bytes hash = 3; + bytes hash = 2; // Start with given block number. - bytes number = 4; + bytes number = 3; } // End at this block. An implementation defined maximum is used when unspecified. - bytes to_block = 5; // optional + bytes to_block = 4; // optional // Sequence direction. - Direction direction = 6; + Direction direction = 5; // Maximum number of blocks to return. An implementation defined maximum is used when unspecified. - uint32 max_blocks = 7; // optional + uint32 max_blocks = 6; // optional } // Response to `BlockRequest` message BlockResponse { - // Id of a request this response was made for. - uint64 id = 1; // Block data for the requested sequence. - repeated BlockData blocks = 2; + repeated BlockData blocks = 1; } // Block data sent in the response. diff --git a/client/network/src/protocol/schema/light.v1.proto b/client/network/src/protocol/schema/light.v1.proto index b9aee67b5ee24..1c98d49730cf9 100644 --- a/client/network/src/protocol/schema/light.v1.proto +++ b/client/network/src/protocol/schema/light.v1.proto @@ -14,26 +14,22 @@ message Pair { // Enumerate all possible light client request messages. message Request { - // Unique request id. - uint64 id = 1; oneof request { - RemoteCallRequest remote_call_request = 2; - RemoteReadRequest remote_read_request = 3; - RemoteHeaderRequest remote_header_request = 4; - RemoteReadChildRequest remote_read_child_request = 5; - RemoteChangesRequest remote_changes_request = 6; + RemoteCallRequest remote_call_request = 1; + RemoteReadRequest remote_read_request = 2; + RemoteHeaderRequest remote_header_request = 3; + RemoteReadChildRequest remote_read_child_request = 4; + RemoteChangesRequest remote_changes_request = 5; } } // Enumerate all possible light client response messages. message Response { - /// Id of a request this response was made for. - uint64 id = 1; oneof response { - RemoteCallResponse remote_call_response = 2; - RemoteReadResponse remote_read_response = 3; - RemoteHeaderResponse remote_header_response = 4; - RemoteChangesResponse remote_changes_response = 6; + RemoteCallResponse remote_call_response = 1; + RemoteReadResponse remote_read_response = 2; + RemoteHeaderResponse remote_header_response = 3; + RemoteChangesResponse remote_changes_response = 4; } } diff --git a/client/network/src/protocol/sync.rs b/client/network/src/protocol/sync.rs index 0c5355ea21f90..d0427e61a818c 100644 --- a/client/network/src/protocol/sync.rs +++ b/client/network/src/protocol/sync.rs @@ -751,7 +751,7 @@ impl ChainSync { | PeerSyncState::DownloadingFinalityProof(..) => Vec::new() } } else { - // When request.is_none() just accept blocks + // When request.is_none() this is a block announcement. Just accept blocks. blocks.into_iter().map(|b| { IncomingBlock { hash: b.hash, @@ -1167,8 +1167,7 @@ impl ChainSync { } /// Restart the sync process. - fn restart<'a>(&'a mut self) -> impl Iterator), BadPeer>> + 'a - { + fn restart<'a>(&'a mut self) -> impl Iterator), BadPeer>> + 'a { self.queue_blocks.clear(); self.blocks.clear(); let info = self.client.info(); diff --git a/client/network/src/protocol/sync/blocks.rs b/client/network/src/protocol/sync/blocks.rs index d4e4581c670bd..279150a225506 100644 --- a/client/network/src/protocol/sync/blocks.rs +++ b/client/network/src/protocol/sync/blocks.rs @@ -104,8 +104,7 @@ impl BlockCollection { common: NumberFor, max_parallel: u32, max_ahead: u32, - ) -> Option>> - { + ) -> Option>> { if peer_best <= common { // Bail out early return None; @@ -165,20 +164,20 @@ impl BlockCollection { pub fn drain(&mut self, from: NumberFor) -> Vec> { let mut drained = Vec::new(); let mut ranges = Vec::new(); - { - let mut prev = from; - for (start, range_data) in &mut self.blocks { - match range_data { - &mut BlockRangeState::Complete(ref mut blocks) if *start <= prev => { - prev = *start + (blocks.len() as u32).into(); - let mut blocks = mem::replace(blocks, Vec::new()); - drained.append(&mut blocks); - ranges.push(*start); - }, - _ => break, - } + + let mut prev = from; + for (start, range_data) in &mut self.blocks { + match range_data { + &mut BlockRangeState::Complete(ref mut blocks) if *start <= prev => { + prev = *start + (blocks.len() as u32).into(); + // Remove all elements from `blocks` and add them to `drained` + drained.append(blocks); + ranges.push(*start); + }, + _ => break, } } + for r in ranges { self.blocks.remove(&r); } diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 288289d95c81e..821847add1df1 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -39,6 +39,7 @@ use libp2p::swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent}; use parking_lot::Mutex; use sc_peerset::PeersetHandle; use sp_runtime::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId}; +use prometheus_endpoint::{Registry, Gauge, U64, register, PrometheusError}; use crate::{behaviour::{Behaviour, BehaviourOut}, config::{parse_str_addr, parse_addr}}; use crate::{transport, config::NonReservedPeerMode, ReputationChange}; @@ -294,6 +295,10 @@ impl NetworkWorker { from_worker, light_client_rqs: params.on_demand.and_then(|od| od.extract_receiver()), event_streams: Vec::new(), + metrics: match params.metrics_registry { + Some(registry) => Some(Metrics::register(®istry)?), + None => None + } }) } @@ -727,6 +732,26 @@ pub struct NetworkWorker { light_client_rqs: Option>>, /// Senders for events that happen on the network. event_streams: Vec>, + /// Prometheus network metrics. + metrics: Option +} + +struct Metrics { + is_major_syncing: Gauge, + peers_count: Gauge, +} + +impl Metrics { + fn register(registry: &Registry) -> Result { + Ok(Self { + is_major_syncing: register(Gauge::new( + "is_major_syncing", "Whether the node is performing a major sync or not.", + )?, registry)?, + peers_count: register(Gauge::new( + "peers_count", "Number of network gossip peers", + )?, registry)?, + }) + } } impl Future for NetworkWorker { @@ -818,16 +843,26 @@ impl Future for NetworkWorker { }; } + let num_connected_peers = this.network_service.user_protocol_mut().num_connected_peers(); + // Update the variables shared with the `NetworkService`. - this.num_connected.store(this.network_service.user_protocol_mut().num_connected_peers(), Ordering::Relaxed); + this.num_connected.store(num_connected_peers, Ordering::Relaxed); { let external_addresses = Swarm::::external_addresses(&this.network_service).cloned().collect(); *this.external_addresses.lock() = external_addresses; } - this.is_major_syncing.store(match this.network_service.user_protocol_mut().sync_state() { + + let is_major_syncing = match this.network_service.user_protocol_mut().sync_state() { SyncState::Idle => false, SyncState::Downloading => true, - }, Ordering::Relaxed); + }; + + this.is_major_syncing.store(is_major_syncing, Ordering::Relaxed); + + if let Some(metrics) = this.metrics.as_ref() { + metrics.is_major_syncing.set(is_major_syncing as u64); + metrics.peers_count.set(num_connected_peers as u64); + } Poll::Pending } diff --git a/client/network/test/Cargo.toml b/client/network/test/Cargo.toml index 5f8a1b6d5e950..7fec4f4da8b47 100644 --- a/client/network/test/Cargo.toml +++ b/client/network/test/Cargo.toml @@ -10,24 +10,22 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -sc-network = { version = "0.8.0-dev", path = "../" } +sc-network = { version = "0.8.0-alpha.2", path = "../" } log = "0.4.8" parking_lot = "0.10.0" -futures = "0.1.29" -futures03 = { package = "futures", version = "0.3.1", features = ["compat"] } +futures = "0.3.1" futures-timer = "3.0.1" rand = "0.7.2" -libp2p = { version = "0.16.1", default-features = false, features = ["libp2p-websocket"] } -sp-consensus = { version = "0.8.0-dev", path = "../../../primitives/consensus/common" } -sc-client = { version = "0.8.0-dev", path = "../../" } -sc-client-api = { version = "2.0.0-dev", path = "../../api" } -sp-blockchain = { version = "2.0.0-dev", path = "../../../primitives/blockchain" } -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } -sc-block-builder = { version = "0.8.0-dev", path = "../../block-builder" } -sp-consensus-babe = { version = "0.8.0-dev", path = "../../../primitives/consensus/babe" } +libp2p = { version = "0.16.2", default-features = false, features = ["libp2p-websocket"] } +sp-consensus = { version = "0.8.0-alpha.2", path = "../../../primitives/consensus/common" } +sc-client = { version = "0.8.0-alpha.2", path = "../../" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../../api" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../../primitives/blockchain" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } +sc-block-builder = { version = "0.8.0-alpha.2", path = "../../block-builder" } +sp-consensus-babe = { version = "0.8.0-alpha.2", path = "../../../primitives/consensus/babe" } env_logger = "0.7.0" substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../../test-utils/runtime/client" } substrate-test-runtime = { version = "2.0.0-dev", path = "../../../test-utils/runtime" } tempfile = "3.1.0" -tokio = "0.1.22" diff --git a/client/network/test/src/lib.rs b/client/network/test/src/lib.rs index 982e2ff512396..0add6c63d5ac9 100644 --- a/client/network/test/src/lib.rs +++ b/client/network/test/src/lib.rs @@ -21,7 +21,7 @@ mod block_import; #[cfg(test)] mod sync; -use std::{collections::HashMap, pin::Pin, sync::Arc, marker::PhantomData}; +use std::{collections::HashMap, pin::Pin, sync::Arc, marker::PhantomData, task::{Poll, Context as FutureContext}}; use libp2p::build_multiaddr; use log::trace; @@ -35,7 +35,7 @@ use sc_client_api::{ FinalityNotification, backend::{TransactionFor, AuxStore, Backend, Finalizer}, }; -use sc_block_builder::BlockBuilder; +use sc_block_builder::{BlockBuilder, BlockBuilderProvider}; use sc_client::LongestChain; use sc_network::config::Roles; use sp_consensus::block_validation::DefaultBlockAnnounceValidator; @@ -46,7 +46,6 @@ use sp_consensus::block_import::{BlockImport, ImportResult}; use sp_consensus::Error as ConsensusError; use sp_consensus::{BlockOrigin, ForkChoiceStrategy, BlockImportParams, BlockCheckParams, JustificationImport}; use futures::prelude::*; -use futures03::{Future as _, FutureExt as _, TryFutureExt as _, StreamExt as _, TryStreamExt as _}; use sc_network::{NetworkWorker, NetworkStateInfo, NetworkService, ReportHandle, config::ProtocolId}; use sc_network::config::{NetworkConfiguration, TransportConfig, BoxFinalityProofRequestBuilder}; use libp2p::PeerId; @@ -187,8 +186,8 @@ pub struct Peer { select_chain: Option>, backend: Option>, network: NetworkWorker::Hash>, - imported_blocks_stream: Box, Error = ()> + Send>, - finality_notification_stream: Box, Error = ()> + Send>, + imported_blocks_stream: Pin> + Send>>, + finality_notification_stream: Pin> + Send>>, } impl Peer { @@ -237,7 +236,7 @@ impl Peer { where F: FnMut(BlockBuilder) -> Block { let best_hash = self.client.info().best_hash; - self.generate_blocks_at(BlockId::Hash(best_hash), count, origin, edit_block) + self.generate_blocks_at(BlockId::Hash(best_hash), count, origin, edit_block, false) } /// Add blocks to the peer -- edit the block before adding. The chain will @@ -247,7 +246,8 @@ impl Peer { at: BlockId, count: usize, origin: BlockOrigin, - mut edit_block: F + mut edit_block: F, + headers_only: bool, ) -> H256 where F: FnMut(BlockBuilder) -> Block { let full_client = self.client.as_full() .expect("blocks could only be generated by full clients"); @@ -272,7 +272,7 @@ impl Peer { origin, header.clone(), None, - Some(block.extrinsics) + if headers_only { None } else { Some(block.extrinsics) }, ).unwrap(); let cache = if let Some(cache) = cache { cache.into_iter().collect() @@ -294,28 +294,46 @@ impl Peer { self.push_blocks_at(BlockId::Hash(best_hash), count, with_tx) } + /// Push blocks to the peer (simplified: with or without a TX) + pub fn push_headers(&mut self, count: usize) -> H256 { + let best_hash = self.client.info().best_hash; + self.generate_tx_blocks_at(BlockId::Hash(best_hash), count, false, true) + } + /// Push blocks to the peer (simplified: with or without a TX) starting from /// given hash. pub fn push_blocks_at(&mut self, at: BlockId, count: usize, with_tx: bool) -> H256 { + self.generate_tx_blocks_at(at, count, with_tx, false) + } + + /// Push blocks/headers to the peer (simplified: with or without a TX) starting from + /// given hash. + fn generate_tx_blocks_at(&mut self, at: BlockId, count: usize, with_tx: bool, headers_only:bool) -> H256 { let mut nonce = 0; if with_tx { - self.generate_blocks_at(at, count, BlockOrigin::File, |mut builder| { - let transfer = Transfer { - from: AccountKeyring::Alice.into(), - to: AccountKeyring::Alice.into(), - amount: 1, - nonce, - }; - builder.push(transfer.into_signed_tx()).unwrap(); - nonce = nonce + 1; - builder.build().unwrap().block - }) + self.generate_blocks_at( + at, + count, + BlockOrigin::File, |mut builder| { + let transfer = Transfer { + from: AccountKeyring::Alice.into(), + to: AccountKeyring::Alice.into(), + amount: 1, + nonce, + }; + builder.push(transfer.into_signed_tx()).unwrap(); + nonce = nonce + 1; + builder.build().unwrap().block + }, + headers_only + ) } else { self.generate_blocks_at( at, count, BlockOrigin::File, |builder| builder.build().unwrap().block, + headers_only, ) } } @@ -622,7 +640,8 @@ pub trait TestNetFactory: Sized { transaction_pool: Arc::new(EmptyTransactionPool), protocol_id: ProtocolId::from(&b"test-protocol-name"[..]), import_queue, - block_announce_validator: Box::new(DefaultBlockAnnounceValidator::new(client.clone())) + block_announce_validator: Box::new(DefaultBlockAnnounceValidator::new(client.clone())), + metrics_registry: None, }).unwrap(); self.mut_peers(|peers| { @@ -630,10 +649,8 @@ pub trait TestNetFactory: Sized { peer.network.add_known_address(network.service().local_peer_id(), listen_addr.clone()); } - let imported_blocks_stream = Box::new(client.import_notification_stream() - .map(|v| Ok::<_, ()>(v)).compat().fuse()); - let finality_notification_stream = Box::new(client.finality_notification_stream() - .map(|v| Ok::<_, ()>(v)).compat().fuse()); + let imported_blocks_stream = Box::pin(client.import_notification_stream().fuse()); + let finality_notification_stream = Box::pin(client.finality_notification_stream().fuse()); peers.push(Peer { data, @@ -697,7 +714,8 @@ pub trait TestNetFactory: Sized { transaction_pool: Arc::new(EmptyTransactionPool), protocol_id: ProtocolId::from(&b"test-protocol-name"[..]), import_queue, - block_announce_validator: Box::new(DefaultBlockAnnounceValidator::new(client.clone())) + block_announce_validator: Box::new(DefaultBlockAnnounceValidator::new(client.clone())), + metrics_registry: None, }).unwrap(); self.mut_peers(|peers| { @@ -705,10 +723,8 @@ pub trait TestNetFactory: Sized { peer.network.add_known_address(network.service().local_peer_id(), listen_addr.clone()); } - let imported_blocks_stream = Box::new(client.import_notification_stream() - .map(|v| Ok::<_, ()>(v)).compat().fuse()); - let finality_notification_stream = Box::new(client.finality_notification_stream() - .map(|v| Ok::<_, ()>(v)).compat().fuse()); + let imported_blocks_stream = Box::pin(client.import_notification_stream().fuse()); + let finality_notification_stream = Box::pin(client.finality_notification_stream().fuse()); peers.push(Peer { data, @@ -727,46 +743,70 @@ pub trait TestNetFactory: Sized { /// Polls the testnet until all nodes are in sync. /// /// Must be executed in a task context. - fn poll_until_sync(&mut self) -> Async<()> { - self.poll(); + fn poll_until_sync(&mut self, cx: &mut FutureContext) -> Poll<()> { + self.poll(cx); // Return `NotReady` if there's a mismatch in the highest block number. let mut highest = None; for peer in self.peers().iter() { if peer.is_major_syncing() || peer.network.num_queued_blocks() != 0 { - return Async::NotReady + return Poll::Pending } if peer.network.num_sync_requests() != 0 { - return Async::NotReady + return Poll::Pending } match (highest, peer.client.info().best_hash) { (None, b) => highest = Some(b), (Some(ref a), ref b) if a == b => {}, - (Some(_), _) => return Async::NotReady, + (Some(_), _) => return Poll::Pending + } + } + Poll::Ready(()) + } + + /// Polls the testnet until theres' no activiy of any kind. + /// + /// Must be executed in a task context. + fn poll_until_idle(&mut self, cx: &mut FutureContext) -> Poll<()> { + self.poll(cx); + + for peer in self.peers().iter() { + if peer.is_major_syncing() || peer.network.num_queued_blocks() != 0 { + return Poll::Pending + } + if peer.network.num_sync_requests() != 0 { + return Poll::Pending } } - Async::Ready(()) + Poll::Ready(()) } /// Blocks the current thread until we are sync'ed. /// - /// Calls `poll_until_sync` repeatedly with the runtime passed as parameter. - fn block_until_sync(&mut self, runtime: &mut tokio::runtime::current_thread::Runtime) { - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| Ok(self.poll_until_sync()))).unwrap(); + /// Calls `poll_until_sync` repeatedly. + fn block_until_sync(&mut self) { + futures::executor::block_on(futures::future::poll_fn::<(), _>(|cx| self.poll_until_sync(cx))); + } + + /// Blocks the current thread until there are no pending packets. + /// + /// Calls `poll_until_idle` repeatedly with the runtime passed as parameter. + fn block_until_idle(&mut self) { + futures::executor::block_on(futures::future::poll_fn::<(), _>(|cx| self.poll_until_idle(cx))); } /// Polls the testnet. Processes all the pending actions and returns `NotReady`. - fn poll(&mut self) { + fn poll(&mut self, cx: &mut FutureContext) { self.mut_peers(|peers| { for peer in peers { trace!(target: "sync", "-- Polling {}", peer.id()); - futures03::future::poll_fn(|cx| Pin::new(&mut peer.network).poll(cx)) - .map(|item| Ok::<_, ()>(item)) - .compat().poll().unwrap(); + if let Poll::Ready(res) = Pin::new(&mut peer.network).poll(cx) { + res.unwrap(); + } trace!(target: "sync", "-- Polling complete {}", peer.id()); // We poll `imported_blocks_stream`. - while let Ok(Async::Ready(Some(notification))) = peer.imported_blocks_stream.poll() { + while let Poll::Ready(Some(notification)) = peer.imported_blocks_stream.as_mut().poll_next(cx) { peer.network.on_block_imported( notification.header, Vec::new(), @@ -776,7 +816,7 @@ pub trait TestNetFactory: Sized { // We poll `finality_notification_stream`, but we only take the last event. let mut last = None; - while let Ok(Async::Ready(Some(item))) = peer.finality_notification_stream.poll() { + while let Poll::Ready(Some(item)) = peer.finality_notification_stream.as_mut().poll_next(cx) { last = Some(item); } if let Some(notification) = last { diff --git a/client/network/test/src/sync.rs b/client/network/test/src/sync.rs index 210a4fb38bb68..3882575168320 100644 --- a/client/network/test/src/sync.rs +++ b/client/network/test/src/sync.rs @@ -16,14 +16,12 @@ use sc_network::config::Roles; use sp_consensus::BlockOrigin; -use futures03::TryFutureExt as _; use std::time::Duration; -use tokio::runtime::current_thread; +use futures::executor::block_on; use super::*; fn test_ancestor_search_when_common_is(n: usize) { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut net = TestNet::new(3); net.peer(0).push_blocks(n, false); @@ -34,7 +32,7 @@ fn test_ancestor_search_when_common_is(n: usize) { net.peer(1).push_blocks(100, false); net.peer(2).push_blocks(100, false); - net.block_until_sync(&mut runtime); + net.block_until_sync(); let peer1 = &net.peers()[1]; assert!(net.peers()[0].blockchain_canon_equals(peer1)); } @@ -42,24 +40,22 @@ fn test_ancestor_search_when_common_is(n: usize) { #[test] fn sync_peers_works() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut net = TestNet::new(3); - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| -> Result<_, ()> { - net.poll(); + block_on(futures::future::poll_fn::<(), _>(|cx| { + net.poll(cx); for peer in 0..3 { if net.peer(peer).num_peers() != 2 { - return Ok(Async::NotReady) + return Poll::Pending } } - Ok(Async::Ready(())) - })).unwrap(); + Poll::Ready(()) + })); } #[test] fn sync_cycle_from_offline_to_syncing_to_offline() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut net = TestNet::new(3); for peer in 0..3 { // Offline, and not major syncing. @@ -71,51 +67,50 @@ fn sync_cycle_from_offline_to_syncing_to_offline() { net.peer(2).push_blocks(100, false); // Block until all nodes are online and nodes 0 and 1 and major syncing. - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| -> Result<_, ()> { - net.poll(); + block_on(futures::future::poll_fn::<(), _>(|cx| { + net.poll(cx); for peer in 0..3 { // Online if net.peer(peer).is_offline() { - return Ok(Async::NotReady) + return Poll::Pending } if peer < 2 { // Major syncing. if net.peer(peer).blocks_count() < 100 && !net.peer(peer).is_major_syncing() { - return Ok(Async::NotReady) + return Poll::Pending } } } - Ok(Async::Ready(())) - })).unwrap(); + Poll::Ready(()) + })); // Block until all nodes are done syncing. - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| -> Result<_, ()> { - net.poll(); + block_on(futures::future::poll_fn::<(), _>(|cx| { + net.poll(cx); for peer in 0..3 { if net.peer(peer).is_major_syncing() { - return Ok(Async::NotReady) + return Poll::Pending } } - Ok(Async::Ready(())) - })).unwrap(); + Poll::Ready(()) + })); // Now drop nodes 1 and 2, and check that node 0 is offline. net.peers.remove(2); net.peers.remove(1); - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| -> Result<_, ()> { - net.poll(); + block_on(futures::future::poll_fn::<(), _>(|cx| { + net.poll(cx); if !net.peer(0).is_offline() { - Ok(Async::NotReady) + Poll::Pending } else { - Ok(Async::Ready(())) + Poll::Ready(()) } - })).unwrap(); + })); } #[test] fn syncing_node_not_major_syncing_when_disconnected() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut net = TestNet::new(3); // Generate blocks. @@ -125,36 +120,35 @@ fn syncing_node_not_major_syncing_when_disconnected() { assert!(!net.peer(1).is_major_syncing()); // Check that we switch to major syncing. - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| -> Result<_, ()> { - net.poll(); + block_on(futures::future::poll_fn::<(), _>(|cx| { + net.poll(cx); if !net.peer(1).is_major_syncing() { - Ok(Async::NotReady) + Poll::Pending } else { - Ok(Async::Ready(())) + Poll::Ready(()) } - })).unwrap(); + })); // Destroy two nodes, and check that we switch to non-major syncing. net.peers.remove(2); net.peers.remove(0); - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| -> Result<_, ()> { - net.poll(); + block_on(futures::future::poll_fn::<(), _>(|cx| { + net.poll(cx); if net.peer(0).is_major_syncing() { - Ok(Async::NotReady) + Poll::Pending } else { - Ok(Async::Ready(())) + Poll::Ready(()) } - })).unwrap(); + })); } #[test] fn sync_from_two_peers_works() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut net = TestNet::new(3); net.peer(1).push_blocks(100, false); net.peer(2).push_blocks(100, false); - net.block_until_sync(&mut runtime); + net.block_until_sync(); let peer1 = &net.peers()[1]; assert!(net.peers()[0].blockchain_canon_equals(peer1)); assert!(!net.peer(0).is_major_syncing()); @@ -163,12 +157,11 @@ fn sync_from_two_peers_works() { #[test] fn sync_from_two_peers_with_ancestry_search_works() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut net = TestNet::new(3); net.peer(0).push_blocks(10, true); net.peer(1).push_blocks(100, false); net.peer(2).push_blocks(100, false); - net.block_until_sync(&mut runtime); + net.block_until_sync(); let peer1 = &net.peers()[1]; assert!(net.peers()[0].blockchain_canon_equals(peer1)); } @@ -176,14 +169,13 @@ fn sync_from_two_peers_with_ancestry_search_works() { #[test] fn ancestry_search_works_when_backoff_is_one() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut net = TestNet::new(3); net.peer(0).push_blocks(1, false); net.peer(1).push_blocks(2, false); net.peer(2).push_blocks(2, false); - net.block_until_sync(&mut runtime); + net.block_until_sync(); let peer1 = &net.peers()[1]; assert!(net.peers()[0].blockchain_canon_equals(peer1)); } @@ -191,14 +183,13 @@ fn ancestry_search_works_when_backoff_is_one() { #[test] fn ancestry_search_works_when_ancestor_is_genesis() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut net = TestNet::new(3); net.peer(0).push_blocks(13, true); net.peer(1).push_blocks(100, false); net.peer(2).push_blocks(100, false); - net.block_until_sync(&mut runtime); + net.block_until_sync(); let peer1 = &net.peers()[1]; assert!(net.peers()[0].blockchain_canon_equals(peer1)); } @@ -221,10 +212,9 @@ fn ancestry_search_works_when_common_is_hundred() { #[test] fn sync_long_chain_works() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut net = TestNet::new(2); net.peer(1).push_blocks(500, false); - net.block_until_sync(&mut runtime); + net.block_until_sync(); let peer1 = &net.peers()[1]; assert!(net.peers()[0].blockchain_canon_equals(peer1)); } @@ -232,18 +222,17 @@ fn sync_long_chain_works() { #[test] fn sync_no_common_longer_chain_fails() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut net = TestNet::new(3); net.peer(0).push_blocks(20, true); net.peer(1).push_blocks(20, false); - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| -> Result<_, ()> { - net.poll(); + block_on(futures::future::poll_fn::<(), _>(|cx| { + net.poll(cx); if net.peer(0).is_major_syncing() { - Ok(Async::NotReady) + Poll::Pending } else { - Ok(Async::Ready(())) + Poll::Ready(()) } - })).unwrap(); + })); let peer1 = &net.peers()[1]; assert!(!net.peers()[0].blockchain_canon_equals(peer1)); } @@ -251,10 +240,9 @@ fn sync_no_common_longer_chain_fails() { #[test] fn sync_justifications() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut net = JustificationTestNet::new(3); net.peer(0).push_blocks(20, false); - net.block_until_sync(&mut runtime); + net.block_until_sync(); // there's currently no justification for block #10 assert_eq!(net.peer(0).client().justification(&BlockId::Number(10)).unwrap(), None); @@ -274,26 +262,25 @@ fn sync_justifications() { net.peer(1).request_justification(&h2.hash().into(), 15); net.peer(1).request_justification(&h3.hash().into(), 20); - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| { - net.poll(); + block_on(futures::future::poll_fn::<(), _>(|cx| { + net.poll(cx); for height in (10..21).step_by(5) { if net.peer(0).client().justification(&BlockId::Number(height)).unwrap() != Some(Vec::new()) { - return Ok(Async::NotReady); + return Poll::Pending; } if net.peer(1).client().justification(&BlockId::Number(height)).unwrap() != Some(Vec::new()) { - return Ok(Async::NotReady); + return Poll::Pending; } } - Ok(Async::Ready(())) - })).unwrap(); + Poll::Ready(()) + })); } #[test] fn sync_justifications_across_forks() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut net = JustificationTestNet::new(3); // we push 5 blocks net.peer(0).push_blocks(5, false); @@ -303,30 +290,29 @@ fn sync_justifications_across_forks() { // peer 1 will only see the longer fork. but we'll request justifications // for both and finalize the small fork instead. - net.block_until_sync(&mut runtime); + net.block_until_sync(); net.peer(0).client().finalize_block(BlockId::Hash(f1_best), Some(Vec::new()), true).unwrap(); net.peer(1).request_justification(&f1_best, 10); net.peer(1).request_justification(&f2_best, 11); - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| { - net.poll(); + block_on(futures::future::poll_fn::<(), _>(|cx| { + net.poll(cx); if net.peer(0).client().justification(&BlockId::Number(10)).unwrap() == Some(Vec::new()) && net.peer(1).client().justification(&BlockId::Number(10)).unwrap() == Some(Vec::new()) { - Ok(Async::Ready(())) + Poll::Ready(()) } else { - Ok(Async::NotReady) + Poll::Pending } - })).unwrap(); + })); } #[test] fn sync_after_fork_works() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut net = TestNet::new(3); net.peer(0).push_blocks(30, false); net.peer(1).push_blocks(30, false); @@ -340,7 +326,7 @@ fn sync_after_fork_works() { net.peer(2).push_blocks(1, false); // peer 1 has the best chain - net.block_until_sync(&mut runtime); + net.block_until_sync(); let peer1 = &net.peers()[1]; assert!(net.peers()[0].blockchain_canon_equals(peer1)); (net.peers()[1].blockchain_canon_equals(peer1)); @@ -350,7 +336,6 @@ fn sync_after_fork_works() { #[test] fn syncs_all_forks() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut net = TestNet::new(4); net.peer(0).push_blocks(2, false); net.peer(1).push_blocks(2, false); @@ -358,7 +343,7 @@ fn syncs_all_forks() { net.peer(0).push_blocks(2, true); net.peer(1).push_blocks(4, false); - net.block_until_sync(&mut runtime); + net.block_until_sync(); // Check that all peers have all of the blocks. assert_eq!(9, net.peer(0).blocks_count()); assert_eq!(9, net.peer(1).blocks_count()); @@ -367,12 +352,11 @@ fn syncs_all_forks() { #[test] fn own_blocks_are_announced() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut net = TestNet::new(3); - net.block_until_sync(&mut runtime); // connect'em + net.block_until_sync(); // connect'em net.peer(0).generate_blocks(1, BlockOrigin::Own, |builder| builder.build().unwrap().block); - net.block_until_sync(&mut runtime); + net.block_until_sync(); assert_eq!(net.peer(0).client.info().best_number, 1); assert_eq!(net.peer(1).client.info().best_number, 1); @@ -384,7 +368,6 @@ fn own_blocks_are_announced() { #[test] fn blocks_are_not_announced_by_light_nodes() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut net = TestNet::new(0); // full peer0 is connected to light peer @@ -397,7 +380,7 @@ fn blocks_are_not_announced_by_light_nodes() { // Sync between 0 and 1. net.peer(0).push_blocks(1, false); assert_eq!(net.peer(0).client.info().best_number, 1); - net.block_until_sync(&mut runtime); + net.block_until_sync(); assert_eq!(net.peer(1).client.info().best_number, 1); // Add another node and remove node 0. @@ -405,18 +388,17 @@ fn blocks_are_not_announced_by_light_nodes() { net.peers.remove(0); // Poll for a few seconds and make sure 1 and 2 (now 0 and 1) don't sync together. - let mut delay = futures_timer::Delay::new(Duration::from_secs(5)).unit_error().compat(); - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| { - net.poll(); - delay.poll().map_err(|_| ()) - })).unwrap(); + let mut delay = futures_timer::Delay::new(Duration::from_secs(5)); + block_on(futures::future::poll_fn::<(), _>(|cx| { + net.poll(cx); + Pin::new(&mut delay).poll(cx) + })); assert_eq!(net.peer(1).client.info().best_number, 0); } #[test] fn can_sync_small_non_best_forks() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut net = TestNet::new(2); net.peer(0).push_blocks(30, false); net.peer(1).push_blocks(30, false); @@ -435,14 +417,14 @@ fn can_sync_small_non_best_forks() { assert!(net.peer(1).client().header(&BlockId::Hash(small_hash)).unwrap().is_none()); // poll until the two nodes connect, otherwise announcing the block will not work - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| -> Result<_, ()> { - net.poll(); + block_on(futures::future::poll_fn::<(), _>(|cx| { + net.poll(cx); if net.peer(0).num_peers() == 0 { - Ok(Async::NotReady) + Poll::Pending } else { - Ok(Async::Ready(())) + Poll::Ready(()) } - })).unwrap(); + })); // synchronization: 0 synced to longer chain and 1 didn't sync to small chain. @@ -455,32 +437,31 @@ fn can_sync_small_non_best_forks() { // after announcing, peer 1 downloads the block. - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| -> Result<_, ()> { - net.poll(); + block_on(futures::future::poll_fn::<(), _>(|cx| { + net.poll(cx); assert!(net.peer(0).client().header(&BlockId::Hash(small_hash)).unwrap().is_some()); if net.peer(1).client().header(&BlockId::Hash(small_hash)).unwrap().is_none() { - return Ok(Async::NotReady) + return Poll::Pending } - Ok(Async::Ready(())) - })).unwrap(); - net.block_until_sync(&mut runtime); + Poll::Ready(()) + })); + net.block_until_sync(); let another_fork = net.peer(0).push_blocks_at(BlockId::Number(35), 2, true); net.peer(0).announce_block(another_fork, Vec::new()); - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| -> Result<_, ()> { - net.poll(); + block_on(futures::future::poll_fn::<(), _>(|cx| { + net.poll(cx); if net.peer(1).client().header(&BlockId::Hash(another_fork)).unwrap().is_none() { - return Ok(Async::NotReady) + return Poll::Pending } - Ok(Async::Ready(())) - })).unwrap(); + Poll::Ready(()) + })); } #[test] fn can_not_sync_from_light_peer() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); // given the network with 1 full nodes (#0) and 1 light node (#1) let mut net = TestNet::new(1); @@ -490,7 +471,7 @@ fn can_not_sync_from_light_peer() { net.peer(0).push_blocks(1, false); // and let the light client sync from this node - net.block_until_sync(&mut runtime); + net.block_until_sync(); // ensure #0 && #1 have the same best block let full0_info = net.peer(0).client.info(); @@ -504,29 +485,28 @@ fn can_not_sync_from_light_peer() { net.peers.remove(0); // ensure that the #2 (now #1) fails to sync block #1 even after 5 seconds - let mut test_finished = futures_timer::Delay::new(Duration::from_secs(5)).unit_error().compat(); - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| -> Result<_, ()> { - net.poll(); - test_finished.poll().map_err(|_| ()) - })).unwrap(); + let mut test_finished = futures_timer::Delay::new(Duration::from_secs(5)); + block_on(futures::future::poll_fn::<(), _>(|cx| { + net.poll(cx); + Pin::new(&mut test_finished).poll(cx) + })); } #[test] fn light_peer_imports_header_from_announce() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); - fn import_with_announce(net: &mut TestNet, runtime: &mut current_thread::Runtime, hash: H256) { + fn import_with_announce(net: &mut TestNet, hash: H256) { net.peer(0).announce_block(hash, Vec::new()); - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| { - net.poll(); + block_on(futures::future::poll_fn::<(), _>(|cx| { + net.poll(cx); if net.peer(1).client().header(&BlockId::Hash(hash)).unwrap().is_some() { - Ok(Async::Ready(())) + Poll::Ready(()) } else { - Ok(Async::NotReady) + Poll::Pending } - })).unwrap(); + })); } // given the network with 1 full nodes (#0) and 1 light node (#1) @@ -534,21 +514,20 @@ fn light_peer_imports_header_from_announce() { net.add_light_peer(&Default::default()); // let them connect to each other - net.block_until_sync(&mut runtime); + net.block_until_sync(); // check that NEW block is imported from announce message let new_hash = net.peer(0).push_blocks(1, false); - import_with_announce(&mut net, &mut runtime, new_hash); + import_with_announce(&mut net, new_hash); // check that KNOWN STALE block is imported from announce message let known_stale_hash = net.peer(0).push_blocks_at(BlockId::Number(0), 1, true); - import_with_announce(&mut net, &mut runtime, known_stale_hash); + import_with_announce(&mut net, known_stale_hash); } #[test] fn can_sync_explicit_forks() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut net = TestNet::new(2); net.peer(0).push_blocks(30, false); net.peer(1).push_blocks(30, false); @@ -568,14 +547,14 @@ fn can_sync_explicit_forks() { assert!(net.peer(1).client().header(&BlockId::Hash(small_hash)).unwrap().is_none()); // poll until the two nodes connect, otherwise announcing the block will not work - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| -> Result<_, ()> { - net.poll(); + block_on(futures::future::poll_fn::<(), _>(|cx| { + net.poll(cx); if net.peer(0).num_peers() == 0 || net.peer(1).num_peers() == 0 { - Ok(Async::NotReady) + Poll::Pending } else { - Ok(Async::Ready(())) + Poll::Ready(()) } - })).unwrap(); + })); // synchronization: 0 synced to longer chain and 1 didn't sync to small chain. @@ -589,21 +568,20 @@ fn can_sync_explicit_forks() { net.peer(1).set_sync_fork_request(vec![first_peer_id], small_hash, small_number); // peer 1 downloads the block. - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| -> Result<_, ()> { - net.poll(); + block_on(futures::future::poll_fn::<(), _>(|cx| { + net.poll(cx); assert!(net.peer(0).client().header(&BlockId::Hash(small_hash)).unwrap().is_some()); if net.peer(1).client().header(&BlockId::Hash(small_hash)).unwrap().is_none() { - return Ok(Async::NotReady) + return Poll::Pending } - Ok(Async::Ready(())) - })).unwrap(); + Poll::Ready(()) + })); } #[test] fn syncs_header_only_forks() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut net = TestNet::new(0); let config = ProtocolConfig::default(); net.add_full_peer_with_states(&config, None); @@ -616,7 +594,7 @@ fn syncs_header_only_forks() { let small_number = net.peer(0).client().info().best_number; net.peer(1).push_blocks(4, false); - net.block_until_sync(&mut runtime); + net.block_until_sync(); // Peer 1 will sync the small fork even though common block state is missing assert_eq!(9, net.peer(0).blocks_count()); assert_eq!(9, net.peer(1).blocks_count()); @@ -624,19 +602,18 @@ fn syncs_header_only_forks() { // Request explicit header-only sync request for the ancient fork. let first_peer_id = net.peer(0).id(); net.peer(1).set_sync_fork_request(vec![first_peer_id], small_hash, small_number); - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| -> Result<_, ()> { - net.poll(); + block_on(futures::future::poll_fn::<(), _>(|cx| { + net.poll(cx); if net.peer(1).client().header(&BlockId::Hash(small_hash)).unwrap().is_none() { - return Ok(Async::NotReady) + return Poll::Pending } - Ok(Async::Ready(())) - })).unwrap(); + Poll::Ready(()) + })); } #[test] fn does_not_sync_announced_old_best_block() { let _ = ::env_logger::try_init(); - let mut runtime = current_thread::Runtime::new().unwrap(); let mut net = TestNet::new(3); let old_hash = net.peer(0).push_blocks(1, false); @@ -645,18 +622,38 @@ fn does_not_sync_announced_old_best_block() { net.peer(1).push_blocks(20, true); net.peer(0).announce_block(old_hash, Vec::new()); - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| -> Result<_, ()> { + block_on(futures::future::poll_fn::<(), _>(|cx| { // poll once to import announcement - net.poll(); - Ok(Async::Ready(())) - })).unwrap(); + net.poll(cx); + Poll::Ready(()) + })); assert!(!net.peer(1).is_major_syncing()); net.peer(0).announce_block(old_hash_with_parent, Vec::new()); - runtime.block_on(futures::future::poll_fn::<(), (), _>(|| -> Result<_, ()> { + block_on(futures::future::poll_fn::<(), _>(|cx| { // poll once to import announcement - net.poll(); - Ok(Async::Ready(())) - })).unwrap(); + net.poll(cx); + Poll::Ready(()) + })); assert!(!net.peer(1).is_major_syncing()); } + +#[test] +fn full_sync_requires_block_body() { + // Check that we don't sync headers-only in full mode. + let _ = ::env_logger::try_init(); + let mut net = TestNet::new(2); + + net.peer(0).push_headers(1); + // Wait for nodes to connect + block_on(futures::future::poll_fn::<(), _>(|cx| { + net.poll(cx); + if net.peer(0).num_peers() == 0 || net.peer(1).num_peers() == 0 { + Poll::Pending + } else { + Poll::Ready(()) + } + })); + net.block_until_idle(); + assert_eq!(net.peer(1).client.info().best_number, 0); +} diff --git a/client/offchain/Cargo.toml b/client/offchain/Cargo.toml index 062f6cab564ea..9ea0372969b66 100644 --- a/client/offchain/Cargo.toml +++ b/client/offchain/Cargo.toml @@ -1,7 +1,7 @@ [package] description = "Substrate offchain workers" name = "sc-offchain" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" license = "GPL-3.0" authors = ["Parity Technologies "] edition = "2018" @@ -10,34 +10,34 @@ repository = "https://github.com/paritytech/substrate/" [dependencies] bytes = "0.5" -sc-client-api = { version = "2.0.0-dev", path = "../api" } -sp-api = { version = "2.0.0-dev", path = "../../primitives/api" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../api" } +sp-api = { version = "2.0.0-alpha.2", path = "../../primitives/api" } fnv = "1.0.6" futures = "0.3.1" futures-timer = "3.0.1" log = "0.4.8" threadpool = "1.7" num_cpus = "1.10" -sp-offchain = { version = "2.0.0-dev", path = "../../primitives/offchain" } -codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } +sp-offchain = { version = "2.0.0-alpha.2", path = "../../primitives/offchain" } +codec = { package = "parity-scale-codec", version = "1.2.0", features = ["derive"] } parking_lot = "0.10.0" -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } rand = "0.7.2" -sp-runtime = { version = "2.0.0-dev", path = "../../primitives/runtime" } -sc-network = { version = "0.8.0-dev", path = "../network" } -sc-keystore = { version = "2.0.0-dev", path = "../keystore" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../primitives/runtime" } +sc-network = { version = "0.8.0-alpha.2", path = "../network" } +sc-keystore = { version = "2.0.0-alpha.2", path = "../keystore" } [target.'cfg(not(target_os = "unknown"))'.dependencies] hyper = "0.13.2" hyper-rustls = "0.19" [dev-dependencies] -sc-client-db = { version = "0.8.0-dev", default-features = true, path = "../db/" } +sc-client-db = { version = "0.8.0-alpha.2", default-features = true, path = "../db/" } env_logger = "0.7.0" substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../test-utils/runtime/client" } tokio = "0.2" -sc-transaction-pool = { version = "2.0.0-dev", path = "../../client/transaction-pool" } -sp-transaction-pool = { version = "2.0.0-dev", path = "../../primitives/transaction-pool" } +sc-transaction-pool = { version = "2.0.0-alpha.2", path = "../../client/transaction-pool" } +sp-transaction-pool = { version = "2.0.0-alpha.2", path = "../../primitives/transaction-pool" } [features] default = [] diff --git a/client/peerset/Cargo.toml b/client/peerset/Cargo.toml index 5a01d9d03babe..9e76b8015afca 100644 --- a/client/peerset/Cargo.toml +++ b/client/peerset/Cargo.toml @@ -3,14 +3,16 @@ description = "Connectivity manager based on reputation" homepage = "http://parity.io" license = "GPL-3.0" name = "sc-peerset" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" repository = "https://github.com/paritytech/substrate/" +documentation = "https://docs.rs/sc-peerset" + [dependencies] futures = "0.3.1" -libp2p = { version = "0.16.1", default-features = false } +libp2p = { version = "0.16.2", default-features = false } log = "0.4.8" serde_json = "1.0.41" wasm-timer = "0.2" diff --git a/client/rpc-api/Cargo.toml b/client/rpc-api/Cargo.toml index bf97f07221967..0f3b72e519ba5 100644 --- a/client/rpc-api/Cargo.toml +++ b/client/rpc-api/Cargo.toml @@ -1,14 +1,15 @@ [package] name = "sc-rpc-api" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Substrate RPC interfaces." [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0" } +codec = { package = "parity-scale-codec", version = "1.2.0" } derive_more = "0.99.2" futures = { version = "0.3.1", features = ["compat"] } jsonrpc-core = "14.0.3" @@ -17,10 +18,10 @@ jsonrpc-derive = "14.0.3" jsonrpc-pubsub = "14.0.3" log = "0.4.8" parking_lot = "0.10.0" -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -sp-version = { version = "2.0.0-dev", path = "../../primitives/version" } -sp-runtime = { path = "../../primitives/runtime" , version = "2.0.0-dev"} +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +sp-version = { version = "2.0.0-alpha.2", path = "../../primitives/version" } +sp-runtime = { path = "../../primitives/runtime" , version = "2.0.0-alpha.2"} serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" -sp-transaction-pool = { version = "2.0.0-dev", path = "../../primitives/transaction-pool" } -sp-rpc = { version = "2.0.0-dev", path = "../../primitives/rpc" } +sp-transaction-pool = { version = "2.0.0-alpha.2", path = "../../primitives/transaction-pool" } +sp-rpc = { version = "2.0.0-alpha.2", path = "../../primitives/rpc" } diff --git a/client/rpc-servers/Cargo.toml b/client/rpc-servers/Cargo.toml index d32aaf3e686fc..79d2984c2293e 100644 --- a/client/rpc-servers/Cargo.toml +++ b/client/rpc-servers/Cargo.toml @@ -1,11 +1,12 @@ [package] name = "sc-rpc-server" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Substrate RPC servers." [dependencies] jsonrpc-core = "14.0.3" @@ -13,7 +14,7 @@ pubsub = { package = "jsonrpc-pubsub", version = "14.0.3" } log = "0.4.8" serde = "1.0.101" serde_json = "1.0.41" -sp-runtime = { version = "2.0.0-dev", path = "../../primitives/runtime" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../primitives/runtime" } [target.'cfg(not(target_os = "unknown"))'.dependencies] http = { package = "jsonrpc-http-server", version = "14.0.3" } diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index 2c0feeb8a95e2..9a8be85becf59 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -1,43 +1,44 @@ [package] name = "sc-rpc" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Substrate Client RPC" [dependencies] -sc-rpc-api = { version = "0.8.0-dev", path = "../rpc-api" } -sc-client-api = { version = "2.0.0-dev", path = "../api" } -sc-client = { version = "0.8.0-dev", path = "../" } -sp-api = { version = "2.0.0-dev", path = "../../primitives/api" } -codec = { package = "parity-scale-codec", version = "1.0.0" } +sc-rpc-api = { version = "0.8.0-alpha.2", path = "../rpc-api" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../api" } +sc-client = { version = "0.8.0-alpha.2", path = "../" } +sp-api = { version = "2.0.0-alpha.2", path = "../../primitives/api" } +codec = { package = "parity-scale-codec", version = "1.2.0" } futures = { version = "0.3.1", features = ["compat"] } jsonrpc-pubsub = "14.0.3" log = "0.4.8" -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } rpc = { package = "jsonrpc-core", version = "14.0.3" } -sp-version = { version = "2.0.0-dev", path = "../../primitives/version" } +sp-version = { version = "2.0.0-alpha.2", path = "../../primitives/version" } serde_json = "1.0.41" -sp-session = { version = "2.0.0-dev", path = "../../primitives/session" } -sp-offchain = { version = "2.0.0-dev", path = "../../primitives/offchain" } -sp-runtime = { version = "2.0.0-dev", path = "../../primitives/runtime" } -sp-rpc = { version = "2.0.0-dev", path = "../../primitives/rpc" } -sp-state-machine = { version = "0.8.0-dev", path = "../../primitives/state-machine" } -sc-executor = { version = "0.8.0-dev", path = "../executor" } -sc-keystore = { version = "2.0.0-dev", path = "../keystore" } -sp-transaction-pool = { version = "2.0.0-dev", path = "../../primitives/transaction-pool" } -sp-blockchain = { version = "2.0.0-dev", path = "../../primitives/blockchain" } +sp-session = { version = "2.0.0-alpha.2", path = "../../primitives/session" } +sp-offchain = { version = "2.0.0-alpha.2", path = "../../primitives/offchain" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../primitives/runtime" } +sp-rpc = { version = "2.0.0-alpha.2", path = "../../primitives/rpc" } +sp-state-machine = { version = "0.8.0-alpha.2", path = "../../primitives/state-machine" } +sc-executor = { version = "0.8.0-alpha.2", path = "../executor" } +sc-keystore = { version = "2.0.0-alpha.2", path = "../keystore" } +sp-transaction-pool = { version = "2.0.0-alpha.2", path = "../../primitives/transaction-pool" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../primitives/blockchain" } hash-db = { version = "0.15.2", default-features = false } parking_lot = "0.10.0" [dev-dependencies] assert_matches = "1.3.0" futures01 = { package = "futures", version = "0.1.29" } -sc-network = { version = "0.8.0-dev", path = "../network" } +sc-network = { version = "0.8.0-alpha.2", path = "../network" } rustc-hex = "2.0.1" -sp-io = { version = "2.0.0-dev", path = "../../primitives/io" } +sp-io = { version = "2.0.0-alpha.2", path = "../../primitives/io" } substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../test-utils/runtime/client" } tokio = "0.1.22" -sc-transaction-pool = { version = "2.0.0-dev", path = "../transaction-pool" } +sc-transaction-pool = { version = "2.0.0-alpha.2", path = "../transaction-pool" } diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index 024f61aba59a1..bfc08eb705aa4 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -1,11 +1,12 @@ [package] name = "sc-service" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Substrate service. Starts a thread that spins up the network, client, and extrinsic pool. Manages communication between them." [features] default = ["rocksdb"] @@ -32,37 +33,36 @@ serde = "1.0.101" serde_json = "1.0.41" sysinfo = "0.9.5" target_info = "0.1.0" -sc-keystore = { version = "2.0.0-dev", path = "../keystore" } -sp-io = { version = "2.0.0-dev", path = "../../primitives/io" } -sp-runtime = { version = "2.0.0-dev", path = "../../primitives/runtime" } -sp-blockchain = { version = "2.0.0-dev", path = "../../primitives/blockchain" } -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -sp-session = { version = "2.0.0-dev", path = "../../primitives/session" } -sp-application-crypto = { version = "2.0.0-dev", path = "../../primitives/application-crypto" } -sp-consensus = { version = "0.8.0-dev", path = "../../primitives/consensus/common" } -sc-network = { version = "0.8.0-dev", path = "../network" } -sc-chain-spec = { version = "2.0.0-dev", path = "../chain-spec" } -sc-client-api = { version = "2.0.0-dev", path = "../api" } -sc-client = { version = "0.8.0-dev", path = "../" } -sp-api = { version = "2.0.0-dev", path = "../../primitives/api" } -sc-client-db = { version = "0.8.0-dev", path = "../db" } -codec = { package = "parity-scale-codec", version = "1.0.0" } -sc-executor = { version = "0.8.0-dev", path = "../executor" } -sc-transaction-pool = { version = "2.0.0-dev", path = "../transaction-pool" } -sp-transaction-pool = { version = "2.0.0-dev", path = "../../primitives/transaction-pool" } -sc-rpc-server = { version = "2.0.0-dev", path = "../rpc-servers" } -sc-rpc = { version = "2.0.0-dev", path = "../rpc" } -sc-telemetry = { version = "2.0.0-dev", path = "../telemetry" } -sc-offchain = { version = "2.0.0-dev", path = "../offchain" } +sc-keystore = { version = "2.0.0-alpha.2", path = "../keystore" } +sp-io = { version = "2.0.0-alpha.2", path = "../../primitives/io" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../primitives/runtime" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../primitives/blockchain" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +sp-session = { version = "2.0.0-alpha.2", path = "../../primitives/session" } +sp-application-crypto = { version = "2.0.0-alpha.2", path = "../../primitives/application-crypto" } +sp-consensus = { version = "0.8.0-alpha.2", path = "../../primitives/consensus/common" } +sc-network = { version = "0.8.0-alpha.2", path = "../network" } +sc-chain-spec = { version = "2.0.0-alpha.2", path = "../chain-spec" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../api" } +sc-client = { version = "0.8.0-alpha.2", path = "../" } +sp-api = { version = "2.0.0-alpha.2", path = "../../primitives/api" } +sc-client-db = { version = "0.8.0-alpha.2", path = "../db" } +codec = { package = "parity-scale-codec", version = "1.2.0" } +sc-executor = { version = "0.8.0-alpha.2", path = "../executor" } +sc-transaction-pool = { version = "2.0.0-alpha.2", path = "../transaction-pool" } +sp-transaction-pool = { version = "2.0.0-alpha.2", path = "../../primitives/transaction-pool" } +sc-rpc-server = { version = "2.0.0-alpha.2", path = "../rpc-servers" } +sc-rpc = { version = "2.0.0-alpha.2", path = "../rpc" } +sc-telemetry = { version = "2.0.0-alpha.2", path = "../telemetry" } +sc-offchain = { version = "2.0.0-alpha.2", path = "../offchain" } parity-multiaddr = { package = "parity-multiaddr", version = "0.5.0" } -prometheus-exporter = { path = "../../utils/prometheus" , version = "0.8.0-dev"} -sc-tracing = { version = "2.0.0-dev", path = "../tracing" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../utils/prometheus" , version = "0.8.0-alpha.2"} +sc-tracing = { version = "2.0.0-alpha.2", path = "../tracing" } tracing = "0.1.10" parity-util-mem = { version = "0.5.1", default-features = false, features = ["primitive-types"] } [dev-dependencies] substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../test-utils/runtime/client" } -sp-consensus-babe = { version = "0.8.0-dev", path = "../../primitives/consensus/babe" } -grandpa = { version = "0.8.0-dev", package = "sc-finality-grandpa", path = "../finality-grandpa" } -grandpa-primitives = { version = "2.0.0-dev", package = "sp-finality-grandpa", path = "../../primitives/finality-grandpa" } -tokio = { version = "0.2", features = ["rt-core"] } +sp-consensus-babe = { version = "0.8.0-alpha.2", path = "../../primitives/consensus/babe" } +grandpa = { version = "0.8.0-alpha.2", package = "sc-finality-grandpa", path = "../finality-grandpa" } +grandpa-primitives = { version = "2.0.0-alpha.2", package = "sp-finality-grandpa", path = "../../primitives/finality-grandpa" } diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index 7159e532c4259..01bba286c64ea 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -53,15 +53,15 @@ use sysinfo::{get_current_pid, ProcessExt, System, SystemExt}; use sc_telemetry::{telemetry, SUBSTRATE_INFO}; use sp_transaction_pool::{MaintainedTransactionPool, ChainEvent}; use sp_blockchain; -use prometheus_exporter::{register, Gauge, U64, F64, Registry, PrometheusError, Opts, GaugeVec}; +use prometheus_endpoint::{register, Gauge, U64, F64, Registry, PrometheusError, Opts, GaugeVec}; struct ServiceMetrics { block_height_number: GaugeVec, - peers_count: Gauge, ready_transactions_number: Gauge, memory_usage_bytes: Gauge, cpu_usage_percentage: Gauge, network_per_sec_bytes: GaugeVec, + node_roles: Gauge, } impl ServiceMetrics { @@ -71,9 +71,6 @@ impl ServiceMetrics { Opts::new("block_height_number", "Height of the chain"), &["status"] )?, registry)?, - peers_count: register(Gauge::new( - "peers_count", "Number of network gossip peers", - )?, registry)?, ready_transactions_number: register(Gauge::new( "ready_transactions_number", "Number of transactions in the ready queue", )?, registry)?, @@ -87,6 +84,10 @@ impl ServiceMetrics { Opts::new("network_per_sec_bytes", "Networking bytes per second"), &["direction"] )?, registry)?, + node_roles: register(Gauge::new( + "node_roles", "The roles the node is running as", + )?, registry)?, + }) } } @@ -742,7 +743,7 @@ pub trait ServiceBuilderCommand { output: impl Write + 'static, from: NumberFor, to: Option>, - json: bool + binary: bool ) -> Pin>>>; /// Performs a revert of `blocks` blocks. @@ -887,6 +888,14 @@ ServiceBuilder< let block_announce_validator = Box::new(sp_consensus::block_validation::DefaultBlockAnnounceValidator::new(client.clone())); + let prometheus_registry_and_port = match config.prometheus_port { + Some(port) => match prometheus_registry { + Some(registry) => Some((registry, port)), + None => Some((Registry::new_custom(Some("substrate".into()), None)?, port)) + }, + None => None + }; + let network_params = sc_network::config::Params { roles: config.roles, executor: { @@ -906,6 +915,7 @@ ServiceBuilder< import_queue, protocol_id, block_announce_validator, + metrics_registry: prometheus_registry_and_port.as_ref().map(|(r, _)| r.clone()) }; let has_bootnodes = !network_params.network_config.boot_nodes.is_empty(); @@ -1020,17 +1030,14 @@ ServiceBuilder< )); } - // Prometheus exporter and metrics - let metrics = if let Some(port) = config.prometheus_port { - let registry = match prometheus_registry { - Some(registry) => registry, - None => Registry::new_custom(Some("substrate".into()), None)? - }; - + // Prometheus metrics + let metrics = if let Some((registry, port)) = prometheus_registry_and_port.clone() { let metrics = ServiceMetrics::register(®istry)?; + metrics.node_roles.set(u64::from(config.roles.bits())); + let future = select( - prometheus_exporter::init_prometheus(port, registry).boxed(), + prometheus_endpoint::init_prometheus(port, registry).boxed(), exit.clone() ).map(drop); @@ -1043,7 +1050,6 @@ ServiceBuilder< } else { None }; - // Periodically notify the telemetry. let transaction_pool_ = transaction_pool.clone(); let client_ = client.clone(); @@ -1085,16 +1091,23 @@ ServiceBuilder< "finalized_hash" => ?info.chain.finalized_hash, "bandwidth_download" => bandwidth_download, "bandwidth_upload" => bandwidth_upload, - "used_state_cache_size" => info.usage.as_ref().map(|usage| usage.memory.state_cache).unwrap_or(0), - "used_db_cache_size" => info.usage.as_ref().map(|usage| usage.memory.database_cache).unwrap_or(0), - "disk_read_per_sec" => info.usage.as_ref().map(|usage| usage.io.bytes_read).unwrap_or(0), - "disk_write_per_sec" => info.usage.as_ref().map(|usage| usage.io.bytes_written).unwrap_or(0), + "used_state_cache_size" => info.usage.as_ref() + .map(|usage| usage.memory.state_cache.as_bytes()) + .unwrap_or(0), + "used_db_cache_size" => info.usage.as_ref() + .map(|usage| usage.memory.database_cache.as_bytes()) + .unwrap_or(0), + "disk_read_per_sec" => info.usage.as_ref() + .map(|usage| usage.io.bytes_read) + .unwrap_or(0), + "disk_write_per_sec" => info.usage.as_ref() + .map(|usage| usage.io.bytes_written) + .unwrap_or(0), ); if let Some(metrics) = metrics.as_ref() { metrics.memory_usage_bytes.set(memory); metrics.cpu_usage_percentage.set(f64::from(cpu_usage)); metrics.ready_transactions_number.set(txpool_status.ready as u64); - metrics.peers_count.set(num_peers as u64); metrics.network_per_sec_bytes.with_label_values(&["download"]).set(net_status.average_download_per_sec); metrics.network_per_sec_bytes.with_label_values(&["upload"]).set(net_status.average_upload_per_sec); @@ -1297,6 +1310,7 @@ ServiceBuilder< _telemetry_on_connect_sinks: telemetry_connection_sinks.clone(), keystore, marker: PhantomData::, + prometheus_registry: prometheus_registry_and_port.map(|(r, _)| r) }) } } diff --git a/client/service/src/chain_ops.rs b/client/service/src/chain_ops.rs index a0724f3e1decc..03db9232a1051 100644 --- a/client/service/src/chain_ops.rs +++ b/client/service/src/chain_ops.rs @@ -203,7 +203,7 @@ impl< mut output: impl Write + 'static, from: NumberFor, to: Option>, - json: bool + binary: bool ) -> Pin>>> { let client = self.client; let mut block = from; @@ -230,7 +230,7 @@ impl< if !wrote_header { info!("Exporting blocks from #{} to #{}", block, last); - if !json { + if binary { let last_: u64 = last.saturated_into::(); let block_: u64 = block.saturated_into::(); let len: u64 = last_ - block_ + 1; @@ -241,13 +241,13 @@ impl< match client.block(&BlockId::number(block))? { Some(block) => { - if json { + if binary { + output.write_all(&block.encode())?; + } else { serde_json::to_writer(&mut output, &block) .map_err(|e| format!("Error writing JSON: {}", e))?; - } else { - output.write_all(&block.encode())?; } - }, + }, // Reached end of the chain. None => return std::task::Poll::Ready(Ok(())), } diff --git a/client/service/src/config.rs b/client/service/src/config.rs index 002754f11ce93..974dac588def9 100644 --- a/client/service/src/config.rs +++ b/client/service/src/config.rs @@ -93,7 +93,7 @@ pub struct Configuration { pub rpc_ws_max_connections: Option, /// CORS settings for HTTP & WS servers. `None` if all origins are allowed. pub rpc_cors: Option>, - /// Prometheus exporter Port. `None` if disabled. + /// Prometheus endpoint Port. `None` if disabled. pub prometheus_port: Option, /// Telemetry service URL. `None` if disabled. pub telemetry_endpoints: Option, diff --git a/client/service/src/error.rs b/client/service/src/error.rs index 4d0a2cef94233..5a78a18789230 100644 --- a/client/service/src/error.rs +++ b/client/service/src/error.rs @@ -53,8 +53,8 @@ impl<'a> From<&'a str> for Error { } } -impl From for Error { - fn from(e: prometheus_exporter::PrometheusError) -> Self { +impl From for Error { + fn from(e: prometheus_endpoint::PrometheusError) -> Self { Error::Other(format!("Prometheus error: {}", e)) } } diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 99b45453411d3..5c59cdf91fcf4 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -114,8 +114,11 @@ pub struct Service { _offchain_workers: Option>, keystore: sc_keystore::KeyStorePtr, marker: PhantomData, + prometheus_registry: Option, } +impl Unpin for Service {} + /// Alias for a an implementation of `futures::future::Executor`. pub type TaskExecutor = Arc; @@ -223,13 +226,16 @@ pub trait AbstractService: 'static + Future> + /// Get a handle to a future that will resolve on exit. fn on_exit(&self) -> ::exit_future::Exit; + + /// Get the prometheus metrics registry, if available. + fn prometheus_registry(&self) -> Option; } impl AbstractService for Service, TSc, NetworkStatus, NetworkService, TExPool, TOc> where - TBl: BlockT + Unpin, + TBl: BlockT, TBackend: 'static + sc_client_api::backend::Backend, TExec: 'static + sc_client::CallExecutor + Send + Sync + Clone, TRtApi: 'static + Send + Sync, @@ -326,9 +332,13 @@ where fn on_exit(&self) -> exit_future::Exit { self.exit.clone() } + + fn prometheus_registry(&self) -> Option { + self.prometheus_registry.clone() + } } -impl Future for +impl Future for Service { type Output = Result<(), Error>; diff --git a/client/service/src/status_sinks.rs b/client/service/src/status_sinks.rs index de5fe865736af..8e189be157be5 100644 --- a/client/service/src/status_sinks.rs +++ b/client/service/src/status_sinks.rs @@ -122,28 +122,17 @@ mod tests { let (tx, rx) = mpsc::unbounded(); status_sinks.push(Duration::from_millis(100), tx); - let mut runtime = tokio::runtime::Runtime::new().unwrap(); - let mut val_order = 5; - runtime.spawn(futures::future::poll_fn(move |cx| { - status_sinks.poll(cx, || { val_order += 1; val_order }); - Poll::<()>::Pending - })); - - let done = rx - .into_future() - .then(|(item, rest)| { - assert_eq!(item, Some(6)); - rest.into_future() - }) - .then(|(item, rest)| { - assert_eq!(item, Some(7)); - rest.into_future() - }) - .map(|(item, _)| { - assert_eq!(item, Some(8)); - }); - runtime.block_on(done); + futures::executor::block_on(futures::future::select( + futures::future::poll_fn(move |cx| { + status_sinks.poll(cx, || { val_order += 1; val_order }); + Poll::<()>::Pending + }), + Box::pin(async { + let items: Vec = rx.take(3).collect().await; + assert_eq!(items, [6, 7, 8]); + }) + )); } } diff --git a/client/service/test/Cargo.toml b/client/service/test/Cargo.toml index d733d9a7bdd6b..f27f8803300b3 100644 --- a/client/service/test/Cargo.toml +++ b/client/service/test/Cargo.toml @@ -16,10 +16,10 @@ log = "0.4.8" env_logger = "0.7.0" fdlimit = "0.1.1" futures = { version = "0.3.1", features = ["compat"] } -sc-service = { version = "0.8.0-dev", default-features = false, path = "../../service" } -sc-network = { version = "0.8.0-dev", path = "../../network" } -sp-consensus = { version = "0.8.0-dev", path = "../../../primitives/consensus/common" } -sc-client = { version = "0.8.0-dev", path = "../../" } -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } -sp-transaction-pool = { version = "2.0.0-dev", path = "../../../primitives/transaction-pool" } +sc-service = { version = "0.8.0-alpha.2", default-features = false, path = "../../service" } +sc-network = { version = "0.8.0-alpha.2", path = "../../network" } +sp-consensus = { version = "0.8.0-alpha.2", path = "../../../primitives/consensus/common" } +sc-client = { version = "0.8.0-alpha.2", path = "../../" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } +sp-transaction-pool = { version = "2.0.0-alpha.2", path = "../../../primitives/transaction-pool" } diff --git a/client/src/client.rs b/client/src/client.rs index e9a8f1228c5e1..d461a17ded75f 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -60,13 +60,13 @@ use sp_api::{ CallApiAt, ConstructRuntimeApi, Core as CoreApi, ApiExt, ApiRef, ProvideRuntimeApi, CallApiAtParams, }; -use sc_block_builder::BlockBuilderApi; +use sc_block_builder::{BlockBuilderApi, BlockBuilderProvider}; pub use sc_client_api::{ backend::{ self, BlockImportOperation, PrunableStateChangesTrieStorage, ClientImportOperation, Finalizer, ImportSummary, NewBlockState, - changes_tries_state_at_block, + LockImportRun, changes_tries_state_at_block, }, client::{ ImportNotifications, FinalityNotification, FinalityNotifications, BlockImportNotification, @@ -218,6 +218,61 @@ impl BlockOf for Client where type Type = Block; } +impl LockImportRun for Client + where + B: backend::Backend, + E: CallExecutor, + Block: BlockT, +{ + fn lock_import_and_run(&self, f: F) -> Result + where + F: FnOnce(&mut ClientImportOperation) -> Result, + Err: From, + { + let inner = || { + let _import_lock = self.backend.get_import_lock().write(); + + let mut op = ClientImportOperation { + op: self.backend.begin_operation()?, + notify_imported: None, + notify_finalized: Vec::new(), + }; + + let r = f(&mut op)?; + + let ClientImportOperation { op, notify_imported, notify_finalized } = op; + self.backend.commit_operation(op)?; + self.notify_finalized(notify_finalized)?; + + if let Some(notify_imported) = notify_imported { + self.notify_imported(notify_imported)?; + } + + Ok(r) + }; + + let result = inner(); + *self.importing_block.write() = None; + + result + } +} + +impl LockImportRun for &Client + where + Block: BlockT, + B: backend::Backend, + E: CallExecutor, +{ + fn lock_import_and_run(&self, f: F) -> Result + where + F: FnOnce(&mut ClientImportOperation) -> Result, + Err: From, + { + (**self).lock_import_and_run(f) + } +} + impl Client where B: backend::Backend, E: CallExecutor, @@ -808,66 +863,6 @@ impl Client where ) } - /// Create a new block, built on top of `parent`. - /// - /// When proof recording is enabled, all accessed trie nodes are saved. - /// These recorded trie nodes can be used by a third party to proof the - /// output of this block builder without having access to the full storage. - pub fn new_block_at>( - &self, - parent: &BlockId, - inherent_digests: DigestFor, - record_proof: R, - ) -> sp_blockchain::Result> where - E: Clone + Send + Sync, - RA: Send + Sync, - Self: ProvideRuntimeApi, - >::Api: BlockBuilderApi + - ApiExt> - { - sc_block_builder::BlockBuilder::new( - self, - self.expect_block_hash_from_id(parent)?, - self.expect_block_number_from_id(parent)?, - record_proof.into(), - inherent_digests, - &self.backend - ) - } - - /// Lock the import lock, and run operations inside. - pub fn lock_import_and_run(&self, f: F) -> Result where - F: FnOnce(&mut ClientImportOperation) -> Result, - Err: From, - { - let inner = || { - let _import_lock = self.backend.get_import_lock().write(); - - let mut op = ClientImportOperation { - op: self.backend.begin_operation()?, - notify_imported: None, - notify_finalized: Vec::new(), - }; - - let r = f(&mut op)?; - - let ClientImportOperation { op, notify_imported, notify_finalized } = op; - self.backend.commit_operation(op)?; - self.notify_finalized(notify_finalized)?; - - if let Some(notify_imported) = notify_imported { - self.notify_imported(notify_imported)?; - } - - Ok(r) - }; - - let result = inner(); - *self.importing_block.write() = None; - - result - } - /// Apply a checked and validated block to an operation. If a justification is provided /// then `finalized` *must* be true. fn apply_block( @@ -1399,6 +1394,32 @@ impl Client where } } +impl BlockBuilderProvider for Client + where + B: backend::Backend + Send + Sync + 'static, + E: CallExecutor + Send + Sync + 'static, + Block: BlockT, + Self: ChainHeaderBackend + ProvideRuntimeApi, + >::Api: ApiExt> + + BlockBuilderApi, +{ + fn new_block_at>( + &self, + parent: &BlockId, + inherent_digests: DigestFor, + record_proof: R, + ) -> sp_blockchain::Result> { + sc_block_builder::BlockBuilder::new( + self, + self.expect_block_hash_from_id(parent)?, + self.expect_block_number_from_id(parent)?, + record_proof.into(), + inherent_digests, + &self.backend + ) + } +} + impl HeaderMetadata for Client where B: backend::Backend, E: CallExecutor, diff --git a/client/src/lib.rs b/client/src/lib.rs index d97246d478c2b..1d279cabad499 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -98,7 +98,7 @@ pub use crate::{ client::{ new_with_backend, new_in_mem, - BlockBody, ImportNotifications, FinalityNotifications, BlockchainEvents, + BlockBody, ImportNotifications, FinalityNotifications, BlockchainEvents, LockImportRun, BlockImportNotification, Client, ClientInfo, ExecutionStrategies, FinalityNotification, LongestChain, BlockOf, ProvideUncles, BadBlocks, ForkBlocks, apply_aux, }, diff --git a/client/state-db/Cargo.toml b/client/state-db/Cargo.toml index 93a12cdf08241..7c7823b534ea2 100644 --- a/client/state-db/Cargo.toml +++ b/client/state-db/Cargo.toml @@ -1,17 +1,21 @@ [package] name = "sc-state-db" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "State database maintenance. Handles canonicalization and pruning in the database." [dependencies] parking_lot = "0.10.0" log = "0.4.8" -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } +sc-client-api = { version = "2.0.0-alpha.2", path = "../api" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +codec = { package = "parity-scale-codec", version = "1.2.0", features = ["derive"] } +parity-util-mem = "0.5.1" +parity-util-mem-derive = "0.1.0" [dev-dependencies] env_logger = "0.7.0" diff --git a/client/state-db/src/lib.rs b/client/state-db/src/lib.rs index 0eab640de84e8..49b1a59285e11 100644 --- a/client/state-db/src/lib.rs +++ b/client/state-db/src/lib.rs @@ -31,7 +31,8 @@ mod noncanonical; mod pruning; -#[cfg(test)] mod test; +#[cfg(test)] +mod test; use std::fmt; use parking_lot::RwLock; @@ -40,6 +41,8 @@ use std::collections::{HashMap, hash_map::Entry}; use noncanonical::NonCanonicalOverlay; use pruning::RefWindow; use log::trace; +use parity_util_mem::{MallocSizeOf, malloc_size}; +use sc_client_api::{StateDbMemoryInfo, MemorySize}; const PRUNING_MODE: &[u8] = b"mode"; const PRUNING_MODE_ARCHIVE: &[u8] = b"archive"; @@ -120,7 +123,6 @@ pub struct ChangeSet { pub deleted: Vec, } - /// A set of changes to the backing database. #[derive(Default, Debug, Clone)] pub struct CommitSet { @@ -196,8 +198,11 @@ struct StateDbSync { pinned: HashMap, } -impl StateDbSync { - pub fn new(mode: PruningMode, db: &D) -> Result, Error> { +impl StateDbSync { + fn new( + mode: PruningMode, + db: &D, + ) -> Result, Error> { trace!(target: "state-db", "StateDb settings: {:?}", mode); // Check that settings match @@ -234,7 +239,13 @@ impl StateDbSync { } } - pub fn insert_block(&mut self, hash: &BlockHash, number: u64, parent_hash: &BlockHash, mut changeset: ChangeSet) -> Result, Error> { + fn insert_block( + &mut self, + hash: &BlockHash, + number: u64, + parent_hash: &BlockHash, + mut changeset: ChangeSet, + ) -> Result, Error> { let mut meta = ChangeSet::default(); if number == 0 { // Save pruning mode when writing first block. @@ -247,7 +258,7 @@ impl StateDbSync { // write changes immediately Ok(CommitSet { data: changeset, - meta: meta, + meta, }) }, PruningMode::Constrained(_) | PruningMode::ArchiveCanonical => { @@ -260,7 +271,10 @@ impl StateDbSync { } } - pub fn canonicalize_block(&mut self, hash: &BlockHash) -> Result, Error> { + fn canonicalize_block( + &mut self, + hash: &BlockHash, + ) -> Result, Error> { let mut commit = CommitSet::default(); if self.mode == PruningMode::ArchiveAll { return Ok(commit) @@ -280,18 +294,23 @@ impl StateDbSync { Ok(commit) } - pub fn best_canonical(&self) -> Option { + fn best_canonical(&self) -> Option { return self.non_canonical.last_canonicalized_block_number() } - pub fn is_pruned(&self, hash: &BlockHash, number: u64) -> bool { + fn is_pruned(&self, hash: &BlockHash, number: u64) -> bool { match self.mode { PruningMode::ArchiveAll => false, PruningMode::ArchiveCanonical | PruningMode::Constrained(_) => { if self.best_canonical().map(|c| number > c).unwrap_or(true) { !self.non_canonical.have_block(hash) } else { - self.pruning.as_ref().map_or(false, |pruning| number < pruning.pending() || !pruning.have_block(hash)) + self.pruning + .as_ref() + .map_or( + false, + |pruning| number < pruning.pending() || !pruning.have_block(hash), + ) } } } @@ -320,7 +339,7 @@ impl StateDbSync { /// Revert all non-canonical blocks with the best block number. /// Returns a database commit or `None` if not possible. /// For archive an empty commit set is returned. - pub fn revert_one(&mut self) -> Option> { + fn revert_one(&mut self) -> Option> { match self.mode { PruningMode::ArchiveAll => { Some(CommitSet::default()) @@ -331,7 +350,7 @@ impl StateDbSync { } } - pub fn pin(&mut self, hash: &BlockHash) -> Result<(), PinError> { + fn pin(&mut self, hash: &BlockHash) -> Result<(), PinError> { match self.mode { PruningMode::ArchiveAll => Ok(()), PruningMode::ArchiveCanonical | PruningMode::Constrained(_) => { @@ -340,7 +359,7 @@ impl StateDbSync { { let refs = self.pinned.entry(hash.clone()).or_default(); if *refs == 0 { - trace!(target: "state-db", "Pinned block: {:?}", hash); + trace!(target: "state-db-pin", "Pinned block: {:?}", hash); self.non_canonical.pin(hash); } *refs += 1; @@ -352,16 +371,16 @@ impl StateDbSync { } } - pub fn unpin(&mut self, hash: &BlockHash) { + fn unpin(&mut self, hash: &BlockHash) { match self.pinned.entry(hash.clone()) { Entry::Occupied(mut entry) => { *entry.get_mut() -= 1; if *entry.get() == 0 { - trace!(target: "state-db", "Unpinned block: {:?}", hash); + trace!(target: "state-db-pin", "Unpinned block: {:?}", hash); entry.remove(); self.non_canonical.unpin(hash); } else { - trace!(target: "state-db", "Releasing reference for {:?}", hash); + trace!(target: "state-db-pin", "Releasing reference for {:?}", hash); } }, Entry::Vacant(_) => {}, @@ -377,12 +396,14 @@ impl StateDbSync { db.get(key.as_ref()).map_err(|e| Error::Db(e)) } - pub fn apply_pending(&mut self) { + fn apply_pending(&mut self) { self.non_canonical.apply_pending(); if let Some(pruning) = &mut self.pruning { pruning.apply_pending(); } - trace!(target: "forks", "First available: {:?} ({}), Last canon: {:?} ({}), Best forks: {:?}", + trace!( + target: "forks", + "First available: {:?} ({}), Last canon: {:?} ({}), Best forks: {:?}", self.pruning.as_ref().and_then(|p| p.next_hash()), self.pruning.as_ref().map(|p| p.pending()).unwrap_or(0), self.non_canonical.last_canonicalized_hash(), @@ -391,12 +412,20 @@ impl StateDbSync { ); } - pub fn revert_pending(&mut self) { + fn revert_pending(&mut self) { if let Some(pruning) = &mut self.pruning { pruning.revert_pending(); } self.non_canonical.revert_pending(); } + + fn memory_info(&self) -> StateDbMemoryInfo { + StateDbMemoryInfo { + non_canonical: MemorySize::from_bytes(malloc_size(&self.non_canonical)), + pruning: self.pruning.as_ref().map(|p| MemorySize::from_bytes(malloc_size(p))), + pinned: MemorySize::from_bytes(malloc_size(&self.pinned)), + } + } } /// State DB maintenance. See module description. @@ -405,21 +434,33 @@ pub struct StateDb { db: RwLock>, } -impl StateDb { +impl StateDb { /// Creates a new instance. Does not expect any metadata in the database. - pub fn new(mode: PruningMode, db: &D) -> Result, Error> { + pub fn new( + mode: PruningMode, + db: &D, + ) -> Result, Error> { Ok(StateDb { db: RwLock::new(StateDbSync::new(mode, db)?) }) } /// Add a new non-canonical block. - pub fn insert_block(&self, hash: &BlockHash, number: u64, parent_hash: &BlockHash, changeset: ChangeSet) -> Result, Error> { + pub fn insert_block( + &self, + hash: &BlockHash, + number: u64, + parent_hash: &BlockHash, + changeset: ChangeSet, + ) -> Result, Error> { self.db.write().insert_block(hash, number, parent_hash, changeset) } /// Finalize a previously inserted block. - pub fn canonicalize_block(&self, hash: &BlockHash) -> Result, Error> { + pub fn canonicalize_block( + &self, + hash: &BlockHash, + ) -> Result, Error> { self.db.write().canonicalize_block(hash) } @@ -466,6 +507,11 @@ impl StateDb { pub fn revert_pending(&self) { self.db.write().revert_pending(); } + + /// Returns the current memory statistics of this instance. + pub fn memory_info(&self) -> StateDbMemoryInfo { + self.db.read().memory_info() + } } #[cfg(test)] diff --git a/client/state-db/src/noncanonical.rs b/client/state-db/src/noncanonical.rs index db2f58fa8981d..6a34523b66fff 100644 --- a/client/state-db/src/noncanonical.rs +++ b/client/state-db/src/noncanonical.rs @@ -30,6 +30,7 @@ const NON_CANONICAL_JOURNAL: &[u8] = b"noncanonical_journal"; const LAST_CANONICAL: &[u8] = b"last_canonical"; /// See module documentation. +#[derive(parity_util_mem_derive::MallocSizeOf)] pub struct NonCanonicalOverlay { last_canonicalized: Option<(BlockHash, u64)>, levels: VecDeque>>, @@ -55,6 +56,7 @@ fn to_journal_key(block: u64, index: u64) -> Vec { } #[cfg_attr(test, derive(PartialEq, Debug))] +#[derive(parity_util_mem_derive::MallocSizeOf)] struct BlockOverlay { hash: BlockHash, journal_key: Vec, @@ -99,8 +101,10 @@ fn discard_descendants( let mut discarded = Vec::new(); if let Some(level) = levels.get_mut(index) { *level = level.drain(..).filter_map(|overlay| { - let parent = parents.get(&overlay.hash).expect("there is a parent entry for each entry in levels; qed").clone(); - if parent == *hash { + let parent = parents.get(&overlay.hash) + .expect("there is a parent entry for each entry in levels; qed"); + + if parent == hash { discarded.push(overlay.hash.clone()); if pinned.contains_key(&overlay.hash) { // save to be discarded later. @@ -375,7 +379,7 @@ impl NonCanonicalOverlay { None } - /// Check if the block is in the canonicalization queue. + /// Check if the block is in the canonicalization queue. pub fn have_block(&self, hash: &BlockHash) -> bool { (self.parents.contains_key(hash) || self.pending_insertions.contains(hash)) && !self.pending_canonicalizations.contains(hash) @@ -436,7 +440,7 @@ impl NonCanonicalOverlay { while let Some(hash) = parent { let refs = self.pinned.entry(hash.clone()).or_default(); if *refs == 0 { - trace!(target: "state-db", "Pinned non-canon block: {:?}", hash); + trace!(target: "state-db-pin", "Pinned non-canon block: {:?}", hash); } *refs += 1; parent = self.parents.get(hash); @@ -455,7 +459,7 @@ impl NonCanonicalOverlay { if *entry.get() == 0 { entry.remove(); if let Some(inserted) = self.pinned_insertions.remove(&hash) { - trace!(target: "state-db", "Discarding unpinned non-canon block: {:?}", hash); + trace!(target: "state-db-pin", "Discarding unpinned non-canon block: {:?}", hash); discard_values(&mut self.values, inserted); self.parents.remove(&hash); } diff --git a/client/state-db/src/pruning.rs b/client/state-db/src/pruning.rs index 71d018087b590..6cf5f260060f5 100644 --- a/client/state-db/src/pruning.rs +++ b/client/state-db/src/pruning.rs @@ -31,6 +31,7 @@ const LAST_PRUNED: &[u8] = b"last_pruned"; const PRUNING_JOURNAL: &[u8] = b"pruning_journal"; /// See module documentation. +#[derive(parity_util_mem_derive::MallocSizeOf)] pub struct RefWindow { /// A queue of keys that should be deleted for each block in the pruning window. death_rows: VecDeque>, @@ -46,7 +47,7 @@ pub struct RefWindow { pending_prunings: usize, } -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, parity_util_mem_derive::MallocSizeOf)] struct DeathRow { hash: BlockHash, journal_key: Vec, diff --git a/client/telemetry/Cargo.toml b/client/telemetry/Cargo.toml index 89ef286804817..248c90ec68623 100644 --- a/client/telemetry/Cargo.toml +++ b/client/telemetry/Cargo.toml @@ -1,12 +1,14 @@ [package] name = "sc-telemetry" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] description = "Telemetry utils" edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +documentation = "https://docs.rs/sc-telemetry" + [dependencies] bytes = "0.5" @@ -14,7 +16,7 @@ parking_lot = "0.10.0" futures = "0.3.1" futures-timer = "3.0.1" wasm-timer = "0.2.0" -libp2p = { version = "0.16.1", default-features = false, features = ["libp2p-websocket"] } +libp2p = { version = "0.16.2", default-features = false, features = ["libp2p-websocket"] } log = "0.4.8" pin-project = "0.4.6" rand = "0.7.2" diff --git a/client/tracing/Cargo.toml b/client/tracing/Cargo.toml index b85c0371f3a2e..ad988f0607953 100644 --- a/client/tracing/Cargo.toml +++ b/client/tracing/Cargo.toml @@ -1,11 +1,12 @@ [package] name = "sc-tracing" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" license = "GPL-3.0" authors = ["Parity Technologies "] edition = "2018" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Instrumentation implementation for substrate." [dependencies] erased-serde = "0.3.9" @@ -16,7 +17,7 @@ serde_json = "1.0.41" slog = { version = "2.5.2", features = ["nested-values"] } tracing-core = "0.1.7" -sc-telemetry = { version = "2.0.0-dev", path = "../telemetry" } +sc-telemetry = { version = "2.0.0-alpha.2", path = "../telemetry" } [dev-dependencies] tracing = "0.1.10" diff --git a/client/transaction-pool/Cargo.toml b/client/transaction-pool/Cargo.toml index 6f863550bc1f1..3d80e06c955f7 100644 --- a/client/transaction-pool/Cargo.toml +++ b/client/transaction-pool/Cargo.toml @@ -1,31 +1,32 @@ [package] name = "sc-transaction-pool" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Substrate transaction pool implementation." [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0" } +codec = { package = "parity-scale-codec", version = "1.2.0" } derive_more = "0.99.2" futures = { version = "0.3.1", features = ["compat"] } futures-diagnose = "1.0" log = "0.4.8" parking_lot = "0.10.0" wasm-timer = "0.2" -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -sp-api = { version = "2.0.0-dev", path = "../../primitives/api" } -sp-runtime = { version = "2.0.0-dev", path = "../../primitives/runtime" } -sc-transaction-graph = { version = "2.0.0-dev", path = "./graph" } -sp-transaction-pool = { version = "2.0.0-dev", path = "../../primitives/transaction-pool" } -sc-client-api = { version = "2.0.0-dev", path = "../api" } -sp-blockchain = { version = "2.0.0-dev", path = "../../primitives/blockchain" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +sp-api = { version = "2.0.0-alpha.2", path = "../../primitives/api" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../primitives/runtime" } +sc-transaction-graph = { version = "2.0.0-alpha.2", path = "./graph" } +sp-transaction-pool = { version = "2.0.0-alpha.2", path = "../../primitives/transaction-pool" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../api" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../primitives/blockchain" } futures-timer = "2.0" parity-util-mem = { version = "0.5.1", default-features = false, features = ["primitive-types"] } [dev-dependencies] -sp-keyring = { version = "2.0.0-dev", path = "../../primitives/keyring" } +sp-keyring = { version = "2.0.0-alpha.2", path = "../../primitives/keyring" } substrate-test-runtime-transaction-pool = { version = "2.0.0-dev", path = "../../test-utils/runtime/transaction-pool" } substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../test-utils/runtime/client" } diff --git a/client/transaction-pool/graph/Cargo.toml b/client/transaction-pool/graph/Cargo.toml index 6335cdecb37b0..10846acfea188 100644 --- a/client/transaction-pool/graph/Cargo.toml +++ b/client/transaction-pool/graph/Cargo.toml @@ -1,11 +1,12 @@ [package] name = "sc-transaction-graph" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Generic Transaction Pool" [dependencies] derive_more = "0.99.2" @@ -14,16 +15,16 @@ log = "0.4.8" parking_lot = "0.10.0" serde = { version = "1.0.101", features = ["derive"] } wasm-timer = "0.2" -sp-blockchain = { version = "2.0.0-dev", path = "../../../primitives/blockchain" } -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } -sp-transaction-pool = { version = "2.0.0-dev", path = "../../../primitives/transaction-pool" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../../primitives/blockchain" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } +sp-transaction-pool = { version = "2.0.0-alpha.2", path = "../../../primitives/transaction-pool" } parity-util-mem = { version = "0.5.1", default-features = false, features = ["primitive-types"] } linked-hash-map = "0.5.2" [dev-dependencies] assert_matches = "1.3.0" -codec = { package = "parity-scale-codec", version = "1.0.0" } +codec = { package = "parity-scale-codec", version = "1.2.0" } substrate-test-runtime = { version = "2.0.0-dev", path = "../../../test-utils/runtime" } criterion = "0.3" diff --git a/client/transaction-pool/src/lib.rs b/client/transaction-pool/src/lib.rs index a69323553fa8f..7ee73b862ad46 100644 --- a/client/transaction-pool/src/lib.rs +++ b/client/transaction-pool/src/lib.rs @@ -16,6 +16,7 @@ //! Substrate transaction pool implementation. +#![recursion_limit="256"] #![warn(missing_docs)] #![warn(unused_extern_crates)] diff --git a/client/transaction-pool/src/revalidation.rs b/client/transaction-pool/src/revalidation.rs index dbf8a29354271..b915f1fe71935 100644 --- a/client/transaction-pool/src/revalidation.rs +++ b/client/transaction-pool/src/revalidation.rs @@ -113,7 +113,9 @@ async fn batch_revalidate( } pool.validated_pool().remove_invalid(&invalid_hashes); - pool.resubmit(revalidated); + if revalidated.len() > 0 { + pool.resubmit(revalidated); + } } impl RevalidationWorker { @@ -149,6 +151,7 @@ impl RevalidationWorker { } else { for xt in &to_queue { extrinsics.remove(xt); + self.members.remove(xt); } } left -= to_queue.len(); @@ -163,6 +166,10 @@ impl RevalidationWorker { queued_exts } + fn len(&self) -> usize { + self.block_ordered.iter().map(|b| b.1.len()).sum() + } + fn push(&mut self, worker_payload: WorkerPayload) { // we don't add something that already scheduled for revalidation let transactions = worker_payload.transactions; @@ -170,7 +177,15 @@ impl RevalidationWorker { for ext_hash in transactions { // we don't add something that already scheduled for revalidation - if self.members.contains_key(&ext_hash) { continue; } + if self.members.contains_key(&ext_hash) { + log::debug!( + target: "txpool", + "[{:?}] Skipped adding for revalidation: Already there.", + ext_hash, + ); + + continue; + } self.block_ordered.entry(block_number) .and_modify(|value| { value.insert(ext_hash.clone()); }) @@ -198,7 +213,18 @@ impl RevalidationWorker { futures::select! { _ = interval.next() => { let next_batch = this.prepare_batch(); + let batch_len = next_batch.len(); + batch_revalidate(this.pool.clone(), this.api.clone(), this.best_block, next_batch).await; + + if batch_len > 0 || this.len() > 0 { + log::debug!( + target: "txpool", + "Revalidated {} transactions. Left in the queue for revalidation: {}.", + batch_len, + this.len(), + ); + } }, workload = from_queue.next() => { match workload { @@ -264,6 +290,10 @@ where /// If queue configured without background worker, this will resolve after /// revalidation is actually done. pub async fn revalidate_later(&self, at: NumberFor, transactions: Vec>) { + if transactions.len() > 0 { + log::debug!(target: "txpool", "Added {} transactions to revalidation queue", transactions.len()); + } + if let Some(ref to_worker) = self.background { if let Err(e) = to_worker.unbounded_send(WorkerPayload { at, transactions }) { log::warn!(target: "txpool", "Failed to update background worker: {:?}", e); diff --git a/client/transaction-pool/src/testing/pool.rs b/client/transaction-pool/src/testing/pool.rs index 6984877eef4aa..d9f54ede94a44 100644 --- a/client/transaction-pool/src/testing/pool.rs +++ b/client/transaction-pool/src/testing/pool.rs @@ -267,6 +267,34 @@ fn should_not_retain_invalid_hashes_from_retracted() { assert_eq!(pool.status().ready, 0); } +#[test] +fn should_revalidate_transaction_multiple_times() { + let xt = uxt(Alice, 209); + + let (pool, _guard) = maintained_pool(); + + block_on(pool.submit_one(&BlockId::number(0), xt.clone())).expect("1. Imported"); + assert_eq!(pool.status().ready, 1); + + pool.api.push_block(1, vec![xt.clone()]); + + // maintenance is in background + block_on(pool.maintain(block_event(1))); + block_on(futures_timer::Delay::new(BACKGROUND_REVALIDATION_INTERVAL*2)); + + block_on(pool.submit_one(&BlockId::number(0), xt.clone())).expect("1. Imported"); + assert_eq!(pool.status().ready, 1); + + pool.api.push_block(2, vec![]); + pool.api.add_invalid(&xt); + + // maintenance is in background + block_on(pool.maintain(block_event(2))); + block_on(futures_timer::Delay::new(BACKGROUND_REVALIDATION_INTERVAL*2)); + + assert_eq!(pool.status().ready, 0); +} + #[test] fn should_push_watchers_during_maintaince() { fn alice_uxt(nonce: u64) -> Extrinsic { diff --git a/frame/assets/Cargo.toml b/frame/assets/Cargo.toml index 9b2b01e91ed38..5b0b5f096a91f 100644 --- a/frame/assets/Cargo.toml +++ b/frame/assets/Cargo.toml @@ -1,26 +1,27 @@ [package] name = "pallet-assets" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME asset management pallet" [dependencies] serde = { version = "1.0.101", optional = true } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false } # Needed for various traits. In our case, `OnFinalize`. -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } # Needed for type-safe access to storage DB. -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } # `system` module provides us with all sorts of useful stuff and macros depend on it being around. -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } [dev-dependencies] -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -sp-std = { version = "2.0.0-dev", path = "../../primitives/std" } -sp-io = { version = "2.0.0-dev", path = "../../primitives/io" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +sp-std = { version = "2.0.0-alpha.2", path = "../../primitives/std" } +sp-io = { version = "2.0.0-alpha.2", path = "../../primitives/io" } [features] default = ["std"] diff --git a/frame/aura/Cargo.toml b/frame/aura/Cargo.toml index 516ee883c4400..77abfe4ae1f48 100644 --- a/frame/aura/Cargo.toml +++ b/frame/aura/Cargo.toml @@ -1,27 +1,28 @@ [package] name = "pallet-aura" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME AURA consensus pallet" [dependencies] -sp-application-crypto = { version = "2.0.0-dev", default-features = false, path = "../../primitives/application-crypto" } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-inherents = { version = "2.0.0-dev", default-features = false, path = "../../primitives/inherents" } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../primitives/core" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } +sp-application-crypto = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/application-crypto" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-inherents = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/inherents" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/core" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } serde = { version = "1.0.101", optional = true } -pallet-session = { version = "2.0.0-dev", default-features = false, path = "../session" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-io ={ path = "../../primitives/io", default-features = false , version = "2.0.0-dev"} -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -sp-consensus-aura = { path = "../../primitives/consensus/aura", default-features = false, version = "0.8.0-dev"} -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } -sp-timestamp = { version = "2.0.0-dev", default-features = false, path = "../../primitives/timestamp" } -pallet-timestamp = { version = "2.0.0-dev", default-features = false, path = "../timestamp" } +pallet-session = { version = "2.0.0-alpha.2", default-features = false, path = "../session" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-io ={ path = "../../primitives/io", default-features = false , version = "2.0.0-alpha.2"} +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +sp-consensus-aura = { path = "../../primitives/consensus/aura", default-features = false, version = "0.8.0-alpha.2"} +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } +sp-timestamp = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/timestamp" } +pallet-timestamp = { version = "2.0.0-alpha.2", default-features = false, path = "../timestamp" } [dev-dependencies] diff --git a/frame/authority-discovery/Cargo.toml b/frame/authority-discovery/Cargo.toml index 77dbd9de4ab5b..c82d1eab588b3 100644 --- a/frame/authority-discovery/Cargo.toml +++ b/frame/authority-discovery/Cargo.toml @@ -1,27 +1,28 @@ [package] name = "pallet-authority-discovery" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME pallet for authority discovery" [dependencies] -sp-authority-discovery = { version = "2.0.0-dev", default-features = false, path = "../../primitives/authority-discovery" } -sp-application-crypto = { version = "2.0.0-dev", default-features = false, path = "../../primitives/application-crypto" } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../primitives/core" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } +sp-authority-discovery = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/authority-discovery" } +sp-application-crypto = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/application-crypto" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/core" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } serde = { version = "1.0.101", optional = true } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } -pallet-session = { version = "2.0.0-dev", features = ["historical" ], path = "../session", default-features = false } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } +pallet-session = { version = "2.0.0-alpha.2", features = ["historical" ], path = "../session", default-features = false } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } [dev-dependencies] -sp-staking = { version = "2.0.0-dev", default-features = false, path = "../../primitives/staking" } +sp-staking = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/staking" } [features] default = ["std"] diff --git a/frame/authorship/Cargo.toml b/frame/authorship/Cargo.toml index afbea4ceecd03..2a01cdbd8ad85 100644 --- a/frame/authorship/Cargo.toml +++ b/frame/authorship/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-authorship" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" description = "Block and Uncle Author tracking for the FRAME" authors = ["Parity Technologies "] edition = "2018" @@ -9,15 +9,15 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../primitives/core" } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-inherents = { version = "2.0.0-dev", default-features = false, path = "../../primitives/inherents" } -sp-authorship = { version = "2.0.0-dev", default-features = false, path = "../../primitives/authorship" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } -sp-io ={ path = "../../primitives/io", default-features = false , version = "2.0.0-dev"} +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/core" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-inherents = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/inherents" } +sp-authorship = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/authorship" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } +sp-io ={ path = "../../primitives/io", default-features = false , version = "2.0.0-alpha.2"} impl-trait-for-tuples = "0.1.3" [features] diff --git a/frame/babe/Cargo.toml b/frame/babe/Cargo.toml index 1748481295df7..7e39e5bed5c29 100644 --- a/frame/babe/Cargo.toml +++ b/frame/babe/Cargo.toml @@ -1,33 +1,34 @@ [package] name = "pallet-babe" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Consensus extension module for BABE consensus. Collects on-chain randomness from VRF outputs and manages epoch transitions." [dependencies] hex-literal = "0.2.1" -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } serde = { version = "1.0.101", optional = true } -sp-inherents = { version = "2.0.0-dev", default-features = false, path = "../../primitives/inherents" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-staking = { version = "2.0.0-dev", default-features = false, path = "../../primitives/staking" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } -pallet-timestamp = { version = "2.0.0-dev", default-features = false, path = "../timestamp" } -sp-timestamp = { version = "2.0.0-dev", default-features = false, path = "../../primitives/timestamp" } -pallet-session = { version = "2.0.0-dev", default-features = false, path = "../session" } -sp-consensus-babe = { version = "0.8.0-dev", default-features = false, path = "../../primitives/consensus/babe" } -sp-io ={ path = "../../primitives/io", default-features = false , version = "2.0.0-dev"} +sp-inherents = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/inherents" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-staking = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/staking" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } +pallet-timestamp = { version = "2.0.0-alpha.2", default-features = false, path = "../timestamp" } +sp-timestamp = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/timestamp" } +pallet-session = { version = "2.0.0-alpha.2", default-features = false, path = "../session" } +sp-consensus-babe = { version = "0.8.0-alpha.2", default-features = false, path = "../../primitives/consensus/babe" } +sp-io ={ path = "../../primitives/io", default-features = false , version = "2.0.0-alpha.2"} [dev-dependencies] lazy_static = "1.4.0" parking_lot = "0.10.0" -sp-version = { version = "2.0.0-dev", default-features = false, path = "../../primitives/version" } -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } +sp-version = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/version" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } substrate-test-runtime = { version = "2.0.0-dev", path = "../../test-utils/runtime" } [features] diff --git a/frame/balances/Cargo.toml b/frame/balances/Cargo.toml index be3fa14c7a057..9d26c5b957e0c 100644 --- a/frame/balances/Cargo.toml +++ b/frame/balances/Cargo.toml @@ -1,25 +1,26 @@ [package] name = "pallet-balances" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME pallet to manage balances" [dependencies] serde = { version = "1.0.101", optional = true } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -frame-benchmarking = { version = "2.0.0-dev", default-features = false, path = "../benchmarking" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +frame-benchmarking = { version = "2.0.0-alpha.2", default-features = false, path = "../benchmarking" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } [dev-dependencies] -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -pallet-transaction-payment = { version = "2.0.0-dev", path = "../transaction-payment" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +pallet-transaction-payment = { version = "2.0.0-alpha.2", path = "../transaction-payment" } [features] default = ["std"] diff --git a/frame/benchmarking/Cargo.toml b/frame/benchmarking/Cargo.toml index 63db66fb2040c..ecaf987bb0273 100644 --- a/frame/benchmarking/Cargo.toml +++ b/frame/benchmarking/Cargo.toml @@ -1,19 +1,21 @@ [package] name = "frame-benchmarking" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Macro for benchmarking a FRAME runtime." [dependencies] -codec = { package = "parity-scale-codec", version = "1.1.2", default-features = false } -sp-api = { version = "2.0.0-dev", path = "../../primitives/api", default-features = false } -sp-runtime-interface = { version = "2.0.0-dev", path = "../../primitives/runtime-interface", default-features = false } -sp-std = { version = "2.0.0-dev", path = "../../primitives/std", default-features = false } -sp-io ={ path = "../../primitives/io", default-features = false , version = "2.0.0-dev"} +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false } +sp-api = { version = "2.0.0-alpha.2", path = "../../primitives/api", default-features = false } +sp-runtime-interface = { version = "2.0.0-alpha.2", path = "../../primitives/runtime-interface", default-features = false } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../primitives/runtime", default-features = false } +sp-std = { version = "2.0.0-alpha.2", path = "../../primitives/std", default-features = false } +sp-io = { path = "../../primitives/io", default-features = false, version = "2.0.0-alpha.2" } [features] default = [ "std" ] -std = [ "sp-runtime-interface/std", "sp-api/std", "codec/std", "sp-std/std" ] +std = [ "sp-runtime-interface/std", "sp-runtime/std", "sp-api/std", "codec/std", "sp-std/std" ] diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index 3ad4a9a8a0736..d979000432c91 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -140,7 +140,13 @@ macro_rules! impl_benchmark { $( $name:ident ),* ) => { impl $crate::Benchmarking<$crate::BenchmarkResults> for Module { - fn run_benchmark(extrinsic: Vec, steps: u32, repeat: u32) -> Result, &'static str> { + fn run_benchmark( + extrinsic: Vec, + lowest_range_values: Vec, + highest_range_values: Vec, + steps: Vec, + repeat: u32, + ) -> Result, &'static str> { // Map the input to the selected benchmark. let extrinsic = sp_std::str::from_utf8(extrinsic.as_slice()) .map_err(|_| "Could not find extrinsic")?; @@ -153,24 +159,42 @@ macro_rules! impl_benchmark { $crate::benchmarking::commit_db(); $crate::benchmarking::wipe_db(); - // first one is set_identity. let components = , RawOrigin>>::components(&selected_benchmark); - // results go here let mut results: Vec<$crate::BenchmarkResults> = Vec::new(); + + // Default number of steps for a component. + let mut prev_steps = 10; + // Select the component we will be benchmarking. Each component will be benchmarked. - for (name, low, high) in components.iter() { + for (idx, (name, low, high)) in components.iter().enumerate() { + // Get the number of steps for this component. + let steps = steps.get(idx).cloned().unwrap_or(prev_steps); + prev_steps = steps; + + let lowest = lowest_range_values.get(idx).cloned().unwrap_or(*low); + let highest = highest_range_values.get(idx).cloned().unwrap_or(*high); + + let diff = highest - lowest; + // Create up to `STEPS` steps for that component between high and low. - let step_size = ((high - low) / steps).max(1); - let num_of_steps = (high - low) / step_size; + let step_size = (diff / steps).max(1); + let num_of_steps = diff / step_size + 1; + for s in 0..num_of_steps { // This is the value we will be testing for component `name` - let component_value = low + step_size * s; + let component_value = lowest + step_size * s; - // Select the mid value for all the other components. + // Select the max value for all the other components. let c: Vec<($crate::BenchmarkParameter, u32)> = components.iter() - .map(|(n, l, h)| - (*n, if n == name { component_value } else { (h - l) / 2 + l }) - ).collect(); + .enumerate() + .map(|(idx, (n, l, h))| + if n == name { + (*n, component_value) + } else { + (*n, *highest_range_values.get(idx).unwrap_or(h)) + } + ) + .collect(); // Run the benchmark `repeat` times. for _ in 0..repeat { diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs index 5a67ea6943181..87996c3f57400 100644 --- a/frame/benchmarking/src/utils.rs +++ b/frame/benchmarking/src/utils.rs @@ -19,6 +19,7 @@ use codec::{Encode, Decode}; use sp_std::vec::Vec; use sp_io::hashing::blake2_256; +use sp_runtime::RuntimeString; /// An alphabet of possible parameters to use for benchmarking. #[derive(codec::Encode, codec::Decode, Clone, Copy, PartialEq, Debug)] @@ -40,9 +41,11 @@ sp_api::decl_runtime_apis! { fn dispatch_benchmark( module: Vec, extrinsic: Vec, - steps: u32, + lowest_range_values: Vec, + highest_range_values: Vec, + steps: Vec, repeat: u32, - ) -> Option>; + ) -> Result, RuntimeString>; } } @@ -77,8 +80,16 @@ pub trait Benchmarking { /// Parameters /// - `extrinsic`: The name of extrinsic function you want to benchmark encoded as bytes. /// - `steps`: The number of sample points you want to take across the range of parameters. + /// - `lowest_range_values`: The lowest number for each range of parameters. + /// - `highest_range_values`: The highest number for each range of parameters. /// - `repeat`: The number of times you want to repeat a benchmark. - fn run_benchmark(extrinsic: Vec, steps: u32, repeat: u32) -> Result, &'static str>; + fn run_benchmark( + extrinsic: Vec, + lowest_range_values: Vec, + highest_range_values: Vec, + steps: Vec, + repeat: u32, + ) -> Result, &'static str>; } /// The required setup for creating a benchmark. diff --git a/frame/collective/Cargo.toml b/frame/collective/Cargo.toml index 1e906e95850bc..60899feb4fbb9 100644 --- a/frame/collective/Cargo.toml +++ b/frame/collective/Cargo.toml @@ -1,25 +1,26 @@ [package] name = "pallet-collective" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Collective system: Members of a set of account IDs can make their collective feelings known through dispatched calls from one of two specialized origins." [dependencies] serde = { version = "1.0.101", optional = true } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../primitives/core" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/core" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } [dev-dependencies] hex-literal = "0.2.1" -pallet-balances = { version = "2.0.0-dev", path = "../balances" } +pallet-balances = { version = "2.0.0-alpha.2", path = "../balances" } [features] default = ["std"] diff --git a/frame/contracts/Cargo.toml b/frame/contracts/Cargo.toml index 571ea2d08a7fb..86f39f8a82b94 100644 --- a/frame/contracts/Cargo.toml +++ b/frame/contracts/Cargo.toml @@ -1,34 +1,35 @@ [package] name = "pallet-contracts" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME pallet for WASM contracts" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } pwasm-utils = { version = "0.12.0", default-features = false } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } parity-wasm = { version = "0.41.0", default-features = false } wasmi-validation = { version = "0.3.0", default-features = false } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../primitives/core" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-sandbox = { version = "0.8.0-dev", default-features = false, path = "../../primitives/sandbox" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } -pallet-contracts-primitives = { version = "2.0.0-dev", default-features = false, path = "common" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/core" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-sandbox = { version = "0.8.0-alpha.2", default-features = false, path = "../../primitives/sandbox" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } +pallet-contracts-primitives = { version = "2.0.0-alpha.2", default-features = false, path = "common" } [dev-dependencies] wabt = "0.9.2" assert_matches = "1.3.0" hex-literal = "0.2.1" -pallet-balances = { version = "2.0.0-dev", path = "../balances" } -pallet-timestamp = { version = "2.0.0-dev", path = "../timestamp" } -pallet-randomness-collective-flip = { version = "2.0.0-dev", path = "../randomness-collective-flip" } +pallet-balances = { version = "2.0.0-alpha.2", path = "../balances" } +pallet-timestamp = { version = "2.0.0-alpha.2", path = "../timestamp" } +pallet-randomness-collective-flip = { version = "2.0.0-alpha.2", path = "../randomness-collective-flip" } [features] default = ["std"] diff --git a/frame/contracts/common/Cargo.toml b/frame/contracts/common/Cargo.toml index e70143f76d380..0d009e7c82b41 100644 --- a/frame/contracts/common/Cargo.toml +++ b/frame/contracts/common/Cargo.toml @@ -1,17 +1,18 @@ [package] name = "pallet-contracts-primitives" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "A crate that hosts a common definitions that are relevant for the pallet-contracts." [dependencies] # This crate should not rely on any of the frame primitives. -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/std" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/runtime" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/std" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/runtime" } [features] default = ["std"] diff --git a/frame/contracts/rpc/Cargo.toml b/frame/contracts/rpc/Cargo.toml index 6120cbe51ee0f..092d049c5414b 100644 --- a/frame/contracts/rpc/Cargo.toml +++ b/frame/contracts/rpc/Cargo.toml @@ -1,25 +1,26 @@ [package] name = "pallet-contracts-rpc" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Node-specific RPC methods for interaction with contracts." [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0" } +codec = { package = "parity-scale-codec", version = "1.2.0" } jsonrpc-core = "14.0.3" jsonrpc-core-client = "14.0.3" jsonrpc-derive = "14.0.3" -sp-blockchain = { version = "2.0.0-dev", path = "../../../primitives/blockchain" } -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } -sp-rpc = { version = "2.0.0-dev", path = "../../../primitives/rpc" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../../primitives/blockchain" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } +sp-rpc = { version = "2.0.0-alpha.2", path = "../../../primitives/rpc" } serde = { version = "1.0.101", features = ["derive"] } -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } -sp-api = { version = "2.0.0-dev", path = "../../../primitives/api" } -pallet-contracts-primitives = { version = "2.0.0-dev", path = "../common" } -pallet-contracts-rpc-runtime-api = { version = "0.8.0-dev", path = "./runtime-api" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } +sp-api = { version = "2.0.0-alpha.2", path = "../../../primitives/api" } +pallet-contracts-primitives = { version = "2.0.0-alpha.2", path = "../common" } +pallet-contracts-rpc-runtime-api = { version = "0.8.0-alpha.2", path = "./runtime-api" } [dev-dependencies] serde_json = "1.0.41" diff --git a/frame/contracts/rpc/runtime-api/Cargo.toml b/frame/contracts/rpc/runtime-api/Cargo.toml index ce810b8be3669..8435a6c4238c9 100644 --- a/frame/contracts/rpc/runtime-api/Cargo.toml +++ b/frame/contracts/rpc/runtime-api/Cargo.toml @@ -1,18 +1,19 @@ [package] name = "pallet-contracts-rpc-runtime-api" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Runtime API definition required by Contracts RPC extensions." [dependencies] -sp-api = { version = "2.0.0-dev", default-features = false, path = "../../../../primitives/api" } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../../../primitives/std" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../../../primitives/runtime" } -pallet-contracts-primitives = { version = "2.0.0-dev", default-features = false, path = "../../common" } +sp-api = { version = "2.0.0-alpha.2", default-features = false, path = "../../../../primitives/api" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../../../primitives/std" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../../../primitives/runtime" } +pallet-contracts-primitives = { version = "2.0.0-alpha.2", default-features = false, path = "../../common" } [features] default = ["std"] diff --git a/frame/contracts/src/gas.rs b/frame/contracts/src/gas.rs index c8572daaa43d4..362f15f3aae79 100644 --- a/frame/contracts/src/gas.rs +++ b/frame/contracts/src/gas.rs @@ -250,7 +250,11 @@ pub fn refund_unused_gas( pub fn approx_gas_for_balance(gas_price: Balance, balance: Balance) -> Gas where Balance: AtLeast32Bit { - (balance / gas_price).saturated_into::() + if gas_price.is_zero() { + Zero::zero() + } else { + (balance / gas_price).saturated_into::() + } } /// A simple utility macro that helps to match against a @@ -294,7 +298,7 @@ macro_rules! match_tokens { #[cfg(test)] mod tests { use super::{GasMeter, Token}; - use crate::tests::Test; + use crate::{tests::Test, gas::approx_gas_for_balance}; /// A trivial token that charges the specified number of gas units. #[derive(Copy, Clone, PartialEq, Eq, Debug)] @@ -382,4 +386,22 @@ mod tests { let mut gas_meter = GasMeter::::with_limit(25, 10); assert!(!gas_meter.charge(&(), SimpleToken(25)).is_out_of_gas()); } + + // A unit test for `fn approx_gas_for_balance()`, and makes + // sure setting gas_price 0 does not cause `div by zero` error. + #[test] + fn approx_gas_for_balance_works() { + let tests = vec![ + (approx_gas_for_balance(0_u64, 123), 0), + (approx_gas_for_balance(0_u64, 456), 0), + (approx_gas_for_balance(1_u64, 123), 123), + (approx_gas_for_balance(1_u64, 456), 456), + (approx_gas_for_balance(100_u64, 900), 9), + (approx_gas_for_balance(123_u64, 900), 7), + ]; + + for (lhs, rhs) in tests { + assert_eq!(lhs, rhs); + } + } } diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index e775998a3a553..51da3e8d1ff97 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -2079,6 +2079,22 @@ fn deploy_and_call_other_contract() { }); } +#[test] +fn deploy_works_without_gas_price() { + let (wasm, code_hash) = compile_module::(CODE_GET_RUNTIME_STORAGE).unwrap(); + ExtBuilder::default().existential_deposit(50).gas_price(0).build().execute_with(|| { + Balances::deposit_creating(&ALICE, 1_000_000); + assert_ok!(Contracts::put_code(Origin::signed(ALICE), 100_000, wasm)); + assert_ok!(Contracts::instantiate( + Origin::signed(ALICE), + 100, + 100_000, + code_hash.into(), + vec![], + )); + }); +} + const CODE_SELF_DESTRUCT: &str = r#" (module (import "env" "ext_scratch_size" (func $ext_scratch_size (result i32))) diff --git a/frame/democracy/Cargo.toml b/frame/democracy/Cargo.toml index cf09d24620012..d2938956bd015 100644 --- a/frame/democracy/Cargo.toml +++ b/frame/democracy/Cargo.toml @@ -1,25 +1,26 @@ [package] name = "pallet-democracy" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME pallet for democracy" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } [dev-dependencies] -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -pallet-balances = { version = "2.0.0-dev", path = "../balances" } -sp-storage = { version = "2.0.0-dev", path = "../../primitives/storage" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +pallet-balances = { version = "2.0.0-alpha.2", path = "../balances" } +sp-storage = { version = "2.0.0-alpha.2", path = "../../primitives/storage" } hex-literal = "0.2.1" [features] diff --git a/frame/elections-phragmen/Cargo.toml b/frame/elections-phragmen/Cargo.toml index 6fc83fb370fc3..62ae091e9a41d 100644 --- a/frame/elections-phragmen/Cargo.toml +++ b/frame/elections-phragmen/Cargo.toml @@ -1,26 +1,27 @@ [package] name = "pallet-elections-phragmen" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME election pallet for PHRAGMEN" [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-phragmen = { version = "2.0.0-dev", default-features = false, path = "../../primitives/phragmen" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-phragmen = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/phragmen" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } [dev-dependencies] -sp-io = { version = "2.0.0-dev", path = "../../primitives/io" } +sp-io = { version = "2.0.0-alpha.2", path = "../../primitives/io" } hex-literal = "0.2.1" -pallet-balances = { version = "2.0.0-dev", path = "../balances" } -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -substrate-test-utils = { version = "2.0.0-dev", path = "../../test-utils" } +pallet-balances = { version = "2.0.0-alpha.2", path = "../balances" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +substrate-test-utils = { version = "2.0.0-alpha.2", path = "../../test-utils" } serde = { version = "1.0.101" } [features] diff --git a/frame/elections/Cargo.toml b/frame/elections/Cargo.toml index eafdb2cc97149..e65f4e5d46278 100644 --- a/frame/elections/Cargo.toml +++ b/frame/elections/Cargo.toml @@ -1,25 +1,26 @@ [package] name = "pallet-elections" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME pallet for elections" [dependencies] serde = { version = "1.0.101", optional = true } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../primitives/core" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/core" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } [dev-dependencies] hex-literal = "0.2.1" -pallet-balances = { version = "2.0.0-dev", path = "../balances" } +pallet-balances = { version = "2.0.0-alpha.2", path = "../balances" } [features] default = ["std"] diff --git a/frame/evm/Cargo.toml b/frame/evm/Cargo.toml index 202cc2323857f..76407d57e4284 100644 --- a/frame/evm/Cargo.toml +++ b/frame/evm/Cargo.toml @@ -1,23 +1,24 @@ [package] name = "pallet-evm" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME EVM contracts pallet" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } -pallet-timestamp = { version = "2.0.0-dev", default-features = false, path = "../timestamp" } -pallet-balances = { version = "2.0.0-dev", default-features = false, path = "../balances" } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../primitives/core" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } +pallet-timestamp = { version = "2.0.0-alpha.2", default-features = false, path = "../timestamp" } +pallet-balances = { version = "2.0.0-alpha.2", default-features = false, path = "../balances" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/core" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } primitive-types = { version = "0.6.2", default-features = false, features = ["rlp"] } rlp = { version = "0.4", default-features = false } evm = { version = "0.15", default-features = false } diff --git a/frame/example-offchain-worker/Cargo.toml b/frame/example-offchain-worker/Cargo.toml index 4f4d797202f4e..ff8d780c3cff3 100644 --- a/frame/example-offchain-worker/Cargo.toml +++ b/frame/example-offchain-worker/Cargo.toml @@ -1,21 +1,22 @@ [package] name = "pallet-example-offchain-worker" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "Unlicense" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME example pallet for offchain worker" [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } serde = { version = "1.0.101", optional = true } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../primitives/core" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/core" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } serde_json = { version = "1.0.46", default-features = false, features = ["alloc"] } [features] diff --git a/frame/example/Cargo.toml b/frame/example/Cargo.toml index 07b0a992b2cca..48c1fd57dc99a 100644 --- a/frame/example/Cargo.toml +++ b/frame/example/Cargo.toml @@ -1,24 +1,25 @@ [package] name = "pallet-example" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "Unlicense" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME example pallet" [dependencies] serde = { version = "1.0.101", optional = true } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } -pallet-balances = { version = "2.0.0-dev", default-features = false, path = "../balances" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } +pallet-balances = { version = "2.0.0-alpha.2", default-features = false, path = "../balances" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } [dev-dependencies] -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } [features] default = ["std"] diff --git a/frame/executive/Cargo.toml b/frame/executive/Cargo.toml index 0becc170a3c40..deafb0cadd5d5 100644 --- a/frame/executive/Cargo.toml +++ b/frame/executive/Cargo.toml @@ -1,27 +1,28 @@ [package] name = "frame-executive" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME executives engine" [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } serde = { version = "1.0.101", optional = true } -sp-io ={ path = "../../primitives/io", default-features = false , version = "2.0.0-dev"} -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } +sp-io ={ path = "../../primitives/io", default-features = false , version = "2.0.0-alpha.2"} +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } [dev-dependencies] hex-literal = "0.2.1" -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -pallet-indices = { version = "2.0.0-dev", path = "../indices" } -pallet-balances = { version = "2.0.0-dev", path = "../balances" } -pallet-transaction-payment = { version = "2.0.0-dev", path = "../transaction-payment" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +pallet-indices = { version = "2.0.0-alpha.2", path = "../indices" } +pallet-balances = { version = "2.0.0-alpha.2", path = "../balances" } +pallet-transaction-payment = { version = "2.0.0-alpha.2", path = "../transaction-payment" } [features] default = ["std"] diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index d7fecf45909c8..643ef411fa576 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -81,7 +81,7 @@ use sp_runtime::{ ApplyExtrinsicResult, traits::{ self, Header, Zero, One, Checkable, Applyable, CheckEqual, OnFinalize, OnInitialize, - NumberFor, Block as BlockT, OffchainWorker, Dispatchable, Saturating, + NumberFor, Block as BlockT, OffchainWorker, Dispatchable, Saturating, OnRuntimeUpgrade, }, transaction_validity::TransactionValidity, }; @@ -110,6 +110,7 @@ impl< Context: Default, UnsignedValidator, AllModules: + OnRuntimeUpgrade + OnInitialize + OnFinalize + OffchainWorker + @@ -135,6 +136,7 @@ impl< Context: Default, UnsignedValidator, AllModules: + OnRuntimeUpgrade + OnInitialize + OnFinalize + OffchainWorker + @@ -183,6 +185,13 @@ where digest, frame_system::InitKind::Full, ); + let last_runtime_upgrade = >::last_runtime_upgrade(); + if last_runtime_upgrade.map(|n| n == *block_number).unwrap_or(false) { + ::on_runtime_upgrade(); + >::register_extra_weight_unchecked( + >::on_runtime_upgrade() + ); + } >::on_initialize(*block_number); >::register_extra_weight_unchecked( >::on_initialize(*block_number) diff --git a/frame/finality-tracker/Cargo.toml b/frame/finality-tracker/Cargo.toml index e848c02a42dde..1313080dfe004 100644 --- a/frame/finality-tracker/Cargo.toml +++ b/frame/finality-tracker/Cargo.toml @@ -1,26 +1,29 @@ [package] name = "pallet-finality-tracker" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME Pallet that tracks the last finalized block, as perceived by block authors." +documentation = "https://docs.rs/pallet-finality-tracker" + [dependencies] serde = { version = "1.0.101", default-features = false, features = ["derive"] } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -sp-inherents = { version = "2.0.0-dev", default-features = false, path = "../../primitives/inherents" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-finality-tracker = { version = "2.0.0-dev", default-features = false, path = "../../primitives/finality-tracker" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false } +sp-inherents = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/inherents" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-finality-tracker = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/finality-tracker" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } impl-trait-for-tuples = "0.1.3" [dev-dependencies] -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../primitives/core" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/core" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } [features] default = ["std"] diff --git a/frame/generic-asset/Cargo.toml b/frame/generic-asset/Cargo.toml index 343267f89f32e..a8df92e3c6170 100644 --- a/frame/generic-asset/Cargo.toml +++ b/frame/generic-asset/Cargo.toml @@ -1,31 +1,32 @@ [package] name = "pallet-generic-asset" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Centrality Developers "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME pallet for generic asset management" [dependencies] serde = { version = "1.0.101", optional = true } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } [dev-dependencies] -sp-io ={ version = "2.0.0-dev", path = "../../primitives/io" } -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } +sp-io ={ version = "2.0.0-alpha.2", path = "../../primitives/io" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } [features] default = ["std"] std =[ - "serde/std", - "codec/std", - "sp-std/std", - "sp-runtime/std", - "frame-support/std", - "frame-system/std", + "serde/std", + "codec/std", + "sp-std/std", + "sp-runtime/std", + "frame-support/std", + "frame-system/std", ] diff --git a/frame/grandpa/Cargo.toml b/frame/grandpa/Cargo.toml index 95ed18b0ddc2b..f5cce65fe906a 100644 --- a/frame/grandpa/Cargo.toml +++ b/frame/grandpa/Cargo.toml @@ -1,27 +1,28 @@ [package] name = "pallet-grandpa" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME pallet for GRANDPA finality gadget" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../primitives/core" } -sp-finality-grandpa = { version = "2.0.0-dev", default-features = false, path = "../../primitives/finality-grandpa" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-staking = { version = "2.0.0-dev", default-features = false, path = "../../primitives/staking" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } -pallet-session = { version = "2.0.0-dev", default-features = false, path = "../session" } -pallet-finality-tracker = { version = "2.0.0-dev", default-features = false, path = "../finality-tracker" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/core" } +sp-finality-grandpa = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/finality-grandpa" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-staking = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/staking" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } +pallet-session = { version = "2.0.0-alpha.2", default-features = false, path = "../session" } +pallet-finality-tracker = { version = "2.0.0-alpha.2", default-features = false, path = "../finality-tracker" } [dev-dependencies] -sp-io ={ version = "2.0.0-dev", path = "../../primitives/io" } +sp-io ={ version = "2.0.0-alpha.2", path = "../../primitives/io" } [features] default = ["std"] diff --git a/frame/identity/Cargo.toml b/frame/identity/Cargo.toml index f275dba069e14..7ea53f776ed11 100644 --- a/frame/identity/Cargo.toml +++ b/frame/identity/Cargo.toml @@ -1,26 +1,27 @@ [package] name = "pallet-identity" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME identity management pallet" [dependencies] serde = { version = "1.0.101", optional = true } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } enumflags2 = { version = "0.6.2" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -frame-benchmarking = { version = "2.0.0-dev", default-features = false, path = "../benchmarking" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +frame-benchmarking = { version = "2.0.0-alpha.2", default-features = false, path = "../benchmarking" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } [dev-dependencies] -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -pallet-balances = { version = "2.0.0-dev", path = "../balances" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +pallet-balances = { version = "2.0.0-alpha.2", path = "../balances" } [features] default = ["std"] diff --git a/frame/im-online/Cargo.toml b/frame/im-online/Cargo.toml index d04b2f47a33e3..ab8c066945480 100644 --- a/frame/im-online/Cargo.toml +++ b/frame/im-online/Cargo.toml @@ -1,25 +1,26 @@ [package] name = "pallet-im-online" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME's I'm online pallet" [dependencies] -sp-application-crypto = { version = "2.0.0-dev", default-features = false, path = "../../primitives/application-crypto" } -pallet-authorship = { version = "2.0.0-dev", default-features = false, path = "../authorship" } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../primitives/core" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } +sp-application-crypto = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/application-crypto" } +pallet-authorship = { version = "2.0.0-alpha.2", default-features = false, path = "../authorship" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/core" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } serde = { version = "1.0.101", optional = true } -pallet-session = { version = "2.0.0-dev", default-features = false, path = "../session" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-staking = { version = "2.0.0-dev", default-features = false, path = "../../primitives/staking" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } +pallet-session = { version = "2.0.0-alpha.2", default-features = false, path = "../session" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-staking = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/staking" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } [features] default = ["std", "pallet-session/historical"] diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index d6d13c66c2501..9aa8d2d67f6fe 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -608,7 +608,9 @@ impl pallet_session::OneSessionHandler for Module { let validator_set_count = keys.len() as u32; let offence = UnresponsivenessOffence { session_index, validator_set_count, offenders }; - T::ReportUnresponsiveness::report_offence(vec![], offence); + if let Err(e) = T::ReportUnresponsiveness::report_offence(vec![], offence) { + sp_runtime::print(e); + } } } diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index a703b24629c0f..78b6409d543eb 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -22,7 +22,7 @@ use std::cell::RefCell; use crate::{Module, Trait}; use sp_runtime::Perbill; -use sp_staking::{SessionIndex, offence::ReportOffence}; +use sp_staking::{SessionIndex, offence::{ReportOffence, OffenceError}}; use sp_runtime::testing::{Header, UintAuthorityId, TestXt}; use sp_runtime::traits::{IdentityLookup, BlakeTwo256, ConvertInto}; use sp_core::H256; @@ -49,6 +49,7 @@ impl pallet_session::SessionManager for TestSessionManager { VALIDATORS.with(|l| l.borrow_mut().take()) } fn end_session(_: SessionIndex) {} + fn start_session(_: SessionIndex) {} } impl pallet_session::historical::SessionManager for TestSessionManager { @@ -62,6 +63,7 @@ impl pallet_session::historical::SessionManager for TestSessionManager ) } fn end_session(_: SessionIndex) {} + fn start_session(_: SessionIndex) {} } /// An extrinsic type used for tests. @@ -77,8 +79,9 @@ thread_local! { /// A mock offence report handler. pub struct OffenceHandler; impl ReportOffence for OffenceHandler { - fn report_offence(reporters: Vec, offence: Offence) { + fn report_offence(reporters: Vec, offence: Offence) -> Result<(), OffenceError> { OFFENCES.with(|l| l.borrow_mut().push((reporters, offence))); + Ok(()) } } diff --git a/frame/indices/Cargo.toml b/frame/indices/Cargo.toml index b02b96fc3bdf3..d7e01765b59d1 100644 --- a/frame/indices/Cargo.toml +++ b/frame/indices/Cargo.toml @@ -1,25 +1,26 @@ [package] name = "pallet-indices" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME indices management pallet" [dependencies] serde = { version = "1.0.101", optional = true } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-keyring = { version = "2.0.0-dev", optional = true, path = "../../primitives/keyring" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../primitives/core" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-keyring = { version = "2.0.0-alpha.2", optional = true, path = "../../primitives/keyring" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/core" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } [dev-dependencies] -pallet-balances = { version = "2.0.0-dev", path = "../balances" } +pallet-balances = { version = "2.0.0-alpha.2", path = "../balances" } [features] default = ["std"] diff --git a/frame/indices/src/lib.rs b/frame/indices/src/lib.rs index d59a50179372d..95ac6cf752838 100644 --- a/frame/indices/src/lib.rs +++ b/frame/indices/src/lib.rs @@ -264,7 +264,7 @@ impl StaticLookup for Module { type Source = address::Address; type Target = T::AccountId; - fn lookup(a: Self::Source) -> Result { + fn lookup(a: Self::Source) -> Result { Self::lookup_address(a).ok_or(LookupError) } diff --git a/frame/membership/Cargo.toml b/frame/membership/Cargo.toml index 2e3356950b1ec..b54109083dc0d 100644 --- a/frame/membership/Cargo.toml +++ b/frame/membership/Cargo.toml @@ -1,23 +1,24 @@ [package] name = "pallet-membership" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME membership management pallet" [dependencies] serde = { version = "1.0.101", optional = true } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } [dev-dependencies] -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } [features] default = ["std"] diff --git a/frame/metadata/Cargo.toml b/frame/metadata/Cargo.toml index 512898879abd4..b3d333f369fbd 100644 --- a/frame/metadata/Cargo.toml +++ b/frame/metadata/Cargo.toml @@ -1,17 +1,18 @@ [package] name = "frame-metadata" -version = "11.0.0-dev" +version = "11.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Decodable variant of the RuntimeMetadata." [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../primitives/core" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/core" } [features] default = ["std"] diff --git a/frame/nicks/Cargo.toml b/frame/nicks/Cargo.toml index eedbaccfe56d5..07c84c439ffaa 100644 --- a/frame/nicks/Cargo.toml +++ b/frame/nicks/Cargo.toml @@ -1,24 +1,25 @@ [package] name = "pallet-nicks" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME pallet for nick management" [dependencies] serde = { version = "1.0.101", optional = true } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } [dev-dependencies] -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -pallet-balances = { version = "2.0.0-dev", path = "../balances" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +pallet-balances = { version = "2.0.0-alpha.2", path = "../balances" } [features] default = ["std"] diff --git a/frame/offences/Cargo.toml b/frame/offences/Cargo.toml index 1c244a74135e8..99c52e4088537 100644 --- a/frame/offences/Cargo.toml +++ b/frame/offences/Cargo.toml @@ -1,25 +1,26 @@ [package] name = "pallet-offences" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME offences pallet" [dependencies] -pallet-balances = { version = "2.0.0-dev", default-features = false, path = "../balances" } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } +pallet-balances = { version = "2.0.0-alpha.2", default-features = false, path = "../balances" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } serde = { version = "1.0.101", optional = true } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-staking = { version = "2.0.0-dev", default-features = false, path = "../../primitives/staking" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-staking = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/staking" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } [dev-dependencies] -sp-io = { version = "2.0.0-dev", path = "../../primitives/io" } -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } +sp-io = { version = "2.0.0-alpha.2", path = "../../primitives/io" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } [features] default = ["std"] diff --git a/frame/offences/src/lib.rs b/frame/offences/src/lib.rs index 7831ba65a3b06..27983cbb5332e 100644 --- a/frame/offences/src/lib.rs +++ b/frame/offences/src/lib.rs @@ -30,7 +30,7 @@ use frame_support::{ }; use sp_runtime::traits::Hash; use sp_staking::{ - offence::{Offence, ReportOffence, Kind, OnOffenceHandler, OffenceDetails}, + offence::{Offence, ReportOffence, Kind, OnOffenceHandler, OffenceDetails, OffenceError}, }; use codec::{Encode, Decode}; use frame_system as system; @@ -90,7 +90,7 @@ impl> where T::IdentificationTuple: Clone, { - fn report_offence(reporters: Vec, offence: O) { + fn report_offence(reporters: Vec, offence: O) -> Result<(), OffenceError> { let offenders = offence.offenders(); let time_slot = offence.time_slot(); let validator_set_count = offence.validator_set_count(); @@ -104,7 +104,7 @@ where ) { Some(triage) => triage, // The report contained only duplicates, so there is no need to slash again. - None => return, + None => return Err(OffenceError::DuplicateReport), }; // Deposit the event. @@ -123,6 +123,8 @@ where &slash_perbill, offence.session_index(), ); + + Ok(()) } } diff --git a/frame/offences/src/tests.rs b/frame/offences/src/tests.rs index f2f82cf7a87ee..0ed98427c65f8 100644 --- a/frame/offences/src/tests.rs +++ b/frame/offences/src/tests.rs @@ -40,7 +40,7 @@ fn should_report_an_authority_and_trigger_on_offence() { }; // when - Offences::report_offence(vec![], offence); + Offences::report_offence(vec![], offence).unwrap(); // then with_on_offence_fractions(|f| { @@ -61,7 +61,7 @@ fn should_not_report_the_same_authority_twice_in_the_same_slot() { time_slot, offenders: vec![5], }; - Offences::report_offence(vec![], offence.clone()); + Offences::report_offence(vec![], offence.clone()).unwrap(); with_on_offence_fractions(|f| { assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); f.clear(); @@ -69,7 +69,7 @@ fn should_not_report_the_same_authority_twice_in_the_same_slot() { // when // report for the second time - Offences::report_offence(vec![], offence); + assert_eq!(Offences::report_offence(vec![], offence), Err(OffenceError::DuplicateReport)); // then with_on_offence_fractions(|f| { @@ -91,7 +91,7 @@ fn should_report_in_different_time_slot() { time_slot, offenders: vec![5], }; - Offences::report_offence(vec![], offence.clone()); + Offences::report_offence(vec![], offence.clone()).unwrap(); with_on_offence_fractions(|f| { assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); f.clear(); @@ -100,7 +100,7 @@ fn should_report_in_different_time_slot() { // when // report for the second time offence.time_slot += 1; - Offences::report_offence(vec![], offence); + Offences::report_offence(vec![], offence).unwrap(); // then with_on_offence_fractions(|f| { @@ -123,7 +123,7 @@ fn should_deposit_event() { }; // when - Offences::report_offence(vec![], offence); + Offences::report_offence(vec![], offence).unwrap(); // then assert_eq!( @@ -149,7 +149,7 @@ fn doesnt_deposit_event_for_dups() { time_slot, offenders: vec![5], }; - Offences::report_offence(vec![], offence.clone()); + Offences::report_offence(vec![], offence.clone()).unwrap(); with_on_offence_fractions(|f| { assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); f.clear(); @@ -157,7 +157,7 @@ fn doesnt_deposit_event_for_dups() { // when // report for the second time - Offences::report_offence(vec![], offence); + assert_eq!(Offences::report_offence(vec![], offence), Err(OffenceError::DuplicateReport)); // then // there is only one event. @@ -191,7 +191,7 @@ fn should_properly_count_offences() { time_slot, offenders: vec![4], }; - Offences::report_offence(vec![], offence1); + Offences::report_offence(vec![], offence1).unwrap(); with_on_offence_fractions(|f| { assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); f.clear(); @@ -199,7 +199,7 @@ fn should_properly_count_offences() { // when // report for the second time - Offences::report_offence(vec![], offence2); + Offences::report_offence(vec![], offence2).unwrap(); // then // the 1st authority should have count 2 and the 2nd one should be reported only once. diff --git a/frame/randomness-collective-flip/Cargo.toml b/frame/randomness-collective-flip/Cargo.toml index d8bac86ab4858..4e4ce76fee7ed 100644 --- a/frame/randomness-collective-flip/Cargo.toml +++ b/frame/randomness-collective-flip/Cargo.toml @@ -1,23 +1,24 @@ [package] name = "pallet-randomness-collective-flip" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME randomness collective flip pallet" [dependencies] safe-mix = { version = "1.0", default-features = false } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } [dev-dependencies] -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -sp-io = { version = "2.0.0-dev", path = "../../primitives/io" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +sp-io = { version = "2.0.0-alpha.2", path = "../../primitives/io" } [features] default = ["std"] diff --git a/frame/recovery/Cargo.toml b/frame/recovery/Cargo.toml index 13a74dcdcb2fd..80456aa375dd2 100644 --- a/frame/recovery/Cargo.toml +++ b/frame/recovery/Cargo.toml @@ -1,25 +1,26 @@ [package] name = "pallet-recovery" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME account recovery pallet" [dependencies] serde = { version = "1.0.101", optional = true } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } enumflags2 = { version = "0.6.2" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } [dev-dependencies] -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -pallet-balances = { version = "2.0.0-dev", path = "../balances" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +pallet-balances = { version = "2.0.0-alpha.2", path = "../balances" } [features] default = ["std"] diff --git a/frame/scored-pool/Cargo.toml b/frame/scored-pool/Cargo.toml index b8ee128df6bd8..a1b7b39d8cd9f 100644 --- a/frame/scored-pool/Cargo.toml +++ b/frame/scored-pool/Cargo.toml @@ -1,24 +1,25 @@ [package] name = "pallet-scored-pool" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME pallet for scored pools" [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } serde = { version = "1.0.101", optional = true } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } [dev-dependencies] -pallet-balances = { version = "2.0.0-dev", path = "../balances" } -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } +pallet-balances = { version = "2.0.0-alpha.2", path = "../balances" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } [features] default = ["std"] diff --git a/frame/session/Cargo.toml b/frame/session/Cargo.toml index bee544f99af0a..74ca9fe67bb41 100644 --- a/frame/session/Cargo.toml +++ b/frame/session/Cargo.toml @@ -1,28 +1,29 @@ [package] name = "pallet-session" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME sessions pallet" [dependencies] serde = { version = "1.0.101", optional = true } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-staking = { version = "2.0.0-dev", default-features = false, path = "../../primitives/staking" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } -pallet-timestamp = { version = "2.0.0-dev", default-features = false, path = "../timestamp" } -sp-trie = { optional = true, path = "../../primitives/trie", default-features = false , version = "2.0.0-dev"} -sp-io ={ path = "../../primitives/io", default-features = false , version = "2.0.0-dev"} +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-staking = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/staking" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } +pallet-timestamp = { version = "2.0.0-alpha.2", default-features = false, path = "../timestamp" } +sp-trie = { optional = true, path = "../../primitives/trie", default-features = false , version = "2.0.0-alpha.2"} +sp-io ={ path = "../../primitives/io", default-features = false , version = "2.0.0-alpha.2"} impl-trait-for-tuples = "0.1.3" [dev-dependencies] -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -sp-application-crypto = { version = "2.0.0-dev", path = "../../primitives/application-crypto" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +sp-application-crypto = { version = "2.0.0-alpha.2", path = "../../primitives/application-crypto" } lazy_static = "1.4.0" [features] diff --git a/frame/session/src/historical.rs b/frame/session/src/historical.rs index ced630e5fd8ae..6c305a1a1d60b 100644 --- a/frame/session/src/historical.rs +++ b/frame/session/src/historical.rs @@ -108,6 +108,7 @@ pub trait SessionManager: crate::SessionManager /// If there was a validator set change, its returns the set of new validators along with their /// full identifications. fn new_session(new_index: SessionIndex) -> Option>; + fn start_session(start_index: SessionIndex); fn end_session(end_index: SessionIndex); } @@ -146,6 +147,9 @@ impl crate::SessionManager for NoteHistoricalRoot>::start_session(start_index) + } fn end_session(end_index: SessionIndex) { >::end_session(end_index) } diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index 6340b79f0f579..1097cfd6be2e4 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -162,10 +162,15 @@ pub trait SessionManager { /// Because the session pallet can queue validator set the ending session can be lower than the /// last new session index. fn end_session(end_index: SessionIndex); + /// Start the session. + /// + /// The session start to be used for validation + fn start_session(start_index: SessionIndex); } impl SessionManager for () { fn new_session(_: SessionIndex) -> Option> { None } + fn start_session(_: SessionIndex) {} fn end_session(_: SessionIndex) {} } @@ -423,6 +428,8 @@ decl_storage! { >::put(initial_validators_0); >::put(queued_keys); + + T::SessionManager::start_session(0); }); } } @@ -520,6 +527,8 @@ impl Module { // Inform the session handlers that a session is going to end. T::SessionHandler::on_before_session_ending(); + T::SessionManager::end_session(session_index); + // Get queued session keys and validators. let session_keys = >::get(); let validators = session_keys.iter() @@ -532,12 +541,12 @@ impl Module { DisabledValidators::take(); } - T::SessionManager::end_session(session_index); - // Increment session index. let session_index = session_index + 1; CurrentIndex::put(session_index); + T::SessionManager::start_session(session_index); + // Get next validator set. let maybe_next_validators = T::SessionManager::new_session(session_index + 1); let (next_validators, next_identities_changed) diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index df858c8ed57ac..9d64285b900f8 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -92,6 +92,7 @@ impl SessionHandler for TestSessionHandler { pub struct TestSessionManager; impl SessionManager for TestSessionManager { fn end_session(_: SessionIndex) {} + fn start_session(_: SessionIndex) {} fn new_session(_: SessionIndex) -> Option> { if !TEST_SESSION_CHANGED.with(|l| *l.borrow()) { VALIDATORS.with(|v| { @@ -112,6 +113,7 @@ impl SessionManager for TestSessionManager { #[cfg(feature = "historical")] impl crate::historical::SessionManager for TestSessionManager { fn end_session(_: SessionIndex) {} + fn start_session(_: SessionIndex) {} fn new_session(new_index: SessionIndex) -> Option> { diff --git a/frame/society/Cargo.toml b/frame/society/Cargo.toml index 248820b522bec..35b1c5c4a4515 100644 --- a/frame/society/Cargo.toml +++ b/frame/society/Cargo.toml @@ -1,25 +1,26 @@ [package] name = "pallet-society" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME society pallet" [dependencies] serde = { version = "1.0.101", optional = true } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-io ={ path = "../../primitives/io", default-features = false , version = "2.0.0-dev"} -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-io ={ path = "../../primitives/io", default-features = false , version = "2.0.0-alpha.2"} +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } rand_chacha = { version = "0.2", default-features = false } [dev-dependencies] -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -pallet-balances = { version = "2.0.0-dev", path = "../balances" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +pallet-balances = { version = "2.0.0-alpha.2", path = "../balances" } [features] default = ["std"] diff --git a/frame/staking/Cargo.toml b/frame/staking/Cargo.toml index 7eb7772054c30..ef4bb60a29e6a 100644 --- a/frame/staking/Cargo.toml +++ b/frame/staking/Cargo.toml @@ -1,32 +1,33 @@ [package] name = "pallet-staking" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME pallet staking" [dependencies] serde = { version = "1.0.101", optional = true } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-keyring = { version = "2.0.0-dev", optional = true, path = "../../primitives/keyring" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-phragmen = { version = "2.0.0-dev", default-features = false, path = "../../primitives/phragmen" } -sp-io ={ path = "../../primitives/io", default-features = false , version = "2.0.0-dev"} -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-staking = { version = "2.0.0-dev", default-features = false, path = "../../primitives/staking" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } -pallet-session = { version = "2.0.0-dev", features = ["historical"], path = "../session", default-features = false } -pallet-authorship = { version = "2.0.0-dev", default-features = false, path = "../authorship" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-keyring = { version = "2.0.0-alpha.2", optional = true, path = "../../primitives/keyring" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-phragmen = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/phragmen" } +sp-io ={ path = "../../primitives/io", default-features = false , version = "2.0.0-alpha.2"} +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-staking = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/staking" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } +pallet-session = { version = "2.0.0-alpha.2", features = ["historical"], path = "../session", default-features = false } +pallet-authorship = { version = "2.0.0-alpha.2", default-features = false, path = "../authorship" } [dev-dependencies] -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -pallet-balances = { version = "2.0.0-dev", path = "../balances" } -pallet-timestamp = { version = "2.0.0-dev", path = "../timestamp" } -pallet-staking-reward-curve = { version = "2.0.0-dev", path = "../staking/reward-curve" } -substrate-test-utils = { version = "2.0.0-dev", path = "../../test-utils" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +pallet-balances = { version = "2.0.0-alpha.2", path = "../balances" } +pallet-timestamp = { version = "2.0.0-alpha.2", path = "../timestamp" } +pallet-staking-reward-curve = { version = "2.0.0-alpha.2", path = "../staking/reward-curve" } +substrate-test-utils = { version = "2.0.0-alpha.2", path = "../../test-utils" } [features] migrate = [] diff --git a/frame/staking/reward-curve/Cargo.toml b/frame/staking/reward-curve/Cargo.toml index 95567f167fac9..3d0920e644f7b 100644 --- a/frame/staking/reward-curve/Cargo.toml +++ b/frame/staking/reward-curve/Cargo.toml @@ -1,11 +1,12 @@ [package] name = "pallet-staking-reward-curve" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Reward Curve for FRAME staking pallet" [lib] proc-macro = true @@ -17,4 +18,4 @@ proc-macro2 = "1.0.6" proc-macro-crate = "0.1.4" [dev-dependencies] -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index ee708dabd3c6e..e6afdd421190a 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -104,6 +104,11 @@ //! The **reward and slashing** procedure is the core of the Staking module, attempting to _embrace //! valid behavior_ while _punishing any misbehavior or lack of availability_. //! +//! Reward must be claimed by stakers for each era before it gets too old by $HISTORY_DEPTH using +//! `payout_nominator` and `payout_validator` calls. +//! Only the [`T::MaxNominatorRewardedPerValidator`] biggest stakers can claim their reward. This +//! limit the i/o cost to compute nominators payout. +//! //! Slashing can occur at any point in time, once misbehavior is reported. Once slashing is //! determined, a value is deducted from the balance of the validator and all the nominators who //! voted for this validator (values are deducted from the _stash_ account of the slashed entity). @@ -122,6 +127,11 @@ //! //! An account can step back via the [`chill`](enum.Call.html#variant.chill) call. //! +//! ### Session managing +//! +//! The module implement the trait `SessionManager`. Which is the only API to query new validator +//! set and allowing these validator set to be rewarded once their era is ended. +//! //! ## Interface //! //! ### Dispatchable Functions @@ -159,14 +169,6 @@ //! //! ## Implementation Details //! -//! ### Slot Stake -//! -//! The term [`SlotStake`](./struct.Module.html#method.slot_stake) will be used throughout this -//! section. It refers to a value calculated at the end of each era, containing the _minimum value -//! at stake among all validators._ Note that a validator's value at stake might be a combination -//! of the validator's own stake and the votes it received. See [`Exposure`](./struct.Exposure.html) -//! for more details. -//! //! ### Reward Calculation //! //! Validators and nominators are rewarded at the end of each era. The total reward of an era is @@ -236,6 +238,7 @@ //! ## GenesisConfig //! //! The Staking module depends on the [`GenesisConfig`](./struct.GenesisConfig.html). +//! The `GenesisConfig` is optional and allow to set some initial stakers. //! //! ## Related Modules //! @@ -254,7 +257,7 @@ mod slashing; pub mod inflation; -use sp_std::{prelude::*, result}; +use sp_std::{prelude::*, result, collections::btree_map::BTreeMap}; use codec::{HasCompact, Encode, Decode}; use frame_support::{ decl_module, decl_event, decl_storage, ensure, decl_error, @@ -270,13 +273,13 @@ use sp_runtime::{ Perbill, PerThing, RuntimeDebug, curve::PiecewiseLinear, traits::{ - Convert, Zero, One, StaticLookup, CheckedSub, Saturating, Bounded, SaturatedConversion, + Convert, Zero, StaticLookup, CheckedSub, Saturating, SaturatedConversion, AtLeast32Bit, EnsureOrigin, } }; use sp_staking::{ SessionIndex, - offence::{OnOffenceHandler, OffenceDetails, Offence, ReportOffence}, + offence::{OnOffenceHandler, OffenceDetails, Offence, ReportOffence, OffenceError}, }; #[cfg(feature = "std")] use sp_runtime::{Serialize, Deserialize}; @@ -293,28 +296,29 @@ const STAKING_ID: LockIdentifier = *b"staking "; pub type EraIndex = u32; /// Counter for the number of "reward" points earned by a given validator. -pub type Points = u32; +pub type RewardPoint = u32; + +/// Information regarding the active era (era in used in session). +#[derive(Encode, Decode, Debug)] +pub struct ActiveEraInfo { + /// Index of era. + index: EraIndex, + /// Moment of start + /// + /// Start can be none if start hasn't been set for the era yet, + /// Start is set on the first on_finalize of the era to guarantee usage of `Time`. + start: Option, +} /// Reward points of an era. Used to split era total payout between validators. -#[derive(Encode, Decode, Default)] -pub struct EraPoints { +/// +/// This points will be used to reward validators and their respective nominators. +#[derive(PartialEq, Encode, Decode, Default, Debug)] +pub struct EraRewardPoints { /// Total number of points. Equals the sum of reward points for each validator. - total: Points, - /// The reward points earned by a given validator. The index of this vec corresponds to the - /// index into the current validator set. - individual: Vec, -} - -impl EraPoints { - /// Add the reward to the validator at the given index. Index must be valid - /// (i.e. `index < current_elected.len()`). - fn add_points_to_index(&mut self, index: u32, points: u32) { - if let Some(new_total) = self.total.checked_add(points) { - self.total = new_total; - self.individual.resize((index as usize + 1).max(self.individual.len()), 0); - self.individual[index as usize] += points; // Addition is less than total - } - } + total: RewardPoint, + /// The reward points earned by a given validator. + individual: BTreeMap, } /// Indicates the initial status of the staker. @@ -390,6 +394,8 @@ pub struct StakingLedger { /// Any balance that is becoming free, which may eventually be transferred out /// of the stash (assuming it doesn't get slashed first). pub unlocking: Vec>, + /// The latest and highest era which the staker has claimed reward for. + pub last_reward: Option, } impl< @@ -408,7 +414,14 @@ impl< false }) .collect(); - Self { total, active: self.active, stash: self.stash, unlocking } + + Self { + stash: self.stash, + total, + active: self.active, + unlocking, + last_reward: self.last_reward + } } /// Re-bond funds that were scheduled for unlocking. @@ -499,6 +512,8 @@ pub struct Nominations { /// The targets of nomination. pub targets: Vec, /// The era the nominations were submitted. + /// + /// Except for initial nominations which are considered submitted at era 0. pub submitted_in: EraIndex, /// Whether the nominations have been suppressed. pub suppressed: bool, @@ -595,6 +610,9 @@ pub trait Trait: frame_system::Trait { type Currency: LockableCurrency; /// Time used for computing era duration. + /// + /// It is guaranteed to start being called from the first `on_finalize`. Thus value at genesis + /// is not used. type Time: Time; /// Convert a balance into a number used for election calculation. @@ -635,6 +653,12 @@ pub trait Trait: frame_system::Trait { /// The NPoS reward curve to use. type RewardCurve: Get<&'static PiecewiseLinear<'static>>; + + /// The maximum number of nominator rewarded for each validator. + /// + /// For each validator only the `$MaxNominatorRewardedPerValidator` biggest stakers can claim + /// their reward. This used to limit the i/o cost for the nominator payout. + type MaxNominatorRewardedPerValidator: Get; } /// Mode of era-forcing. @@ -657,9 +681,18 @@ impl Default for Forcing { decl_storage! { trait Store for Module as Staking { + /// Number of era to keep in history. + /// + /// Information is kept for eras in `[current_era - history_depth; current_era] + /// + /// Must be more than the number of era delayed by session otherwise. + /// i.e. active era must always be in history. + /// i.e. `active_era > current_era - history_depth` must be guaranteed. + HistoryDepth get(fn history_depth) config(): u32 = 84; /// The ideal number of staking participants. pub ValidatorCount get(fn validator_count) config(): u32; + /// Minimum number of staking participants before emergency conditions are imposed. pub MinimumValidatorCount get(fn minimum_validator_count) config(): u32 = DEFAULT_MINIMUM_VALIDATOR_COUNT; @@ -671,6 +704,7 @@ decl_storage! { /// Map from all locked "stash" accounts to the controller account. pub Bonded get(fn bonded): map hasher(blake2_256) T::AccountId => Option; + /// Map from all (unlocked) "controller" accounts to the info regarding the staking. pub Ledger get(fn ledger): map hasher(blake2_256) T::AccountId @@ -684,40 +718,74 @@ decl_storage! { linked_map hasher(blake2_256) T::AccountId => ValidatorPrefs; /// The map from nominator stash key to the set of stash keys of all validators to nominate. - /// - /// NOTE: is private so that we can ensure upgraded before all typical accesses. - /// Direct storage APIs can still bypass this protection. - Nominators get(fn nominators): + pub Nominators get(fn nominators): linked_map hasher(blake2_256) T::AccountId => Option>; - /// Nominators for a particular account that is in action right now. You can't iterate - /// through validators here, but you can find them in the Session module. + /// The current era index. /// - /// This is keyed by the stash account. - pub Stakers get(fn stakers): - map hasher(blake2_256) T::AccountId => Exposure>; + /// This is the latest planned era, depending on how session module queues the validator + /// set, it might be active or not. + pub CurrentEra get(fn current_era): Option; - /// The currently elected validator set keyed by stash account ID. - pub CurrentElected get(fn current_elected): Vec; + /// The active era information, it holds index and start. + /// + /// The active era is the era currently rewarded. + /// Validator set of this era must be equal to `SessionInterface::validators`. + pub ActiveEra get(fn active_era): Option>>; - /// The current era index. - pub CurrentEra get(fn current_era) config(): EraIndex; + /// The session index at which the era start for the last `HISTORY_DEPTH` eras + pub ErasStartSessionIndex get(fn eras_start_session_index): + map hasher(blake2_256) EraIndex => Option; - /// The start of the current era. - pub CurrentEraStart get(fn current_era_start): MomentOf; + /// Exposure of validator at era. + /// + /// This is keyed first by the era index to allow bulk deletion and then the stash account. + /// + /// Is it removed after `HISTORY_DEPTH` eras. + /// If stakers hasn't been set or has been removed then empty exposure is returned. + pub ErasStakers get(fn eras_stakers): + double_map hasher(twox_64_concat) EraIndex, hasher(twox_64_concat) T::AccountId + => Exposure>; - /// The session index at which the current era started. - pub CurrentEraStartSessionIndex get(fn current_era_start_session_index): SessionIndex; + /// Clipped Exposure of validator at era. + /// + /// This is similar to [`ErasStakers`] but number of nominators exposed is reduce to the + /// `T::MaxNominatorRewardedPerValidator` biggest stakers. + /// This is used to limit the i/o cost for the nominator payout. + /// + /// This is keyed fist by the era index to allow bulk deletion and then the stash account. + /// + /// Is it removed after `HISTORY_DEPTH` eras. + /// If stakers hasn't been set or has been removed then empty exposure is returned. + pub ErasStakersClipped get(fn eras_stakers_clipped): + double_map hasher(twox_64_concat) EraIndex, hasher(twox_64_concat) T::AccountId + => Exposure>; - /// Rewards for the current era. Using indices of current elected set. - CurrentEraPointsEarned get(fn current_era_reward): EraPoints; + /// Similarly to `ErasStakers` this holds the preferences of validators. + /// + /// This is keyed fist by the era index to allow bulk deletion and then the stash account. + /// + /// Is it removed after `HISTORY_DEPTH` eras. + // If prefs hasn't been set or has been removed then 0 commission is returned. + pub ErasValidatorPrefs get(fn eras_validator_prefs): + double_map hasher(twox_64_concat) EraIndex, hasher(twox_64_concat) T::AccountId + => ValidatorPrefs; - /// The amount of balance actively at stake for each validator slot, currently. + /// The total validator era payout for the last `HISTORY_DEPTH` eras. /// - /// This is used to derive rewards and punishments. - pub SlotStake get(fn slot_stake) build(|config: &GenesisConfig| { - config.stakers.iter().map(|&(_, _, value, _)| value).min().unwrap_or_default() - }): BalanceOf; + /// Eras that haven't finished yet or has been removed doesn't have reward. + pub ErasValidatorReward get(fn eras_validator_reward): + map hasher(blake2_256) EraIndex => Option>; + + /// Rewards for the last `HISTORY_DEPTH` eras. + /// If reward hasn't been set or has been removed then 0 reward is returned. + pub ErasRewardPoints get(fn eras_reward_points): + map hasher(blake2_256) EraIndex => EraRewardPoints; + + /// The total amount staked for the last `HISTORY_DEPTH` eras. + /// If total hasn't been set or has been removed then 0 stake is returned. + pub ErasTotalStake get(fn eras_total_stake): + map hasher(blake2_256) EraIndex => BalanceOf; /// True if the next session change will be a new era regardless of index. pub ForceEra get(fn force_era) config(): Forcing; @@ -736,6 +804,9 @@ decl_storage! { map hasher(blake2_256) EraIndex => Vec>>; /// A mapping from still-bonded eras to the first session index of that era. + /// + /// Must contains information for eras for the range: + /// `[active_era - bounding_duration; active_era]` BondedEras: Vec<(EraIndex, SessionIndex)>; /// All slashing events on validators, mapped by era to the highest slash proportion @@ -760,6 +831,11 @@ decl_storage! { /// The earliest era for which we have a pending, unapplied slash. EarliestUnappliedSlash: Option; + + /// True if network has been upgraded to this version. + /// + /// True for new networks. + IsUpgraded build(|_| true): bool; } add_extra_genesis { config(stakers): @@ -797,9 +873,8 @@ decl_storage! { decl_event!( pub enum Event where Balance = BalanceOf, ::AccountId { - /// All validators have been rewarded by the first balance; the second is the remainder - /// from the maximum amount of reward. - Reward(Balance, Balance), + /// The staker has been rewarded by this amount. AccountId is controller account. + Reward(AccountId, Balance), /// One validator (and its nominators) has been slashed by the given amount. Slash(AccountId, Balance), /// An old slashing report from a prior era was discarded because it could @@ -833,6 +908,10 @@ decl_error! { NoUnlockChunk, /// Attempting to target a stash that still has funds. FundedTarget, + /// Invalid era to reward. + InvalidEraToReward, + /// Invalid number of nominations. + InvalidNumberOfNominations, } } @@ -848,14 +927,20 @@ decl_module! { fn deposit_event() = default; - fn on_initialize() { + fn on_runtime_upgrade() { Self::ensure_storage_upgraded(); } + fn on_initialize() { + } + fn on_finalize() { // Set the start of the first era. - if !>::exists() { - >::put(T::Time::now()); + if let Some(mut active_era) = Self::active_era() { + if active_era.start.is_none() { + active_era.start = Some(T::Time::now()); + >::put(active_era); + } } } @@ -906,7 +991,13 @@ decl_module! { let stash_balance = T::Currency::free_balance(&stash); let value = value.min(stash_balance); - let item = StakingLedger { stash, total: value, active: value, unlocking: vec![] }; + let item = StakingLedger { + stash, + total: value, + active: value, + unlocking: vec![], + last_reward: Self::current_era(), + }; Self::update_ledger(&controller, &item); } @@ -961,7 +1052,8 @@ decl_module! { /// - Contains a limited number of reads. /// - Each call (requires the remainder of the bonded balance to be above `minimum_balance`) /// will cause a new entry to be inserted into a vector (`Ledger.unlocking`) kept in storage. - /// The only way to clean the aforementioned storage item is also user-controlled via `withdraw_unbonded`. + /// The only way to clean the aforementioned storage item is also user-controlled via + /// `withdraw_unbonded`. /// - One DB entry. /// #[weight = SimpleDispatchInfo::FixedNormal(400_000)] @@ -984,7 +1076,8 @@ decl_module! { ledger.active = Zero::zero(); } - let era = Self::current_era() + T::BondingDuration::get(); + // Note: in case there is no current era it is fine to bond one era more. + let era = Self::current_era().unwrap_or(0) + T::BondingDuration::get(); ledger.unlocking.push(UnlockChunk { value, era }); Self::update_ledger(&controller, &ledger); } @@ -1009,8 +1102,10 @@ decl_module! { #[weight = SimpleDispatchInfo::FixedNormal(400_000)] fn withdraw_unbonded(origin) { let controller = ensure_signed(origin)?; - let ledger = Self::ledger(&controller).ok_or(Error::::NotController)?; - let ledger = ledger.consolidate_unlocked(Self::current_era()); + let mut ledger = Self::ledger(&controller).ok_or(Error::::NotController)?; + if let Some(current_era) = Self::current_era() { + ledger = ledger.consolidate_unlocked(current_era) + } if ledger.unlocking.is_empty() && ledger.active.is_zero() { // This account must have called `unbond()` with some value that caused the active @@ -1075,7 +1170,8 @@ decl_module! { let nominations = Nominations { targets, - submitted_in: Self::current_era(), + // initial nominations are considered submitted at era 0. See `Nominations` doc + submitted_in: Self::current_era().unwrap_or(0), suppressed: false, }; @@ -1243,6 +1339,58 @@ decl_module! { ::UnappliedSlashes::insert(&era, &unapplied); } + /// Make one nominator's payout for one era. + /// + /// - `who` is the controller account of the nominator to pay out. + /// - `era` may not be lower than one following the most recently paid era. If it is higher, + /// then it indicates an instruction to skip the payout of all previous eras. + /// - `validators` is the list of all validators that `who` had exposure to during `era`. + /// If it is incomplete, then less than the full reward will be paid out. + /// It must not exceed `MAX_NOMINATIONS`. + /// + /// WARNING: once an era is payed for a validator such validator can't claim the payout of + /// previous era. + /// + /// WARNING: Incorrect arguments here can result in loss of payout. Be very careful. + /// + /// # + /// - Number of storage read of `O(validators)`; `validators` is the argument of the call, + /// and is bounded by `MAX_NOMINATIONS`. + /// - Each storage read is `O(N)` size and decode complexity; `N` is the maximum + /// nominations that can be given to a single validator. + /// - Computation complexity: `O(MAX_NOMINATIONS * logN)`; `MAX_NOMINATIONS` is the + /// maximum number of validators that may be nominated by a single nominator, it is + /// bounded only economically (all nominators are required to place a minimum stake). + /// # + #[weight = SimpleDispatchInfo::FixedNormal(500_000)] + fn payout_nominator(origin, era: EraIndex, validators: Vec<(T::AccountId, u32)>) + -> DispatchResult + { + let who = ensure_signed(origin)?; + Self::do_payout_nominator(who, era, validators) + } + + /// Make one validator's payout for one era. + /// + /// - `who` is the controller account of the validator to pay out. + /// - `era` may not be lower than one following the most recently paid era. If it is higher, + /// then it indicates an instruction to skip the payout of all previous eras. + /// + /// WARNING: once an era is payed for a validator such validator can't claim the payout of + /// previous era. + /// + /// WARNING: Incorrect arguments here can result in loss of payout. Be very careful. + /// + /// # + /// - Time complexity: O(1). + /// - Contains a limited number of reads and writes. + /// # + #[weight = SimpleDispatchInfo::FixedNormal(500_000)] + fn payout_validator(origin, era: EraIndex) -> DispatchResult { + let who = ensure_signed(origin)?; + Self::do_payout_validator(who, era) + } + /// Rebond a portion of the stash scheduled to be unlocked. /// /// # @@ -1262,6 +1410,24 @@ decl_module! { Self::update_ledger(&controller, &ledger); } + /// Set history_depth value. + /// + /// Origin must be root. + #[weight = SimpleDispatchInfo::FixedOperational(500_000)] + fn set_history_depth(origin, #[compact] new_history_depth: EraIndex) { + ensure_root(origin)?; + if let Some(current_era) = Self::current_era() { + HistoryDepth::mutate(|history_depth| { + let last_kept = current_era.checked_sub(*history_depth).unwrap_or(0); + let new_last_kept = current_era.checked_sub(new_history_depth).unwrap_or(0); + for era_index in last_kept..new_last_kept { + Self::clear_era_information(era_index); + } + *history_depth = new_history_depth + }) + } + } + /// Remove all data structure concerning a staker/stash once its balance is zero. /// This is essentially equivalent to `withdraw_unbonded` except it can be called by anyone /// and the target `stash` must have no funds left. @@ -1288,6 +1454,111 @@ impl Module { // MUTABLES (DANGEROUS) + fn do_payout_nominator(who: T::AccountId, era: EraIndex, validators: Vec<(T::AccountId, u32)>) + -> DispatchResult + { + // validators len must not exceed `MAX_NOMINATIONS` to avoid querying more validator + // exposure than necessary. + if validators.len() > MAX_NOMINATIONS { + return Err(Error::::InvalidNumberOfNominations.into()); + } + + // Note: if era has no reward to be claimed, era may be future. better not to update + // `nominator_ledger.last_reward` in this case. + let era_payout = >::get(&era) + .ok_or_else(|| Error::::InvalidEraToReward)?; + + let mut nominator_ledger = >::get(&who).ok_or_else(|| Error::::NotController)?; + + if nominator_ledger.last_reward.map(|last_reward| last_reward >= era).unwrap_or(false) { + return Err(Error::::InvalidEraToReward.into()); + } + + nominator_ledger.last_reward = Some(era); + >::insert(&who, &nominator_ledger); + + let mut reward = Perbill::zero(); + let era_reward_points = >::get(&era); + + for (validator, nominator_index) in validators.into_iter() { + let commission = Self::eras_validator_prefs(&era, &validator).commission; + let validator_exposure = >::get(&era, &validator); + + if let Some(nominator_exposure) = validator_exposure.others + .get(nominator_index as usize) + { + if nominator_exposure.who != nominator_ledger.stash { + continue; + } + + let nominator_exposure_part = Perbill::from_rational_approximation( + nominator_exposure.value, + validator_exposure.total, + ); + let validator_point = era_reward_points.individual.get(&validator) + .map(|points| *points) + .unwrap_or_else(|| Zero::zero()); + let validator_point_part = Perbill::from_rational_approximation( + validator_point, + era_reward_points.total, + ); + reward = reward.saturating_add( + validator_point_part + .saturating_mul(Perbill::one().saturating_sub(commission)) + .saturating_mul(nominator_exposure_part) + ); + } + } + + if let Some(imbalance) = Self::make_payout(&nominator_ledger.stash, reward * era_payout) { + Self::deposit_event(RawEvent::Reward(who, imbalance.peek())); + } + + Ok(()) + } + + fn do_payout_validator(who: T::AccountId, era: EraIndex) -> DispatchResult { + // Note: if era has no reward to be claimed, era may be future. better not to update + // `ledger.last_reward` in this case. + let era_payout = >::get(&era) + .ok_or_else(|| Error::::InvalidEraToReward)?; + + let mut ledger = >::get(&who).ok_or_else(|| Error::::NotController)?; + if ledger.last_reward.map(|last_reward| last_reward >= era).unwrap_or(false) { + return Err(Error::::InvalidEraToReward.into()); + } + + ledger.last_reward = Some(era); + >::insert(&who, &ledger); + + let era_reward_points = >::get(&era); + let commission = Self::eras_validator_prefs(&era, &ledger.stash).commission; + let exposure = >::get(&era, &ledger.stash); + + let exposure_part = Perbill::from_rational_approximation( + exposure.own, + exposure.total, + ); + let validator_point = era_reward_points.individual.get(&ledger.stash) + .map(|points| *points) + .unwrap_or_else(|| Zero::zero()); + let validator_point_part = Perbill::from_rational_approximation( + validator_point, + era_reward_points.total, + ); + let reward = validator_point_part.saturating_mul( + commission.saturating_add( + Perbill::one().saturating_sub(commission).saturating_mul(exposure_part) + ) + ); + + if let Some(imbalance) = Self::make_payout(&ledger.stash, reward * era_payout) { + Self::deposit_event(RawEvent::Reward(who, imbalance.peek())); + } + + Ok(()) + } + /// Update the ledger for a controller. This will also update the stash lock. The lock will /// will lock the entire funds except paying for further transactions. fn update_ledger( @@ -1310,10 +1581,12 @@ impl Module { } /// Ensures storage is upgraded to most recent necessary state. - /// - /// Right now it's a no-op as all networks that are supported by Substrate Frame Core are - /// running with the latest staking storage scheme. - fn ensure_storage_upgraded() {} + fn ensure_storage_upgraded() { + if !IsUpgraded::get() { + IsUpgraded::put(true); + Self::do_upgrade(); + } + } /// Actually make a payment to a staker. This uses the currency's reward function /// to pay the right payee for the given staker account. @@ -1338,113 +1611,90 @@ impl Module { } } - /// Reward a given validator by a specific amount. Add the reward to the validator's, and its - /// nominators' balance, pro-rata based on their exposure, after having removed the validator's - /// pre-payout cut. - fn reward_validator(stash: &T::AccountId, reward: BalanceOf) -> PositiveImbalanceOf { - let off_the_table = Self::validators(stash).commission * reward; - let reward = reward.saturating_sub(off_the_table); - let mut imbalance = >::zero(); - let validator_cut = if reward.is_zero() { - Zero::zero() - } else { - let exposure = Self::stakers(stash); - let total = exposure.total.max(One::one()); - - for i in &exposure.others { - let per_u64 = Perbill::from_rational_approximation(i.value, total); - imbalance.maybe_subsume(Self::make_payout(&i.who, per_u64 * reward)); + /// Plan a new session potentially trigger a new era. + fn new_session(session_index: SessionIndex) -> Option> { + if let Some(current_era) = Self::current_era() { + // Initial era has been set. + + let current_era_start_session_index = Self::eras_start_session_index(current_era) + .unwrap_or_else(|| { + frame_support::print("Error: start_session_index must be set for current_era"); + 0 + }); + + let era_length = session_index.checked_sub(current_era_start_session_index) + .unwrap_or(0); // Must never happen. + + match ForceEra::get() { + Forcing::ForceNew => ForceEra::kill(), + Forcing::ForceAlways => (), + Forcing::NotForcing if era_length >= T::SessionsPerEra::get() => (), + _ => return None, } - let per_u64 = Perbill::from_rational_approximation(exposure.own, total); - per_u64 * reward - }; - - imbalance.maybe_subsume(Self::make_payout(stash, validator_cut + off_the_table)); - - imbalance - } - - /// Session has just ended. Provide the validator set for the next session if it's an era-end. - fn new_session(session_index: SessionIndex) -> Option> { - let era_length = session_index.checked_sub(Self::current_era_start_session_index()).unwrap_or(0); - match ForceEra::get() { - Forcing::ForceNew => ForceEra::kill(), - Forcing::ForceAlways => (), - Forcing::NotForcing if era_length >= T::SessionsPerEra::get() => (), - _ => return None, + Self::new_era(session_index) + } else { + // Set initial era + Self::new_era(session_index) } - - Self::new_era(session_index) } - /// Initialize the first session (and consequently the first era) - fn initial_session() -> Option> { - // note: `CurrentEraStart` is set in `on_finalize` of the first block because now is not - // available yet. - CurrentEraStartSessionIndex::put(0); - BondedEras::mutate(|bonded| bonded.push((0, 0))); - Self::select_validators().1 + /// Start a session potentially starting an era. + fn start_session(start_session: SessionIndex) { + let next_active_era = Self::active_era().map(|e| e.index + 1).unwrap_or(0); + if let Some(next_active_era_start_session_index) = + Self::eras_start_session_index(next_active_era) + { + if next_active_era_start_session_index == start_session { + Self::start_era(start_session); + } else if next_active_era_start_session_index < start_session { + // This arm should never happen, but better handle it than to stall the + // staking pallet. + frame_support::print("Warning: A session appears to have been skipped."); + Self::start_era(start_session); + } + } } - /// The era has changed - enact new staking set. - /// - /// NOTE: This always happens immediately before a session change to ensure that new validators - /// get a chance to set their session keys. - fn new_era(start_session_index: SessionIndex) -> Option> { - // Payout - let points = CurrentEraPointsEarned::take(); - let now = T::Time::now(); - let previous_era_start = >::mutate(|v| { - sp_std::mem::replace(v, now) - }); - let era_duration = now - previous_era_start; - if !era_duration.is_zero() { - let validators = Self::current_elected(); - - let validator_len: BalanceOf = (validators.len() as u32).into(); - let total_rewarded_stake = Self::slot_stake() * validator_len; - - let (total_payout, max_payout) = inflation::compute_total_payout( - &T::RewardCurve::get(), - total_rewarded_stake.clone(), - T::Currency::total_issuance(), - // Duration of era; more than u64::MAX is rewarded as u64::MAX. - era_duration.saturated_into::(), - ); - - let mut total_imbalance = >::zero(); + /// End a session potentially ending an era. + fn end_session(session_index: SessionIndex) { + if let Some(active_era) = Self::active_era() { + let next_active_era_start_session_index = + Self::eras_start_session_index(active_era.index + 1) + .unwrap_or_else(|| { + frame_support::print( + "Error: start_session_index must be set for active_era + 1" + ); + 0 + }); - for (v, p) in validators.iter().zip(points.individual.into_iter()) { - if p != 0 { - let reward = Perbill::from_rational_approximation(p, points.total) * total_payout; - total_imbalance.subsume(Self::reward_validator(v, reward)); - } + if next_active_era_start_session_index == session_index + 1 { + Self::end_era(active_era, session_index); } - - // assert!(total_imbalance.peek() == total_payout) - let total_payout = total_imbalance.peek(); - - let rest = max_payout.saturating_sub(total_payout); - Self::deposit_event(RawEvent::Reward(total_payout, rest)); - - T::Reward::on_unbalanced(total_imbalance); - T::RewardRemainder::on_unbalanced(T::Currency::issue(rest)); } + } - // Increment current era. - let current_era = CurrentEra::mutate(|s| { *s += 1; *s }); - - CurrentEraStartSessionIndex::mutate(|v| { - *v = start_session_index; + /// * Increment `active_era.index`, + /// * reset `active_era.start`, + /// * update `BondedEras` and apply slashes. + fn start_era(start_session: SessionIndex) { + let active_era = >::mutate(|active_era| { + let new_index = active_era.as_ref().map(|info| info.index + 1).unwrap_or(0); + *active_era = Some(ActiveEraInfo { + index: new_index, + // Set new active era start in next `on_finalize`. To guarantee usage of `Time` + start: None, + }); + new_index }); + let bonding_duration = T::BondingDuration::get(); BondedEras::mutate(|bonded| { - bonded.push((current_era, start_session_index)); + bonded.push((active_era, start_session)); - if current_era > bonding_duration { - let first_kept = current_era - bonding_duration; + if active_era > bonding_duration { + let first_kept = active_era - bonding_duration; // prune out everything that's from before the first-kept index. let n_to_prune = bonded.iter() @@ -1462,18 +1712,65 @@ impl Module { } }); - // Reassign all Stakers. - let (_slot_stake, maybe_new_validators) = Self::select_validators(); - Self::apply_unapplied_slashes(current_era); + Self::apply_unapplied_slashes(active_era); + } + + /// Compute payout for era. + fn end_era(active_era: ActiveEraInfo>, _session_index: SessionIndex) { + // Note: active_era_start can be None if end era is called during genesis config. + if let Some(active_era_start) = active_era.start { + let now = T::Time::now(); + + let era_duration = now - active_era_start; + let (total_payout, _max_payout) = inflation::compute_total_payout( + &T::RewardCurve::get(), + Self::eras_total_stake(&active_era.index), + T::Currency::total_issuance(), + // Duration of era; more than u64::MAX is rewarded as u64::MAX. + era_duration.saturated_into::(), + ); + + // Set ending era reward. + >::insert(&active_era.index, total_payout); + } + } + + /// Plan a new era. Return the potential new staking set. + fn new_era(start_session_index: SessionIndex) -> Option> { + // Increment or set current era. + let current_era = CurrentEra::mutate(|s| { + *s = Some(s.map(|s| s + 1).unwrap_or(0)); + s.unwrap() + }); + ErasStartSessionIndex::insert(¤t_era, &start_session_index); + + // Clean old era information. + if let Some(old_era) = current_era.checked_sub(Self::history_depth() + 1) { + Self::clear_era_information(old_era); + } + + // Set staking information for new era. + let maybe_new_validators = Self::select_validators(current_era); maybe_new_validators } + /// Clear all era information for given era. + fn clear_era_information(era_index: EraIndex) { + >::remove_prefix(era_index); + >::remove_prefix(era_index); + >::remove_prefix(era_index); + >::remove(era_index); + >::remove(era_index); + >::remove(era_index); + ErasStartSessionIndex::remove(era_index); + } + /// Apply previously-unapplied slashes on the beginning of a new era, after a delay. - fn apply_unapplied_slashes(current_era: EraIndex) { + fn apply_unapplied_slashes(active_era: EraIndex) { let slash_defer_duration = T::SlashDeferDuration::get(); ::EarliestUnappliedSlash::mutate(|earliest| if let Some(ref mut earliest) = earliest { - let keep_from = current_era.saturating_sub(slash_defer_duration); + let keep_from = active_era.saturating_sub(slash_defer_duration); for era in (*earliest)..keep_from { let era_slashes = ::UnappliedSlashes::take(&era); for slash in era_slashes { @@ -1485,19 +1782,25 @@ impl Module { }) } - /// Select a new validator set from the assembled stakers and their role preferences. + /// Select a new validator set from the assembled stakers and their role preferences, and store + /// staking information for the new current era. + /// + /// Fill the storages `ErasStakers`, `ErasStakersClipped`, `ErasValidatorPrefs` and + /// `ErasTotalStake` for current era. /// - /// Returns the new `SlotStake` value and a set of newly selected _stash_ IDs. + /// Returns a set of newly selected _stash_ IDs. /// /// Assumes storage is coherent with the declaration. - fn select_validators() -> (BalanceOf, Option>) { + fn select_validators(current_era: EraIndex) -> Option> { let mut all_nominators: Vec<(T::AccountId, Vec)> = Vec::new(); - let all_validator_candidates_iter = >::enumerate(); - let all_validators = all_validator_candidates_iter.map(|(who, _pref)| { - let self_vote = (who.clone(), vec![who.clone()]); + let mut all_validators_and_prefs = BTreeMap::new(); + let mut all_validators = Vec::new(); + for (validator, preference) in >::enumerate() { + let self_vote = (validator.clone(), vec![validator.clone()]); all_nominators.push(self_vote); - who - }).collect::>(); + all_validators_and_prefs.insert(validator.clone(), preference); + all_validators.push(validator); + } let nominator_votes = >::enumerate().map(|(nominator, nominations)| { let Nominations { submitted_in, mut targets, suppressed: _ } = nominations; @@ -1524,8 +1827,8 @@ impl Module { ); if let Some(phragmen_result) = maybe_phragmen_result { - let elected_stashes = phragmen_result.winners.iter() - .map(|(s, _)| s.clone()) + let elected_stashes = phragmen_result.winners.into_iter() + .map(|(s, _)| s) .collect::>(); let assignments = phragmen_result.assignments; @@ -1538,13 +1841,8 @@ impl Module { Self::slashable_balance_of, ); - // Clear Stakers. - for v in Self::current_elected().iter() { - >::remove(v); - } - - // Populate Stakers and figure out the minimum stake behind a slot. - let mut slot_stake = BalanceOf::::max_value(); + // Populate stakers information and figure out the total stake. + let mut total_staked = BalanceOf::::zero(); for (c, s) in supports.into_iter() { // build `struct exposure` from `support` let mut others = Vec::new(); @@ -1561,6 +1859,9 @@ impl Module { } total = total.saturating_add(value); }); + + total_staked = total_staked.saturating_add(total); + let exposure = Exposure { own, others, @@ -1570,24 +1871,31 @@ impl Module { // we simulate it in some tests. total, }; + >::insert(¤t_era, &c, &exposure); - if exposure.total < slot_stake { - slot_stake = exposure.total; + let mut exposure_clipped = exposure; + let clipped_max_len = T::MaxNominatorRewardedPerValidator::get() as usize; + if exposure_clipped.others.len() > clipped_max_len { + exposure_clipped.others.sort_unstable_by(|a, b| a.value.cmp(&b.value).reverse()); + exposure_clipped.others.truncate(clipped_max_len); } - >::insert(&c, exposure.clone()); + >::insert(¤t_era, &c, exposure_clipped); } - // Update slot stake. - >::put(&slot_stake); - - // Set the new validator set in sessions. - >::put(&elected_stashes); + // Insert current era staking informations + >::insert(¤t_era, total_staked); + let default_pref = ValidatorPrefs::default(); + for stash in &elected_stashes { + let pref = all_validators_and_prefs.get(stash) + .unwrap_or(&default_pref); // Must never happen, but better to be safe. + >::insert(¤t_era, stash, pref); + } // In order to keep the property required by `n_session_ending` // that we must return the new validator set even if it's the same as the old, // as long as any underlying economic conditions have changed, we don't attempt // to do any optimization where we compare against the prior set. - (slot_stake, Some(elected_stashes)) + Some(elected_stashes) } else { // There were not enough candidates for even our minimal level of functionality. // This is bad. @@ -1595,7 +1903,7 @@ impl Module { // and let the chain keep producing blocks until we can decide on a sufficiently // substantial set. // TODO: #2494 - (Self::slot_stake(), None) + None } } @@ -1633,66 +1941,207 @@ impl Module { /// /// COMPLEXITY: Complexity is `number_of_validator_to_reward x current_elected_len`. /// If you need to reward lots of validator consider using `reward_by_indices`. - pub fn reward_by_ids(validators_points: impl IntoIterator) { - CurrentEraPointsEarned::mutate(|rewards| { - let current_elected = >::current_elected(); - for (validator, points) in validators_points.into_iter() { - if let Some(index) = current_elected.iter() - .position(|elected| *elected == validator) - { - rewards.add_points_to_index(index as u32, points); + pub fn reward_by_ids( + validators_points: impl IntoIterator + ) { + if let Some(active_era) = Self::active_era() { + >::mutate(active_era.index, |era_rewards| { + for (validator, points) in validators_points.into_iter() { + *era_rewards.individual.entry(validator).or_default() += points; + era_rewards.total += points; } - } - }); + }); + } } - /// Add reward points to validators using their validator index. + /// Ensures that at the end of the current session there will be a new era. + fn ensure_new_era() { + match ForceEra::get() { + Forcing::ForceAlways | Forcing::ForceNew => (), + _ => ForceEra::put(Forcing::ForceNew), + } + } + + /// Update storages to current version /// - /// For each element in the iterator the given number of points in u32 is added to the - /// validator, thus duplicates are handled. - pub fn reward_by_indices(validators_points: impl IntoIterator) { - let current_elected_len = >::current_elected().len() as u32; + /// In old version the staking module has several issue about handling session delay, the + /// current era was always considered the active one. + /// + /// After the migration the current era will still be considered the active one for the era of + /// the upgrade. And the delay issue will be fixed when planning the next era. + // * create: + // * ActiveEraStart + // * ErasRewardPoints + // * ActiveEra + // * ErasStakers + // * ErasStakersClipped + // * ErasValidatorPrefs + // * ErasTotalStake + // * ErasStartSessionIndex + // * translate StakingLedger + // * removal of: + // * Stakers + // * SlotStake + // * CurrentElected + // * CurrentEraStart + // * CurrentEraStartSessionIndex + // * CurrentEraPointsEarned + fn do_upgrade() { + /// Deprecated storages used for migration only. + mod deprecated { + use crate::{Trait, BalanceOf, MomentOf, SessionIndex, Exposure}; + use codec::{Encode, Decode}; + use frame_support::{decl_module, decl_storage}; + use sp_std::prelude::*; + + /// Reward points of an era. Used to split era total payout between validators. + #[derive(Encode, Decode, Default)] + pub struct EraPoints { + /// Total number of points. Equals the sum of reward points for each validator. + pub total: u32, + /// The reward points earned by a given validator. The index of this vec corresponds to the + /// index into the current validator set. + pub individual: Vec, + } - CurrentEraPointsEarned::mutate(|rewards| { - for (validator_index, points) in validators_points.into_iter() { - if validator_index < current_elected_len { - rewards.add_points_to_index(validator_index, points); + decl_module! { + pub struct Module for enum Call where origin: T::Origin { } + } + + decl_storage! { + pub trait Store for Module as Staking { + pub SlotStake: BalanceOf; + + /// The currently elected validator set keyed by stash account ID. + pub CurrentElected: Vec; + + /// The start of the current era. + pub CurrentEraStart: MomentOf; + + /// The session index at which the current era started. + pub CurrentEraStartSessionIndex: SessionIndex; + + /// Rewards for the current era. Using indices of current elected set. + pub CurrentEraPointsEarned: EraPoints; + + /// Nominators for a particular account that is in action right now. You can't iterate + /// through validators here, but you can find them in the Session module. + /// + /// This is keyed by the stash account. + pub Stakers: map hasher(blake2_256) T::AccountId => Exposure>; } } + } + + #[derive(Encode, Decode)] + struct OldStakingLedger { + stash: AccountId, + #[codec(compact)] + total: Balance, + #[codec(compact)] + active: Balance, + unlocking: Vec>, + } + + let current_era_start_index = deprecated::CurrentEraStartSessionIndex::get(); + let current_era = as Store>::CurrentEra::get().unwrap_or(0); + let current_era_start = deprecated::CurrentEraStart::::get(); + as Store>::ErasStartSessionIndex::insert(current_era, current_era_start_index); + as Store>::ActiveEra::put(ActiveEraInfo { + index: current_era, + start: Some(current_era_start), }); - } - /// Ensures that at the end of the current session there will be a new era. - fn ensure_new_era() { - match ForceEra::get() { - Forcing::ForceAlways | Forcing::ForceNew => (), - _ => ForceEra::put(Forcing::ForceNew), + let current_elected = deprecated::CurrentElected::::get(); + let mut current_total_stake = >::zero(); + for validator in ¤t_elected { + let exposure = deprecated::Stakers::::get(validator); + current_total_stake += exposure.total; + as Store>::ErasStakers::insert(current_era, validator, &exposure); + + let mut exposure_clipped = exposure; + let clipped_max_len = T::MaxNominatorRewardedPerValidator::get() as usize; + if exposure_clipped.others.len() > clipped_max_len { + exposure_clipped.others.sort_unstable_by(|a, b| a.value.cmp(&b.value).reverse()); + exposure_clipped.others.truncate(clipped_max_len); + } + as Store>::ErasStakersClipped::insert(current_era, validator, exposure_clipped); + + let pref = as Store>::Validators::get(validator); + as Store>::ErasValidatorPrefs::insert(current_era, validator, pref); } + as Store>::ErasTotalStake::insert(current_era, current_total_stake); + + let points = deprecated::CurrentEraPointsEarned::get(); + as Store>::ErasRewardPoints::insert(current_era, EraRewardPoints { + total: points.total, + individual: current_elected.iter().cloned().zip(points.individual.iter().cloned()).collect(), + }); + + let res = as Store>::Ledger::translate_values( + |old: OldStakingLedger>| StakingLedger { + stash: old.stash, + total: old.total, + active: old.active, + unlocking: old.unlocking, + last_reward: None, + } + ); + if let Err(e) = res { + frame_support::print("Encountered error in migration of Staking::Ledger map."); + frame_support::print("The number of removed key/value is:"); + frame_support::print(e); + } + + + // Kill old storages + deprecated::Stakers::::remove_all(); + deprecated::SlotStake::::kill(); + deprecated::CurrentElected::::kill(); + deprecated::CurrentEraStart::::kill(); + deprecated::CurrentEraStartSessionIndex::kill(); + deprecated::CurrentEraPointsEarned::kill(); } } +/// In this implementation `new_session(session)` must be called before `end_session(session-1)` +/// i.e. the new session must be planned before the ending of the previous session. +/// +/// Once the first new_session is planned, all session must start and then end in order, though +/// some session can lag in between the newest session planned and the latest session started. impl pallet_session::SessionManager for Module { fn new_session(new_index: SessionIndex) -> Option> { Self::ensure_storage_upgraded(); - if new_index == 0 { - return Self::initial_session(); - } - Self::new_session(new_index - 1) + Self::new_session(new_index) + } + fn start_session(start_index: SessionIndex) { + Self::start_session(start_index) + } + fn end_session(end_index: SessionIndex) { + Self::end_session(end_index) } - fn end_session(_end_index: SessionIndex) {} } +/// This implementation has the same constrains as the implementation of +/// `pallet_session::SessionManager`. impl SessionManager>> for Module { fn new_session(new_index: SessionIndex) -> Option>)>> { >::new_session(new_index).map(|validators| { + let current_era = Self::current_era() + // Must be some as a new era has been created. + .unwrap_or(0); + validators.into_iter().map(|v| { - let exposure = >::get(&v); + let exposure = Self::eras_stakers(current_era, &v); (v, exposure) }).collect() }) } + fn start_session(start_index: SessionIndex) { + >::start_session(start_index) + } fn end_session(end_index: SessionIndex) { >::end_session(end_index) } @@ -1702,9 +2151,12 @@ impl SessionManager> /// * 20 points to the block producer for producing a (non-uncle) block in the relay chain, /// * 2 points to the block producer for each reference to a previously unreferenced uncle, and /// * 1 point to the producer of each referenced uncle block. -impl pallet_authorship::EventHandler for Module { +impl pallet_authorship::EventHandler for Module + where + T: Trait + pallet_authorship::Trait + pallet_session::Trait +{ fn note_author(author: T::AccountId) { - Self::reward_by_ids(vec![(author, 20)]); + Self::reward_by_ids(vec![(author, 20)]) } fn note_uncle(author: T::AccountId, _age: T::BlockNumber) { Self::reward_by_ids(vec![ @@ -1724,15 +2176,22 @@ impl Convert> for StashOf { } } -/// A typed conversion from stash account ID to the current exposure of nominators +/// A typed conversion from stash account ID to the active exposure of nominators /// on that account. +/// +/// Active exposure is the exposure of the validator set currently validating, i.e. in +/// `active_era`. It can differ from the latest planned exposure in `current_era`. pub struct ExposureOf(sp_std::marker::PhantomData); impl Convert>>> for ExposureOf { fn convert(validator: T::AccountId) -> Option>> { - Some(>::stakers(&validator)) + if let Some(active_era) = >::active_era() { + Some(>::eras_stakers(active_era.index, &validator)) + } else { + None + } } } @@ -1756,13 +2215,25 @@ impl OnOffenceHandler= current_era_start_session { - era_now + let window_start = active_era.saturating_sub(T::BondingDuration::get()); + + // fast path for active-era report - most likely. + // `slash_session` cannot be in a future active era. It must be in `active_era` or before. + let slash_era = if slash_session >= active_era_start_session_index { + active_era } else { let eras = BondedEras::get(); @@ -1775,7 +2246,7 @@ impl OnOffenceHandler::EarliestUnappliedSlash::mutate(|earliest| { if earliest.is_none() { - *earliest = Some(era_now) + *earliest = Some(active_era) } }); @@ -1796,7 +2267,7 @@ impl OnOffenceHandler OnOffenceHandler::UnappliedSlashes::mutate( - era_now, + active_era, move |for_later| for_later.push(unapplied), ); } @@ -1828,7 +2299,7 @@ impl ReportOffence R: ReportOffence, O: Offence, { - fn report_offence(reporters: Vec, offence: O) { + fn report_offence(reporters: Vec, offence: O) -> Result<(), OffenceError> { >::ensure_storage_upgraded(); // disallow any slashing from before the current bonding period. @@ -1840,7 +2311,8 @@ impl ReportOffence } else { >::deposit_event( RawEvent::OldSlashingReportDiscarded(offence_session) - ) + ); + Ok(()) } } } diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 22d662846356e..b7cae91bedfa5 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -16,22 +16,23 @@ //! Test utilities -use std::{collections::HashSet, cell::RefCell}; +use std::{collections::{HashSet, HashMap}, cell::RefCell}; use sp_runtime::{Perbill, KeyTypeId}; use sp_runtime::curve::PiecewiseLinear; -use sp_runtime::traits::{IdentityLookup, Convert, OpaqueKeys, OnInitialize, SaturatedConversion}; +use sp_runtime::traits::{IdentityLookup, Convert, OpaqueKeys, OnInitialize, OnFinalize, SaturatedConversion}; use sp_runtime::testing::{Header, UintAuthorityId}; use sp_staking::{SessionIndex, offence::{OffenceDetails, OnOffenceHandler}}; use sp_core::{H256, crypto::key_types}; use sp_io; use frame_support::{ - assert_ok, impl_outer_origin, parameter_types, StorageLinkedMap, StorageValue, + assert_ok, impl_outer_origin, parameter_types, StorageLinkedMap, StorageValue, StorageMap, + StorageDoubleMap, traits::{Currency, Get, FindAuthor}, weights::Weight, }; use crate::{ EraIndex, GenesisConfig, Module, Trait, StakerStatus, ValidatorPrefs, RewardDestination, - Nominators, inflation + Nominators, inflation, SessionInterface, Exposure, ErasStakers, ErasRewardPoints }; /// The AccountId alias in this test module. @@ -198,6 +199,7 @@ parameter_types! { pub const SessionsPerEra: SessionIndex = 3; pub const BondingDuration: EraIndex = 3; pub const RewardCurve: &'static PiecewiseLinear<'static> = &I_NPOS; + pub const MaxNominatorRewardedPerValidator: u32 = 64; } impl Trait for Test { type Currency = pallet_balances::Module; @@ -213,6 +215,7 @@ impl Trait for Test { type BondingDuration = BondingDuration; type SessionInterface = Self; type RewardCurve = RewardCurve; + type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; } pub struct ExtBuilder { @@ -328,7 +331,6 @@ impl ExtBuilder { }; let nominated = if self.nominate { vec![11, 21] } else { vec![] }; let _ = GenesisConfig::{ - current_era: 0, stakers: vec![ // (stash, controller, staked_amount, status) (11, 10, balance_factor * 1000, StakerStatus::::Validator), @@ -366,35 +368,34 @@ pub type Session = pallet_session::Module; pub type Timestamp = pallet_timestamp::Module; pub type Staking = Module; -pub fn check_exposure_all() { - Staking::current_elected().into_iter().for_each(|acc| check_exposure(acc)); +pub fn check_exposure_all(era: EraIndex) { + ErasStakers::::iter_prefix(era).for_each(check_exposure) } -pub fn check_nominator_all() { - >::enumerate().for_each(|(acc, _)| check_nominator_exposure(acc)); +pub fn check_nominator_all(era: EraIndex) { + >::enumerate() + .for_each(|(acc, _)| check_nominator_exposure(era, acc)); } /// Check for each selected validator: expo.total = Sum(expo.other) + expo.own -pub fn check_exposure(stash: u64) { - assert_is_stash(stash); - let expo = Staking::stakers(&stash); +pub fn check_exposure(expo: Exposure) { assert_eq!( expo.total as u128, expo.own as u128 + expo.others.iter().map(|e| e.value as u128).sum::(), - "wrong total exposure for {:?}: {:?}", stash, expo, + "wrong total exposure {:?}", expo, ); } /// Check that for each nominator: slashable_balance > sum(used_balance) /// Note: we might not consume all of a nominator's balance, but we MUST NOT over spend it. -pub fn check_nominator_exposure(stash: u64) { +pub fn check_nominator_exposure(era: EraIndex, stash: AccountId) { assert_is_stash(stash); let mut sum = 0; - Staking::current_elected() - .iter() - .map(|v| Staking::stakers(v)) - .for_each(|e| e.others.iter() - .filter(|i| i.who == stash) - .for_each(|i| sum += i.value)); + ErasStakers::::iter_prefix(era) + .for_each(|exposure| { + exposure.others.iter() + .filter(|i| i.who == stash) + .for_each(|i| sum += i.value) + }); let nominator_stake = Staking::slashable_balance_of(&stash); // a nominator cannot over-spend. assert!( @@ -403,11 +404,11 @@ pub fn check_nominator_exposure(stash: u64) { ); } -pub fn assert_is_stash(acc: u64) { +pub fn assert_is_stash(acc: AccountId) { assert!(Staking::bonded(&acc).is_some(), "Not a stash."); } -pub fn assert_ledger_consistent(stash: u64) { +pub fn assert_ledger_consistent(stash: AccountId) { assert_is_stash(stash); let ledger = Staking::ledger(stash - 1).unwrap(); @@ -437,9 +438,8 @@ pub fn advance_session() { } pub fn start_session(session_index: SessionIndex) { - // Compensate for session delay - let session_index = session_index + 1; for i in Session::current_index()..session_index { + Staking::on_finalize(System::block_number()); System::set_block_number((i + 1).into()); Timestamp::set_timestamp(System::block_number() * 1000); Session::on_initialize(System::block_number()); @@ -450,22 +450,21 @@ pub fn start_session(session_index: SessionIndex) { pub fn start_era(era_index: EraIndex) { start_session((era_index * 3).into()); - assert_eq!(Staking::current_era(), era_index); + assert_eq!(Staking::active_era().unwrap().index, era_index); } pub fn current_total_payout_for_duration(duration: u64) -> u64 { inflation::compute_total_payout( ::RewardCurve::get(), - >::slot_stake() * 2, + Staking::eras_total_stake(Staking::active_era().unwrap().index), Balances::total_issuance(), duration, ).0 } pub fn reward_all_elected() { - let rewards = >::current_elected().iter() - .map(|v| (*v, 1)) - .collect::>(); + let rewards = ::SessionInterface::validators().into_iter() + .map(|v| (v, 1)); >::reward_by_ids(rewards) } @@ -489,8 +488,8 @@ pub fn on_offence_in_era( } } - if Staking::current_era() == era { - Staking::on_offence(offenders, slash_fraction, Staking::current_era_start_session_index()); + if Staking::active_era().unwrap().index == era { + Staking::on_offence(offenders, slash_fraction, Staking::eras_start_session_index(era).unwrap()); } else { panic!("cannot slash in era {}", era); } @@ -500,6 +499,38 @@ pub fn on_offence_now( offenders: &[OffenceDetails>], slash_fraction: &[Perbill], ) { - let now = Staking::current_era(); + let now = Staking::active_era().unwrap().index; on_offence_in_era(offenders, slash_fraction, now) } + +/// Make all validator and nominator request their payment +pub fn make_all_reward_payment(era: EraIndex) { + let validators_with_reward = ErasRewardPoints::::get(era).individual.keys() + .cloned() + .collect::>(); + + // reward nominators + let mut nominator_controllers = HashMap::new(); + for validator in Staking::eras_reward_points(era).individual.keys() { + let validator_exposure = Staking::eras_stakers_clipped(era, validator); + for (nom_index, nom) in validator_exposure.others.iter().enumerate() { + if let Some(nom_ctrl) = Staking::bonded(nom.who) { + nominator_controllers.entry(nom_ctrl) + .or_insert(vec![]) + .push((validator.clone(), nom_index as u32)); + } + } + } + for (nominator_controller, validators_with_nom_index) in nominator_controllers { + assert_ok!(Staking::payout_nominator( + Origin::signed(nominator_controller), + era, + validators_with_nom_index, + )); + } + + // reward validators + for validator_controller in validators_with_reward.iter().filter_map(Staking::bonded) { + assert_ok!(Staking::payout_validator(Origin::signed(validator_controller), era)); + } +} diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index d950c171ad18d..98536a042aa82 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -16,6 +16,8 @@ //! Tests for the module. +mod test_upgrade_from_master_dataset; + use super::*; use mock::*; use sp_runtime::{assert_eq_error_rate, traits::{OnInitialize, BadOrigin}}; @@ -23,9 +25,13 @@ use sp_staking::offence::OffenceDetails; use frame_support::{ assert_ok, assert_noop, traits::{Currency, ReservableCurrency}, - dispatch::DispatchError, StorageMap, + StorageMap, + storage::migration::{put_storage_value, get_storage_value}, }; +use pallet_balances::Error as BalancesError; +use sp_io::hashing::blake2_256; use substrate_test_utils::assert_eq_uvec; +use crate::Store; #[test] fn force_unstake_works() { @@ -36,11 +42,7 @@ fn force_unstake_works() { // Cant transfer assert_noop!( Balances::transfer(Origin::signed(11), 1, 10), - DispatchError::Module { - index: 0, - error: 1, - message: Some("LiquidityRestrictions"), - } + BalancesError::::LiquidityRestrictions ); // Force unstake requires root. assert_noop!(Staking::force_unstake(Origin::signed(11), 11), BadOrigin); @@ -67,12 +69,12 @@ fn basic_setup_works() { // Account 10 controls the stash from account 11, which is 100 * balance_factor units assert_eq!( Staking::ledger(&10), - Some(StakingLedger { stash: 11, total: 1000, active: 1000, unlocking: vec![] }) + Some(StakingLedger { stash: 11, total: 1000, active: 1000, unlocking: vec![], last_reward: None }) ); // Account 20 controls the stash from account 21, which is 200 * balance_factor units assert_eq!( Staking::ledger(&20), - Some(StakingLedger { stash: 21, total: 1000, active: 1000, unlocking: vec![] }) + Some(StakingLedger { stash: 21, total: 1000, active: 1000, unlocking: vec![], last_reward: None }) ); // Account 1 does not control any stash assert_eq!(Staking::ledger(&1), None); @@ -86,27 +88,35 @@ fn basic_setup_works() { assert_eq!( Staking::ledger(100), - Some(StakingLedger { stash: 101, total: 500, active: 500, unlocking: vec![] }) + Some(StakingLedger { stash: 101, total: 500, active: 500, unlocking: vec![], last_reward: None }) ); assert_eq!(Staking::nominators(101).unwrap().targets, vec![11, 21]); assert_eq!( - Staking::stakers(11), - Exposure { total: 1125, own: 1000, others: vec![ IndividualExposure { who: 101, value: 125 }] } + Staking::eras_stakers(Staking::active_era().unwrap().index, 11), + Exposure { + total: 1125, + own: 1000, + others: vec![ IndividualExposure { who: 101, value: 125 }] + }, ); assert_eq!( - Staking::stakers(21), - Exposure { total: 1375, own: 1000, others: vec![ IndividualExposure { who: 101, value: 375 }] } + Staking::eras_stakers(Staking::active_era().unwrap().index, 21), + Exposure { + total: 1375, + own: 1000, + others: vec![ IndividualExposure { who: 101, value: 375 }] + }, ); // initial slot_stake - assert_eq!(Staking::slot_stake(), 1125); + assert_eq!(Staking::eras_total_stake(Staking::active_era().unwrap().index), 2500); // The number of validators required. assert_eq!(Staking::validator_count(), 2); // Initial Era and session - assert_eq!(Staking::current_era(), 0); + assert_eq!(Staking::active_era().unwrap().index, 0); // Account 10 has `balance_factor` free balance assert_eq!(Balances::free_balance(10), 1); @@ -116,8 +126,8 @@ fn basic_setup_works() { assert_eq!(Staking::force_era(), Forcing::NotForcing); // All exposures must be correct. - check_exposure_all(); - check_nominator_all(); + check_exposure_all(Staking::active_era().unwrap().index); + check_nominator_all(Staking::active_era().unwrap().index); }); } @@ -126,10 +136,10 @@ fn change_controller_works() { ExtBuilder::default().build().execute_with(|| { assert_eq!(Staking::bonded(&11), Some(10)); - assert!(>::enumerate().map(|(c, _)| c).collect::>().contains(&11)); + assert!(Session::validators().contains(&11)); // 10 can control 11 who is initially a validator. assert_ok!(Staking::chill(Origin::signed(10))); - assert!(!>::enumerate().map(|(c, _)| c).collect::>().contains(&11)); + assert!(Session::validators().contains(&11)); assert_ok!(Staking::set_controller(Origin::signed(11), 5)); @@ -149,114 +159,87 @@ fn rewards_should_work() { // * rewards get recorded per session // * rewards get paid per Era // * Check that nominators are also rewarded - ExtBuilder::default().nominate(false).build().execute_with(|| { - // Init some balances - let _ = Balances::make_free_balance_be(&2, 500); - - let delay = 1000; - let init_balance_2 = Balances::total_balance(&2); + ExtBuilder::default().nominate(true).build().execute_with(|| { let init_balance_10 = Balances::total_balance(&10); let init_balance_11 = Balances::total_balance(&11); + let init_balance_20 = Balances::total_balance(&20); + let init_balance_21 = Balances::total_balance(&21); + let init_balance_100 = Balances::total_balance(&100); + let init_balance_101 = Balances::total_balance(&101); - // Set payee to controller - assert_ok!(Staking::set_payee(Origin::signed(10), RewardDestination::Controller)); - - // Initial config should be correct - assert_eq!(Staking::current_era(), 0); - assert_eq!(Session::current_index(), 0); + // Check state + Payee::::insert(11, RewardDestination::Controller); + Payee::::insert(21, RewardDestination::Controller); + Payee::::insert(101, RewardDestination::Controller); - // Add a dummy nominator. - // - // Equal division indicates that the reward will be equally divided among validator and - // nominator. - >::insert(&11, Exposure { - own: 500, - total: 1000, - others: vec![IndividualExposure {who: 2, value: 500 }] - }); - - >::insert(&2, RewardDestination::Stash); - assert_eq!(Staking::payee(2), RewardDestination::Stash); - assert_eq!(Staking::payee(11), RewardDestination::Controller); - - let mut block = 3; // Block 3 => Session 1 => Era 0 - System::set_block_number(block); - Timestamp::set_timestamp(block * 5000); // on time. - Session::on_initialize(System::block_number()); - assert_eq!(Staking::current_era(), 0); - assert_eq!(Session::current_index(), 1); >::reward_by_ids(vec![(11, 50)]); >::reward_by_ids(vec![(11, 50)]); // This is the second validator of the current elected set. >::reward_by_ids(vec![(21, 50)]); - // This must be no-op as it is not an elected validator. - >::reward_by_ids(vec![(1001, 10_000)]); // Compute total payout now for whole duration as other parameter won't change - let total_payout = current_total_payout_for_duration(9 * 5 * 1000); - assert!(total_payout > 10); // Test is meaningful if reward something - - // No reward yet - assert_eq!(Balances::total_balance(&2), init_balance_2); - assert_eq!(Balances::total_balance(&10), init_balance_10); - assert_eq!(Balances::total_balance(&11), init_balance_11); - - block = 6; // Block 6 => Session 2 => Era 0 - System::set_block_number(block); - Timestamp::set_timestamp(block * 5000 + delay); // a little late. - Session::on_initialize(System::block_number()); - assert_eq!(Staking::current_era(), 0); - assert_eq!(Session::current_index(), 2); + let total_payout_0 = current_total_payout_for_duration(3 * 1000); + assert!(total_payout_0 > 10); // Test is meaningful if reward something - block = 9; // Block 9 => Session 3 => Era 1 - System::set_block_number(block); - Timestamp::set_timestamp(block * 5000); // back to being on time. no delays - Session::on_initialize(System::block_number()); - assert_eq!(Staking::current_era(), 1); - assert_eq!(Session::current_index(), 3); + start_session(1); - // 11 validator has 2/3 of the total rewards and half half for it and its nominator - assert_eq_error_rate!(Balances::total_balance(&2), init_balance_2 + total_payout / 3, 1); - assert_eq_error_rate!(Balances::total_balance(&10), init_balance_10 + total_payout / 3, 1); + assert_eq!(Balances::total_balance(&10), init_balance_10); assert_eq!(Balances::total_balance(&11), init_balance_11); - }); -} - -#[test] -fn multi_era_reward_should_work() { - // Should check that: - // The value of current_session_reward is set at the end of each era, based on - // slot_stake and session_reward. - ExtBuilder::default().nominate(false).build().execute_with(|| { - let init_balance_10 = Balances::total_balance(&10); - - // Set payee to controller - assert_ok!(Staking::set_payee(Origin::signed(10), RewardDestination::Controller)); - - // Compute now as other parameter won't change - let total_payout_0 = current_total_payout_for_duration(3000); - assert!(total_payout_0 > 10); // Test is meaningful if reward something - >::reward_by_ids(vec![(11, 1)]); + assert_eq!(Balances::total_balance(&20), init_balance_20); + assert_eq!(Balances::total_balance(&21), init_balance_21); + assert_eq!(Balances::total_balance(&100), init_balance_100); + assert_eq!(Balances::total_balance(&101), init_balance_101); + assert_eq_uvec!(Session::validators(), vec![11, 21]); + assert_eq!(Staking::eras_reward_points(Staking::active_era().unwrap().index), EraRewardPoints { + total: 50*3, + individual: vec![(11, 100), (21, 50)].into_iter().collect(), + }); + let part_for_10 = Perbill::from_rational_approximation::(1000, 1125); + let part_for_20 = Perbill::from_rational_approximation::(1000, 1375); + let part_for_100_from_10 = Perbill::from_rational_approximation::(125, 1125); + let part_for_100_from_20 = Perbill::from_rational_approximation::(375, 1375); - start_session(0); - start_session(1); start_session(2); start_session(3); - assert_eq!(Staking::current_era(), 1); - assert_eq!(Balances::total_balance(&10), init_balance_10 + total_payout_0); + assert_eq!(Staking::active_era().unwrap().index, 1); + mock::make_all_reward_payment(0); + + assert_eq_error_rate!(Balances::total_balance(&10), init_balance_10 + part_for_10 * total_payout_0*2/3, 2); + assert_eq_error_rate!(Balances::total_balance(&11), init_balance_11, 2); + assert_eq_error_rate!(Balances::total_balance(&20), init_balance_20 + part_for_20 * total_payout_0*1/3, 2); + assert_eq_error_rate!(Balances::total_balance(&21), init_balance_21, 2); + assert_eq_error_rate!( + Balances::total_balance(&100), + init_balance_100 + + part_for_100_from_10 * total_payout_0 * 2/3 + + part_for_100_from_20 * total_payout_0 * 1/3, + 2 + ); + assert_eq_error_rate!(Balances::total_balance(&101), init_balance_101, 2); - start_session(4); + assert_eq_uvec!(Session::validators(), vec![11, 21]); + >::reward_by_ids(vec![(11, 1)]); - let total_payout_1 = current_total_payout_for_duration(3000); + // Compute total payout now for whole duration as other parameter won't change + let total_payout_1 = current_total_payout_for_duration(3 * 1000); assert!(total_payout_1 > 10); // Test is meaningful if reward something - >::reward_by_ids(vec![(11, 101)]); - - // new era is triggered here. - start_session(5); - // pay time - assert_eq!(Balances::total_balance(&10), init_balance_10 + total_payout_0 + total_payout_1); + start_era(2); + mock::make_all_reward_payment(1); + + assert_eq_error_rate!(Balances::total_balance(&10), init_balance_10 + part_for_10 * (total_payout_0 * 2/3 + total_payout_1), 2); + assert_eq_error_rate!(Balances::total_balance(&11), init_balance_11, 2); + assert_eq_error_rate!(Balances::total_balance(&20), init_balance_20 + part_for_20 * total_payout_0 * 1/3, 2); + assert_eq_error_rate!(Balances::total_balance(&21), init_balance_21, 2); + assert_eq_error_rate!( + Balances::total_balance(&100), + init_balance_100 + + part_for_100_from_10 * (total_payout_0 * 2/3 + total_payout_1) + + part_for_100_from_20 * total_payout_0 * 1/3, + 2 + ); + assert_eq_error_rate!(Balances::total_balance(&101), init_balance_101, 2); }); } @@ -271,6 +254,9 @@ fn staking_should_work() { .fair(false) // to give 20 more staked value .build() .execute_with(|| { + // --- Block 1: + start_session(1); + Timestamp::set_timestamp(1); // Initialize time. // remember + compare this along with the test. @@ -279,55 +265,64 @@ fn staking_should_work() { // put some money in account that we'll use. for i in 1..5 { let _ = Balances::make_free_balance_be(&i, 2000); } - // --- Block 1: - start_session(1); + // --- Block 2: + start_session(2); // add a new candidate for being a validator. account 3 controlled by 4. assert_ok!(Staking::bond(Origin::signed(3), 4, 1500, RewardDestination::Controller)); + let current_era_at_bond = Staking::current_era(); assert_ok!(Staking::validate(Origin::signed(4), ValidatorPrefs::default())); // No effects will be seen so far. assert_eq_uvec!(validator_controllers(), vec![20, 10]); - // --- Block 2: - start_session(2); + // --- Block 3: + start_session(3); // No effects will be seen so far. Era has not been yet triggered. assert_eq_uvec!(validator_controllers(), vec![20, 10]); - // --- Block 3: the validators will now be queued. - start_session(3); - assert_eq!(Staking::current_era(), 1); - - // --- Block 4: the validators will now be changed. + // --- Block 4: the validators will now be queued. start_session(4); + assert_eq!(Staking::active_era().unwrap().index, 1); + + // --- Block 5: the validators are still in queue. + start_session(5); + + // --- Block 6: the validators will now be changed. + start_session(6); assert_eq_uvec!(validator_controllers(), vec![20, 4]); - // --- Block 4: Unstake 4 as a validator, freeing up the balance stashed in 3 + // --- Block 6: Unstake 4 as a validator, freeing up the balance stashed in 3 // 4 will chill Staking::chill(Origin::signed(4)).unwrap(); - // --- Block 5: nothing. 4 is still there. - start_session(5); + // --- Block 7: nothing. 4 is still there. + start_session(7); assert_eq_uvec!(validator_controllers(), vec![20, 4]); - // --- Block 6: 4 will not be a validator. - start_session(7); + // --- Block 8: + start_session(8); + + // --- Block 9: 4 will not be a validator. + start_session(9); assert_eq_uvec!(validator_controllers(), vec![20, 10]); // Note: the stashed value of 4 is still lock assert_eq!( Staking::ledger(&4), - Some(StakingLedger { stash: 3, total: 1500, active: 1500, unlocking: vec![] }) + Some(StakingLedger { + stash: 3, + total: 1500, + active: 1500, + unlocking: vec![], + last_reward: current_era_at_bond, + }) ); // e.g. it cannot spend more than 500 that it has free from the total 2000 assert_noop!( Balances::reserve(&3, 501), - DispatchError::Module { - index: 0, - error: 1, - message: Some("LiquidityRestrictions"), - } + BalancesError::::LiquidityRestrictions ); assert_ok!(Balances::reserve(&3, 409)); }); @@ -353,11 +348,12 @@ fn less_than_needed_candidates_works() { // But the exposure is updated in a simple way. No external votes exists. // This is purely self-vote. - assert_eq!(Staking::stakers(10).others.len(), 0); - assert_eq!(Staking::stakers(20).others.len(), 0); - assert_eq!(Staking::stakers(30).others.len(), 0); - check_exposure_all(); - check_nominator_all(); + assert!( + ErasStakers::::iter_prefix(Staking::active_era().unwrap().index) + .all(|exposure| exposure.others.is_empty()) + ); + check_exposure_all(Staking::active_era().unwrap().index); + check_nominator_all(Staking::active_era().unwrap().index); }); } @@ -379,6 +375,7 @@ fn no_candidate_emergency_condition() { // set the minimum validator count. ::MinimumValidatorCount::put(10); + // try to chill let _ = Staking::chill(Origin::signed(10)); // trigger era @@ -461,8 +458,6 @@ fn nominating_and_rewards_should_work() { assert!(total_payout_0 > 100); // Test is meaningful if reward something >::reward_by_ids(vec![(41, 1)]); >::reward_by_ids(vec![(31, 1)]); - >::reward_by_ids(vec![(21, 10)]); // must be no-op - >::reward_by_ids(vec![(11, 10)]); // must be no-op start_era(1); @@ -470,45 +465,40 @@ fn nominating_and_rewards_should_work() { assert_eq_uvec!(validator_controllers(), vec![20, 10]); // OLD validators must have already received some rewards. + mock::make_all_reward_payment(0); assert_eq!(Balances::total_balance(&40), 1 + total_payout_0 / 2); assert_eq!(Balances::total_balance(&30), 1 + total_payout_0 / 2); // ------ check the staked value of all parties. - // total expo of 10, with 1200 coming from nominators (externals), according to phragmen. - assert_eq!(Staking::stakers(11).own, 1000); - assert_eq!(Staking::stakers(11).total, 1000 + 800); - // 2 and 4 supported 10, each with stake 600, according to phragmen. - assert_eq!( - Staking::stakers(11).others.iter().map(|e| e.value).collect::>>(), - vec![400, 400] - ); + // 30 and 40 are not chosen anymore + assert_eq!(ErasStakers::::iter_prefix(Staking::active_era().unwrap().index).count(), 2); assert_eq!( - Staking::stakers(11).others.iter().map(|e| e.who).collect::>(), - vec![3, 1] - ); - // total expo of 20, with 500 coming from nominators (externals), according to phragmen. - assert_eq!(Staking::stakers(21).own, 1000); - assert_eq_error_rate!(Staking::stakers(21).total, 1000 + 1200, 2); - // 2 and 4 supported 20, each with stake 250, according to phragmen. - assert_eq!( - Staking::stakers(21).others.iter().map(|e| e.value).collect::>>(), - vec![600, 600] + Staking::eras_stakers(Staking::active_era().unwrap().index, 11), + Exposure { + total: 1000 + 800, + own: 1000, + others: vec![ + IndividualExposure { who: 3, value: 400 }, + IndividualExposure { who: 1, value: 400 }, + ] + }, ); assert_eq!( - Staking::stakers(21).others.iter().map(|e| e.who).collect::>(), - vec![3, 1] + Staking::eras_stakers(Staking::active_era().unwrap().index, 21), + Exposure { + total: 1000 + 1200, + own: 1000, + others: vec![ + IndividualExposure { who: 3, value: 600 }, + IndividualExposure { who: 1, value: 600 }, + ] + }, ); - // They are not chosen anymore - assert_eq!(Staking::stakers(31).total, 0); - assert_eq!(Staking::stakers(41).total, 0); - // the total reward for era 1 let total_payout_1 = current_total_payout_for_duration(3000); assert!(total_payout_1 > 100); // Test is meaningful if reward something - >::reward_by_ids(vec![(41, 10)]); // must be no-op - >::reward_by_ids(vec![(31, 10)]); // must be no-op >::reward_by_ids(vec![(21, 2)]); >::reward_by_ids(vec![(11, 1)]); @@ -517,6 +507,7 @@ fn nominating_and_rewards_should_work() { // nothing else will happen, era ends and rewards are paid again, // it is expected that nominators will also be paid. See below + mock::make_all_reward_payment(1); let payout_for_10 = total_payout_1 / 3; let payout_for_20 = 2 * total_payout_1 / 3; // Nominator 2: has [400/1800 ~ 2/9 from 10] + [600/2200 ~ 3/11 from 20]'s reward. ==> 2/9 + 3/11 @@ -545,8 +536,8 @@ fn nominating_and_rewards_should_work() { 1, ); - check_exposure_all(); - check_nominator_all(); + check_exposure_all(Staking::active_era().unwrap().index); + check_nominator_all(Staking::active_era().unwrap().index); }); } @@ -589,13 +580,13 @@ fn nominators_also_get_slashed() { &[OffenceDetails { offender: ( 11, - Staking::stakers(&11), + Staking::eras_stakers(Staking::active_era().unwrap().index, 11), ), reporters: vec![], }], &[Perbill::from_percent(5)], ); - let expo = Staking::stakers(11); + let expo = Staking::eras_stakers(Staking::active_era().unwrap().index, 11); let slash_value = 50; let total_slash = expo.total.min(slash_value); let validator_slash = expo.own.min(total_slash); @@ -604,8 +595,8 @@ fn nominators_also_get_slashed() { // initial + first era reward + slash assert_eq!(Balances::total_balance(&11), initial_balance - validator_slash); assert_eq!(Balances::total_balance(&2), initial_balance - nominator_slash); - check_exposure_all(); - check_nominator_all(); + check_exposure_all(Staking::active_era().unwrap().index); + check_nominator_all(Staking::active_era().unwrap().index); // Because slashing happened. assert!(is_disabled(10)); }); @@ -660,42 +651,52 @@ fn double_controlling_should_fail() { #[test] fn session_and_eras_work() { ExtBuilder::default().build().execute_with(|| { - assert_eq!(Staking::current_era(), 0); + assert_eq!(Staking::active_era().unwrap().index, 0); // Block 1: No change. - start_session(0); + start_session(1); assert_eq!(Session::current_index(), 1); - assert_eq!(Staking::current_era(), 0); + assert_eq!(Staking::active_era().unwrap().index, 0); - // Block 2: Simple era change. + // Block 2: No change. start_session(2); - assert_eq!(Session::current_index(), 3); - assert_eq!(Staking::current_era(), 1); + assert_eq!(Session::current_index(), 2); + assert_eq!(Staking::active_era().unwrap().index, 0); - // Block 3: Schedule an era length change; no visible changes. + // Block 3: Era increment. start_session(3); + assert_eq!(Session::current_index(), 3); + assert_eq!(Staking::active_era().unwrap().index, 1); + + // Block 4: No change. + start_session(4); assert_eq!(Session::current_index(), 4); - assert_eq!(Staking::current_era(), 1); + assert_eq!(Staking::active_era().unwrap().index, 1); - // Block 4: Era change kicks in. + // Block 5: No change. start_session(5); - assert_eq!(Session::current_index(), 6); - assert_eq!(Staking::current_era(), 2); + assert_eq!(Session::current_index(), 5); + assert_eq!(Staking::active_era().unwrap().index, 1); - // Block 5: No change. + // Block 6: Era increment. start_session(6); - assert_eq!(Session::current_index(), 7); - assert_eq!(Staking::current_era(), 2); + assert_eq!(Session::current_index(), 6); + assert_eq!(Staking::active_era().unwrap().index, 2); - // Block 6: No change. + // Block 7: No change. start_session(7); - assert_eq!(Session::current_index(), 8); - assert_eq!(Staking::current_era(), 2); + assert_eq!(Session::current_index(), 7); + assert_eq!(Staking::active_era().unwrap().index, 2); - // Block 7: Era increment. + // Block 8: No change. start_session(8); + assert_eq!(Session::current_index(), 8); + assert_eq!(Staking::active_era().unwrap().index, 2); + + // Block 9: Era increment. + start_session(9); assert_eq!(Session::current_index(), 9); - assert_eq!(Staking::current_era(), 3); + assert_eq!(Staking::active_era().unwrap().index, 3); }); } @@ -703,50 +704,53 @@ fn session_and_eras_work() { fn forcing_new_era_works() { ExtBuilder::default().build().execute_with(|| { // normal flow of session. - assert_eq!(Staking::current_era(), 0); + assert_eq!(Staking::active_era().unwrap().index, 0); start_session(0); - assert_eq!(Staking::current_era(), 0); + assert_eq!(Staking::active_era().unwrap().index, 0); start_session(1); - assert_eq!(Staking::current_era(), 0); + assert_eq!(Staking::active_era().unwrap().index, 0); start_session(2); - assert_eq!(Staking::current_era(), 1); + assert_eq!(Staking::active_era().unwrap().index, 0); + start_session(3); + assert_eq!(Staking::active_era().unwrap().index, 1); // no era change. ForceEra::put(Forcing::ForceNone); - start_session(3); - assert_eq!(Staking::current_era(), 1); start_session(4); - assert_eq!(Staking::current_era(), 1); + assert_eq!(Staking::active_era().unwrap().index, 1); start_session(5); - assert_eq!(Staking::current_era(), 1); + assert_eq!(Staking::active_era().unwrap().index, 1); start_session(6); - assert_eq!(Staking::current_era(), 1); + assert_eq!(Staking::active_era().unwrap().index, 1); + start_session(7); + assert_eq!(Staking::active_era().unwrap().index, 1); // back to normal. // this immediately starts a new session. ForceEra::put(Forcing::NotForcing); - start_session(7); - assert_eq!(Staking::current_era(), 2); start_session(8); - assert_eq!(Staking::current_era(), 2); + assert_eq!(Staking::active_era().unwrap().index, 1); // There is one session delay + start_session(9); + assert_eq!(Staking::active_era().unwrap().index, 2); // forceful change ForceEra::put(Forcing::ForceAlways); - start_session(9); - assert_eq!(Staking::current_era(), 3); start_session(10); - assert_eq!(Staking::current_era(), 4); + assert_eq!(Staking::active_era().unwrap().index, 2); // There is one session delay start_session(11); - assert_eq!(Staking::current_era(), 5); + assert_eq!(Staking::active_era().unwrap().index, 3); + start_session(12); + assert_eq!(Staking::active_era().unwrap().index, 4); // just one forceful change ForceEra::put(Forcing::ForceNew); - start_session(12); - assert_eq!(Staking::current_era(), 6); - - assert_eq!(ForceEra::get(), Forcing::NotForcing); start_session(13); - assert_eq!(Staking::current_era(), 6); + assert_eq!(Staking::active_era().unwrap().index, 5); + assert_eq!(ForceEra::get(), Forcing::NotForcing); + start_session(14); + assert_eq!(Staking::active_era().unwrap().index, 6); + start_session(15); + assert_eq!(Staking::active_era().unwrap().index, 6); }); } @@ -760,15 +764,11 @@ fn cannot_transfer_staked_balance() { // Confirm account 11 has some free balance assert_eq!(Balances::free_balance(11), 1000); // Confirm account 11 (via controller 10) is totally staked - assert_eq!(Staking::stakers(&11).total, 1000); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 11).total, 1000); // Confirm account 11 cannot transfer as a result assert_noop!( Balances::transfer(Origin::signed(11), 20, 1), - DispatchError::Module { - index: 0, - error: 1, - message: Some("LiquidityRestrictions"), - } + BalancesError::::LiquidityRestrictions ); // Give account 11 extra free balance @@ -789,15 +789,11 @@ fn cannot_transfer_staked_balance_2() { // Confirm account 21 has some free balance assert_eq!(Balances::free_balance(21), 2000); // Confirm account 21 (via controller 20) is totally staked - assert_eq!(Staking::stakers(&21).total, 1000); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 21).total, 1000); // Confirm account 21 can transfer at most 1000 assert_noop!( Balances::transfer(Origin::signed(21), 20, 1001), - DispatchError::Module { - index: 0, - error: 1, - message: Some("LiquidityRestrictions"), - } + BalancesError::::LiquidityRestrictions ); assert_ok!(Balances::transfer(Origin::signed(21), 20, 1000)); }); @@ -812,15 +808,11 @@ fn cannot_reserve_staked_balance() { // Confirm account 11 has some free balance assert_eq!(Balances::free_balance(11), 1000); // Confirm account 11 (via controller 10) is totally staked - assert_eq!(Staking::stakers(&11).own, 1000); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 11).own, 1000); // Confirm account 11 cannot transfer as a result assert_noop!( Balances::reserve(&11, 1), - DispatchError::Module { - index: 0, - error: 1, - message: Some("LiquidityRestrictions"), - } + BalancesError::::LiquidityRestrictions ); // Give account 11 extra free balance @@ -835,7 +827,7 @@ fn reward_destination_works() { // Rewards go to the correct destination as determined in Payee ExtBuilder::default().nominate(false).build().execute_with(|| { // Check that account 11 is a validator - assert!(Staking::current_elected().contains(&11)); + assert!(Session::validators().contains(&11)); // Check the balance of the validator account assert_eq!(Balances::free_balance(10), 1); // Check the balance of the stash account @@ -846,6 +838,7 @@ fn reward_destination_works() { total: 1000, active: 1000, unlocking: vec![], + last_reward: None, })); // Compute total payout now for whole duration as other parameter won't change @@ -854,6 +847,7 @@ fn reward_destination_works() { >::reward_by_ids(vec![(11, 1)]); start_era(1); + mock::make_all_reward_payment(0); // Check that RewardDestination is Staked (default) assert_eq!(Staking::payee(&11), RewardDestination::Staked); @@ -865,6 +859,7 @@ fn reward_destination_works() { total: 1000 + total_payout_0, active: 1000 + total_payout_0, unlocking: vec![], + last_reward: Some(0), })); //Change RewardDestination to Stash @@ -876,6 +871,7 @@ fn reward_destination_works() { >::reward_by_ids(vec![(11, 1)]); start_era(2); + mock::make_all_reward_payment(1); // Check that RewardDestination is Stash assert_eq!(Staking::payee(&11), RewardDestination::Stash); @@ -889,6 +885,7 @@ fn reward_destination_works() { total: 1000 + total_payout_0, active: 1000 + total_payout_0, unlocking: vec![], + last_reward: Some(1), })); // Change RewardDestination to Controller @@ -903,6 +900,7 @@ fn reward_destination_works() { >::reward_by_ids(vec![(11, 1)]); start_era(3); + mock::make_all_reward_payment(2); // Check that RewardDestination is Controller assert_eq!(Staking::payee(&11), RewardDestination::Controller); @@ -914,6 +912,7 @@ fn reward_destination_works() { total: 1000 + total_payout_0, active: 1000 + total_payout_0, unlocking: vec![], + last_reward: Some(2), })); // Check that amount in staked account is NOT increased. assert_eq!(Balances::free_balance(11), recorded_stash_balance); @@ -926,45 +925,39 @@ fn validator_payment_prefs_work() { // Note: unstake threshold is being directly tested in slashing tests. // This test will focus on validator payment. ExtBuilder::default().build().execute_with(|| { - // Initial config - let stash_initial_balance = Balances::total_balance(&11); - - // check the balance of a validator accounts. - assert_eq!(Balances::total_balance(&10), 1); - // check the balance of a validator's stash accounts. - assert_eq!(Balances::total_balance(&11), stash_initial_balance); - // and the nominator (to-be) - let _ = Balances::make_free_balance_be(&2, 500); - - // add a dummy nominator. - >::insert(&11, Exposure { - own: 500, // equal division indicates that the reward will be equally divided among validator and nominator. - total: 1000, - others: vec![IndividualExposure {who: 2, value: 500 }] - }); - >::insert(&2, RewardDestination::Stash); + let commission = Perbill::from_percent(40); >::insert(&11, ValidatorPrefs { - commission: Perbill::from_percent(50), + commission: commission.clone(), }); + // Reward controller so staked ratio doesn't change. + >::insert(&11, RewardDestination::Controller); + >::insert(&101, RewardDestination::Controller); + + start_era(1); + mock::make_all_reward_payment(0); + + let balance_era_1_10 = Balances::total_balance(&10); + let balance_era_1_100 = Balances::total_balance(&100); + // Compute total payout now for whole duration as other parameter won't change - let total_payout_0 = current_total_payout_for_duration(3000); - assert!(total_payout_0 > 100); // Test is meaningful if reward something + let total_payout_1 = current_total_payout_for_duration(3000); + assert!(total_payout_1 > 100); // Test is meaningful if reward something + let exposure_1 = Staking::eras_stakers(Staking::active_era().unwrap().index, 11); >::reward_by_ids(vec![(11, 1)]); - start_era(1); + start_era(2); + mock::make_all_reward_payment(1); - // whats left to be shared is the sum of 3 rounds minus the validator's cut. - let shared_cut = total_payout_0 / 2; - // Validator's payee is Staked account, 11, reward will be paid here. - assert_eq!(Balances::total_balance(&11), stash_initial_balance + shared_cut / 2 + shared_cut); - // Controller account will not get any reward. - assert_eq!(Balances::total_balance(&10), 1); - // Rest of the reward will be shared and paid to the nominator in stake. - assert_eq!(Balances::total_balance(&2), 500 + shared_cut / 2); + let taken_cut = commission * total_payout_1; + let shared_cut = total_payout_1 - taken_cut; + let reward_of_10 = shared_cut * exposure_1.own / exposure_1.total + taken_cut; + let reward_of_100 = shared_cut * exposure_1.others[0].value / exposure_1.total; + assert_eq_error_rate!(Balances::total_balance(&10), balance_era_1_10 + reward_of_10, 2); + assert_eq_error_rate!(Balances::total_balance(&100), balance_era_1_100 + reward_of_100, 2); - check_exposure_all(); - check_nominator_all(); + check_exposure_all(Staking::active_era().unwrap().index); + check_nominator_all(Staking::active_era().unwrap().index); }); } @@ -985,6 +978,7 @@ fn bond_extra_works() { total: 1000, active: 1000, unlocking: vec![], + last_reward: None, })); // Give account 11 some large free balance greater than total @@ -998,6 +992,7 @@ fn bond_extra_works() { total: 1000 + 100, active: 1000 + 100, unlocking: vec![], + last_reward: None, })); // Call the bond_extra function with a large number, should handle it @@ -1008,6 +1003,7 @@ fn bond_extra_works() { total: 1000000, active: 1000000, unlocking: vec![], + last_reward: None, })); }); } @@ -1027,7 +1023,7 @@ fn bond_extra_and_withdraw_unbonded_works() { let _ = Balances::make_free_balance_be(&11, 1000000); // Initial config should be correct - assert_eq!(Staking::current_era(), 0); + assert_eq!(Staking::active_era().unwrap().index, 0); assert_eq!(Session::current_index(), 0); // check the balance of a validator accounts. @@ -1042,8 +1038,9 @@ fn bond_extra_and_withdraw_unbonded_works() { total: 1000, active: 1000, unlocking: vec![], + last_reward: None, })); - assert_eq!(Staking::stakers(&11), Exposure { total: 1000, own: 1000, others: vec![] }); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 11), Exposure { total: 1000, own: 1000, others: vec![] }); // deposit the extra 100 units Staking::bond_extra(Origin::signed(11), 100).unwrap(); @@ -1053,14 +1050,15 @@ fn bond_extra_and_withdraw_unbonded_works() { total: 1000 + 100, active: 1000 + 100, unlocking: vec![], + last_reward: None, })); // Exposure is a snapshot! only updated after the next era update. - assert_ne!(Staking::stakers(&11), Exposure { total: 1000 + 100, own: 1000 + 100, others: vec![] }); + assert_ne!(Staking::eras_stakers(Staking::active_era().unwrap().index, 11), Exposure { total: 1000 + 100, own: 1000 + 100, others: vec![] }); // trigger next era. Timestamp::set_timestamp(10); start_era(2); - assert_eq!(Staking::current_era(), 2); + assert_eq!(Staking::active_era().unwrap().index, 2); // ledger should be the same. assert_eq!(Staking::ledger(&10), Some(StakingLedger { @@ -1068,20 +1066,21 @@ fn bond_extra_and_withdraw_unbonded_works() { total: 1000 + 100, active: 1000 + 100, unlocking: vec![], + last_reward: None, })); // Exposure is now updated. - assert_eq!(Staking::stakers(&11), Exposure { total: 1000 + 100, own: 1000 + 100, others: vec![] }); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 11), Exposure { total: 1000 + 100, own: 1000 + 100, others: vec![] }); // Unbond almost all of the funds in stash. Staking::unbond(Origin::signed(10), 1000).unwrap(); assert_eq!(Staking::ledger(&10), Some(StakingLedger { - stash: 11, total: 1000 + 100, active: 100, unlocking: vec![UnlockChunk{ value: 1000, era: 2 + 3}] }) + stash: 11, total: 1000 + 100, active: 100, unlocking: vec![UnlockChunk{ value: 1000, era: 2 + 3}], last_reward: None }) ); // Attempting to free the balances now will fail. 2 eras need to pass. Staking::withdraw_unbonded(Origin::signed(10)).unwrap(); assert_eq!(Staking::ledger(&10), Some(StakingLedger { - stash: 11, total: 1000 + 100, active: 100, unlocking: vec![UnlockChunk{ value: 1000, era: 2 + 3}] })); + stash: 11, total: 1000 + 100, active: 100, unlocking: vec![UnlockChunk{ value: 1000, era: 2 + 3}], last_reward: None })); // trigger next era. start_era(3); @@ -1089,7 +1088,7 @@ fn bond_extra_and_withdraw_unbonded_works() { // nothing yet Staking::withdraw_unbonded(Origin::signed(10)).unwrap(); assert_eq!(Staking::ledger(&10), Some(StakingLedger { - stash: 11, total: 1000 + 100, active: 100, unlocking: vec![UnlockChunk{ value: 1000, era: 2 + 3}] })); + stash: 11, total: 1000 + 100, active: 100, unlocking: vec![UnlockChunk{ value: 1000, era: 2 + 3}], last_reward: None })); // trigger next era. start_era(5); @@ -1097,7 +1096,7 @@ fn bond_extra_and_withdraw_unbonded_works() { Staking::withdraw_unbonded(Origin::signed(10)).unwrap(); // Now the value is free and the staking ledger is updated. assert_eq!(Staking::ledger(&10), Some(StakingLedger { - stash: 11, total: 100, active: 100, unlocking: vec![] })); + stash: 11, total: 100, active: 100, unlocking: vec![], last_reward: None })); }) } @@ -1158,11 +1157,12 @@ fn rebond_works() { total: 1000, active: 1000, unlocking: vec![], + last_reward: None, }) ); start_era(2); - assert_eq!(Staking::current_era(), 2); + assert_eq!(Staking::active_era().unwrap().index, 2); // Try to rebond some funds. We get an error since no fund is unbonded. assert_noop!( @@ -1180,8 +1180,9 @@ fn rebond_works() { active: 100, unlocking: vec![UnlockChunk { value: 900, - era: 2 + 3 - },] + era: 2 + 3, + }], + last_reward: None, }) ); @@ -1194,6 +1195,7 @@ fn rebond_works() { total: 1000, active: 1000, unlocking: vec![], + last_reward: None, }) ); @@ -1206,6 +1208,7 @@ fn rebond_works() { total: 1000, active: 100, unlocking: vec![UnlockChunk { value: 900, era: 5 }], + last_reward: None, }) ); @@ -1218,6 +1221,7 @@ fn rebond_works() { total: 1000, active: 600, unlocking: vec![UnlockChunk { value: 400, era: 5 }], + last_reward: None, }) ); @@ -1229,7 +1233,8 @@ fn rebond_works() { stash: 11, total: 1000, active: 1000, - unlocking: vec![] + unlocking: vec![], + last_reward: None, }) ); @@ -1247,7 +1252,8 @@ fn rebond_works() { UnlockChunk { value: 300, era: 5 }, UnlockChunk { value: 300, era: 5 }, UnlockChunk { value: 300, era: 5 }, - ] + ], + last_reward: None, }) ); @@ -1262,7 +1268,8 @@ fn rebond_works() { unlocking: vec![ UnlockChunk { value: 300, era: 5 }, UnlockChunk { value: 100, era: 5 }, - ] + ], + last_reward: None, }) ); }) @@ -1295,6 +1302,7 @@ fn rebond_is_fifo() { total: 1000, active: 1000, unlocking: vec![], + last_reward: None, }) ); @@ -1310,7 +1318,8 @@ fn rebond_is_fifo() { active: 600, unlocking: vec![ UnlockChunk { value: 400, era: 2 + 3 }, - ] + ], + last_reward: None, }) ); @@ -1327,7 +1336,8 @@ fn rebond_is_fifo() { unlocking: vec![ UnlockChunk { value: 400, era: 2 + 3 }, UnlockChunk { value: 300, era: 3 + 3 }, - ] + ], + last_reward: None, }) ); @@ -1345,7 +1355,8 @@ fn rebond_is_fifo() { UnlockChunk { value: 400, era: 2 + 3 }, UnlockChunk { value: 300, era: 3 + 3 }, UnlockChunk { value: 200, era: 4 + 3 }, - ] + ], + last_reward: None, }) ); @@ -1360,36 +1371,34 @@ fn rebond_is_fifo() { unlocking: vec![ UnlockChunk { value: 400, era: 2 + 3 }, UnlockChunk { value: 100, era: 3 + 3 }, - ] + ], + last_reward: None, }) ); }) } #[test] -fn slot_stake_is_least_staked_validator_and_exposure_defines_maximum_punishment() { - // Test that slot_stake is determined by the least staked validator - // Test that slot_stake is the maximum punishment that can happen to a validator +fn reward_to_stake_works() { ExtBuilder::default().nominate(false).fair(false).build().execute_with(|| { // Confirm validator count is 2 assert_eq!(Staking::validator_count(), 2); // Confirm account 10 and 20 are validators assert!(>::contains_key(&11) && >::contains_key(&21)); - assert_eq!(Staking::stakers(&11).total, 1000); - assert_eq!(Staking::stakers(&21).total, 2000); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 11).total, 1000); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 21).total, 2000); // Give the man some money. let _ = Balances::make_free_balance_be(&10, 1000); let _ = Balances::make_free_balance_be(&20, 1000); - // We confirm initialized slot_stake is this value - assert_eq!(Staking::slot_stake(), Staking::stakers(&11).total); + // Bypass logic and change current exposure + ErasStakers::::insert(0, 21, Exposure { total: 69, own: 69, others: vec![] }); // Now lets lower account 20 stake - >::insert(&21, Exposure { total: 69, own: 69, others: vec![] }); - assert_eq!(Staking::stakers(&21).total, 69); - >::insert(&20, StakingLedger { stash: 22, total: 69, active: 69, unlocking: vec![] }); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 21).total, 69); + >::insert(&20, StakingLedger { stash: 21, total: 69, active: 69, unlocking: vec![], last_reward: None }); // Compute total payout now for whole duration as other parameter won't change let total_payout_0 = current_total_payout_for_duration(3000); @@ -1399,19 +1408,23 @@ fn slot_stake_is_least_staked_validator_and_exposure_defines_maximum_punishment( // New era --> rewards are paid --> stakes are changed start_era(1); + mock::make_all_reward_payment(0); - // -- new balances + reward - assert_eq!(Staking::stakers(&11).total, 1000 + total_payout_0 / 2); - assert_eq!(Staking::stakers(&21).total, 69 + total_payout_0 / 2); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 11).total, 1000); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 21).total, 69); let _11_balance = Balances::free_balance(&11); assert_eq!(_11_balance, 1000 + total_payout_0 / 2); - // -- slot stake should also be updated. - assert_eq!(Staking::slot_stake(), 69 + total_payout_0 / 2); + // Trigger another new era as the info are frozen before the era start. + start_era(2); + + // -- new infos + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 11).total, 1000 + total_payout_0 / 2); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 21).total, 69 + total_payout_0 / 2); - check_exposure_all(); - check_nominator_all(); + check_exposure_all(Staking::active_era().unwrap().index); + check_nominator_all(Staking::active_era().unwrap().index); }); } @@ -1529,8 +1542,6 @@ fn on_free_balance_zero_stash_removes_nominator() { fn switching_roles() { // Test that it should be possible to switch between roles (nominator, validator, idle) with minimal overhead. ExtBuilder::default().nominate(false).build().execute_with(|| { - Timestamp::set_timestamp(1); // Initialize time. - // Reset reward destination for i in &[10, 20] { assert_ok!(Staking::set_payee(Origin::signed(*i), RewardDestination::Controller)); } @@ -1550,20 +1561,7 @@ fn switching_roles() { assert_ok!(Staking::bond(Origin::signed(5), 6, 1000, RewardDestination::Controller)); assert_ok!(Staking::validate(Origin::signed(6), ValidatorPrefs::default())); - // new block - start_session(1); - - // no change - assert_eq_uvec!(validator_controllers(), vec![20, 10]); - - // new block - start_session(2); - - // no change - assert_eq_uvec!(validator_controllers(), vec![20, 10]); - - // new block --> ne era --> new validators - start_session(3); + start_era(1); // with current nominators 10 and 5 have the most stake assert_eq_uvec!(validator_controllers(), vec![6, 10]); @@ -1577,18 +1575,12 @@ fn switching_roles() { // 2 : 2000 self vote + 250 vote. // Winners: 20 and 2 - start_session(4); - assert_eq_uvec!(validator_controllers(), vec![6, 10]); - - start_session(5); - assert_eq_uvec!(validator_controllers(), vec![6, 10]); + start_era(2); - // ne era - start_session(6); assert_eq_uvec!(validator_controllers(), vec![2, 20]); - check_exposure_all(); - check_nominator_all(); + check_exposure_all(Staking::active_era().unwrap().index); + check_nominator_all(Staking::active_era().unwrap().index); }); } @@ -1632,6 +1624,7 @@ fn bond_with_no_staked_value() { ); // bonded with absolute minimum value possible. assert_ok!(Staking::bond(Origin::signed(1), 2, 5, RewardDestination::Controller)); + let current_era_at_bond = Staking::current_era(); assert_eq!(Balances::locks(&1)[0].amount, 5); // unbonding even 1 will cause all to be unbonded. @@ -1642,7 +1635,8 @@ fn bond_with_no_staked_value() { stash: 1, active: 0, total: 5, - unlocking: vec![UnlockChunk {value: 5, era: 3}] + unlocking: vec![UnlockChunk {value: 5, era: 3}], + last_reward: current_era_at_bond, }) ); @@ -1664,7 +1658,7 @@ fn bond_with_no_staked_value() { } #[test] -fn bond_with_little_staked_value_bounded_by_slot_stake() { +fn bond_with_little_staked_value_bounded() { // Behavior when someone bonds with little staked value. // Particularly when she votes and the candidate is elected. ExtBuilder::default() @@ -1683,36 +1677,40 @@ fn bond_with_little_staked_value_bounded_by_slot_stake() { assert_ok!(Staking::bond(Origin::signed(1), 2, 1, RewardDestination::Controller)); assert_ok!(Staking::validate(Origin::signed(2), ValidatorPrefs::default())); + // reward era 0 let total_payout_0 = current_total_payout_for_duration(3000); assert!(total_payout_0 > 100); // Test is meaningful if reward something reward_all_elected(); start_era(1); + mock::make_all_reward_payment(0); // 2 is elected. - // and fucks up the slot stake. assert_eq_uvec!(validator_controllers(), vec![20, 10, 2]); - assert_eq!(Staking::slot_stake(), 1); + // And has minimal stake + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 2).total, 0); // Old ones are rewarded. assert_eq!(Balances::free_balance(10), init_balance_10 + total_payout_0 / 3); // no rewards paid to 2. This was initial election. assert_eq!(Balances::free_balance(2), init_balance_2); + // reward era 1 let total_payout_1 = current_total_payout_for_duration(3000); assert!(total_payout_1 > 100); // Test is meaningful if reward something reward_all_elected(); start_era(2); + mock::make_all_reward_payment(1); assert_eq_uvec!(validator_controllers(), vec![20, 10, 2]); - assert_eq!(Staking::slot_stake(), 1); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 2).total, 0); assert_eq!(Balances::free_balance(2), init_balance_2 + total_payout_1 / 3); assert_eq!( Balances::free_balance(&10), init_balance_10 + total_payout_0 / 3 + total_payout_1 / 3, ); - check_exposure_all(); - check_nominator_all(); + check_exposure_all(Staking::active_era().unwrap().index); + check_nominator_all(Staking::active_era().unwrap().index); }); } @@ -1732,8 +1730,8 @@ fn new_era_elects_correct_number_of_validators() { Session::on_initialize(System::block_number()); assert_eq!(validator_controllers().len(), 1); - check_exposure_all(); - check_nominator_all(); + check_exposure_all(Staking::active_era().unwrap().index); + check_nominator_all(Staking::active_era().unwrap().index); }) } @@ -1755,8 +1753,8 @@ fn phragmen_should_not_overflow_validators() { // This test will fail this. Will saturate. // check_exposure_all(); - assert_eq!(Staking::stakers(3).total, u64::max_value()); - assert_eq!(Staking::stakers(5).total, u64::max_value()); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 3).total, u64::max_value()); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 5).total, u64::max_value()); }) } @@ -1777,8 +1775,8 @@ fn phragmen_should_not_overflow_nominators() { assert_eq_uvec!(validator_controllers(), vec![4, 2]); // Saturate. - assert_eq!(Staking::stakers(3).total, u64::max_value()); - assert_eq!(Staking::stakers(5).total, u64::max_value()); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 3).total, u64::max_value()); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 5).total, u64::max_value()); }) } @@ -1796,8 +1794,8 @@ fn phragmen_should_not_overflow_ultimate() { assert_eq_uvec!(validator_controllers(), vec![4, 2]); // Saturate. - assert_eq!(Staking::stakers(3).total, u64::max_value()); - assert_eq!(Staking::stakers(5).total, u64::max_value()); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 3).total, u64::max_value()); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 5).total, u64::max_value()); }) } @@ -1812,10 +1810,19 @@ fn reward_validator_slashing_validator_doesnt_overflow() { // Set staker let _ = Balances::make_free_balance_be(&11, stake); - >::insert(&11, Exposure { total: stake, own: stake, others: vec![] }); + + let exposure = Exposure:: { total: stake, own: stake, others: vec![] }; + let reward = EraRewardPoints:: { + total: 1, + individual: vec![(11, 1)].into_iter().collect(), + }; // Check reward - let _ = Staking::reward_validator(&11, reward_slash); + ErasRewardPoints::::insert(0, reward); + ErasStakers::::insert(0, 11, &exposure); + ErasStakersClipped::::insert(0, 11, exposure); + ErasValidatorReward::::insert(0, stake); + assert_ok!(Staking::payout_validator(Origin::signed(10), 0)); assert_eq!(Balances::total_balance(&11), stake * 2); // Set staker @@ -1825,16 +1832,18 @@ fn reward_validator_slashing_validator_doesnt_overflow() { // only slashes out of bonded stake are applied. without this line, // it is 0. Staking::bond(Origin::signed(2), 20000, stake - 1, RewardDestination::default()).unwrap(); - >::insert(&11, Exposure { total: stake, own: 1, others: vec![ - IndividualExposure { who: 2, value: stake - 1 } - ]}); - + // Override exposure of 11 + ErasStakers::::insert(0, 11, Exposure { + total: stake, + own: 1, + others: vec![ IndividualExposure { who: 2, value: stake - 1 }] + }); // Check slashing on_offence_now( &[ OffenceDetails { - offender: (11, Staking::stakers(&11)), + offender: (11, Staking::eras_stakers(Staking::active_era().unwrap().index, 11)), reporters: vec![], }, ], @@ -1855,45 +1864,49 @@ fn reward_from_authorship_event_handler_works() { >::note_author(11); >::note_uncle(21, 1); - // An uncle author that is not currently elected doesn't get rewards, - // but the block producer does get reward for referencing it. - >::note_uncle(31, 1); // Rewarding the same two times works. >::note_uncle(11, 1); // Not mandatory but must be coherent with rewards - assert_eq!(>::get(), vec![21, 11]); + assert_eq_uvec!(Session::validators(), vec![11, 21]); // 21 is rewarded as an uncle producer // 11 is rewarded as a block producer and uncle referencer and uncle producer - assert_eq!(CurrentEraPointsEarned::get().individual, vec![1, 20 + 2 * 3 + 1]); - assert_eq!(CurrentEraPointsEarned::get().total, 28); + assert_eq!( + ErasRewardPoints::::get(Staking::active_era().unwrap().index), + EraRewardPoints { + individual: vec![(11, 20 + 2 * 2 + 1), (21, 1)].into_iter().collect(), + total: 26, + }, + ); }) } #[test] fn add_reward_points_fns_works() { ExtBuilder::default().build().execute_with(|| { - let validators = >::current_elected(); // Not mandatory but must be coherent with rewards - assert_eq!(validators, vec![21, 11]); + assert_eq!(Session::validators(), vec![21, 11]); - >::reward_by_indices(vec![ - (0, 1), - (1, 1), - (2, 1), - (1, 1), + >::reward_by_ids(vec![ + (21, 1), + (11, 1), + (11, 1), ]); >::reward_by_ids(vec![ (21, 1), (11, 1), - (31, 1), (11, 1), ]); - assert_eq!(CurrentEraPointsEarned::get().individual, vec![2, 4]); - assert_eq!(CurrentEraPointsEarned::get().total, 6); + assert_eq!( + ErasRewardPoints::::get(Staking::active_era().unwrap().index), + EraRewardPoints { + individual: vec![(11, 4), (21, 2)].into_iter().collect(), + total: 6, + }, + ); }) } @@ -1916,19 +1929,20 @@ fn era_is_always_same_length() { // session changes. ExtBuilder::default().build().execute_with(|| { start_era(1); - assert_eq!(Staking::current_era_start_session_index(), SessionsPerEra::get()); + assert_eq!(Staking::eras_start_session_index(Staking::active_era().unwrap().index).unwrap(), SessionsPerEra::get()); start_era(2); - assert_eq!(Staking::current_era_start_session_index(), SessionsPerEra::get() * 2); + assert_eq!(Staking::eras_start_session_index(Staking::active_era().unwrap().index).unwrap(), SessionsPerEra::get() * 2); let session = Session::current_index(); ForceEra::put(Forcing::ForceNew); advance_session(); - assert_eq!(Staking::current_era(), 3); - assert_eq!(Staking::current_era_start_session_index(), session + 1); + advance_session(); + assert_eq!(Staking::active_era().unwrap().index, 3); + assert_eq!(Staking::eras_start_session_index(Staking::active_era().unwrap().index).unwrap(), session + 2); start_era(4); - assert_eq!(Staking::current_era_start_session_index(), session + SessionsPerEra::get() + 1); + assert_eq!(Staking::eras_start_session_index(Staking::active_era().unwrap().index).unwrap(), session + 2 + SessionsPerEra::get()); }); } @@ -1939,7 +1953,7 @@ fn offence_forces_new_era() { &[OffenceDetails { offender: ( 11, - Staking::stakers(&11), + Staking::eras_stakers(Staking::active_era().unwrap().index, 11), ), reporters: vec![], }], @@ -1959,7 +1973,7 @@ fn offence_ensures_new_era_without_clobbering() { &[OffenceDetails { offender: ( 11, - Staking::stakers(&11), + Staking::eras_stakers(Staking::active_era().unwrap().index, 11), ), reporters: vec![], }], @@ -1973,12 +1987,13 @@ fn offence_ensures_new_era_without_clobbering() { #[test] fn offence_deselects_validator_when_slash_is_zero() { ExtBuilder::default().build().execute_with(|| { + assert!(Session::validators().contains(&11)); assert!(>::contains_key(11)); on_offence_now( &[OffenceDetails { offender: ( 11, - Staking::stakers(&11), + Staking::eras_stakers(Staking::active_era().unwrap().index, 11), ), reporters: vec![], }], @@ -1986,6 +2001,9 @@ fn offence_deselects_validator_when_slash_is_zero() { ); assert_eq!(Staking::force_era(), Forcing::ForceNew); assert!(!>::contains_key(11)); + start_era(1); + assert!(!Session::validators().contains(&11)); + assert!(!>::contains_key(11)); }); } @@ -1994,7 +2012,7 @@ fn slashing_performed_according_exposure() { // This test checks that slashing is performed according the exposure (or more precisely, // historical exposure), not the current balance. ExtBuilder::default().build().execute_with(|| { - assert_eq!(Staking::stakers(&11).own, 1000); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 11).own, 1000); // Handle an offence with a historical exposure. on_offence_now( @@ -2023,11 +2041,12 @@ fn slash_in_old_span_does_not_deselect() { start_era(1); assert!(>::contains_key(11)); + assert!(Session::validators().contains(&11)); on_offence_now( &[OffenceDetails { offender: ( 11, - Staking::stakers(&11), + Staking::eras_stakers(Staking::active_era().unwrap().index, 11), ), reporters: vec![], }], @@ -2041,6 +2060,7 @@ fn slash_in_old_span_does_not_deselect() { Staking::validate(Origin::signed(10), Default::default()).unwrap(); assert_eq!(Staking::force_era(), Forcing::NotForcing); assert!(>::contains_key(11)); + assert!(!Session::validators().contains(&11)); start_era(3); @@ -2051,7 +2071,7 @@ fn slash_in_old_span_does_not_deselect() { &[OffenceDetails { offender: ( 11, - Staking::stakers(&11), + Staking::eras_stakers(Staking::active_era().unwrap().index, 11), ), reporters: vec![], }], @@ -2062,12 +2082,13 @@ fn slash_in_old_span_does_not_deselect() { // not for zero-slash. assert_eq!(Staking::force_era(), Forcing::NotForcing); assert!(>::contains_key(11)); + assert!(Session::validators().contains(&11)); on_offence_in_era( &[OffenceDetails { offender: ( 11, - Staking::stakers(&11), + Staking::eras_stakers(Staking::active_era().unwrap().index, 11), ), reporters: vec![], }], @@ -2079,6 +2100,7 @@ fn slash_in_old_span_does_not_deselect() { // or non-zero. assert_eq!(Staking::force_era(), Forcing::NotForcing); assert!(>::contains_key(11)); + assert!(Session::validators().contains(&11)); assert_ledger_consistent(11); }); } @@ -2091,13 +2113,13 @@ fn reporters_receive_their_slice() { // The reporters' reward is calculated from the total exposure. let initial_balance = 1125; - assert_eq!(Staking::stakers(&11).total, initial_balance); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 11).total, initial_balance); on_offence_now( &[OffenceDetails { offender: ( 11, - Staking::stakers(&11), + Staking::eras_stakers(Staking::active_era().unwrap().index, 11), ), reporters: vec![1, 2], }], @@ -2122,13 +2144,13 @@ fn subsequent_reports_in_same_span_pay_out_less() { // The reporters' reward is calculated from the total exposure. let initial_balance = 1125; - assert_eq!(Staking::stakers(&11).total, initial_balance); + assert_eq!(Staking::eras_stakers(Staking::active_era().unwrap().index, 11).total, initial_balance); on_offence_now( &[OffenceDetails { offender: ( 11, - Staking::stakers(&11), + Staking::eras_stakers(Staking::active_era().unwrap().index, 11), ), reporters: vec![1], }], @@ -2144,7 +2166,7 @@ fn subsequent_reports_in_same_span_pay_out_less() { &[OffenceDetails { offender: ( 11, - Staking::stakers(&11), + Staking::eras_stakers(Staking::active_era().unwrap().index, 11), ), reporters: vec![1], }], @@ -2168,7 +2190,7 @@ fn invulnerables_are_not_slashed() { assert_eq!(Balances::free_balance(11), 1000); assert_eq!(Balances::free_balance(21), 2000); - let exposure = Staking::stakers(&21); + let exposure = Staking::eras_stakers(Staking::active_era().unwrap().index, 21); let initial_balance = Staking::slashable_balance_of(&21); let nominator_balances: Vec<_> = exposure.others @@ -2177,11 +2199,11 @@ fn invulnerables_are_not_slashed() { on_offence_now( &[ OffenceDetails { - offender: (11, Staking::stakers(&11)), + offender: (11, Staking::eras_stakers(Staking::active_era().unwrap().index, 11)), reporters: vec![], }, OffenceDetails { - offender: (21, Staking::stakers(&21)), + offender: (21, Staking::eras_stakers(Staking::active_era().unwrap().index, 21)), reporters: vec![], }, ], @@ -2215,7 +2237,7 @@ fn dont_slash_if_fraction_is_zero() { &[OffenceDetails { offender: ( 11, - Staking::stakers(&11), + Staking::eras_stakers(Staking::active_era().unwrap().index, 11), ), reporters: vec![], }], @@ -2236,7 +2258,7 @@ fn only_slash_for_max_in_era() { on_offence_now( &[ OffenceDetails { - offender: (11, Staking::stakers(&11)), + offender: (11, Staking::eras_stakers(Staking::active_era().unwrap().index, 11)), reporters: vec![], }, ], @@ -2250,7 +2272,7 @@ fn only_slash_for_max_in_era() { on_offence_now( &[ OffenceDetails { - offender: (11, Staking::stakers(&11)), + offender: (11, Staking::eras_stakers(Staking::active_era().unwrap().index, 11)), reporters: vec![], }, ], @@ -2263,7 +2285,7 @@ fn only_slash_for_max_in_era() { on_offence_now( &[ OffenceDetails { - offender: (11, Staking::stakers(&11)), + offender: (11, Staking::eras_stakers(Staking::active_era().unwrap().index, 11)), reporters: vec![], }, ], @@ -2284,7 +2306,7 @@ fn garbage_collection_after_slashing() { on_offence_now( &[ OffenceDetails { - offender: (11, Staking::stakers(&11)), + offender: (11, Staking::eras_stakers(Staking::active_era().unwrap().index, 11)), reporters: vec![], }, ], @@ -2298,7 +2320,7 @@ fn garbage_collection_after_slashing() { on_offence_now( &[ OffenceDetails { - offender: (11, Staking::stakers(&11)), + offender: (11, Staking::eras_stakers(Staking::active_era().unwrap().index, 11)), reporters: vec![], }, ], @@ -2325,21 +2347,21 @@ fn garbage_collection_on_window_pruning() { assert_eq!(Balances::free_balance(11), 1000); - let exposure = Staking::stakers(&11); + let exposure = Staking::eras_stakers(Staking::active_era().unwrap().index, 11); assert_eq!(Balances::free_balance(101), 2000); let nominated_value = exposure.others.iter().find(|o| o.who == 101).unwrap().value; on_offence_now( &[ OffenceDetails { - offender: (11, Staking::stakers(&11)), + offender: (11, Staking::eras_stakers(Staking::active_era().unwrap().index, 11)), reporters: vec![], }, ], &[Perbill::from_percent(10)], ); - let now = Staking::current_era(); + let now = Staking::active_era().unwrap().index; assert_eq!(Balances::free_balance(11), 900); assert_eq!(Balances::free_balance(101), 2000 - (nominated_value / 10)); @@ -2373,8 +2395,8 @@ fn slashing_nominators_by_span_max() { assert_eq!(Staking::slashable_balance_of(&21), 1000); - let exposure_11 = Staking::stakers(&11); - let exposure_21 = Staking::stakers(&21); + let exposure_11 = Staking::eras_stakers(Staking::active_era().unwrap().index, 11); + let exposure_21 = Staking::eras_stakers(Staking::active_era().unwrap().index, 21); assert_eq!(Balances::free_balance(101), 2000); let nominated_value_11 = exposure_11.others.iter().find(|o| o.who == 101).unwrap().value; let nominated_value_21 = exposure_21.others.iter().find(|o| o.who == 101).unwrap().value; @@ -2382,7 +2404,7 @@ fn slashing_nominators_by_span_max() { on_offence_in_era( &[ OffenceDetails { - offender: (11, Staking::stakers(&11)), + offender: (11, Staking::eras_stakers(Staking::active_era().unwrap().index, 11)), reporters: vec![], }, ], @@ -2416,7 +2438,7 @@ fn slashing_nominators_by_span_max() { on_offence_in_era( &[ OffenceDetails { - offender: (21, Staking::stakers(&21)), + offender: (21, Staking::eras_stakers(Staking::active_era().unwrap().index, 21)), reporters: vec![], }, ], @@ -2439,7 +2461,7 @@ fn slashing_nominators_by_span_max() { on_offence_in_era( &[ OffenceDetails { - offender: (11, Staking::stakers(&11)), + offender: (11, Staking::eras_stakers(Staking::active_era().unwrap().index, 11)), reporters: vec![], }, ], @@ -2475,7 +2497,7 @@ fn slashes_are_summed_across_spans() { on_offence_now( &[ OffenceDetails { - offender: (21, Staking::stakers(&21)), + offender: (21, Staking::eras_stakers(Staking::active_era().unwrap().index, 21)), reporters: vec![], }, ], @@ -2500,7 +2522,7 @@ fn slashes_are_summed_across_spans() { on_offence_now( &[ OffenceDetails { - offender: (21, Staking::stakers(&21)), + offender: (21, Staking::eras_stakers(Staking::active_era().unwrap().index, 21)), reporters: vec![], }, ], @@ -2525,14 +2547,14 @@ fn deferred_slashes_are_deferred() { assert_eq!(Balances::free_balance(11), 1000); - let exposure = Staking::stakers(&11); + let exposure = Staking::eras_stakers(Staking::active_era().unwrap().index, 11); assert_eq!(Balances::free_balance(101), 2000); let nominated_value = exposure.others.iter().find(|o| o.who == 101).unwrap().value; on_offence_now( &[ OffenceDetails { - offender: (11, Staking::stakers(&11)), + offender: (11, Staking::eras_stakers(Staking::active_era().unwrap().index, 11)), reporters: vec![], }, ], @@ -2568,7 +2590,7 @@ fn remove_deferred() { assert_eq!(Balances::free_balance(11), 1000); - let exposure = Staking::stakers(&11); + let exposure = Staking::eras_stakers(Staking::active_era().unwrap().index, 11); assert_eq!(Balances::free_balance(101), 2000); let nominated_value = exposure.others.iter().find(|o| o.who == 101).unwrap().value; @@ -2638,7 +2660,7 @@ fn remove_multi_deferred() { assert_eq!(Balances::free_balance(11), 1000); - let exposure = Staking::stakers(&11); + let exposure = Staking::eras_stakers(Staking::active_era().unwrap().index, 11); assert_eq!(Balances::free_balance(101), 2000); on_offence_now( @@ -2654,7 +2676,7 @@ fn remove_multi_deferred() { on_offence_now( &[ OffenceDetails { - offender: (21, Staking::stakers(&21)), + offender: (21, Staking::eras_stakers(Staking::active_era().unwrap().index, 21)), reporters: vec![], } ], @@ -2687,7 +2709,7 @@ fn slash_kicks_validators_not_nominators() { assert_eq!(Balances::free_balance(11), 1000); - let exposure = Staking::stakers(&11); + let exposure = Staking::eras_stakers(Staking::active_era().unwrap().index, 11); assert_eq!(Balances::free_balance(101), 2000); let nominated_value = exposure.others.iter().find(|o| o.who == 101).unwrap().value; @@ -2719,6 +2741,199 @@ fn slash_kicks_validators_not_nominators() { }); } +#[test] +fn claim_reward_at_the_last_era_and_no_double_claim_and_invalid_claim() { + // should check that: + // * rewards get paid until history_depth for both validators and nominators + // * an invalid era to claim doesn't update last_reward + // * double claim of one era fails + ExtBuilder::default().nominate(true).build().execute_with(|| { + let init_balance_10 = Balances::total_balance(&10); + let init_balance_100 = Balances::total_balance(&100); + + let part_for_10 = Perbill::from_rational_approximation::(1000, 1125); + let part_for_100 = Perbill::from_rational_approximation::(125, 1125); + + // Check state + Payee::::insert(11, RewardDestination::Controller); + Payee::::insert(101, RewardDestination::Controller); + + >::reward_by_ids(vec![(11, 1)]); + // Compute total payout now for whole duration as other parameter won't change + let total_payout_0 = current_total_payout_for_duration(3000); + assert!(total_payout_0 > 10); // Test is meaningful if reward something + + start_era(1); + + >::reward_by_ids(vec![(11, 1)]); + // Change total issuance in order to modify total payout + let _ = Balances::deposit_creating(&999, 1_000_000_000); + // Compute total payout now for whole duration as other parameter won't change + let total_payout_1 = current_total_payout_for_duration(3000); + assert!(total_payout_1 > 10); // Test is meaningful if reward something + assert!(total_payout_1 != total_payout_0); + + start_era(2); + + >::reward_by_ids(vec![(11, 1)]); + // Change total issuance in order to modify total payout + let _ = Balances::deposit_creating(&999, 1_000_000_000); + // Compute total payout now for whole duration as other parameter won't change + let total_payout_2 = current_total_payout_for_duration(3000); + assert!(total_payout_2 > 10); // Test is meaningful if reward something + assert!(total_payout_2 != total_payout_0); + assert!(total_payout_2 != total_payout_1); + + start_era(Staking::history_depth() + 1); + + let active_era = Staking::active_era().unwrap().index; + + // This is the latest planned era in staking, not the active era + let current_era = Staking::current_era().unwrap(); + + // Last kept is 1: + assert!(current_era - Staking::history_depth() == 1); + assert_noop!( + Staking::payout_validator(Origin::signed(10), 0), + // Fail: Era out of history + Error::::InvalidEraToReward + ); + assert_ok!(Staking::payout_validator(Origin::signed(10), 1)); + assert_ok!(Staking::payout_validator(Origin::signed(10), 2)); + assert_noop!( + Staking::payout_validator(Origin::signed(10), 2), + // Fail: Double claim + Error::::InvalidEraToReward + ); + assert_noop!( + Staking::payout_validator(Origin::signed(10), active_era), + // Fail: Era not finished yet + Error::::InvalidEraToReward + ); + + assert_noop!( + Staking::payout_nominator(Origin::signed(100), 0, vec![(11, 0)]), + // Fail: Era out of history + Error::::InvalidEraToReward + ); + assert_ok!(Staking::payout_nominator(Origin::signed(100), 1, vec![(11, 0)])); + assert_ok!(Staking::payout_nominator(Origin::signed(100), 2, vec![(11, 0)])); + assert_noop!( + Staking::payout_nominator(Origin::signed(100), 2, vec![(11, 0)]), + // Fail: Double claim + Error::::InvalidEraToReward + ); + assert_noop!( + Staking::payout_nominator(Origin::signed(100), active_era, vec![(11, 0)]), + // Fail: Era not finished yet + Error::::InvalidEraToReward + ); + + // Era 0 can't be rewarded anymore and current era can't be rewarded yet + // only era 1 and 2 can be rewarded. + + assert_eq!( + Balances::total_balance(&10), + init_balance_10 + part_for_10 * (total_payout_1 + total_payout_2), + ); + assert_eq!( + Balances::total_balance(&100), + init_balance_100 + part_for_100 * (total_payout_1 + total_payout_2), + ); + }); +} + +#[test] +fn upgrade_works() { + ExtBuilder::default().build().execute_with(|| { + start_era(3); + + assert_eq!(Session::validators(), vec![21, 11]); + + // Insert fake data to check the migration + put_storage_value::>(b"Staking", b"CurrentElected", b"", vec![21, 31]); + put_storage_value::(b"Staking", b"CurrentEraStartSessionIndex", b"", 5); + put_storage_value::>(b"Staking", b"CurrentEraStart", b"", 777); + put_storage_value( + b"Staking", b"Stakers", &blake2_256(&11u64.encode()), + Exposure:: { + total: 10, + own: 10, + others: vec![], + } + ); + put_storage_value( + b"Staking", b"Stakers", &blake2_256(&21u64.encode()), + Exposure:: { + total: 20, + own: 20, + others: vec![], + } + ); + put_storage_value( + b"Staking", b"Stakers", &blake2_256(&31u64.encode()), + Exposure:: { + total: 30, + own: 30, + others: vec![], + } + ); + put_storage_value::<(u32, Vec)>(b"Staking", b"CurrentEraPointsEarned", b"", (12, vec![2, 10])); + ::ErasStakers::remove_all(); + ::ErasStakersClipped::remove_all(); + + ::IsUpgraded::put(false); + + // Perform upgrade + Staking::ensure_storage_upgraded(); + + assert_eq!(::IsUpgraded::get(), true); + + // Check migration + assert_eq!(::ErasStartSessionIndex::get(3).unwrap(), 5); + assert_eq!(::ErasRewardPoints::get(3), EraRewardPoints { + total: 12, + individual: vec![(21, 2), (31, 10)].into_iter().collect(), + }); + assert_eq!(::ActiveEra::get().unwrap().index, 3); + assert_eq!(::ActiveEra::get().unwrap().start, Some(777)); + assert_eq!(::CurrentEra::get().unwrap(), 3); + assert_eq!(::ErasStakers::get(3, 11), Exposure { + total: 0, + own: 0, + others: vec![], + }); + assert_eq!(::ErasStakers::get(3, 21), Exposure { + total: 20, + own: 20, + others: vec![], + }); + assert_eq!(::ErasStakers::get(3, 31), Exposure { + total: 30, + own: 30, + others: vec![], + }); + assert_eq!(::ErasStakersClipped::get(3, 11), Exposure { + total: 0, + own: 0, + others: vec![], + }); + assert_eq!(::ErasStakersClipped::get(3, 21), Exposure { + total: 20, + own: 20, + others: vec![], + }); + assert_eq!(::ErasStakersClipped::get(3, 31), Exposure { + total: 30, + own: 30, + others: vec![], + }); + assert_eq!(::ErasValidatorPrefs::get(3, 21), Staking::validators(21)); + assert_eq!(::ErasValidatorPrefs::get(3, 31), Staking::validators(31)); + assert_eq!(::ErasTotalStake::get(3), 50); + }) +} + #[test] fn zero_slash_keeps_nominators() { ExtBuilder::default().build().execute_with(|| { @@ -2726,7 +2941,7 @@ fn zero_slash_keeps_nominators() { assert_eq!(Balances::free_balance(11), 1000); - let exposure = Staking::stakers(&11); + let exposure = Staking::eras_stakers(Staking::active_era().unwrap().index, 11); assert_eq!(Balances::free_balance(101), 2000); on_offence_now( @@ -2756,3 +2971,245 @@ fn zero_slash_keeps_nominators() { assert!(nominations.submitted_in >= last_slash); }); } + +#[test] +fn six_session_delay() { + ExtBuilder::default().build().execute_with(|| { + use pallet_session::SessionManager; + + let val_set = Session::validators(); + let init_session = Session::current_index(); + let init_active_era = Staking::active_era().unwrap().index; + // pallet-session is delaying session by one, thus the next session to plan is +2. + assert_eq!(>::new_session(init_session + 2), None); + assert_eq!(>::new_session(init_session + 3), Some(val_set.clone())); + assert_eq!(>::new_session(init_session + 4), None); + assert_eq!(>::new_session(init_session + 5), None); + assert_eq!(>::new_session(init_session + 6), Some(val_set.clone())); + + >::end_session(init_session); + >::start_session(init_session + 1); + assert_eq!(Staking::active_era().unwrap().index, init_active_era); + >::end_session(init_session + 1); + >::start_session(init_session + 2); + assert_eq!(Staking::active_era().unwrap().index, init_active_era); + + // Reward current era + Staking::reward_by_ids(vec![(11, 1)]); + + // New active era is triggered here. + >::end_session(init_session + 2); + >::start_session(init_session + 3); + assert_eq!(Staking::active_era().unwrap().index, init_active_era + 1); + >::end_session(init_session + 3); + >::start_session(init_session + 4); + assert_eq!(Staking::active_era().unwrap().index, init_active_era + 1); + >::end_session(init_session + 4); + >::start_session(init_session + 5); + assert_eq!(Staking::active_era().unwrap().index, init_active_era + 1); + + // Reward current era + Staking::reward_by_ids(vec![(21, 2)]); + + // New active era is triggered here. + >::end_session(init_session + 5); + >::start_session(init_session + 6); + assert_eq!(Staking::active_era().unwrap().index, init_active_era + 2); + + // That reward are correct + assert_eq!(Staking::eras_reward_points(init_active_era).total, 1); + assert_eq!(Staking::eras_reward_points(init_active_era + 1).total, 2); + }); +} + +#[test] +fn test_max_nominator_rewarded_per_validator_and_cant_steal_someone_else_reward() { + // Test: + // * If nominator nomination is below the $MaxNominatorRewardedPerValidator other nominator + // then the nominator can't claim its reward + // * A nominator can't claim another nominator reward + ExtBuilder::default().build().execute_with(|| { + for i in 0..=::MaxNominatorRewardedPerValidator::get() { + let stash = 10_000 + i as u64; + let controller = 20_000 + i as u64; + let balance = 10_000 + i as u64; + Balances::make_free_balance_be(&stash, balance); + assert_ok!( + Staking::bond( + Origin::signed(stash), + controller, + balance, + RewardDestination::Stash + ) + ); + assert_ok!(Staking::nominate(Origin::signed(controller), vec![11])); + } + mock::start_era(1); + + >::reward_by_ids(vec![(11, 1)]); + // Compute total payout now for whole duration as other parameter won't change + let total_payout_0 = current_total_payout_for_duration(3 * 1000); + assert!(total_payout_0 > 100); // Test is meaningful if reward something + + mock::start_era(2); + mock::make_all_reward_payment(1); + + // nominator 10_000 can't get its reward because exposure is clipped. However it will try + // to query other people reward. + assert_ok!(Staking::payout_nominator(Origin::signed(20_000), 1, vec![(11, 0)])); + + // Assert only nominators from 1 to Max are rewarded + for i in 0..=::MaxNominatorRewardedPerValidator::get() { + let stash = 10_000 + i as u64; + let balance = 10_000 + i as u64; + if stash == 10_000 { + assert!(Balances::free_balance(&stash) == balance); + } else { + assert!(Balances::free_balance(&stash) > balance); + } + } + }); +} + +// Test that an upgrade from previous test environment works. +#[test] +fn test_upgrade_from_master_works() { + let data_sets = &[ + test_upgrade_from_master_dataset::_0, + test_upgrade_from_master_dataset::_1, + test_upgrade_from_master_dataset::_2, + test_upgrade_from_master_dataset::_3, + test_upgrade_from_master_dataset::_4, + test_upgrade_from_master_dataset::_5, + test_upgrade_from_master_dataset::_6, + test_upgrade_from_master_dataset::_7, + test_upgrade_from_master_dataset::_8, + ]; + for data_set in data_sets.iter() { + let mut storage = sp_runtime::Storage::default(); + for (key, value) in data_set.iter() { + storage.top.insert(key.to_vec(), value.to_vec()); + } + let mut ext = sp_io::TestExternalities::from(storage); + ext.execute_with(|| { + let old_stakers = + get_storage_value::>(b"Staking", b"CurrentElected", b"").unwrap(); + let old_staker_0 = old_stakers[0]; + let old_staker_1 = old_stakers[1]; + let old_current_era = + get_storage_value::(b"Staking", b"CurrentEra", b"").unwrap(); + let old_staker_0_exposure = get_storage_value::>( + b"Staking", b"Stakers", &blake2_256(&old_staker_0.encode()) + ).unwrap(); + let old_staker_1_exposure = get_storage_value::>( + b"Staking", b"Stakers", &blake2_256(&old_staker_1.encode()) + ).unwrap(); + let ( + old_era_points_earned_total, + old_era_points_earned_individual + ) = get_storage_value::<(u32, Vec)>(b"Staking", b"CurrentEraPointsEarned", b"") + .unwrap_or((0, vec![])); + + Staking::ensure_storage_upgraded(); + assert!(::IsUpgraded::get()); + + // Check ActiveEra and CurrentEra + let active_era = Staking::active_era().unwrap().index; + let current_era = Staking::current_era().unwrap(); + assert!(current_era == active_era); + assert!(current_era == old_current_era); + + // Check ErasStartSessionIndex + let active_era_start = Staking::eras_start_session_index(active_era).unwrap(); + let current_era_start = Staking::eras_start_session_index(current_era).unwrap(); + let current_session_index = Session::current_index(); + assert!(current_era_start == active_era_start); + assert!(active_era_start <= current_session_index); + assert_eq!(::ErasStartSessionIndex::iter().count(), 1); + + // Check ErasStakers + assert_eq!(::ErasStakers::iter().count(), 2); + assert_eq!( + ::ErasStakers::get(current_era, old_staker_0), + old_staker_0_exposure + ); + assert_eq!( + ::ErasStakers::get(current_era, old_staker_1), + old_staker_1_exposure + ); + + // Check ErasStakersClipped + assert_eq!(::ErasStakersClipped::iter().count(), 2); + assert!(::ErasStakersClipped::iter().all(|exposure_clipped| { + let max = ::MaxNominatorRewardedPerValidator::get() as usize; + exposure_clipped.others.len() <= max + })); + assert_eq!( + ::ErasStakersClipped::get(current_era, old_staker_0), + old_staker_0_exposure + ); + assert_eq!( + ::ErasStakersClipped::get(current_era, old_staker_1), + old_staker_1_exposure + ); + + // Check ErasValidatorPrefs + assert_eq!(::ErasValidatorPrefs::iter().count(), 2); + assert_eq!( + ::ErasValidatorPrefs::get(current_era, old_staker_0), + Staking::validators(old_staker_0) + ); + assert_eq!( + ::ErasValidatorPrefs::get(current_era, old_staker_1), + Staking::validators(old_staker_1) + ); + + // Check ErasTotalStake + assert_eq!(::ErasTotalStake::iter().count(), 1); + assert_eq!( + ::ErasTotalStake::get(current_era), + old_staker_0_exposure.total + old_staker_1_exposure.total + ); + + // Check ErasRewardPoints + assert_eq!(::ErasRewardPoints::iter().count(), 1); + let mut individual = BTreeMap::new(); + if let Some(p) = old_era_points_earned_individual.get(0) { + individual.insert(old_staker_0, p.clone()); + } + if let Some(p) = old_era_points_earned_individual.get(1) { + individual.insert(old_staker_1, p.clone()); + } + assert_eq!( + ::ErasRewardPoints::get(current_era), + EraRewardPoints { + total: old_era_points_earned_total, + individual, + } + ); + + // Check ErasValidatorReward + assert_eq!(::ErasValidatorReward::iter().count(), 0); + }); + } +} + +#[test] +fn set_history_depth_works() { + ExtBuilder::default().build().execute_with(|| { + start_era(10); + Staking::set_history_depth(Origin::ROOT, 20).unwrap(); + assert!(::ErasTotalStake::contains_key(10 - 4)); + assert!(::ErasTotalStake::contains_key(10 - 5)); + Staking::set_history_depth(Origin::ROOT, 4).unwrap(); + assert!(::ErasTotalStake::contains_key(10 - 4)); + assert!(!::ErasTotalStake::contains_key(10 - 5)); + Staking::set_history_depth(Origin::ROOT, 3).unwrap(); + assert!(!::ErasTotalStake::contains_key(10 - 4)); + assert!(!::ErasTotalStake::contains_key(10 - 5)); + Staking::set_history_depth(Origin::ROOT, 8).unwrap(); + assert!(!::ErasTotalStake::contains_key(10 - 4)); + assert!(!::ErasTotalStake::contains_key(10 - 5)); + }); +} + diff --git a/frame/staking/src/tests/test_upgrade_from_master_dataset.rs b/frame/staking/src/tests/test_upgrade_from_master_dataset.rs new file mode 100644 index 0000000000000..32f9b0a3edb96 --- /dev/null +++ b/frame/staking/src/tests/test_upgrade_from_master_dataset.rs @@ -0,0 +1,59 @@ +// Copyright 2020-2020 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate 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. + +// Substrate 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 Substrate. If not, see . + +//! Data set for testing update from previous staking module. +//! +//! Each data set correspond to the storage state for its corresponding block just before the +//! staking initialisation. +//! +//! it has been generated using the following code at commit +//! dc92587bea4032e0a0fc96785bfd9aa17c95459e +//! +//! ```nocompile +//! fn print_storage(i: u32) { +//! let mut storage = vec![]; +//! let mut current_key = vec![]; +//! while let Some(key) = sp_io::storage::next_key(¤t_key) { +//! storage.push((key.clone(), sp_io::storage::get(&key).unwrap())); +//! current_key = key; +//! } +//! println!("const _{}: &[(&[u8], &[u8])] = {:?};", i, storage); +//! } +//! +//! #[test] +//! fn get_states() { +//! let mut ext = ExtBuilder::default().build(); +//! +//! for index in 1..10u32 { +//! ext.execute_with(|| { +//! print_storage(index - 1); +//! System::set_block_number((index).into()); +//! Timestamp::set_timestamp(System::block_number() * 1000); +//! Session::on_initialize(System::block_number()); +//! }); +//! } +//! } +//! ``` + +pub const _0: &[(&[u8], &[u8])] = &[(&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 2, 165, 193, 177, 154, 183, 160, 79, 83, 108, 81, 154, 202, 73, 131, 172], &[1, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 10, 152, 253, 190, 156, 230, 197, 88, 55, 87, 108, 96, 199, 175, 56, 80], &[15, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 128, 212, 30, 94, 22, 5, 103, 101, 188, 132, 97, 133, 16, 114, 201, 215], &[60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 138, 66, 243, 51, 35, 203, 92, 237, 59, 68, 221, 130, 95, 218, 159, 204], &[69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 164, 71, 4, 181, 104, 210, 22, 103, 53, 106, 90, 5, 12, 17, 135, 70, 129, 228, 122, 25, 230, 178, 155, 10, 101, 185, 89, 23, 98, 206, 81, 67, 237, 48, 208, 38, 30, 93, 36, 163, 32, 23, 82, 80, 107, 32, 241, 92], &[69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 29, 189, 125, 11, 86, 26, 65, 210, 60, 42, 70, 154, 212, 47, 189, 112, 213, 67, 139, 174, 130, 111, 111, 214, 7, 65, 49, 144, 195, 124, 54, 59], &[0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 94, 90, 15, 75, 176, 234, 179, 121, 134, 37, 171, 24, 100, 84, 93, 19, 212, 232, 208, 104, 153, 217, 219, 77, 97, 219, 157, 238, 147, 186, 2, 221], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 100, 74, 81, 252, 33, 158, 145, 69, 184, 87, 123, 183, 118, 40, 118, 123, 28, 47, 115, 116, 142, 218, 139, 120, 139, 252, 102, 161, 181, 42, 32, 248], &[0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 165, 212, 232, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 108, 221, 179, 103, 175, 189, 88, 59, 180, 143, 155, 189, 125, 91, 163, 177, 208, 115, 139, 72, 129, 177, 205, 221, 56, 22, 149, 38, 216, 21, 129, 55], &[0, 0, 0, 0, 0, 0, 0, 0, 44, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 165, 186, 85, 195, 163, 151, 212, 60, 23, 89, 63, 40, 154, 164, 151, 157, 10, 229, 146, 68, 179, 47, 3, 236, 19, 65, 97, 129, 175, 134, 209, 11], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 189, 225, 131, 90, 186, 237, 15, 242, 121, 87, 0, 55, 252, 73, 213, 189, 23, 110, 180, 130, 163, 178, 129, 109, 244, 252, 194, 204, 27, 200, 106, 202], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 213, 92, 123, 109, 126, 139, 228, 10, 88, 51, 198, 4, 8, 188, 78, 184, 171, 234, 78, 93, 168, 211, 37, 233, 8, 135, 156, 195, 59, 151, 205, 153], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 216, 247, 229, 16, 146, 46, 205, 71, 180, 10, 28, 88, 41, 56, 34, 6, 69, 103, 185, 191, 60, 126, 225, 114, 12, 144, 76, 94, 12, 87, 247, 55], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 232, 139, 67, 253, 237, 99, 35, 239, 2, 255, 239, 251, 216, 196, 8, 70, 238, 9, 191, 49, 98, 113, 189, 34, 54, 150, 89, 201, 89, 221, 115, 58], &[0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 233, 103, 96, 210, 116, 101, 58, 57, 180, 41, 168, 126, 186, 174, 157, 58, 164, 253, 245, 139, 144, 150, 207, 11, 235, 199, 196, 229, 164, 194, 237, 141], &[0, 0, 0, 0, 0, 0, 0, 0, 144, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 244, 1, 0, 0, 0, 0, 0, 0, 244, 1, 0, 0, 0, 0, 0, 0]), (&[58, 99, 111, 100, 101], &[]), (&[58, 101, 120, 116, 114, 105, 110, 115, 105, 99, 95, 105, 110, 100, 101, 120], &[0, 0, 0, 0]), (&[58, 104, 101, 97, 112, 112, 97, 103, 101, 115], &[8, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 11, 106, 69, 50, 30, 250, 233, 42, 234, 21, 224, 116, 14, 199, 175, 231], &[0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 14, 160, 236, 172, 118, 69, 125, 15, 155, 57, 185, 129, 221, 16, 112, 18], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 19, 142, 113, 97, 36, 145, 25, 45, 104, 222, 171, 126, 111, 86, 63, 225], &[2, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 40, 220, 203, 85, 155, 149, 196, 1, 104, 161, 178, 105, 101, 129, 181, 167], &[0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[40, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[10, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[30, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[20, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[100, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 94, 90, 15, 75, 176, 234, 179, 121, 134, 37, 171, 24, 100, 84, 93, 19, 212, 232, 208, 104, 153, 217, 219, 77, 97, 219, 157, 238, 147, 186, 2, 221], &[21, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 165, 186, 85, 195, 163, 151, 212, 60, 23, 89, 63, 40, 154, 164, 151, 157, 10, 229, 146, 68, 179, 47, 3, 236, 19, 65, 97, 129, 175, 134, 209, 11], &[31, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 189, 225, 131, 90, 186, 237, 15, 242, 121, 87, 0, 55, 252, 73, 213, 189, 23, 110, 180, 130, 163, 178, 129, 109, 244, 252, 194, 204, 27, 200, 106, 202], &[11, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 213, 92, 123, 109, 126, 139, 228, 10, 88, 51, 198, 4, 8, 188, 78, 184, 171, 234, 78, 93, 168, 211, 37, 233, 8, 135, 156, 195, 59, 151, 205, 153], &[101, 0, 0, 0, 0, 0, 0, 0, 209, 7, 209, 7, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 216, 247, 229, 16, 146, 46, 205, 71, 180, 10, 28, 88, 41, 56, 34, 6, 69, 103, 185, 191, 60, 126, 225, 114, 12, 144, 76, 94, 12, 87, 247, 55], &[41, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 80, 154, 155, 110, 250, 147, 245, 187, 131, 248, 88, 240, 186, 191, 211, 11], &[0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 85, 121, 41, 127, 77, 251, 150, 9, 231, 228, 194, 235, 171, 156, 228, 10], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 86, 239, 98, 39, 206, 203, 47, 7, 39, 76, 176, 87, 45, 143, 164, 194], &[101, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 106, 147, 17, 38, 51, 187, 51, 84, 230, 121, 82, 252, 221, 116, 12, 213], &[31, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 131, 229, 133, 187, 197, 253, 206, 197, 114, 25, 192, 220, 129, 239, 95, 244, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[149, 17, 161, 15, 4, 101, 0, 0, 0, 0, 0, 0, 0, 245, 1]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 131, 229, 133, 187, 197, 253, 206, 197, 114, 25, 192, 220, 129, 239, 95, 244, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[125, 21, 161, 15, 4, 101, 0, 0, 0, 0, 0, 0, 0, 221, 5]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0, 1, 21, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0, 0, 1, 21, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0, 1, 31, 0, 0, 0, 0, 0, 0, 0, 1, 11, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 156, 106, 99, 127, 98, 174, 42, 241, 199, 227, 30, 237, 126, 150, 190, 4, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[8, 11, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 156, 189, 47, 11, 41, 160, 8, 163, 96, 9, 172, 68, 204, 160, 201, 105], &[101, 4, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 180, 154, 39, 56, 238, 179, 8, 150, 170, 203, 139, 63, 180, 100, 113, 189], &[0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 194, 154, 3, 16, 225, 187, 69, 210, 12, 172, 231, 124, 203, 98, 201, 125], &[0, 225, 245, 5]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 234, 7, 222, 43, 143, 1, 5, 22, 220, 163, 247, 239, 82, 247, 172, 90], &[4, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 247, 218, 208, 49, 115, 36, 174, 202, 232, 116, 75, 135, 252, 149, 242, 243], &[0]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 1, 0, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 244, 1, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 87, 200, 117, 228, 207, 247, 65, 72, 228, 98, 143, 38, 75, 151, 76, 128], &[214, 61, 165, 212, 232, 0, 0, 0]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 227, 253, 141, 247, 41, 112, 188, 130, 229, 38, 126, 160, 30, 221, 217, 73], &[1]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 76, 1, 78, 107, 248, 184, 194, 192, 17, 231, 41, 11, 133, 105, 107, 179, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 76, 1, 78, 107, 248, 184, 194, 192, 17, 231, 41, 11, 133, 105, 107, 179, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[21, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 99, 128, 64, 70, 131, 252, 137, 232, 35, 52, 80, 200, 170, 25, 80, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 109, 123, 24, 86, 30, 19, 159, 228, 49, 200, 33, 139, 70, 205, 244, 47, 40, 190, 110, 43, 138, 12, 26, 121, 5, 219, 103, 1, 110, 91, 142, 123], &[11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 99, 128, 64, 70, 131, 252, 137, 232, 35, 52, 80, 200, 170, 25, 80, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 238, 43, 102, 225, 142, 104, 190, 12, 183, 86, 115, 25, 37, 223, 229, 65, 253, 167, 152, 54, 57, 147, 167, 137, 80, 161, 2, 235, 195, 174, 40, 244], &[21, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 17, 218, 109, 31, 118, 29, 223, 155, 219, 76, 157, 110, 83, 3, 235, 212, 31, 97, 133, 141, 10, 86, 71, 161, 167, 191, 224, 137, 191, 146, 27, 233], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 225, 44, 34, 212, 241, 98, 217, 160, 18, 201, 49, 146, 51, 218, 93, 62, 146, 60, 197, 225, 2, 155, 143, 144, 228, 114, 73, 201, 171, 37, 107, 53], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 224, 205, 208, 98, 230, 234, 242, 66, 149, 173, 76, 207, 196, 29, 70, 9], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 255, 58, 225, 39, 112, 190, 162, 228, 141, 155, 222, 115, 133, 231, 162, 95], &[0, 0, 0, 0, 2, 0, 0, 0])]; +pub const _1: &[(&[u8], &[u8])] = &[(&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 2, 165, 193, 177, 154, 183, 160, 79, 83, 108, 81, 154, 202, 73, 131, 172], &[1, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 10, 152, 253, 190, 156, 230, 197, 88, 55, 87, 108, 96, 199, 175, 56, 80], &[16, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 128, 212, 30, 94, 22, 5, 103, 101, 188, 132, 97, 133, 16, 114, 201, 215], &[64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 138, 66, 243, 51, 35, 203, 92, 237, 59, 68, 221, 130, 95, 218, 159, 204], &[69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 164, 71, 4, 181, 104, 210, 22, 103, 53, 106, 90, 5, 12, 17, 135, 70, 129, 228, 122, 25, 230, 178, 155, 10, 101, 185, 89, 23, 98, 206, 81, 67, 237, 48, 208, 38, 30, 93, 36, 163, 32, 23, 82, 80, 107, 32, 241, 92], &[69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 29, 189, 125, 11, 86, 26, 65, 210, 60, 42, 70, 154, 212, 47, 189, 112, 213, 67, 139, 174, 130, 111, 111, 214, 7, 65, 49, 144, 195, 124, 54, 59], &[0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 94, 90, 15, 75, 176, 234, 179, 121, 134, 37, 171, 24, 100, 84, 93, 19, 212, 232, 208, 104, 153, 217, 219, 77, 97, 219, 157, 238, 147, 186, 2, 221], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 100, 74, 81, 252, 33, 158, 145, 69, 184, 87, 123, 183, 118, 40, 118, 123, 28, 47, 115, 116, 142, 218, 139, 120, 139, 252, 102, 161, 181, 42, 32, 248], &[0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 165, 212, 232, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 108, 221, 179, 103, 175, 189, 88, 59, 180, 143, 155, 189, 125, 91, 163, 177, 208, 115, 139, 72, 129, 177, 205, 221, 56, 22, 149, 38, 216, 21, 129, 55], &[0, 0, 0, 0, 0, 0, 0, 0, 44, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 165, 186, 85, 195, 163, 151, 212, 60, 23, 89, 63, 40, 154, 164, 151, 157, 10, 229, 146, 68, 179, 47, 3, 236, 19, 65, 97, 129, 175, 134, 209, 11], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 189, 225, 131, 90, 186, 237, 15, 242, 121, 87, 0, 55, 252, 73, 213, 189, 23, 110, 180, 130, 163, 178, 129, 109, 244, 252, 194, 204, 27, 200, 106, 202], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 213, 92, 123, 109, 126, 139, 228, 10, 88, 51, 198, 4, 8, 188, 78, 184, 171, 234, 78, 93, 168, 211, 37, 233, 8, 135, 156, 195, 59, 151, 205, 153], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 216, 247, 229, 16, 146, 46, 205, 71, 180, 10, 28, 88, 41, 56, 34, 6, 69, 103, 185, 191, 60, 126, 225, 114, 12, 144, 76, 94, 12, 87, 247, 55], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 232, 139, 67, 253, 237, 99, 35, 239, 2, 255, 239, 251, 216, 196, 8, 70, 238, 9, 191, 49, 98, 113, 189, 34, 54, 150, 89, 201, 89, 221, 115, 58], &[0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 233, 103, 96, 210, 116, 101, 58, 57, 180, 41, 168, 126, 186, 174, 157, 58, 164, 253, 245, 139, 144, 150, 207, 11, 235, 199, 196, 229, 164, 194, 237, 141], &[0, 0, 0, 0, 0, 0, 0, 0, 144, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 244, 1, 0, 0, 0, 0, 0, 0, 244, 1, 0, 0, 0, 0, 0, 0]), (&[58, 99, 111, 100, 101], &[]), (&[58, 101, 120, 116, 114, 105, 110, 115, 105, 99, 95, 105, 110, 100, 101, 120], &[0, 0, 0, 0]), (&[58, 104, 101, 97, 112, 112, 97, 103, 101, 115], &[8, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 11, 106, 69, 50, 30, 250, 233, 42, 234, 21, 224, 116, 14, 199, 175, 231], &[0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 14, 160, 236, 172, 118, 69, 125, 15, 155, 57, 185, 129, 221, 16, 112, 18], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 19, 142, 113, 97, 36, 145, 25, 45, 104, 222, 171, 126, 111, 86, 63, 225], &[2, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 40, 220, 203, 85, 155, 149, 196, 1, 104, 161, 178, 105, 101, 129, 181, 167], &[0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[40, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[10, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[30, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[20, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[100, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 94, 90, 15, 75, 176, 234, 179, 121, 134, 37, 171, 24, 100, 84, 93, 19, 212, 232, 208, 104, 153, 217, 219, 77, 97, 219, 157, 238, 147, 186, 2, 221], &[21, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 165, 186, 85, 195, 163, 151, 212, 60, 23, 89, 63, 40, 154, 164, 151, 157, 10, 229, 146, 68, 179, 47, 3, 236, 19, 65, 97, 129, 175, 134, 209, 11], &[31, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 189, 225, 131, 90, 186, 237, 15, 242, 121, 87, 0, 55, 252, 73, 213, 189, 23, 110, 180, 130, 163, 178, 129, 109, 244, 252, 194, 204, 27, 200, 106, 202], &[11, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 213, 92, 123, 109, 126, 139, 228, 10, 88, 51, 198, 4, 8, 188, 78, 184, 171, 234, 78, 93, 168, 211, 37, 233, 8, 135, 156, 195, 59, 151, 205, 153], &[101, 0, 0, 0, 0, 0, 0, 0, 209, 7, 209, 7, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 216, 247, 229, 16, 146, 46, 205, 71, 180, 10, 28, 88, 41, 56, 34, 6, 69, 103, 185, 191, 60, 126, 225, 114, 12, 144, 76, 94, 12, 87, 247, 55], &[41, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 80, 154, 155, 110, 250, 147, 245, 187, 131, 248, 88, 240, 186, 191, 211, 11], &[0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 85, 121, 41, 127, 77, 251, 150, 9, 231, 228, 194, 235, 171, 156, 228, 10], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 86, 239, 98, 39, 206, 203, 47, 7, 39, 76, 176, 87, 45, 143, 164, 194], &[101, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 106, 147, 17, 38, 51, 187, 51, 84, 230, 121, 82, 252, 221, 116, 12, 213], &[31, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 131, 229, 133, 187, 197, 253, 206, 197, 114, 25, 192, 220, 129, 239, 95, 244, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[149, 17, 161, 15, 4, 101, 0, 0, 0, 0, 0, 0, 0, 245, 1]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 131, 229, 133, 187, 197, 253, 206, 197, 114, 25, 192, 220, 129, 239, 95, 244, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[125, 21, 161, 15, 4, 101, 0, 0, 0, 0, 0, 0, 0, 221, 5]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0, 1, 21, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0, 0, 1, 21, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0, 1, 31, 0, 0, 0, 0, 0, 0, 0, 1, 11, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 156, 106, 99, 127, 98, 174, 42, 241, 199, 227, 30, 237, 126, 150, 190, 4, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[8, 11, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 156, 189, 47, 11, 41, 160, 8, 163, 96, 9, 172, 68, 204, 160, 201, 105], &[101, 4, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 180, 154, 39, 56, 238, 179, 8, 150, 170, 203, 139, 63, 180, 100, 113, 189], &[0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 194, 154, 3, 16, 225, 187, 69, 210, 12, 172, 231, 124, 203, 98, 201, 125], &[0, 225, 245, 5]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 234, 7, 222, 43, 143, 1, 5, 22, 220, 163, 247, 239, 82, 247, 172, 90], &[4, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 247, 218, 208, 49, 115, 36, 174, 202, 232, 116, 75, 135, 252, 149, 242, 243], &[0]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 1, 0, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 244, 1, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 87, 200, 117, 228, 207, 247, 65, 72, 228, 98, 143, 38, 75, 151, 76, 128], &[214, 61, 165, 212, 232, 0, 0, 0]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 227, 253, 141, 247, 41, 112, 188, 130, 229, 38, 126, 160, 30, 221, 217, 73], &[1]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 76, 1, 78, 107, 248, 184, 194, 192, 17, 231, 41, 11, 133, 105, 107, 179, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 76, 1, 78, 107, 248, 184, 194, 192, 17, 231, 41, 11, 133, 105, 107, 179, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[21, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 99, 128, 64, 70, 131, 252, 137, 232, 35, 52, 80, 200, 170, 25, 80, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 109, 123, 24, 86, 30, 19, 159, 228, 49, 200, 33, 139, 70, 205, 244, 47, 40, 190, 110, 43, 138, 12, 26, 121, 5, 219, 103, 1, 110, 91, 142, 123], &[11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 99, 128, 64, 70, 131, 252, 137, 232, 35, 52, 80, 200, 170, 25, 80, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 238, 43, 102, 225, 142, 104, 190, 12, 183, 86, 115, 25, 37, 223, 229, 65, 253, 167, 152, 54, 57, 147, 167, 137, 80, 161, 2, 235, 195, 174, 40, 244], &[21, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 118, 56, 0, 163, 106, 153, 253, 252, 124, 16, 246, 65, 95, 110, 230], &[1, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 148, 80, 191, 164, 185, 106, 63, 167, 163, 200, 244, 13, 166, 191, 50, 225], &[0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 17, 218, 109, 31, 118, 29, 223, 155, 219, 76, 157, 110, 83, 3, 235, 212, 31, 97, 133, 141, 10, 86, 71, 161, 167, 191, 224, 137, 191, 146, 27, 233], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 123, 10, 161, 115, 94, 91, 165, 141, 50, 54, 49, 108, 103, 31, 228, 240, 14, 211, 102, 238, 114, 65, 124, 158, 208, 42, 83, 168, 1, 158, 133, 184], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 225, 44, 34, 212, 241, 98, 217, 160, 18, 201, 49, 146, 51, 218, 93, 62, 146, 60, 197, 225, 2, 155, 143, 144, 228, 114, 73, 201, 171, 37, 107, 53], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 224, 205, 208, 98, 230, 234, 242, 66, 149, 173, 76, 207, 196, 29, 70, 9], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 255, 58, 225, 39, 112, 190, 162, 228, 141, 155, 222, 115, 133, 231, 162, 95], &[0, 0, 0, 0, 3, 0, 0, 0]), (&[240, 195, 101, 195, 207, 89, 214, 113, 235, 114, 218, 14, 122, 65, 19, 196, 159, 31, 5, 21, 244, 98, 205, 207, 132, 224, 241, 214, 4, 93, 252, 187], &[232, 3, 0, 0, 0, 0, 0, 0])]; +pub const _2: &[(&[u8], &[u8])] = &[(&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 2, 165, 193, 177, 154, 183, 160, 79, 83, 108, 81, 154, 202, 73, 131, 172], &[2, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 10, 152, 253, 190, 156, 230, 197, 88, 55, 87, 108, 96, 199, 175, 56, 80], &[17, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 128, 212, 30, 94, 22, 5, 103, 101, 188, 132, 97, 133, 16, 114, 201, 215], &[68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 138, 66, 243, 51, 35, 203, 92, 237, 59, 68, 221, 130, 95, 218, 159, 204], &[69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 164, 71, 4, 181, 104, 210, 22, 103, 53, 106, 90, 5, 12, 17, 135, 70, 129, 228, 122, 25, 230, 178, 155, 10, 101, 185, 89, 23, 98, 206, 81, 67, 237, 48, 208, 38, 30, 93, 36, 163, 32, 23, 82, 80, 107, 32, 241, 92], &[69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 29, 189, 125, 11, 86, 26, 65, 210, 60, 42, 70, 154, 212, 47, 189, 112, 213, 67, 139, 174, 130, 111, 111, 214, 7, 65, 49, 144, 195, 124, 54, 59], &[0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 94, 90, 15, 75, 176, 234, 179, 121, 134, 37, 171, 24, 100, 84, 93, 19, 212, 232, 208, 104, 153, 217, 219, 77, 97, 219, 157, 238, 147, 186, 2, 221], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 100, 74, 81, 252, 33, 158, 145, 69, 184, 87, 123, 183, 118, 40, 118, 123, 28, 47, 115, 116, 142, 218, 139, 120, 139, 252, 102, 161, 181, 42, 32, 248], &[0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 165, 212, 232, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 108, 221, 179, 103, 175, 189, 88, 59, 180, 143, 155, 189, 125, 91, 163, 177, 208, 115, 139, 72, 129, 177, 205, 221, 56, 22, 149, 38, 216, 21, 129, 55], &[0, 0, 0, 0, 0, 0, 0, 0, 44, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 165, 186, 85, 195, 163, 151, 212, 60, 23, 89, 63, 40, 154, 164, 151, 157, 10, 229, 146, 68, 179, 47, 3, 236, 19, 65, 97, 129, 175, 134, 209, 11], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 189, 225, 131, 90, 186, 237, 15, 242, 121, 87, 0, 55, 252, 73, 213, 189, 23, 110, 180, 130, 163, 178, 129, 109, 244, 252, 194, 204, 27, 200, 106, 202], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 213, 92, 123, 109, 126, 139, 228, 10, 88, 51, 198, 4, 8, 188, 78, 184, 171, 234, 78, 93, 168, 211, 37, 233, 8, 135, 156, 195, 59, 151, 205, 153], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 216, 247, 229, 16, 146, 46, 205, 71, 180, 10, 28, 88, 41, 56, 34, 6, 69, 103, 185, 191, 60, 126, 225, 114, 12, 144, 76, 94, 12, 87, 247, 55], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 232, 139, 67, 253, 237, 99, 35, 239, 2, 255, 239, 251, 216, 196, 8, 70, 238, 9, 191, 49, 98, 113, 189, 34, 54, 150, 89, 201, 89, 221, 115, 58], &[0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 233, 103, 96, 210, 116, 101, 58, 57, 180, 41, 168, 126, 186, 174, 157, 58, 164, 253, 245, 139, 144, 150, 207, 11, 235, 199, 196, 229, 164, 194, 237, 141], &[0, 0, 0, 0, 0, 0, 0, 0, 144, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 244, 1, 0, 0, 0, 0, 0, 0, 244, 1, 0, 0, 0, 0, 0, 0]), (&[58, 99, 111, 100, 101], &[]), (&[58, 101, 120, 116, 114, 105, 110, 115, 105, 99, 95, 105, 110, 100, 101, 120], &[0, 0, 0, 0]), (&[58, 104, 101, 97, 112, 112, 97, 103, 101, 115], &[8, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 11, 106, 69, 50, 30, 250, 233, 42, 234, 21, 224, 116, 14, 199, 175, 231], &[0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 14, 160, 236, 172, 118, 69, 125, 15, 155, 57, 185, 129, 221, 16, 112, 18], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 19, 142, 113, 97, 36, 145, 25, 45, 104, 222, 171, 126, 111, 86, 63, 225], &[2, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 40, 220, 203, 85, 155, 149, 196, 1, 104, 161, 178, 105, 101, 129, 181, 167], &[0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[40, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[10, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[30, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[20, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[100, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 94, 90, 15, 75, 176, 234, 179, 121, 134, 37, 171, 24, 100, 84, 93, 19, 212, 232, 208, 104, 153, 217, 219, 77, 97, 219, 157, 238, 147, 186, 2, 221], &[21, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 165, 186, 85, 195, 163, 151, 212, 60, 23, 89, 63, 40, 154, 164, 151, 157, 10, 229, 146, 68, 179, 47, 3, 236, 19, 65, 97, 129, 175, 134, 209, 11], &[31, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 189, 225, 131, 90, 186, 237, 15, 242, 121, 87, 0, 55, 252, 73, 213, 189, 23, 110, 180, 130, 163, 178, 129, 109, 244, 252, 194, 204, 27, 200, 106, 202], &[11, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 213, 92, 123, 109, 126, 139, 228, 10, 88, 51, 198, 4, 8, 188, 78, 184, 171, 234, 78, 93, 168, 211, 37, 233, 8, 135, 156, 195, 59, 151, 205, 153], &[101, 0, 0, 0, 0, 0, 0, 0, 209, 7, 209, 7, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 216, 247, 229, 16, 146, 46, 205, 71, 180, 10, 28, 88, 41, 56, 34, 6, 69, 103, 185, 191, 60, 126, 225, 114, 12, 144, 76, 94, 12, 87, 247, 55], &[41, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 80, 154, 155, 110, 250, 147, 245, 187, 131, 248, 88, 240, 186, 191, 211, 11], &[0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 85, 121, 41, 127, 77, 251, 150, 9, 231, 228, 194, 235, 171, 156, 228, 10], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 86, 239, 98, 39, 206, 203, 47, 7, 39, 76, 176, 87, 45, 143, 164, 194], &[101, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 106, 147, 17, 38, 51, 187, 51, 84, 230, 121, 82, 252, 221, 116, 12, 213], &[31, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 131, 229, 133, 187, 197, 253, 206, 197, 114, 25, 192, 220, 129, 239, 95, 244, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[149, 17, 161, 15, 4, 101, 0, 0, 0, 0, 0, 0, 0, 245, 1]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 131, 229, 133, 187, 197, 253, 206, 197, 114, 25, 192, 220, 129, 239, 95, 244, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[125, 21, 161, 15, 4, 101, 0, 0, 0, 0, 0, 0, 0, 221, 5]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0, 1, 21, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0, 0, 1, 21, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0, 1, 31, 0, 0, 0, 0, 0, 0, 0, 1, 11, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 156, 106, 99, 127, 98, 174, 42, 241, 199, 227, 30, 237, 126, 150, 190, 4, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[8, 11, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 156, 189, 47, 11, 41, 160, 8, 163, 96, 9, 172, 68, 204, 160, 201, 105], &[101, 4, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 180, 154, 39, 56, 238, 179, 8, 150, 170, 203, 139, 63, 180, 100, 113, 189], &[0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 194, 154, 3, 16, 225, 187, 69, 210, 12, 172, 231, 124, 203, 98, 201, 125], &[0, 225, 245, 5]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 234, 7, 222, 43, 143, 1, 5, 22, 220, 163, 247, 239, 82, 247, 172, 90], &[4, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 247, 218, 208, 49, 115, 36, 174, 202, 232, 116, 75, 135, 252, 149, 242, 243], &[0]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 1, 0, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 244, 1, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 87, 200, 117, 228, 207, 247, 65, 72, 228, 98, 143, 38, 75, 151, 76, 128], &[214, 61, 165, 212, 232, 0, 0, 0]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 227, 253, 141, 247, 41, 112, 188, 130, 229, 38, 126, 160, 30, 221, 217, 73], &[1]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 76, 1, 78, 107, 248, 184, 194, 192, 17, 231, 41, 11, 133, 105, 107, 179, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 76, 1, 78, 107, 248, 184, 194, 192, 17, 231, 41, 11, 133, 105, 107, 179, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[21, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 99, 128, 64, 70, 131, 252, 137, 232, 35, 52, 80, 200, 170, 25, 80, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 109, 123, 24, 86, 30, 19, 159, 228, 49, 200, 33, 139, 70, 205, 244, 47, 40, 190, 110, 43, 138, 12, 26, 121, 5, 219, 103, 1, 110, 91, 142, 123], &[11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 99, 128, 64, 70, 131, 252, 137, 232, 35, 52, 80, 200, 170, 25, 80, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 238, 43, 102, 225, 142, 104, 190, 12, 183, 86, 115, 25, 37, 223, 229, 65, 253, 167, 152, 54, 57, 147, 167, 137, 80, 161, 2, 235, 195, 174, 40, 244], &[21, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 118, 56, 0, 163, 106, 153, 253, 252, 124, 16, 246, 65, 95, 110, 230], &[2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 148, 80, 191, 164, 185, 106, 63, 167, 163, 200, 244, 13, 166, 191, 50, 225], &[0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 17, 218, 109, 31, 118, 29, 223, 155, 219, 76, 157, 110, 83, 3, 235, 212, 31, 97, 133, 141, 10, 86, 71, 161, 167, 191, 224, 137, 191, 146, 27, 233], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 123, 10, 161, 115, 94, 91, 165, 141, 50, 54, 49, 108, 103, 31, 228, 240, 14, 211, 102, 238, 114, 65, 124, 158, 208, 42, 83, 168, 1, 158, 133, 184], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 140, 3, 159, 247, 202, 161, 124, 206, 191, 202, 220, 68, 189, 159, 206, 106, 75, 102, 153, 196, 208, 61, 226, 227, 52, 154, 161, 220, 17, 25, 60, 215], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 225, 44, 34, 212, 241, 98, 217, 160, 18, 201, 49, 146, 51, 218, 93, 62, 146, 60, 197, 225, 2, 155, 143, 144, 228, 114, 73, 201, 171, 37, 107, 53], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 224, 205, 208, 98, 230, 234, 242, 66, 149, 173, 76, 207, 196, 29, 70, 9], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 255, 58, 225, 39, 112, 190, 162, 228, 141, 155, 222, 115, 133, 231, 162, 95], &[0, 0, 0, 0, 4, 0, 0, 0]), (&[240, 195, 101, 195, 207, 89, 214, 113, 235, 114, 218, 14, 122, 65, 19, 196, 159, 31, 5, 21, 244, 98, 205, 207, 132, 224, 241, 214, 4, 93, 252, 187], &[208, 7, 0, 0, 0, 0, 0, 0])]; +pub const _3: &[(&[u8], &[u8])] = &[(&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 2, 165, 193, 177, 154, 183, 160, 79, 83, 108, 81, 154, 202, 73, 131, 172], &[3, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 10, 152, 253, 190, 156, 230, 197, 88, 55, 87, 108, 96, 199, 175, 56, 80], &[19, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 128, 212, 30, 94, 22, 5, 103, 101, 188, 132, 97, 133, 16, 114, 201, 215], &[76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 138, 66, 243, 51, 35, 203, 92, 237, 59, 68, 221, 130, 95, 218, 159, 204], &[69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 164, 71, 4, 181, 104, 210, 22, 103, 53, 106, 90, 5, 12, 17, 135, 70, 129, 228, 122, 25, 230, 178, 155, 10, 101, 185, 89, 23, 98, 206, 81, 67, 237, 48, 208, 38, 30, 93, 36, 163, 32, 23, 82, 80, 107, 32, 241, 92], &[69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 29, 189, 125, 11, 86, 26, 65, 210, 60, 42, 70, 154, 212, 47, 189, 112, 213, 67, 139, 174, 130, 111, 111, 214, 7, 65, 49, 144, 195, 124, 54, 59], &[0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 94, 90, 15, 75, 176, 234, 179, 121, 134, 37, 171, 24, 100, 84, 93, 19, 212, 232, 208, 104, 153, 217, 219, 77, 97, 219, 157, 238, 147, 186, 2, 221], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 100, 74, 81, 252, 33, 158, 145, 69, 184, 87, 123, 183, 118, 40, 118, 123, 28, 47, 115, 116, 142, 218, 139, 120, 139, 252, 102, 161, 181, 42, 32, 248], &[0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 165, 212, 232, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 108, 221, 179, 103, 175, 189, 88, 59, 180, 143, 155, 189, 125, 91, 163, 177, 208, 115, 139, 72, 129, 177, 205, 221, 56, 22, 149, 38, 216, 21, 129, 55], &[0, 0, 0, 0, 0, 0, 0, 0, 44, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 165, 186, 85, 195, 163, 151, 212, 60, 23, 89, 63, 40, 154, 164, 151, 157, 10, 229, 146, 68, 179, 47, 3, 236, 19, 65, 97, 129, 175, 134, 209, 11], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 189, 225, 131, 90, 186, 237, 15, 242, 121, 87, 0, 55, 252, 73, 213, 189, 23, 110, 180, 130, 163, 178, 129, 109, 244, 252, 194, 204, 27, 200, 106, 202], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 213, 92, 123, 109, 126, 139, 228, 10, 88, 51, 198, 4, 8, 188, 78, 184, 171, 234, 78, 93, 168, 211, 37, 233, 8, 135, 156, 195, 59, 151, 205, 153], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 216, 247, 229, 16, 146, 46, 205, 71, 180, 10, 28, 88, 41, 56, 34, 6, 69, 103, 185, 191, 60, 126, 225, 114, 12, 144, 76, 94, 12, 87, 247, 55], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 232, 139, 67, 253, 237, 99, 35, 239, 2, 255, 239, 251, 216, 196, 8, 70, 238, 9, 191, 49, 98, 113, 189, 34, 54, 150, 89, 201, 89, 221, 115, 58], &[0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 233, 103, 96, 210, 116, 101, 58, 57, 180, 41, 168, 126, 186, 174, 157, 58, 164, 253, 245, 139, 144, 150, 207, 11, 235, 199, 196, 229, 164, 194, 237, 141], &[0, 0, 0, 0, 0, 0, 0, 0, 144, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 244, 1, 0, 0, 0, 0, 0, 0, 244, 1, 0, 0, 0, 0, 0, 0]), (&[58, 99, 111, 100, 101], &[]), (&[58, 101, 120, 116, 114, 105, 110, 115, 105, 99, 95, 105, 110, 100, 101, 120], &[0, 0, 0, 0]), (&[58, 104, 101, 97, 112, 112, 97, 103, 101, 115], &[8, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 11, 106, 69, 50, 30, 250, 233, 42, 234, 21, 224, 116, 14, 199, 175, 231], &[1, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 14, 160, 236, 172, 118, 69, 125, 15, 155, 57, 185, 129, 221, 16, 112, 18], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 19, 142, 113, 97, 36, 145, 25, 45, 104, 222, 171, 126, 111, 86, 63, 225], &[2, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 40, 220, 203, 85, 155, 149, 196, 1, 104, 161, 178, 105, 101, 129, 181, 167], &[0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[40, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[10, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[30, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[20, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[100, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 94, 90, 15, 75, 176, 234, 179, 121, 134, 37, 171, 24, 100, 84, 93, 19, 212, 232, 208, 104, 153, 217, 219, 77, 97, 219, 157, 238, 147, 186, 2, 221], &[21, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 165, 186, 85, 195, 163, 151, 212, 60, 23, 89, 63, 40, 154, 164, 151, 157, 10, 229, 146, 68, 179, 47, 3, 236, 19, 65, 97, 129, 175, 134, 209, 11], &[31, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 189, 225, 131, 90, 186, 237, 15, 242, 121, 87, 0, 55, 252, 73, 213, 189, 23, 110, 180, 130, 163, 178, 129, 109, 244, 252, 194, 204, 27, 200, 106, 202], &[11, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 213, 92, 123, 109, 126, 139, 228, 10, 88, 51, 198, 4, 8, 188, 78, 184, 171, 234, 78, 93, 168, 211, 37, 233, 8, 135, 156, 195, 59, 151, 205, 153], &[101, 0, 0, 0, 0, 0, 0, 0, 209, 7, 209, 7, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 216, 247, 229, 16, 146, 46, 205, 71, 180, 10, 28, 88, 41, 56, 34, 6, 69, 103, 185, 191, 60, 126, 225, 114, 12, 144, 76, 94, 12, 87, 247, 55], &[41, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 80, 154, 155, 110, 250, 147, 245, 187, 131, 248, 88, 240, 186, 191, 211, 11], &[3, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 85, 121, 41, 127, 77, 251, 150, 9, 231, 228, 194, 235, 171, 156, 228, 10], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 86, 239, 98, 39, 206, 203, 47, 7, 39, 76, 176, 87, 45, 143, 164, 194], &[101, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 106, 147, 17, 38, 51, 187, 51, 84, 230, 121, 82, 252, 221, 116, 12, 213], &[31, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 131, 229, 133, 187, 197, 253, 206, 197, 114, 25, 192, 220, 129, 239, 95, 244, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[149, 17, 161, 15, 4, 101, 0, 0, 0, 0, 0, 0, 0, 245, 1]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 131, 229, 133, 187, 197, 253, 206, 197, 114, 25, 192, 220, 129, 239, 95, 244, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[125, 21, 161, 15, 4, 101, 0, 0, 0, 0, 0, 0, 0, 221, 5]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0, 1, 21, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0, 0, 1, 21, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0, 1, 31, 0, 0, 0, 0, 0, 0, 0, 1, 11, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 156, 106, 99, 127, 98, 174, 42, 241, 199, 227, 30, 237, 126, 150, 190, 4, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[8, 11, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 156, 189, 47, 11, 41, 160, 8, 163, 96, 9, 172, 68, 204, 160, 201, 105], &[101, 4, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 166, 97, 104, 247, 231, 37, 155, 102, 112, 160, 111, 37, 101, 227, 229, 242], &[184, 11, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 180, 154, 39, 56, 238, 179, 8, 150, 170, 203, 139, 63, 180, 100, 113, 189], &[0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 194, 154, 3, 16, 225, 187, 69, 210, 12, 172, 231, 124, 203, 98, 201, 125], &[0, 225, 245, 5]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 234, 7, 222, 43, 143, 1, 5, 22, 220, 163, 247, 239, 82, 247, 172, 90], &[8, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 247, 218, 208, 49, 115, 36, 174, 202, 232, 116, 75, 135, 252, 149, 242, 243], &[0]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 1, 0, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 244, 1, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 87, 200, 117, 228, 207, 247, 65, 72, 228, 98, 143, 38, 75, 151, 76, 128], &[214, 61, 165, 212, 232, 0, 0, 0]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 227, 253, 141, 247, 41, 112, 188, 130, 229, 38, 126, 160, 30, 221, 217, 73], &[1]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 76, 1, 78, 107, 248, 184, 194, 192, 17, 231, 41, 11, 133, 105, 107, 179, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 76, 1, 78, 107, 248, 184, 194, 192, 17, 231, 41, 11, 133, 105, 107, 179, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[21, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 99, 128, 64, 70, 131, 252, 137, 232, 35, 52, 80, 200, 170, 25, 80, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 109, 123, 24, 86, 30, 19, 159, 228, 49, 200, 33, 139, 70, 205, 244, 47, 40, 190, 110, 43, 138, 12, 26, 121, 5, 219, 103, 1, 110, 91, 142, 123], &[11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 99, 128, 64, 70, 131, 252, 137, 232, 35, 52, 80, 200, 170, 25, 80, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 238, 43, 102, 225, 142, 104, 190, 12, 183, 86, 115, 25, 37, 223, 229, 65, 253, 167, 152, 54, 57, 147, 167, 137, 80, 161, 2, 235, 195, 174, 40, 244], &[21, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 118, 56, 0, 163, 106, 153, 253, 252, 124, 16, 246, 65, 95, 110, 230], &[3, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 148, 80, 191, 164, 185, 106, 63, 167, 163, 200, 244, 13, 166, 191, 50, 225], &[1]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 17, 218, 109, 31, 118, 29, 223, 155, 219, 76, 157, 110, 83, 3, 235, 212, 31, 97, 133, 141, 10, 86, 71, 161, 167, 191, 224, 137, 191, 146, 27, 233], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 38, 160, 142, 77, 12, 81, 144, 240, 24, 113, 224, 86, 155, 98, 144, 184, 103, 96, 8, 93, 153, 241, 126, 180, 231, 230, 181, 143, 235, 141, 98, 73], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 123, 10, 161, 115, 94, 91, 165, 141, 50, 54, 49, 108, 103, 31, 228, 240, 14, 211, 102, 238, 114, 65, 124, 158, 208, 42, 83, 168, 1, 158, 133, 184], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 140, 3, 159, 247, 202, 161, 124, 206, 191, 202, 220, 68, 189, 159, 206, 106, 75, 102, 153, 196, 208, 61, 226, 227, 52, 154, 161, 220, 17, 25, 60, 215], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 225, 44, 34, 212, 241, 98, 217, 160, 18, 201, 49, 146, 51, 218, 93, 62, 146, 60, 197, 225, 2, 155, 143, 144, 228, 114, 73, 201, 171, 37, 107, 53], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 224, 205, 208, 98, 230, 234, 242, 66, 149, 173, 76, 207, 196, 29, 70, 9], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 255, 58, 225, 39, 112, 190, 162, 228, 141, 155, 222, 115, 133, 231, 162, 95], &[0, 0, 0, 0, 5, 0, 0, 0]), (&[240, 195, 101, 195, 207, 89, 214, 113, 235, 114, 218, 14, 122, 65, 19, 196, 159, 31, 5, 21, 244, 98, 205, 207, 132, 224, 241, 214, 4, 93, 252, 187], &[184, 11, 0, 0, 0, 0, 0, 0])]; +pub const _4: &[(&[u8], &[u8])] = &[(&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 2, 165, 193, 177, 154, 183, 160, 79, 83, 108, 81, 154, 202, 73, 131, 172], &[4, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 10, 152, 253, 190, 156, 230, 197, 88, 55, 87, 108, 96, 199, 175, 56, 80], &[20, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 128, 212, 30, 94, 22, 5, 103, 101, 188, 132, 97, 133, 16, 114, 201, 215], &[80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 138, 66, 243, 51, 35, 203, 92, 237, 59, 68, 221, 130, 95, 218, 159, 204], &[69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 164, 71, 4, 181, 104, 210, 22, 103, 53, 106, 90, 5, 12, 17, 135, 70, 129, 228, 122, 25, 230, 178, 155, 10, 101, 185, 89, 23, 98, 206, 81, 67, 237, 48, 208, 38, 30, 93, 36, 163, 32, 23, 82, 80, 107, 32, 241, 92], &[69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 29, 189, 125, 11, 86, 26, 65, 210, 60, 42, 70, 154, 212, 47, 189, 112, 213, 67, 139, 174, 130, 111, 111, 214, 7, 65, 49, 144, 195, 124, 54, 59], &[0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 94, 90, 15, 75, 176, 234, 179, 121, 134, 37, 171, 24, 100, 84, 93, 19, 212, 232, 208, 104, 153, 217, 219, 77, 97, 219, 157, 238, 147, 186, 2, 221], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 100, 74, 81, 252, 33, 158, 145, 69, 184, 87, 123, 183, 118, 40, 118, 123, 28, 47, 115, 116, 142, 218, 139, 120, 139, 252, 102, 161, 181, 42, 32, 248], &[0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 165, 212, 232, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 108, 221, 179, 103, 175, 189, 88, 59, 180, 143, 155, 189, 125, 91, 163, 177, 208, 115, 139, 72, 129, 177, 205, 221, 56, 22, 149, 38, 216, 21, 129, 55], &[0, 0, 0, 0, 0, 0, 0, 0, 44, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 165, 186, 85, 195, 163, 151, 212, 60, 23, 89, 63, 40, 154, 164, 151, 157, 10, 229, 146, 68, 179, 47, 3, 236, 19, 65, 97, 129, 175, 134, 209, 11], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 189, 225, 131, 90, 186, 237, 15, 242, 121, 87, 0, 55, 252, 73, 213, 189, 23, 110, 180, 130, 163, 178, 129, 109, 244, 252, 194, 204, 27, 200, 106, 202], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 213, 92, 123, 109, 126, 139, 228, 10, 88, 51, 198, 4, 8, 188, 78, 184, 171, 234, 78, 93, 168, 211, 37, 233, 8, 135, 156, 195, 59, 151, 205, 153], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 216, 247, 229, 16, 146, 46, 205, 71, 180, 10, 28, 88, 41, 56, 34, 6, 69, 103, 185, 191, 60, 126, 225, 114, 12, 144, 76, 94, 12, 87, 247, 55], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 232, 139, 67, 253, 237, 99, 35, 239, 2, 255, 239, 251, 216, 196, 8, 70, 238, 9, 191, 49, 98, 113, 189, 34, 54, 150, 89, 201, 89, 221, 115, 58], &[0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 233, 103, 96, 210, 116, 101, 58, 57, 180, 41, 168, 126, 186, 174, 157, 58, 164, 253, 245, 139, 144, 150, 207, 11, 235, 199, 196, 229, 164, 194, 237, 141], &[0, 0, 0, 0, 0, 0, 0, 0, 144, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 244, 1, 0, 0, 0, 0, 0, 0, 244, 1, 0, 0, 0, 0, 0, 0]), (&[58, 99, 111, 100, 101], &[]), (&[58, 101, 120, 116, 114, 105, 110, 115, 105, 99, 95, 105, 110, 100, 101, 120], &[0, 0, 0, 0]), (&[58, 104, 101, 97, 112, 112, 97, 103, 101, 115], &[8, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 11, 106, 69, 50, 30, 250, 233, 42, 234, 21, 224, 116, 14, 199, 175, 231], &[1, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 14, 160, 236, 172, 118, 69, 125, 15, 155, 57, 185, 129, 221, 16, 112, 18], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 19, 142, 113, 97, 36, 145, 25, 45, 104, 222, 171, 126, 111, 86, 63, 225], &[2, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 40, 220, 203, 85, 155, 149, 196, 1, 104, 161, 178, 105, 101, 129, 181, 167], &[0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[40, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[10, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[30, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[20, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[100, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 94, 90, 15, 75, 176, 234, 179, 121, 134, 37, 171, 24, 100, 84, 93, 19, 212, 232, 208, 104, 153, 217, 219, 77, 97, 219, 157, 238, 147, 186, 2, 221], &[21, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 165, 186, 85, 195, 163, 151, 212, 60, 23, 89, 63, 40, 154, 164, 151, 157, 10, 229, 146, 68, 179, 47, 3, 236, 19, 65, 97, 129, 175, 134, 209, 11], &[31, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 189, 225, 131, 90, 186, 237, 15, 242, 121, 87, 0, 55, 252, 73, 213, 189, 23, 110, 180, 130, 163, 178, 129, 109, 244, 252, 194, 204, 27, 200, 106, 202], &[11, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 213, 92, 123, 109, 126, 139, 228, 10, 88, 51, 198, 4, 8, 188, 78, 184, 171, 234, 78, 93, 168, 211, 37, 233, 8, 135, 156, 195, 59, 151, 205, 153], &[101, 0, 0, 0, 0, 0, 0, 0, 209, 7, 209, 7, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 216, 247, 229, 16, 146, 46, 205, 71, 180, 10, 28, 88, 41, 56, 34, 6, 69, 103, 185, 191, 60, 126, 225, 114, 12, 144, 76, 94, 12, 87, 247, 55], &[41, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 80, 154, 155, 110, 250, 147, 245, 187, 131, 248, 88, 240, 186, 191, 211, 11], &[3, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 85, 121, 41, 127, 77, 251, 150, 9, 231, 228, 194, 235, 171, 156, 228, 10], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 86, 239, 98, 39, 206, 203, 47, 7, 39, 76, 176, 87, 45, 143, 164, 194], &[101, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 106, 147, 17, 38, 51, 187, 51, 84, 230, 121, 82, 252, 221, 116, 12, 213], &[31, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 131, 229, 133, 187, 197, 253, 206, 197, 114, 25, 192, 220, 129, 239, 95, 244, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[149, 17, 161, 15, 4, 101, 0, 0, 0, 0, 0, 0, 0, 245, 1]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 131, 229, 133, 187, 197, 253, 206, 197, 114, 25, 192, 220, 129, 239, 95, 244, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[125, 21, 161, 15, 4, 101, 0, 0, 0, 0, 0, 0, 0, 221, 5]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0, 1, 21, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0, 0, 1, 21, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0, 1, 31, 0, 0, 0, 0, 0, 0, 0, 1, 11, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 156, 106, 99, 127, 98, 174, 42, 241, 199, 227, 30, 237, 126, 150, 190, 4, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[8, 11, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 156, 189, 47, 11, 41, 160, 8, 163, 96, 9, 172, 68, 204, 160, 201, 105], &[101, 4, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 166, 97, 104, 247, 231, 37, 155, 102, 112, 160, 111, 37, 101, 227, 229, 242], &[184, 11, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 180, 154, 39, 56, 238, 179, 8, 150, 170, 203, 139, 63, 180, 100, 113, 189], &[0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 194, 154, 3, 16, 225, 187, 69, 210, 12, 172, 231, 124, 203, 98, 201, 125], &[0, 225, 245, 5]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 234, 7, 222, 43, 143, 1, 5, 22, 220, 163, 247, 239, 82, 247, 172, 90], &[8, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 247, 218, 208, 49, 115, 36, 174, 202, 232, 116, 75, 135, 252, 149, 242, 243], &[0]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 1, 0, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 244, 1, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 87, 200, 117, 228, 207, 247, 65, 72, 228, 98, 143, 38, 75, 151, 76, 128], &[214, 61, 165, 212, 232, 0, 0, 0]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 227, 253, 141, 247, 41, 112, 188, 130, 229, 38, 126, 160, 30, 221, 217, 73], &[1]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 76, 1, 78, 107, 248, 184, 194, 192, 17, 231, 41, 11, 133, 105, 107, 179, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 76, 1, 78, 107, 248, 184, 194, 192, 17, 231, 41, 11, 133, 105, 107, 179, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[21, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 99, 128, 64, 70, 131, 252, 137, 232, 35, 52, 80, 200, 170, 25, 80, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 109, 123, 24, 86, 30, 19, 159, 228, 49, 200, 33, 139, 70, 205, 244, 47, 40, 190, 110, 43, 138, 12, 26, 121, 5, 219, 103, 1, 110, 91, 142, 123], &[11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 99, 128, 64, 70, 131, 252, 137, 232, 35, 52, 80, 200, 170, 25, 80, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 238, 43, 102, 225, 142, 104, 190, 12, 183, 86, 115, 25, 37, 223, 229, 65, 253, 167, 152, 54, 57, 147, 167, 137, 80, 161, 2, 235, 195, 174, 40, 244], &[21, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 118, 56, 0, 163, 106, 153, 253, 252, 124, 16, 246, 65, 95, 110, 230], &[4, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 148, 80, 191, 164, 185, 106, 63, 167, 163, 200, 244, 13, 166, 191, 50, 225], &[0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 17, 218, 109, 31, 118, 29, 223, 155, 219, 76, 157, 110, 83, 3, 235, 212, 31, 97, 133, 141, 10, 86, 71, 161, 167, 191, 224, 137, 191, 146, 27, 233], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 38, 160, 142, 77, 12, 81, 144, 240, 24, 113, 224, 86, 155, 98, 144, 184, 103, 96, 8, 93, 153, 241, 126, 180, 231, 230, 181, 143, 235, 141, 98, 73], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 123, 10, 161, 115, 94, 91, 165, 141, 50, 54, 49, 108, 103, 31, 228, 240, 14, 211, 102, 238, 114, 65, 124, 158, 208, 42, 83, 168, 1, 158, 133, 184], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 140, 3, 159, 247, 202, 161, 124, 206, 191, 202, 220, 68, 189, 159, 206, 106, 75, 102, 153, 196, 208, 61, 226, 227, 52, 154, 161, 220, 17, 25, 60, 215], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 140, 53, 210, 47, 69, 157, 119, 202, 76, 11, 11, 80, 53, 134, 151, 102, 214, 13, 24, 43, 151, 22, 171, 62, 136, 121, 224, 102, 71, 136, 153, 168], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 225, 44, 34, 212, 241, 98, 217, 160, 18, 201, 49, 146, 51, 218, 93, 62, 146, 60, 197, 225, 2, 155, 143, 144, 228, 114, 73, 201, 171, 37, 107, 53], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 224, 205, 208, 98, 230, 234, 242, 66, 149, 173, 76, 207, 196, 29, 70, 9], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 255, 58, 225, 39, 112, 190, 162, 228, 141, 155, 222, 115, 133, 231, 162, 95], &[0, 0, 0, 0, 6, 0, 0, 0]), (&[240, 195, 101, 195, 207, 89, 214, 113, 235, 114, 218, 14, 122, 65, 19, 196, 159, 31, 5, 21, 244, 98, 205, 207, 132, 224, 241, 214, 4, 93, 252, 187], &[160, 15, 0, 0, 0, 0, 0, 0])]; +pub const _5: &[(&[u8], &[u8])] = &[(&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 2, 165, 193, 177, 154, 183, 160, 79, 83, 108, 81, 154, 202, 73, 131, 172], &[5, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 10, 152, 253, 190, 156, 230, 197, 88, 55, 87, 108, 96, 199, 175, 56, 80], &[21, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 128, 212, 30, 94, 22, 5, 103, 101, 188, 132, 97, 133, 16, 114, 201, 215], &[84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 138, 66, 243, 51, 35, 203, 92, 237, 59, 68, 221, 130, 95, 218, 159, 204], &[69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 164, 71, 4, 181, 104, 210, 22, 103, 53, 106, 90, 5, 12, 17, 135, 70, 129, 228, 122, 25, 230, 178, 155, 10, 101, 185, 89, 23, 98, 206, 81, 67, 237, 48, 208, 38, 30, 93, 36, 163, 32, 23, 82, 80, 107, 32, 241, 92], &[69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 29, 189, 125, 11, 86, 26, 65, 210, 60, 42, 70, 154, 212, 47, 189, 112, 213, 67, 139, 174, 130, 111, 111, 214, 7, 65, 49, 144, 195, 124, 54, 59], &[0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 94, 90, 15, 75, 176, 234, 179, 121, 134, 37, 171, 24, 100, 84, 93, 19, 212, 232, 208, 104, 153, 217, 219, 77, 97, 219, 157, 238, 147, 186, 2, 221], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 100, 74, 81, 252, 33, 158, 145, 69, 184, 87, 123, 183, 118, 40, 118, 123, 28, 47, 115, 116, 142, 218, 139, 120, 139, 252, 102, 161, 181, 42, 32, 248], &[0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 165, 212, 232, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 108, 221, 179, 103, 175, 189, 88, 59, 180, 143, 155, 189, 125, 91, 163, 177, 208, 115, 139, 72, 129, 177, 205, 221, 56, 22, 149, 38, 216, 21, 129, 55], &[0, 0, 0, 0, 0, 0, 0, 0, 44, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 165, 186, 85, 195, 163, 151, 212, 60, 23, 89, 63, 40, 154, 164, 151, 157, 10, 229, 146, 68, 179, 47, 3, 236, 19, 65, 97, 129, 175, 134, 209, 11], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 189, 225, 131, 90, 186, 237, 15, 242, 121, 87, 0, 55, 252, 73, 213, 189, 23, 110, 180, 130, 163, 178, 129, 109, 244, 252, 194, 204, 27, 200, 106, 202], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 213, 92, 123, 109, 126, 139, 228, 10, 88, 51, 198, 4, 8, 188, 78, 184, 171, 234, 78, 93, 168, 211, 37, 233, 8, 135, 156, 195, 59, 151, 205, 153], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 216, 247, 229, 16, 146, 46, 205, 71, 180, 10, 28, 88, 41, 56, 34, 6, 69, 103, 185, 191, 60, 126, 225, 114, 12, 144, 76, 94, 12, 87, 247, 55], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 232, 139, 67, 253, 237, 99, 35, 239, 2, 255, 239, 251, 216, 196, 8, 70, 238, 9, 191, 49, 98, 113, 189, 34, 54, 150, 89, 201, 89, 221, 115, 58], &[0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 233, 103, 96, 210, 116, 101, 58, 57, 180, 41, 168, 126, 186, 174, 157, 58, 164, 253, 245, 139, 144, 150, 207, 11, 235, 199, 196, 229, 164, 194, 237, 141], &[0, 0, 0, 0, 0, 0, 0, 0, 144, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 244, 1, 0, 0, 0, 0, 0, 0, 244, 1, 0, 0, 0, 0, 0, 0]), (&[58, 99, 111, 100, 101], &[]), (&[58, 101, 120, 116, 114, 105, 110, 115, 105, 99, 95, 105, 110, 100, 101, 120], &[0, 0, 0, 0]), (&[58, 104, 101, 97, 112, 112, 97, 103, 101, 115], &[8, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 11, 106, 69, 50, 30, 250, 233, 42, 234, 21, 224, 116, 14, 199, 175, 231], &[1, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 14, 160, 236, 172, 118, 69, 125, 15, 155, 57, 185, 129, 221, 16, 112, 18], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 19, 142, 113, 97, 36, 145, 25, 45, 104, 222, 171, 126, 111, 86, 63, 225], &[2, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 40, 220, 203, 85, 155, 149, 196, 1, 104, 161, 178, 105, 101, 129, 181, 167], &[0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[40, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[10, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[30, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[20, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[100, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 94, 90, 15, 75, 176, 234, 179, 121, 134, 37, 171, 24, 100, 84, 93, 19, 212, 232, 208, 104, 153, 217, 219, 77, 97, 219, 157, 238, 147, 186, 2, 221], &[21, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 165, 186, 85, 195, 163, 151, 212, 60, 23, 89, 63, 40, 154, 164, 151, 157, 10, 229, 146, 68, 179, 47, 3, 236, 19, 65, 97, 129, 175, 134, 209, 11], &[31, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 189, 225, 131, 90, 186, 237, 15, 242, 121, 87, 0, 55, 252, 73, 213, 189, 23, 110, 180, 130, 163, 178, 129, 109, 244, 252, 194, 204, 27, 200, 106, 202], &[11, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 213, 92, 123, 109, 126, 139, 228, 10, 88, 51, 198, 4, 8, 188, 78, 184, 171, 234, 78, 93, 168, 211, 37, 233, 8, 135, 156, 195, 59, 151, 205, 153], &[101, 0, 0, 0, 0, 0, 0, 0, 209, 7, 209, 7, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 216, 247, 229, 16, 146, 46, 205, 71, 180, 10, 28, 88, 41, 56, 34, 6, 69, 103, 185, 191, 60, 126, 225, 114, 12, 144, 76, 94, 12, 87, 247, 55], &[41, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 80, 154, 155, 110, 250, 147, 245, 187, 131, 248, 88, 240, 186, 191, 211, 11], &[3, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 85, 121, 41, 127, 77, 251, 150, 9, 231, 228, 194, 235, 171, 156, 228, 10], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 86, 239, 98, 39, 206, 203, 47, 7, 39, 76, 176, 87, 45, 143, 164, 194], &[101, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 106, 147, 17, 38, 51, 187, 51, 84, 230, 121, 82, 252, 221, 116, 12, 213], &[31, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 131, 229, 133, 187, 197, 253, 206, 197, 114, 25, 192, 220, 129, 239, 95, 244, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[149, 17, 161, 15, 4, 101, 0, 0, 0, 0, 0, 0, 0, 245, 1]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 131, 229, 133, 187, 197, 253, 206, 197, 114, 25, 192, 220, 129, 239, 95, 244, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[125, 21, 161, 15, 4, 101, 0, 0, 0, 0, 0, 0, 0, 221, 5]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0, 1, 21, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0, 0, 1, 21, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0, 1, 31, 0, 0, 0, 0, 0, 0, 0, 1, 11, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 156, 106, 99, 127, 98, 174, 42, 241, 199, 227, 30, 237, 126, 150, 190, 4, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[8, 11, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 156, 189, 47, 11, 41, 160, 8, 163, 96, 9, 172, 68, 204, 160, 201, 105], &[101, 4, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 166, 97, 104, 247, 231, 37, 155, 102, 112, 160, 111, 37, 101, 227, 229, 242], &[184, 11, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 180, 154, 39, 56, 238, 179, 8, 150, 170, 203, 139, 63, 180, 100, 113, 189], &[0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 194, 154, 3, 16, 225, 187, 69, 210, 12, 172, 231, 124, 203, 98, 201, 125], &[0, 225, 245, 5]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 234, 7, 222, 43, 143, 1, 5, 22, 220, 163, 247, 239, 82, 247, 172, 90], &[8, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 247, 218, 208, 49, 115, 36, 174, 202, 232, 116, 75, 135, 252, 149, 242, 243], &[0]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 1, 0, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 244, 1, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 87, 200, 117, 228, 207, 247, 65, 72, 228, 98, 143, 38, 75, 151, 76, 128], &[214, 61, 165, 212, 232, 0, 0, 0]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 227, 253, 141, 247, 41, 112, 188, 130, 229, 38, 126, 160, 30, 221, 217, 73], &[1]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 76, 1, 78, 107, 248, 184, 194, 192, 17, 231, 41, 11, 133, 105, 107, 179, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 76, 1, 78, 107, 248, 184, 194, 192, 17, 231, 41, 11, 133, 105, 107, 179, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[21, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 99, 128, 64, 70, 131, 252, 137, 232, 35, 52, 80, 200, 170, 25, 80, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 109, 123, 24, 86, 30, 19, 159, 228, 49, 200, 33, 139, 70, 205, 244, 47, 40, 190, 110, 43, 138, 12, 26, 121, 5, 219, 103, 1, 110, 91, 142, 123], &[11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 99, 128, 64, 70, 131, 252, 137, 232, 35, 52, 80, 200, 170, 25, 80, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 238, 43, 102, 225, 142, 104, 190, 12, 183, 86, 115, 25, 37, 223, 229, 65, 253, 167, 152, 54, 57, 147, 167, 137, 80, 161, 2, 235, 195, 174, 40, 244], &[21, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 118, 56, 0, 163, 106, 153, 253, 252, 124, 16, 246, 65, 95, 110, 230], &[5, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 148, 80, 191, 164, 185, 106, 63, 167, 163, 200, 244, 13, 166, 191, 50, 225], &[0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 17, 218, 109, 31, 118, 29, 223, 155, 219, 76, 157, 110, 83, 3, 235, 212, 31, 97, 133, 141, 10, 86, 71, 161, 167, 191, 224, 137, 191, 146, 27, 233], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 38, 160, 142, 77, 12, 81, 144, 240, 24, 113, 224, 86, 155, 98, 144, 184, 103, 96, 8, 93, 153, 241, 126, 180, 231, 230, 181, 143, 235, 141, 98, 73], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 123, 10, 161, 115, 94, 91, 165, 141, 50, 54, 49, 108, 103, 31, 228, 240, 14, 211, 102, 238, 114, 65, 124, 158, 208, 42, 83, 168, 1, 158, 133, 184], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 140, 3, 159, 247, 202, 161, 124, 206, 191, 202, 220, 68, 189, 159, 206, 106, 75, 102, 153, 196, 208, 61, 226, 227, 52, 154, 161, 220, 17, 25, 60, 215], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 140, 53, 210, 47, 69, 157, 119, 202, 76, 11, 11, 80, 53, 134, 151, 102, 214, 13, 24, 43, 151, 22, 171, 62, 136, 121, 224, 102, 71, 136, 153, 168], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 225, 44, 34, 212, 241, 98, 217, 160, 18, 201, 49, 146, 51, 218, 93, 62, 146, 60, 197, 225, 2, 155, 143, 144, 228, 114, 73, 201, 171, 37, 107, 53], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 244, 170, 194, 251, 227, 63, 3, 85, 75, 254, 181, 89, 234, 38, 144, 237, 133, 33, 202, 164, 190, 150, 30, 97, 201, 26, 201, 161, 83, 13, 206, 122], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 224, 205, 208, 98, 230, 234, 242, 66, 149, 173, 76, 207, 196, 29, 70, 9], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 255, 58, 225, 39, 112, 190, 162, 228, 141, 155, 222, 115, 133, 231, 162, 95], &[0, 0, 0, 0, 7, 0, 0, 0]), (&[240, 195, 101, 195, 207, 89, 214, 113, 235, 114, 218, 14, 122, 65, 19, 196, 159, 31, 5, 21, 244, 98, 205, 207, 132, 224, 241, 214, 4, 93, 252, 187], &[136, 19, 0, 0, 0, 0, 0, 0])]; +pub const _6: &[(&[u8], &[u8])] = &[(&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 2, 165, 193, 177, 154, 183, 160, 79, 83, 108, 81, 154, 202, 73, 131, 172], &[6, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 10, 152, 253, 190, 156, 230, 197, 88, 55, 87, 108, 96, 199, 175, 56, 80], &[23, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 128, 212, 30, 94, 22, 5, 103, 101, 188, 132, 97, 133, 16, 114, 201, 215], &[92, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 138, 66, 243, 51, 35, 203, 92, 237, 59, 68, 221, 130, 95, 218, 159, 204], &[69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 164, 71, 4, 181, 104, 210, 22, 103, 53, 106, 90, 5, 12, 17, 135, 70, 129, 228, 122, 25, 230, 178, 155, 10, 101, 185, 89, 23, 98, 206, 81, 67, 237, 48, 208, 38, 30, 93, 36, 163, 32, 23, 82, 80, 107, 32, 241, 92], &[69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 29, 189, 125, 11, 86, 26, 65, 210, 60, 42, 70, 154, 212, 47, 189, 112, 213, 67, 139, 174, 130, 111, 111, 214, 7, 65, 49, 144, 195, 124, 54, 59], &[0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 94, 90, 15, 75, 176, 234, 179, 121, 134, 37, 171, 24, 100, 84, 93, 19, 212, 232, 208, 104, 153, 217, 219, 77, 97, 219, 157, 238, 147, 186, 2, 221], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 100, 74, 81, 252, 33, 158, 145, 69, 184, 87, 123, 183, 118, 40, 118, 123, 28, 47, 115, 116, 142, 218, 139, 120, 139, 252, 102, 161, 181, 42, 32, 248], &[0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 165, 212, 232, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 108, 221, 179, 103, 175, 189, 88, 59, 180, 143, 155, 189, 125, 91, 163, 177, 208, 115, 139, 72, 129, 177, 205, 221, 56, 22, 149, 38, 216, 21, 129, 55], &[0, 0, 0, 0, 0, 0, 0, 0, 44, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 165, 186, 85, 195, 163, 151, 212, 60, 23, 89, 63, 40, 154, 164, 151, 157, 10, 229, 146, 68, 179, 47, 3, 236, 19, 65, 97, 129, 175, 134, 209, 11], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 189, 225, 131, 90, 186, 237, 15, 242, 121, 87, 0, 55, 252, 73, 213, 189, 23, 110, 180, 130, 163, 178, 129, 109, 244, 252, 194, 204, 27, 200, 106, 202], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 213, 92, 123, 109, 126, 139, 228, 10, 88, 51, 198, 4, 8, 188, 78, 184, 171, 234, 78, 93, 168, 211, 37, 233, 8, 135, 156, 195, 59, 151, 205, 153], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 216, 247, 229, 16, 146, 46, 205, 71, 180, 10, 28, 88, 41, 56, 34, 6, 69, 103, 185, 191, 60, 126, 225, 114, 12, 144, 76, 94, 12, 87, 247, 55], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 232, 139, 67, 253, 237, 99, 35, 239, 2, 255, 239, 251, 216, 196, 8, 70, 238, 9, 191, 49, 98, 113, 189, 34, 54, 150, 89, 201, 89, 221, 115, 58], &[0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 233, 103, 96, 210, 116, 101, 58, 57, 180, 41, 168, 126, 186, 174, 157, 58, 164, 253, 245, 139, 144, 150, 207, 11, 235, 199, 196, 229, 164, 194, 237, 141], &[0, 0, 0, 0, 0, 0, 0, 0, 144, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 244, 1, 0, 0, 0, 0, 0, 0, 244, 1, 0, 0, 0, 0, 0, 0]), (&[58, 99, 111, 100, 101], &[]), (&[58, 101, 120, 116, 114, 105, 110, 115, 105, 99, 95, 105, 110, 100, 101, 120], &[0, 0, 0, 0]), (&[58, 104, 101, 97, 112, 112, 97, 103, 101, 115], &[8, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 11, 106, 69, 50, 30, 250, 233, 42, 234, 21, 224, 116, 14, 199, 175, 231], &[2, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 14, 160, 236, 172, 118, 69, 125, 15, 155, 57, 185, 129, 221, 16, 112, 18], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 19, 142, 113, 97, 36, 145, 25, 45, 104, 222, 171, 126, 111, 86, 63, 225], &[2, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 40, 220, 203, 85, 155, 149, 196, 1, 104, 161, 178, 105, 101, 129, 181, 167], &[0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[40, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[10, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[30, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[20, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[100, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 94, 90, 15, 75, 176, 234, 179, 121, 134, 37, 171, 24, 100, 84, 93, 19, 212, 232, 208, 104, 153, 217, 219, 77, 97, 219, 157, 238, 147, 186, 2, 221], &[21, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 165, 186, 85, 195, 163, 151, 212, 60, 23, 89, 63, 40, 154, 164, 151, 157, 10, 229, 146, 68, 179, 47, 3, 236, 19, 65, 97, 129, 175, 134, 209, 11], &[31, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 189, 225, 131, 90, 186, 237, 15, 242, 121, 87, 0, 55, 252, 73, 213, 189, 23, 110, 180, 130, 163, 178, 129, 109, 244, 252, 194, 204, 27, 200, 106, 202], &[11, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 213, 92, 123, 109, 126, 139, 228, 10, 88, 51, 198, 4, 8, 188, 78, 184, 171, 234, 78, 93, 168, 211, 37, 233, 8, 135, 156, 195, 59, 151, 205, 153], &[101, 0, 0, 0, 0, 0, 0, 0, 209, 7, 209, 7, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 216, 247, 229, 16, 146, 46, 205, 71, 180, 10, 28, 88, 41, 56, 34, 6, 69, 103, 185, 191, 60, 126, 225, 114, 12, 144, 76, 94, 12, 87, 247, 55], &[41, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 80, 154, 155, 110, 250, 147, 245, 187, 131, 248, 88, 240, 186, 191, 211, 11], &[6, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 85, 121, 41, 127, 77, 251, 150, 9, 231, 228, 194, 235, 171, 156, 228, 10], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 86, 239, 98, 39, 206, 203, 47, 7, 39, 76, 176, 87, 45, 143, 164, 194], &[101, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 106, 147, 17, 38, 51, 187, 51, 84, 230, 121, 82, 252, 221, 116, 12, 213], &[31, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 131, 229, 133, 187, 197, 253, 206, 197, 114, 25, 192, 220, 129, 239, 95, 244, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[149, 17, 161, 15, 4, 101, 0, 0, 0, 0, 0, 0, 0, 245, 1]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 131, 229, 133, 187, 197, 253, 206, 197, 114, 25, 192, 220, 129, 239, 95, 244, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[125, 21, 161, 15, 4, 101, 0, 0, 0, 0, 0, 0, 0, 221, 5]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0, 1, 21, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0, 0, 1, 21, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0, 1, 31, 0, 0, 0, 0, 0, 0, 0, 1, 11, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 156, 106, 99, 127, 98, 174, 42, 241, 199, 227, 30, 237, 126, 150, 190, 4, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[8, 11, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 156, 189, 47, 11, 41, 160, 8, 163, 96, 9, 172, 68, 204, 160, 201, 105], &[101, 4, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 166, 97, 104, 247, 231, 37, 155, 102, 112, 160, 111, 37, 101, 227, 229, 242], &[112, 23, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 180, 154, 39, 56, 238, 179, 8, 150, 170, 203, 139, 63, 180, 100, 113, 189], &[0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 194, 154, 3, 16, 225, 187, 69, 210, 12, 172, 231, 124, 203, 98, 201, 125], &[0, 225, 245, 5]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 234, 7, 222, 43, 143, 1, 5, 22, 220, 163, 247, 239, 82, 247, 172, 90], &[12, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 2, 0, 0, 0, 6, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 247, 218, 208, 49, 115, 36, 174, 202, 232, 116, 75, 135, 252, 149, 242, 243], &[0]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 1, 0, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 244, 1, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 87, 200, 117, 228, 207, 247, 65, 72, 228, 98, 143, 38, 75, 151, 76, 128], &[214, 61, 165, 212, 232, 0, 0, 0]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 227, 253, 141, 247, 41, 112, 188, 130, 229, 38, 126, 160, 30, 221, 217, 73], &[1]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 76, 1, 78, 107, 248, 184, 194, 192, 17, 231, 41, 11, 133, 105, 107, 179, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 76, 1, 78, 107, 248, 184, 194, 192, 17, 231, 41, 11, 133, 105, 107, 179, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[21, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 99, 128, 64, 70, 131, 252, 137, 232, 35, 52, 80, 200, 170, 25, 80, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 109, 123, 24, 86, 30, 19, 159, 228, 49, 200, 33, 139, 70, 205, 244, 47, 40, 190, 110, 43, 138, 12, 26, 121, 5, 219, 103, 1, 110, 91, 142, 123], &[11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 99, 128, 64, 70, 131, 252, 137, 232, 35, 52, 80, 200, 170, 25, 80, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 238, 43, 102, 225, 142, 104, 190, 12, 183, 86, 115, 25, 37, 223, 229, 65, 253, 167, 152, 54, 57, 147, 167, 137, 80, 161, 2, 235, 195, 174, 40, 244], &[21, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 118, 56, 0, 163, 106, 153, 253, 252, 124, 16, 246, 65, 95, 110, 230], &[6, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 148, 80, 191, 164, 185, 106, 63, 167, 163, 200, 244, 13, 166, 191, 50, 225], &[1]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 17, 218, 109, 31, 118, 29, 223, 155, 219, 76, 157, 110, 83, 3, 235, 212, 31, 97, 133, 141, 10, 86, 71, 161, 167, 191, 224, 137, 191, 146, 27, 233], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 38, 160, 142, 77, 12, 81, 144, 240, 24, 113, 224, 86, 155, 98, 144, 184, 103, 96, 8, 93, 153, 241, 126, 180, 231, 230, 181, 143, 235, 141, 98, 73], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 91, 143, 41, 219, 118, 207, 78, 103, 110, 79, 201, 177, 112, 64, 49, 45, 235, 237, 175, 205, 86, 55, 251, 60, 123, 173, 210, 205, 220, 230, 164, 69], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 123, 10, 161, 115, 94, 91, 165, 141, 50, 54, 49, 108, 103, 31, 228, 240, 14, 211, 102, 238, 114, 65, 124, 158, 208, 42, 83, 168, 1, 158, 133, 184], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 140, 3, 159, 247, 202, 161, 124, 206, 191, 202, 220, 68, 189, 159, 206, 106, 75, 102, 153, 196, 208, 61, 226, 227, 52, 154, 161, 220, 17, 25, 60, 215], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 140, 53, 210, 47, 69, 157, 119, 202, 76, 11, 11, 80, 53, 134, 151, 102, 214, 13, 24, 43, 151, 22, 171, 62, 136, 121, 224, 102, 71, 136, 153, 168], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 225, 44, 34, 212, 241, 98, 217, 160, 18, 201, 49, 146, 51, 218, 93, 62, 146, 60, 197, 225, 2, 155, 143, 144, 228, 114, 73, 201, 171, 37, 107, 53], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 244, 170, 194, 251, 227, 63, 3, 85, 75, 254, 181, 89, 234, 38, 144, 237, 133, 33, 202, 164, 190, 150, 30, 97, 201, 26, 201, 161, 83, 13, 206, 122], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 224, 205, 208, 98, 230, 234, 242, 66, 149, 173, 76, 207, 196, 29, 70, 9], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 255, 58, 225, 39, 112, 190, 162, 228, 141, 155, 222, 115, 133, 231, 162, 95], &[0, 0, 0, 0, 8, 0, 0, 0]), (&[240, 195, 101, 195, 207, 89, 214, 113, 235, 114, 218, 14, 122, 65, 19, 196, 159, 31, 5, 21, 244, 98, 205, 207, 132, 224, 241, 214, 4, 93, 252, 187], &[112, 23, 0, 0, 0, 0, 0, 0])]; +pub const _7: &[(&[u8], &[u8])] = &[(&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 2, 165, 193, 177, 154, 183, 160, 79, 83, 108, 81, 154, 202, 73, 131, 172], &[7, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 10, 152, 253, 190, 156, 230, 197, 88, 55, 87, 108, 96, 199, 175, 56, 80], &[24, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 128, 212, 30, 94, 22, 5, 103, 101, 188, 132, 97, 133, 16, 114, 201, 215], &[96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 138, 66, 243, 51, 35, 203, 92, 237, 59, 68, 221, 130, 95, 218, 159, 204], &[69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 164, 71, 4, 181, 104, 210, 22, 103, 53, 106, 90, 5, 12, 17, 135, 70, 129, 228, 122, 25, 230, 178, 155, 10, 101, 185, 89, 23, 98, 206, 81, 67, 237, 48, 208, 38, 30, 93, 36, 163, 32, 23, 82, 80, 107, 32, 241, 92], &[69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 29, 189, 125, 11, 86, 26, 65, 210, 60, 42, 70, 154, 212, 47, 189, 112, 213, 67, 139, 174, 130, 111, 111, 214, 7, 65, 49, 144, 195, 124, 54, 59], &[0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 94, 90, 15, 75, 176, 234, 179, 121, 134, 37, 171, 24, 100, 84, 93, 19, 212, 232, 208, 104, 153, 217, 219, 77, 97, 219, 157, 238, 147, 186, 2, 221], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 100, 74, 81, 252, 33, 158, 145, 69, 184, 87, 123, 183, 118, 40, 118, 123, 28, 47, 115, 116, 142, 218, 139, 120, 139, 252, 102, 161, 181, 42, 32, 248], &[0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 165, 212, 232, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 108, 221, 179, 103, 175, 189, 88, 59, 180, 143, 155, 189, 125, 91, 163, 177, 208, 115, 139, 72, 129, 177, 205, 221, 56, 22, 149, 38, 216, 21, 129, 55], &[0, 0, 0, 0, 0, 0, 0, 0, 44, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 165, 186, 85, 195, 163, 151, 212, 60, 23, 89, 63, 40, 154, 164, 151, 157, 10, 229, 146, 68, 179, 47, 3, 236, 19, 65, 97, 129, 175, 134, 209, 11], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 189, 225, 131, 90, 186, 237, 15, 242, 121, 87, 0, 55, 252, 73, 213, 189, 23, 110, 180, 130, 163, 178, 129, 109, 244, 252, 194, 204, 27, 200, 106, 202], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 213, 92, 123, 109, 126, 139, 228, 10, 88, 51, 198, 4, 8, 188, 78, 184, 171, 234, 78, 93, 168, 211, 37, 233, 8, 135, 156, 195, 59, 151, 205, 153], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 216, 247, 229, 16, 146, 46, 205, 71, 180, 10, 28, 88, 41, 56, 34, 6, 69, 103, 185, 191, 60, 126, 225, 114, 12, 144, 76, 94, 12, 87, 247, 55], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 232, 139, 67, 253, 237, 99, 35, 239, 2, 255, 239, 251, 216, 196, 8, 70, 238, 9, 191, 49, 98, 113, 189, 34, 54, 150, 89, 201, 89, 221, 115, 58], &[0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 233, 103, 96, 210, 116, 101, 58, 57, 180, 41, 168, 126, 186, 174, 157, 58, 164, 253, 245, 139, 144, 150, 207, 11, 235, 199, 196, 229, 164, 194, 237, 141], &[0, 0, 0, 0, 0, 0, 0, 0, 144, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 244, 1, 0, 0, 0, 0, 0, 0, 244, 1, 0, 0, 0, 0, 0, 0]), (&[58, 99, 111, 100, 101], &[]), (&[58, 101, 120, 116, 114, 105, 110, 115, 105, 99, 95, 105, 110, 100, 101, 120], &[0, 0, 0, 0]), (&[58, 104, 101, 97, 112, 112, 97, 103, 101, 115], &[8, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 11, 106, 69, 50, 30, 250, 233, 42, 234, 21, 224, 116, 14, 199, 175, 231], &[2, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 14, 160, 236, 172, 118, 69, 125, 15, 155, 57, 185, 129, 221, 16, 112, 18], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 19, 142, 113, 97, 36, 145, 25, 45, 104, 222, 171, 126, 111, 86, 63, 225], &[2, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 40, 220, 203, 85, 155, 149, 196, 1, 104, 161, 178, 105, 101, 129, 181, 167], &[0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[40, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[10, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[30, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[20, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[100, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 94, 90, 15, 75, 176, 234, 179, 121, 134, 37, 171, 24, 100, 84, 93, 19, 212, 232, 208, 104, 153, 217, 219, 77, 97, 219, 157, 238, 147, 186, 2, 221], &[21, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 165, 186, 85, 195, 163, 151, 212, 60, 23, 89, 63, 40, 154, 164, 151, 157, 10, 229, 146, 68, 179, 47, 3, 236, 19, 65, 97, 129, 175, 134, 209, 11], &[31, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 189, 225, 131, 90, 186, 237, 15, 242, 121, 87, 0, 55, 252, 73, 213, 189, 23, 110, 180, 130, 163, 178, 129, 109, 244, 252, 194, 204, 27, 200, 106, 202], &[11, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 213, 92, 123, 109, 126, 139, 228, 10, 88, 51, 198, 4, 8, 188, 78, 184, 171, 234, 78, 93, 168, 211, 37, 233, 8, 135, 156, 195, 59, 151, 205, 153], &[101, 0, 0, 0, 0, 0, 0, 0, 209, 7, 209, 7, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 216, 247, 229, 16, 146, 46, 205, 71, 180, 10, 28, 88, 41, 56, 34, 6, 69, 103, 185, 191, 60, 126, 225, 114, 12, 144, 76, 94, 12, 87, 247, 55], &[41, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 80, 154, 155, 110, 250, 147, 245, 187, 131, 248, 88, 240, 186, 191, 211, 11], &[6, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 85, 121, 41, 127, 77, 251, 150, 9, 231, 228, 194, 235, 171, 156, 228, 10], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 86, 239, 98, 39, 206, 203, 47, 7, 39, 76, 176, 87, 45, 143, 164, 194], &[101, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 106, 147, 17, 38, 51, 187, 51, 84, 230, 121, 82, 252, 221, 116, 12, 213], &[31, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 131, 229, 133, 187, 197, 253, 206, 197, 114, 25, 192, 220, 129, 239, 95, 244, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[149, 17, 161, 15, 4, 101, 0, 0, 0, 0, 0, 0, 0, 245, 1]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 131, 229, 133, 187, 197, 253, 206, 197, 114, 25, 192, 220, 129, 239, 95, 244, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[125, 21, 161, 15, 4, 101, 0, 0, 0, 0, 0, 0, 0, 221, 5]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0, 1, 21, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0, 0, 1, 21, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0, 1, 31, 0, 0, 0, 0, 0, 0, 0, 1, 11, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 156, 106, 99, 127, 98, 174, 42, 241, 199, 227, 30, 237, 126, 150, 190, 4, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[8, 11, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 156, 189, 47, 11, 41, 160, 8, 163, 96, 9, 172, 68, 204, 160, 201, 105], &[101, 4, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 166, 97, 104, 247, 231, 37, 155, 102, 112, 160, 111, 37, 101, 227, 229, 242], &[112, 23, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 180, 154, 39, 56, 238, 179, 8, 150, 170, 203, 139, 63, 180, 100, 113, 189], &[0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 194, 154, 3, 16, 225, 187, 69, 210, 12, 172, 231, 124, 203, 98, 201, 125], &[0, 225, 245, 5]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 234, 7, 222, 43, 143, 1, 5, 22, 220, 163, 247, 239, 82, 247, 172, 90], &[12, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 2, 0, 0, 0, 6, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 247, 218, 208, 49, 115, 36, 174, 202, 232, 116, 75, 135, 252, 149, 242, 243], &[0]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 1, 0, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 244, 1, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 87, 200, 117, 228, 207, 247, 65, 72, 228, 98, 143, 38, 75, 151, 76, 128], &[214, 61, 165, 212, 232, 0, 0, 0]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 227, 253, 141, 247, 41, 112, 188, 130, 229, 38, 126, 160, 30, 221, 217, 73], &[1]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 76, 1, 78, 107, 248, 184, 194, 192, 17, 231, 41, 11, 133, 105, 107, 179, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 76, 1, 78, 107, 248, 184, 194, 192, 17, 231, 41, 11, 133, 105, 107, 179, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[21, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 99, 128, 64, 70, 131, 252, 137, 232, 35, 52, 80, 200, 170, 25, 80, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 109, 123, 24, 86, 30, 19, 159, 228, 49, 200, 33, 139, 70, 205, 244, 47, 40, 190, 110, 43, 138, 12, 26, 121, 5, 219, 103, 1, 110, 91, 142, 123], &[11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 99, 128, 64, 70, 131, 252, 137, 232, 35, 52, 80, 200, 170, 25, 80, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 238, 43, 102, 225, 142, 104, 190, 12, 183, 86, 115, 25, 37, 223, 229, 65, 253, 167, 152, 54, 57, 147, 167, 137, 80, 161, 2, 235, 195, 174, 40, 244], &[21, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 118, 56, 0, 163, 106, 153, 253, 252, 124, 16, 246, 65, 95, 110, 230], &[7, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 148, 80, 191, 164, 185, 106, 63, 167, 163, 200, 244, 13, 166, 191, 50, 225], &[0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 17, 218, 109, 31, 118, 29, 223, 155, 219, 76, 157, 110, 83, 3, 235, 212, 31, 97, 133, 141, 10, 86, 71, 161, 167, 191, 224, 137, 191, 146, 27, 233], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 38, 160, 142, 77, 12, 81, 144, 240, 24, 113, 224, 86, 155, 98, 144, 184, 103, 96, 8, 93, 153, 241, 126, 180, 231, 230, 181, 143, 235, 141, 98, 73], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 91, 143, 41, 219, 118, 207, 78, 103, 110, 79, 201, 177, 112, 64, 49, 45, 235, 237, 175, 205, 86, 55, 251, 60, 123, 173, 210, 205, 220, 230, 164, 69], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 123, 10, 161, 115, 94, 91, 165, 141, 50, 54, 49, 108, 103, 31, 228, 240, 14, 211, 102, 238, 114, 65, 124, 158, 208, 42, 83, 168, 1, 158, 133, 184], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 140, 3, 159, 247, 202, 161, 124, 206, 191, 202, 220, 68, 189, 159, 206, 106, 75, 102, 153, 196, 208, 61, 226, 227, 52, 154, 161, 220, 17, 25, 60, 215], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 140, 53, 210, 47, 69, 157, 119, 202, 76, 11, 11, 80, 53, 134, 151, 102, 214, 13, 24, 43, 151, 22, 171, 62, 136, 121, 224, 102, 71, 136, 153, 168], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 157, 255, 135, 106, 75, 148, 45, 10, 151, 17, 209, 130, 33, 137, 143, 17, 202, 57, 117, 21, 137, 235, 244, 212, 157, 116, 159, 107, 62, 73, 50, 146], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 225, 44, 34, 212, 241, 98, 217, 160, 18, 201, 49, 146, 51, 218, 93, 62, 146, 60, 197, 225, 2, 155, 143, 144, 228, 114, 73, 201, 171, 37, 107, 53], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 244, 170, 194, 251, 227, 63, 3, 85, 75, 254, 181, 89, 234, 38, 144, 237, 133, 33, 202, 164, 190, 150, 30, 97, 201, 26, 201, 161, 83, 13, 206, 122], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 224, 205, 208, 98, 230, 234, 242, 66, 149, 173, 76, 207, 196, 29, 70, 9], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 255, 58, 225, 39, 112, 190, 162, 228, 141, 155, 222, 115, 133, 231, 162, 95], &[0, 0, 0, 0, 9, 0, 0, 0]), (&[240, 195, 101, 195, 207, 89, 214, 113, 235, 114, 218, 14, 122, 65, 19, 196, 159, 31, 5, 21, 244, 98, 205, 207, 132, 224, 241, 214, 4, 93, 252, 187], &[88, 27, 0, 0, 0, 0, 0, 0])]; +pub const _8: &[(&[u8], &[u8])] = &[(&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 2, 165, 193, 177, 154, 183, 160, 79, 83, 108, 81, 154, 202, 73, 131, 172], &[8, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 10, 152, 253, 190, 156, 230, 197, 88, 55, 87, 108, 96, 199, 175, 56, 80], &[25, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 128, 212, 30, 94, 22, 5, 103, 101, 188, 132, 97, 133, 16, 114, 201, 215], &[100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 138, 66, 243, 51, 35, 203, 92, 237, 59, 68, 221, 130, 95, 218, 159, 204], &[69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 164, 71, 4, 181, 104, 210, 22, 103, 53, 106, 90, 5, 12, 17, 135, 70, 129, 228, 122, 25, 230, 178, 155, 10, 101, 185, 89, 23, 98, 206, 81, 67, 237, 48, 208, 38, 30, 93, 36, 163, 32, 23, 82, 80, 107, 32, 241, 92], &[69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 29, 189, 125, 11, 86, 26, 65, 210, 60, 42, 70, 154, 212, 47, 189, 112, 213, 67, 139, 174, 130, 111, 111, 214, 7, 65, 49, 144, 195, 124, 54, 59], &[0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 94, 90, 15, 75, 176, 234, 179, 121, 134, 37, 171, 24, 100, 84, 93, 19, 212, 232, 208, 104, 153, 217, 219, 77, 97, 219, 157, 238, 147, 186, 2, 221], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 100, 74, 81, 252, 33, 158, 145, 69, 184, 87, 123, 183, 118, 40, 118, 123, 28, 47, 115, 116, 142, 218, 139, 120, 139, 252, 102, 161, 181, 42, 32, 248], &[0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 165, 212, 232, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 108, 221, 179, 103, 175, 189, 88, 59, 180, 143, 155, 189, 125, 91, 163, 177, 208, 115, 139, 72, 129, 177, 205, 221, 56, 22, 149, 38, 216, 21, 129, 55], &[0, 0, 0, 0, 0, 0, 0, 0, 44, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 165, 186, 85, 195, 163, 151, 212, 60, 23, 89, 63, 40, 154, 164, 151, 157, 10, 229, 146, 68, 179, 47, 3, 236, 19, 65, 97, 129, 175, 134, 209, 11], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 189, 225, 131, 90, 186, 237, 15, 242, 121, 87, 0, 55, 252, 73, 213, 189, 23, 110, 180, 130, 163, 178, 129, 109, 244, 252, 194, 204, 27, 200, 106, 202], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 213, 92, 123, 109, 126, 139, 228, 10, 88, 51, 198, 4, 8, 188, 78, 184, 171, 234, 78, 93, 168, 211, 37, 233, 8, 135, 156, 195, 59, 151, 205, 153], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 216, 247, 229, 16, 146, 46, 205, 71, 180, 10, 28, 88, 41, 56, 34, 6, 69, 103, 185, 191, 60, 126, 225, 114, 12, 144, 76, 94, 12, 87, 247, 55], &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 232, 139, 67, 253, 237, 99, 35, 239, 2, 255, 239, 251, 216, 196, 8, 70, 238, 9, 191, 49, 98, 113, 189, 34, 54, 150, 89, 201, 89, 221, 115, 58], &[0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 233, 103, 96, 210, 116, 101, 58, 57, 180, 41, 168, 126, 186, 174, 157, 58, 164, 253, 245, 139, 144, 150, 207, 11, 235, 199, 196, 229, 164, 194, 237, 141], &[0, 0, 0, 0, 0, 0, 0, 0, 144, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247, 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[0, 0, 0, 0, 0, 0, 0, 0, 208, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 244, 1, 0, 0, 0, 0, 0, 0, 244, 1, 0, 0, 0, 0, 0, 0]), (&[58, 99, 111, 100, 101], &[]), (&[58, 101, 120, 116, 114, 105, 110, 115, 105, 99, 95, 105, 110, 100, 101, 120], &[0, 0, 0, 0]), (&[58, 104, 101, 97, 112, 112, 97, 103, 101, 115], &[8, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 11, 106, 69, 50, 30, 250, 233, 42, 234, 21, 224, 116, 14, 199, 175, 231], &[2, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 14, 160, 236, 172, 118, 69, 125, 15, 155, 57, 185, 129, 221, 16, 112, 18], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 19, 142, 113, 97, 36, 145, 25, 45, 104, 222, 171, 126, 111, 86, 63, 225], &[2, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 40, 220, 203, 85, 155, 149, 196, 1, 104, 161, 178, 105, 101, 129, 181, 167], &[0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[40, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[10, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[30, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[20, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 62, 209, 75, 69, 237, 32, 208, 84, 240, 94, 55, 226, 84, 44, 254, 112, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[100, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 94, 90, 15, 75, 176, 234, 179, 121, 134, 37, 171, 24, 100, 84, 93, 19, 212, 232, 208, 104, 153, 217, 219, 77, 97, 219, 157, 238, 147, 186, 2, 221], &[21, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 165, 186, 85, 195, 163, 151, 212, 60, 23, 89, 63, 40, 154, 164, 151, 157, 10, 229, 146, 68, 179, 47, 3, 236, 19, 65, 97, 129, 175, 134, 209, 11], &[31, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 189, 225, 131, 90, 186, 237, 15, 242, 121, 87, 0, 55, 252, 73, 213, 189, 23, 110, 180, 130, 163, 178, 129, 109, 244, 252, 194, 204, 27, 200, 106, 202], &[11, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 213, 92, 123, 109, 126, 139, 228, 10, 88, 51, 198, 4, 8, 188, 78, 184, 171, 234, 78, 93, 168, 211, 37, 233, 8, 135, 156, 195, 59, 151, 205, 153], &[101, 0, 0, 0, 0, 0, 0, 0, 209, 7, 209, 7, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 66, 42, 219, 87, 159, 29, 191, 79, 56, 134, 197, 207, 163, 187, 140, 196, 216, 247, 229, 16, 146, 46, 205, 71, 180, 10, 28, 88, 41, 56, 34, 6, 69, 103, 185, 191, 60, 126, 225, 114, 12, 144, 76, 94, 12, 87, 247, 55], &[41, 0, 0, 0, 0, 0, 0, 0, 161, 15, 161, 15, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 80, 154, 155, 110, 250, 147, 245, 187, 131, 248, 88, 240, 186, 191, 211, 11], &[6, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 85, 121, 41, 127, 77, 251, 150, 9, 231, 228, 194, 235, 171, 156, 228, 10], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 86, 239, 98, 39, 206, 203, 47, 7, 39, 76, 176, 87, 45, 143, 164, 194], &[101, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 106, 147, 17, 38, 51, 187, 51, 84, 230, 121, 82, 252, 221, 116, 12, 213], &[31, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 131, 229, 133, 187, 197, 253, 206, 197, 114, 25, 192, 220, 129, 239, 95, 244, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[149, 17, 161, 15, 4, 101, 0, 0, 0, 0, 0, 0, 0, 245, 1]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 131, 229, 133, 187, 197, 253, 206, 197, 114, 25, 192, 220, 129, 239, 95, 244, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[125, 21, 161, 15, 4, 101, 0, 0, 0, 0, 0, 0, 0, 221, 5]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0, 1, 21, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0, 0, 1, 21, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0, 1, 31, 0, 0, 0, 0, 0, 0, 0, 1, 11, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 146, 32, 225, 114, 190, 211, 22, 96, 95, 115, 241, 255, 123, 74, 222, 152, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 156, 106, 99, 127, 98, 174, 42, 241, 199, 227, 30, 237, 126, 150, 190, 4, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[8, 11, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 156, 189, 47, 11, 41, 160, 8, 163, 96, 9, 172, 68, 204, 160, 201, 105], &[101, 4, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 166, 97, 104, 247, 231, 37, 155, 102, 112, 160, 111, 37, 101, 227, 229, 242], &[112, 23, 0, 0, 0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 180, 154, 39, 56, 238, 179, 8, 150, 170, 203, 139, 63, 180, 100, 113, 189], &[0, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 194, 154, 3, 16, 225, 187, 69, 210, 12, 172, 231, 124, 203, 98, 201, 125], &[0, 225, 245, 5]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 234, 7, 222, 43, 143, 1, 5, 22, 220, 163, 247, 239, 82, 247, 172, 90], &[12, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 2, 0, 0, 0, 6, 0, 0, 0]), (&[95, 62, 73, 7, 247, 22, 172, 137, 182, 52, 125, 21, 236, 236, 237, 202, 247, 218, 208, 49, 115, 36, 174, 202, 232, 116, 75, 135, 252, 149, 242, 243], &[0]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 77, 254, 57, 245, 78, 123, 168, 74, 190, 191, 139, 138, 100, 234, 72, 46, 45, 174, 43, 141, 96, 79, 230, 7, 252, 242, 172, 39, 100, 43, 161, 177], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 137, 6, 59, 94, 171, 160, 104, 80, 196, 182, 201, 87, 28, 70, 86, 200, 124, 206, 182, 4, 38, 77, 37, 233, 32, 121, 227, 154, 137, 129, 91, 166], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 1, 0, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 232, 3, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 33, 143, 38, 199, 58, 221, 99, 72, 151, 85, 11, 64, 3, 178, 107, 198, 250, 67, 84, 127, 177, 206, 187, 248, 7, 171, 139, 143, 54, 116, 13, 218, 140, 198, 7, 172, 12, 47, 130, 190, 178, 198, 48, 211, 195, 137, 122, 61], &[4, 115, 116, 97, 107, 105, 110, 103, 32, 244, 1, 0, 0, 0, 0, 0, 0, 2]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 87, 200, 117, 228, 207, 247, 65, 72, 228, 98, 143, 38, 75, 151, 76, 128], &[214, 61, 165, 212, 232, 0, 0, 0]), (&[194, 38, 18, 118, 204, 157, 31, 133, 152, 234, 75, 106, 116, 177, 92, 47, 227, 253, 141, 247, 41, 112, 188, 130, 229, 38, 126, 160, 30, 221, 217, 73], &[1]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 76, 1, 78, 107, 248, 184, 194, 192, 17, 231, 41, 11, 133, 105, 107, 179, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 83, 50, 194, 39, 103, 192, 178, 217, 125, 32, 22, 246, 168, 239, 120, 222, 173, 2, 155, 120, 7, 166, 176, 226, 172, 7, 43, 102, 21, 204, 92, 8], &[11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 76, 1, 78, 107, 248, 184, 194, 192, 17, 231, 41, 11, 133, 105, 107, 179, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 170, 10, 228, 226, 42, 96, 247, 17, 144, 247, 250, 141, 205, 84, 104, 175, 49, 59, 161, 58, 250, 178, 59, 219, 34, 1, 81, 12, 128, 142, 182, 22], &[21, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 99, 128, 64, 70, 131, 252, 137, 232, 35, 52, 80, 200, 170, 25, 80, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 109, 123, 24, 86, 30, 19, 159, 228, 49, 200, 33, 139, 70, 205, 244, 47, 40, 190, 110, 43, 138, 12, 26, 121, 5, 219, 103, 1, 110, 91, 142, 123], &[11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 99, 128, 64, 70, 131, 252, 137, 232, 35, 52, 80, 200, 170, 25, 80, 159, 230, 50, 156, 192, 179, 158, 9, 52, 58, 115, 101, 115, 115, 105, 111, 110, 58, 107, 101, 121, 115, 238, 43, 102, 225, 142, 104, 190, 12, 183, 86, 115, 25, 37, 223, 229, 65, 253, 167, 152, 54, 57, 147, 167, 137, 80, 161, 2, 235, 195, 174, 40, 244], &[21, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 114, 118, 56, 0, 163, 106, 153, 253, 252, 124, 16, 246, 65, 95, 110, 230], &[8, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 136, 220, 222, 147, 76, 101, 130, 39, 238, 29, 250, 252, 214, 225, 105, 3], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 148, 80, 191, 164, 185, 106, 63, 167, 163, 200, 244, 13, 166, 191, 50, 225], &[0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 17, 218, 109, 31, 118, 29, 223, 155, 219, 76, 157, 110, 83, 3, 235, 212, 31, 97, 133, 141, 10, 86, 71, 161, 167, 191, 224, 137, 191, 146, 27, 233], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 38, 160, 142, 77, 12, 81, 144, 240, 24, 113, 224, 86, 155, 98, 144, 184, 103, 96, 8, 93, 153, 241, 126, 180, 231, 230, 181, 143, 235, 141, 98, 73], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 47, 1, 107, 122, 93, 185, 48, 218, 189, 234, 3, 170, 104, 210, 115, 77, 47, 164, 122, 5, 87, 226, 13, 19, 12, 193, 224, 68, 248, 220, 87, 150], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 91, 143, 41, 219, 118, 207, 78, 103, 110, 79, 201, 177, 112, 64, 49, 45, 235, 237, 175, 205, 86, 55, 251, 60, 123, 173, 210, 205, 220, 230, 164, 69], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 123, 10, 161, 115, 94, 91, 165, 141, 50, 54, 49, 108, 103, 31, 228, 240, 14, 211, 102, 238, 114, 65, 124, 158, 208, 42, 83, 168, 1, 158, 133, 184], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 140, 3, 159, 247, 202, 161, 124, 206, 191, 202, 220, 68, 189, 159, 206, 106, 75, 102, 153, 196, 208, 61, 226, 227, 52, 154, 161, 220, 17, 25, 60, 215], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 140, 53, 210, 47, 69, 157, 119, 202, 76, 11, 11, 80, 53, 134, 151, 102, 214, 13, 24, 43, 151, 22, 171, 62, 136, 121, 224, 102, 71, 136, 153, 168], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 157, 255, 135, 106, 75, 148, 45, 10, 151, 17, 209, 130, 33, 137, 143, 17, 202, 57, 117, 21, 137, 235, 244, 212, 157, 116, 159, 107, 62, 73, 50, 146], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 225, 44, 34, 212, 241, 98, 217, 160, 18, 201, 49, 146, 51, 218, 93, 62, 146, 60, 197, 225, 2, 155, 143, 144, 228, 114, 73, 201, 171, 37, 107, 53], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 152, 239, 125, 192, 96, 67, 110, 78, 216, 3, 175, 7, 99, 43, 137, 182, 244, 170, 194, 251, 227, 63, 3, 85, 75, 254, 181, 89, 234, 38, 144, 237, 133, 33, 202, 164, 190, 150, 30, 97, 201, 26, 201, 161, 83, 13, 206, 122], &[44, 175, 112, 32, 141, 187, 198, 225, 208, 96, 126, 2, 8, 79, 212, 67, 222, 67, 84, 75, 213, 91, 72, 122, 231, 108, 125, 176, 42, 11, 117, 78, 2, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 224, 205, 208, 98, 230, 234, 242, 66, 149, 173, 76, 207, 196, 29, 70, 9], &[8, 21, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0]), (&[206, 197, 7, 13, 96, 157, 211, 73, 127, 114, 189, 224, 127, 201, 107, 160, 255, 58, 225, 39, 112, 190, 162, 228, 141, 155, 222, 115, 133, 231, 162, 95], &[0, 0, 0, 0, 10, 0, 0, 0]), (&[240, 195, 101, 195, 207, 89, 214, 113, 235, 114, 218, 14, 122, 65, 19, 196, 159, 31, 5, 21, 244, 98, 205, 207, 132, 224, 241, 214, 4, 93, 252, 187], &[64, 31, 0, 0, 0, 0, 0, 0])]; diff --git a/frame/sudo/Cargo.toml b/frame/sudo/Cargo.toml index 979d58ee4e058..8d645df85cb94 100644 --- a/frame/sudo/Cargo.toml +++ b/frame/sudo/Cargo.toml @@ -1,23 +1,24 @@ [package] name = "pallet-sudo" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME pallet for sudo" [dependencies] serde = { version = "1.0.101", optional = true } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } [dev-dependencies] -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } [features] default = ["std"] diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index 08c81ba5efc84..78a7642d9f107 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -1,34 +1,35 @@ [package] name = "frame-support" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Support code for the runtime." [dependencies] log = "0.4" serde = { version = "1.0.101", optional = true, features = ["derive"] } -codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] } -frame-metadata = { version = "11.0.0-dev", default-features = false, path = "../metadata" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-io ={ path = "../../primitives/io", default-features = false , version = "2.0.0-dev"} -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../primitives/core" } -sp-arithmetic = { version = "2.0.0-dev", default-features = false, path = "../../primitives/arithmetic" } -sp-inherents = { version = "2.0.0-dev", default-features = false, path = "../../primitives/inherents" } -frame-support-procedural = { version = "2.0.0-dev", path = "./procedural" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +frame-metadata = { version = "11.0.0-alpha.2", default-features = false, path = "../metadata" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-io ={ path = "../../primitives/io", default-features = false , version = "2.0.0-alpha.2"} +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/core" } +sp-arithmetic = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/arithmetic" } +sp-inherents = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/inherents" } +frame-support-procedural = { version = "2.0.0-alpha.2", path = "./procedural" } paste = "0.1.6" once_cell = { version = "1", default-features = false, optional = true } -sp-state-machine = { version = "0.8.0-dev", optional = true, path = "../../primitives/state-machine" } +sp-state-machine = { version = "0.8.0-alpha.2", optional = true, path = "../../primitives/state-machine" } bitmask = { version = "0.5.0", default-features = false } impl-trait-for-tuples = "0.1.3" tracing = { version = "0.1.10", optional = true } [dev-dependencies] pretty_assertions = "0.6.1" -frame-system = { version = "2.0.0-dev", path = "../system" } +frame-system = { version = "2.0.0-alpha.2", path = "../system" } [features] default = ["std"] diff --git a/frame/support/procedural/Cargo.toml b/frame/support/procedural/Cargo.toml index 965f964b2d590..1f5ec04d25e04 100644 --- a/frame/support/procedural/Cargo.toml +++ b/frame/support/procedural/Cargo.toml @@ -1,17 +1,18 @@ [package] name = "frame-support-procedural" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Proc macro of Support code for the runtime." [lib] proc-macro = true [dependencies] -frame-support-procedural-tools = { version = "2.0.0-dev", path = "./tools" } +frame-support-procedural-tools = { version = "2.0.0-alpha.2", path = "./tools" } proc-macro2 = "1.0.6" quote = "1.0.2" syn = { version = "1.0.7", features = ["full"] } diff --git a/frame/support/procedural/tools/Cargo.toml b/frame/support/procedural/tools/Cargo.toml index c1f56fecc7bd1..8f0ce7b06a058 100644 --- a/frame/support/procedural/tools/Cargo.toml +++ b/frame/support/procedural/tools/Cargo.toml @@ -1,14 +1,15 @@ [package] name = "frame-support-procedural-tools" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Proc macro helpers for procedural macros" [dependencies] -frame-support-procedural-tools-derive = { version = "2.0.0-dev", path = "./derive" } +frame-support-procedural-tools-derive = { version = "2.0.0-alpha.2", path = "./derive" } proc-macro2 = "1.0.6" quote = "1.0.2" syn = { version = "1.0.7", features = ["full", "visit"] } diff --git a/frame/support/procedural/tools/derive/Cargo.toml b/frame/support/procedural/tools/derive/Cargo.toml index 6eee6d3186f61..872185d19fc7c 100644 --- a/frame/support/procedural/tools/derive/Cargo.toml +++ b/frame/support/procedural/tools/derive/Cargo.toml @@ -1,11 +1,12 @@ [package] name = "frame-support-procedural-tools-derive" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Use to derive parsing for parsing struct." [lib] proc-macro = true diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 084ea285af464..3c13de11be4a3 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -196,6 +196,10 @@ impl Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {} /// /// The following reserved functions also take the block number (with type `T::BlockNumber`) as an optional input: /// +/// * `on_runtime_upgrade`: Executes at the beginning of a block prior to on_initialize when there +/// is a runtime ugprade. This allow each module to upgrade their storage, calling other module +/// must be avoided. Using this function will implement the +/// [`OnInitialize`](../sp_runtime/traits/trait.OnInitialize.html) trait. /// * `on_initialize`: Executes at the beginning of a block. Using this function will /// implement the [`OnInitialize`](../sp_runtime/traits/trait.OnInitialize.html) trait. /// * `on_finalize`: Executes at the end of a block. Using this function will @@ -229,6 +233,7 @@ macro_rules! decl_module { {} {} {} + {} [] $($t)* ); @@ -261,6 +266,7 @@ macro_rules! decl_module { {} {} {} + {} [] $($t)* ); @@ -274,6 +280,7 @@ macro_rules! decl_module { { $( $other_where_bounds:tt )* } {} { $( $on_initialize:tt )* } + { $( $on_runtime_upgrade:tt )* } { $( $on_finalize:tt )* } { $( $offchain:tt )* } { $( $constants:tt )* } @@ -290,6 +297,7 @@ macro_rules! decl_module { { $( $other_where_bounds )* } { $vis fn deposit_event() = default; } { $( $on_initialize )* } + { $( $on_runtime_upgrade )* } { $( $on_finalize )* } { $( $offchain )* } { $( $constants )* } @@ -305,6 +313,7 @@ macro_rules! decl_module { { $( $other_where_bounds:tt )* } {} { $( $on_initialize:tt )* } + { $( $on_runtime_upgrade:tt )* } { $( $on_finalize:tt )* } { $( $offchain:tt )* } { $( $constants:tt )* } @@ -326,6 +335,7 @@ macro_rules! decl_module { { $( $other_where_bounds:tt )* } { $( $deposit_event:tt )* } { $( $on_initialize:tt )* } + { $( $on_runtime_upgrade:tt )* } {} { $( $offchain:tt )* } { $( $constants:tt )* } @@ -342,6 +352,7 @@ macro_rules! decl_module { { $( $other_where_bounds )* } { $( $deposit_event )* } { $( $on_initialize )* } + { $( $on_runtime_upgrade )* } { #[weight = $crate::dispatch::SimpleDispatchInfo::zero()] fn on_finalize( $( $param_name : $param ),* ) { $( $impl )* } @@ -361,6 +372,7 @@ macro_rules! decl_module { { $( $other_where_bounds:tt )* } { $( $deposit_event:tt )* } { $( $on_initialize:tt )* } + { $( $on_runtime_upgrade:tt )* } {} { $( $offchain:tt )* } { $( $constants:tt )* } @@ -378,6 +390,7 @@ macro_rules! decl_module { { $( $other_where_bounds )* } { $( $deposit_event )* } { $( $on_initialize )* } + { $( $on_runtime_upgrade )* } { #[weight = $weight] fn on_finalize( $( $param_name : $param ),* ) { $( $impl )* } @@ -389,6 +402,85 @@ macro_rules! decl_module { $($rest)* ); }; + // Add on_runtime_upgrade, without a given weight. + (@normalize + $(#[$attr:meta])* + pub struct $mod_type:ident< + $trait_instance:ident: $trait_name:ident$(, I: $instantiable:path $(= $module_default_instance:path)?)? + > + for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident + { $( $other_where_bounds:tt )* } + { $( $deposit_event:tt )* } + { $( $on_initialize:tt )* } + {} + { $( $on_finalize:tt )* } + { $( $offchain:tt )* } + { $( $constants:tt )* } + { $( $error_type:tt )* } + [ $( $dispatchables:tt )* ] + $(#[doc = $doc_attr:tt])* + fn on_runtime_upgrade( $( $param_name:ident : $param:ty ),* $(,)? ) { $( $impl:tt )* } + $($rest:tt)* + ) => { + $crate::decl_module!(@normalize + $(#[$attr])* + pub struct $mod_type<$trait_instance: $trait_name$(, I: $instantiable $(= $module_default_instance)?)?> + for enum $call_type where origin: $origin_type, system = $system + { $( $other_where_bounds )* } + { $( $deposit_event )* } + { $( $on_initialize )* } + { + #[weight = $crate::dispatch::SimpleDispatchInfo::zero()] + fn on_runtime_upgrade( $( $param_name : $param ),* ) { $( $impl )* } + } + { $( $on_finalize )* } + { $( $offchain )* } + { $( $constants )* } + { $( $error_type )* } + [ $( $dispatchables )* ] + $($rest)* + ); + }; + // Add on_runtime_upgrade, given weight. + (@normalize + $(#[$attr:meta])* + pub struct $mod_type:ident< + $trait_instance:ident: $trait_name:ident$(, I: $instantiable:path $(= $module_default_instance:path)?)? + > + for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident + { $( $other_where_bounds:tt )* } + { $( $deposit_event:tt )* } + { $( $on_initialize:tt )* } + {} + { $( $on_finalize:tt )* } + { $( $offchain:tt )* } + { $( $constants:tt )* } + { $( $error_type:tt )* } + [ $( $dispatchables:tt )* ] + $(#[doc = $doc_attr:tt])* + #[weight = $weight:expr] + fn on_runtime_upgrade( $( $param_name:ident : $param:ty ),* $(,)? ) { $( $impl:tt )* } + $($rest:tt)* + ) => { + $crate::decl_module!(@normalize + $(#[$attr])* + pub struct $mod_type<$trait_instance: $trait_name$(, I: $instantiable $(= $module_default_instance)?)?> + for enum $call_type where origin: $origin_type, system = $system + { $( $other_where_bounds )* } + { $( $deposit_event )* } + { $( $on_initialize )* } + { + #[weight = $weight] + fn on_runtime_upgrade( $( $param_name : $param ),* ) { $( $impl )* } + } + { $( $on_finalize )* } + { $( $offchain )* } + { $( $constants )* } + { $( $error_type )* } + [ $( $dispatchables )* ] + $($rest)* + ); + }; // Add on_initialize, without a given weight. (@normalize $(#[$attr:meta])* @@ -399,6 +491,7 @@ macro_rules! decl_module { { $( $other_where_bounds:tt )* } { $( $deposit_event:tt )* } {} + { $( $on_runtime_upgrade:tt )* } { $( $on_finalize:tt )* } { $( $offchain:tt )* } { $( $constants:tt )* } @@ -418,6 +511,7 @@ macro_rules! decl_module { #[weight = $crate::dispatch::SimpleDispatchInfo::zero()] fn on_initialize( $( $param_name : $param ),* ) { $( $impl )* } } + { $( $on_runtime_upgrade )* } { $( $on_finalize )* } { $( $offchain )* } { $( $constants )* } @@ -436,6 +530,7 @@ macro_rules! decl_module { { $( $other_where_bounds:tt )* } { $( $deposit_event:tt )* } {} + { $( $on_runtime_upgrade:tt )* } { $( $on_finalize:tt )* } { $( $offchain:tt )* } { $( $constants:tt )* } @@ -456,6 +551,7 @@ macro_rules! decl_module { #[weight = $weight] fn on_initialize( $( $param_name : $param ),* ) { $( $impl )* } } + { $( $on_runtime_upgrade )* } { $( $on_finalize )* } { $( $offchain )* } { $( $constants )* } @@ -474,6 +570,7 @@ macro_rules! decl_module { { $( $other_where_bounds:tt )* } { $( $deposit_event:tt )* } { $( $on_initialize:tt )* } + { $( $on_runtime_upgrade:tt )* } { $( $on_finalize:tt )* } { } { $( $constants:tt )* } @@ -492,6 +589,7 @@ macro_rules! decl_module { { $( $other_where_bounds )* } { $( $deposit_event )* } { $( $on_initialize )* } + { $( $on_runtime_upgrade )* } { $( $on_finalize )* } { fn offchain_worker( $( $param_name : $param ),* ) { $( $impl )* } } { $( $constants )* } @@ -512,6 +610,7 @@ macro_rules! decl_module { { $( $other_where_bounds:tt )* } { $( $deposit_event:tt )* } { $( $on_initialize:tt )* } + { $( $on_runtime_upgrade:tt )* } { $( $on_finalize:tt )* } { $( $offchain:tt )* } { $( $constants:tt )* } @@ -531,6 +630,7 @@ macro_rules! decl_module { { $( $other_where_bounds )* } { $( $deposit_event )* } { $( $on_initialize )* } + { $( $on_runtime_upgrade )* } { $( $on_finalize )* } { $( $offchain )* } { @@ -555,6 +655,7 @@ macro_rules! decl_module { { $( $other_where_bounds:tt )* } { $( $deposit_event:tt )* } { $( $on_initialize:tt )* } + { $( $on_runtime_upgrade:tt )* } { $( $on_finalize:tt )* } { $( $offchain:tt )* } { $( $constants:tt )* } @@ -573,6 +674,7 @@ macro_rules! decl_module { { $( $other_where_bounds )* } { $( $deposit_event )* } { $( $on_initialize )* } + { $( $on_runtime_upgrade )* } { $( $on_finalize )* } { $( $offchain )* } { $( $constants )* } @@ -592,6 +694,7 @@ macro_rules! decl_module { { $( $other_where_bounds:tt )* } { $( $deposit_event:tt )* } { $( $on_initialize:tt )* } + { $( $on_runtime_upgrade:tt )* } { $( $on_finalize:tt )* } { $( $offchain:tt )* } { $( $constants:tt )* } @@ -608,6 +711,7 @@ macro_rules! decl_module { { $( $other_where_bounds )* } { $( $deposit_event )* } { $( $on_initialize )* } + { $( $on_runtime_upgrade )* } { $( $on_finalize )* } { $( $offchain )* } { $( $constants )* } @@ -628,6 +732,7 @@ macro_rules! decl_module { { $( $other_where_bounds:tt )* } { $( $deposit_event:tt )* } { $( $on_initialize:tt )* } + { $( $on_runtime_upgrade:tt )* } { $( $on_finalize:tt )* } { $( $offchain:tt )* } { $( $constants:tt )* } @@ -649,6 +754,7 @@ macro_rules! decl_module { { $( $other_where_bounds )* } { $( $deposit_event )* } { $( $on_initialize )* } + { $( $on_runtime_upgrade )* } { $( $on_finalize )* } { $( $offchain )* } { $( $constants )* } @@ -676,6 +782,7 @@ macro_rules! decl_module { { $( $other_where_bounds:tt )* } { $( $deposit_event:tt )* } { $( $on_initialize:tt )* } + { $( $on_runtime_upgrade:tt )* } { $( $on_finalize:tt )* } { $( $offchain:tt )* } { $( $constants:tt )* } @@ -696,6 +803,7 @@ macro_rules! decl_module { { $( $other_where_bounds )* } { $( $deposit_event )* } { $( $on_initialize )* } + { $( $on_runtime_upgrade )* } { $( $on_finalize )* } { $( $offchain )* } { $( $constants )* } @@ -717,6 +825,7 @@ macro_rules! decl_module { { $( $other_where_bounds:tt )* } { $( $deposit_event:tt )* } { $( $on_initialize:tt )* } + { $( $on_runtime_upgrade:tt )* } { $( $on_finalize:tt )* } { $( $offchain:tt )* } { $( $constants:tt )* } @@ -742,6 +851,7 @@ macro_rules! decl_module { { $( $other_where_bounds:tt )* } { $( $deposit_event:tt )* } { $( $on_initialize:tt )* } + { $( $on_runtime_upgrade:tt )* } { $( $on_finalize:tt )* } { $( $offchain:tt )* } { $( $constants:tt )* } @@ -767,6 +877,7 @@ macro_rules! decl_module { { $( $other_where_bounds:tt )* } { $( $deposit_event:tt )* } { $( $on_initialize:tt )* } + { $( $on_runtime_upgrade:tt )* } { $( $on_finalize:tt )* } { $( $offchain:tt )* } { $( $constants:tt )* } @@ -793,6 +904,7 @@ macro_rules! decl_module { { $( $other_where_bounds:tt )* } { $( $deposit_event:tt )* } { $( $on_initialize:tt )* } + { $( $on_runtime_upgrade:tt )* } { $( $on_finalize:tt )* } { $( $offchain:tt )* } { $( $constants:tt )* } @@ -808,6 +920,7 @@ macro_rules! decl_module { { $( $other_where_bounds )* } { $( $deposit_event )* } { $( $on_initialize )* } + { $( $on_runtime_upgrade )* } { $( $on_finalize )* } { $( $offchain )* } { $( $constants )* } @@ -903,6 +1016,39 @@ macro_rules! decl_module { {} }; + (@impl_on_runtime_upgrade + $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; + { $( $other_where_bounds:tt )* } + #[weight = $weight:expr] + fn on_runtime_upgrade() { $( $impl:tt )* } + ) => { + impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> + $crate::sp_runtime::traits::OnRuntimeUpgrade + for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )* + { + fn on_runtime_upgrade() { + use $crate::sp_std::if_std; + if_std! { + use $crate::tracing; + let span = tracing::span!(tracing::Level::DEBUG, "on_runtime_upgrade"); + let _enter = span.enter(); + } + { $( $impl )* } + } + } + }; + + (@impl_on_runtime_upgrade + $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; + { $( $other_where_bounds:tt )* } + ) => { + impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> + $crate::sp_runtime::traits::OnRuntimeUpgrade + for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )* + {} + }; + + (@impl_on_finalize $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; { $( $other_where_bounds:tt )* } @@ -961,6 +1107,10 @@ macro_rules! decl_module { (@impl_block_hooks_weight $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; { $( $other_where_bounds:tt )* } + @runtime_upgrade $( + #[weight = $weight_runtime_update:expr] + fn on_runtime_upgrade($( $param_runtime_upgrade:ident : $param_ty_runtime_upgrade:ty )*) { $( $impl_runtime_upgrade:tt )* } + )? @init $( #[weight = $weight_initialize:expr] fn on_initialize($( $param_initialize:ident : $param_ty_initialize:ty )*) { $( $impl_initialize:tt )* } @@ -974,6 +1124,11 @@ macro_rules! decl_module { $crate::dispatch::WeighBlock<$trait_instance::BlockNumber> for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )* { + $( + fn on_runtime_upgrade() -> $crate::dispatch::Weight { + >::weigh_data(&$weight_initialize, ()) + } + )? $( fn on_initialize(n: $trait_instance::BlockNumber) -> $crate::dispatch::Weight { >::weigh_data(&$weight_initialize, n) @@ -1208,6 +1363,7 @@ macro_rules! decl_module { { $( $other_where_bounds:tt )* } { $( $deposit_event:tt )* } { $( $on_initialize:tt )* } + { $( $on_runtime_upgrade:tt )* } { $( $on_finalize:tt )* } { $( $offchain:tt )* } { $( $constants:tt )* } @@ -1231,6 +1387,14 @@ macro_rules! decl_module { $( $on_initialize )* } + $crate::decl_module! { + @impl_on_runtime_upgrade + $mod_type<$trait_instance: $trait_name $(, $instance: $instantiable)?>; + { $( $other_where_bounds )* } + $( $on_runtime_upgrade )* + } + + $crate::decl_module! { @impl_on_finalize $mod_type<$trait_instance: $trait_name $(, $instance: $instantiable)?>; @@ -1242,6 +1406,7 @@ macro_rules! decl_module { @impl_block_hooks_weight $mod_type<$trait_instance: $trait_name $(, $instance: $instantiable)?>; { $( $other_where_bounds )* } + @runtime_upgrade $( $on_runtime_upgrade )* @init $( $on_initialize )* @fin $( $on_finalize )* } @@ -1869,6 +2034,9 @@ macro_rules! __check_reserved_fn_name { (on_initialize $( $rest:ident )*) => { $crate::__check_reserved_fn_name!(@compile_error on_initialize); }; + (on_runtime_upgrade $( $rest:ident )*) => { + $crate::__check_reserved_fn_name!(@compile_error on_runtime_upgrade); + }; (on_initialise $( $rest:ident )*) => { $crate::__check_reserved_fn_name!(@compile_error_renamed on_initialise on_initialize); }; diff --git a/frame/support/src/weights.rs b/frame/support/src/weights.rs index c46cca683ba93..883aed693ddda 100644 --- a/frame/support/src/weights.rs +++ b/frame/support/src/weights.rs @@ -70,6 +70,8 @@ pub trait ClassifyDispatch { /// Means of determining the weight of a block's life cycle hooks: `on_initialize`, `on_finalize` and /// such. pub trait WeighBlock { + /// Return the weight of the block's on_runtime_upgrade hook. + fn on_runtime_upgrade() -> Weight { Zero::zero() } /// Return the weight of the block's on_initialize hook. fn on_initialize(_: BlockNumber) -> Weight { Zero::zero() } /// Return the weight of the block's on_finalize hook. @@ -87,6 +89,14 @@ pub trait PaysFee { /// Maybe I can do something to remove the duplicate code here. #[impl_for_tuples(30)] impl WeighBlock for SingleModule { + fn on_runtime_upgrade() -> Weight { + let mut accumulated_weight: Weight = Zero::zero(); + for_tuples!( + #( accumulated_weight = accumulated_weight.saturating_add(SingleModule::on_runtime_upgrade()); )* + ); + accumulated_weight + } + fn on_initialize(n: BlockNumber) -> Weight { let mut accumulated_weight: Weight = Zero::zero(); for_tuples!( diff --git a/frame/support/test/Cargo.toml b/frame/support/test/Cargo.toml index df66918a2e862..0a5595914b07b 100644 --- a/frame/support/test/Cargo.toml +++ b/frame/support/test/Cargo.toml @@ -10,13 +10,13 @@ repository = "https://github.com/paritytech/substrate/" [dependencies] serde = { version = "1.0.101", default-features = false, features = ["derive"] } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-io ={ path = "../../../primitives/io", default-features = false , version = "2.0.0-dev"} -sp-state-machine = { version = "0.8.0-dev", optional = true, path = "../../../primitives/state-machine" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../" } -sp-inherents = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/inherents" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/runtime" } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../../primitives/core" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-io ={ path = "../../../primitives/io", default-features = false , version = "2.0.0-alpha.2"} +sp-state-machine = { version = "0.8.0-alpha.2", optional = true, path = "../../../primitives/state-machine" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../" } +sp-inherents = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/inherents" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/runtime" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../../primitives/core" } trybuild = "1.0.17" pretty_assertions = "0.6.1" diff --git a/frame/system/Cargo.toml b/frame/system/Cargo.toml index 0c779e5d34e13..6a418cab8ec8e 100644 --- a/frame/system/Cargo.toml +++ b/frame/system/Cargo.toml @@ -1,26 +1,27 @@ [package] name = "frame-system" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME system module" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../primitives/core" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-io ={ path = "../../primitives/io", default-features = false , version = "2.0.0-dev"} -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-version = { version = "2.0.0-dev", default-features = false, path = "../../primitives/version" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/core" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-io = { path = "../../primitives/io", default-features = false, version = "2.0.0-alpha.2" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-version = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/version" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } impl-trait-for-tuples = "0.1.3" [dev-dependencies] criterion = "0.2.11" -sp-externalities = { version = "0.8.0-dev", path = "../../primitives/externalities" } +sp-externalities = { version = "0.8.0-alpha.2", path = "../../primitives/externalities" } substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../test-utils/runtime/client" } [features] diff --git a/frame/system/rpc/runtime-api/Cargo.toml b/frame/system/rpc/runtime-api/Cargo.toml index 1d1ed8da47ed3..3bcc34698a56e 100644 --- a/frame/system/rpc/runtime-api/Cargo.toml +++ b/frame/system/rpc/runtime-api/Cargo.toml @@ -1,15 +1,16 @@ [package] name = "frame-system-rpc-runtime-api" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Runtime API definition required by System RPC extensions." [dependencies] -sp-api = { version = "2.0.0-dev", default-features = false, path = "../../../../primitives/api" } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } +sp-api = { version = "2.0.0-alpha.2", default-features = false, path = "../../../../primitives/api" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false } [features] default = ["std"] diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index f89c9efbd2962..7968e11082131 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -367,6 +367,9 @@ decl_storage! { /// the `EventIndex` then in case if the topic has the same contents on the next block /// no notification will be triggered thus the event might be lost. EventTopics get(fn event_topics): map hasher(blake2_256) T::Hash => Vec<(T::BlockNumber, EventIndex)>; + + /// Store the block number of last runtime upgrade. + LastRuntimeUpgrade get(fn last_runtime_upgrade): Option; } add_extra_genesis { config(changes_trie_config): Option; @@ -486,6 +489,7 @@ decl_module! { } storage::unhashed::put_raw(well_known_keys::CODE, &code); + >::put(Self::block_number()); Self::deposit_event(RawEvent::CodeUpdated); } @@ -494,6 +498,7 @@ decl_module! { pub fn set_code_without_checks(origin, code: Vec) { ensure_root(origin)?; storage::unhashed::put_raw(well_known_keys::CODE, &code); + >::put(Self::block_number()); Self::deposit_event(RawEvent::CodeUpdated); } diff --git a/frame/timestamp/Cargo.toml b/frame/timestamp/Cargo.toml index 136036b3074e5..db1d9aaf37a8a 100644 --- a/frame/timestamp/Cargo.toml +++ b/frame/timestamp/Cargo.toml @@ -1,28 +1,31 @@ [package] name = "pallet-timestamp" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME Timestamp Module" +documentation = "https://docs.rs/pallet-timestamp" + [dependencies] serde = { version = "1.0.101", optional = true } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-inherents = { version = "2.0.0-dev", default-features = false, path = "../../primitives/inherents" } -frame-benchmarking = { version = "2.0.0-dev", default-features = false, path = "../benchmarking" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } -sp-timestamp = { version = "2.0.0-dev", default-features = false, path = "../../primitives/timestamp" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-inherents = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/inherents" } +frame-benchmarking = { version = "2.0.0-alpha.2", default-features = false, path = "../benchmarking" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } +sp-timestamp = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/timestamp" } impl-trait-for-tuples = "0.1.3" [dev-dependencies] -sp-io ={ version = "2.0.0-dev", path = "../../primitives/io" } -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } +sp-io ={ version = "2.0.0-alpha.2", path = "../../primitives/io" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } [features] default = ["std"] diff --git a/frame/transaction-payment/Cargo.toml b/frame/transaction-payment/Cargo.toml index f989a7e339526..3a291dc516312 100644 --- a/frame/transaction-payment/Cargo.toml +++ b/frame/transaction-payment/Cargo.toml @@ -1,24 +1,25 @@ [package] name = "pallet-transaction-payment" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME pallet to manage transaction payments" [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } -pallet-transaction-payment-rpc-runtime-api = { version = "2.0.0-dev", default-features = false, path = "./rpc/runtime-api" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } +pallet-transaction-payment-rpc-runtime-api = { version = "2.0.0-alpha.2", default-features = false, path = "./rpc/runtime-api" } [dev-dependencies] -sp-io = { version = "2.0.0-dev", path = "../../primitives/io" } -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -pallet-balances = { version = "2.0.0-dev", path = "../balances" } +sp-io = { version = "2.0.0-alpha.2", path = "../../primitives/io" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +pallet-balances = { version = "2.0.0-alpha.2", path = "../balances" } [features] default = ["std"] diff --git a/frame/transaction-payment/rpc/Cargo.toml b/frame/transaction-payment/rpc/Cargo.toml index c8f3aa2776bee..309dfeedd5be4 100644 --- a/frame/transaction-payment/rpc/Cargo.toml +++ b/frame/transaction-payment/rpc/Cargo.toml @@ -1,21 +1,22 @@ [package] name = "pallet-transaction-payment-rpc" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "RPC interface for the transaction payment module." [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0" } +codec = { package = "parity-scale-codec", version = "1.2.0" } jsonrpc-core = "14.0.3" jsonrpc-core-client = "14.0.3" jsonrpc-derive = "14.0.3" -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } -sp-rpc = { version = "2.0.0-dev", path = "../../../primitives/rpc" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } +sp-rpc = { version = "2.0.0-alpha.2", path = "../../../primitives/rpc" } serde = { version = "1.0.101", features = ["derive"] } -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } -sp-api = { version = "2.0.0-dev", path = "../../../primitives/api" } -sp-blockchain = { version = "2.0.0-dev", path = "../../../primitives/blockchain" } -pallet-transaction-payment-rpc-runtime-api = { version = "2.0.0-dev", path = "./runtime-api" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } +sp-api = { version = "2.0.0-alpha.2", path = "../../../primitives/api" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../../primitives/blockchain" } +pallet-transaction-payment-rpc-runtime-api = { version = "2.0.0-alpha.2", path = "./runtime-api" } diff --git a/frame/transaction-payment/rpc/runtime-api/Cargo.toml b/frame/transaction-payment/rpc/runtime-api/Cargo.toml index f42ffabbefe40..96716769a39a8 100644 --- a/frame/transaction-payment/rpc/runtime-api/Cargo.toml +++ b/frame/transaction-payment/rpc/runtime-api/Cargo.toml @@ -1,19 +1,20 @@ [package] name = "pallet-transaction-payment-rpc-runtime-api" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "RPC runtime API for transaction payment FRAME pallet" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-api = { version = "2.0.0-dev", default-features = false, path = "../../../../primitives/api" } -codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../../../primitives/std" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../../../primitives/runtime" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../../../support" } +sp-api = { version = "2.0.0-alpha.2", default-features = false, path = "../../../../primitives/api" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../../../primitives/std" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../../../primitives/runtime" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../../../support" } [dev-dependencies] serde_json = "1.0.41" diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 67b3fa63ac07f..3de0f944debce 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -119,7 +119,8 @@ impl Module { { let dispatch_info = ::get_dispatch_info(&unchecked_extrinsic); - let partial_fee = >::compute_fee(len, dispatch_info, 0u32.into()); + let partial_fee = + >::compute_fee(len, dispatch_info, 0u32.into()); let DispatchInfo { weight, class, .. } = dispatch_info; RuntimeDispatchInfo { weight, class, partial_fee } @@ -165,9 +166,10 @@ impl ChargeTransactionPayment { let len_fee = per_byte.saturating_mul(len); let weight_fee = { - // cap the weight to the maximum defined in runtime, otherwise it will be the `Bounded` - // maximum of its data type, which is not desired. - let capped_weight = info.weight.min(::MaximumBlockWeight::get()); + // cap the weight to the maximum defined in runtime, otherwise it will be the + // `Bounded` maximum of its data type, which is not desired. + let capped_weight = info.weight + .min(::MaximumBlockWeight::get()); T::WeightToFee::convert(capped_weight) }; @@ -248,20 +250,21 @@ mod tests { use super::*; use codec::Encode; use frame_support::{ - parameter_types, impl_outer_origin, impl_outer_dispatch, + impl_outer_dispatch, impl_outer_origin, parameter_types, weights::{DispatchClass, DispatchInfo, GetDispatchInfo, Weight}, }; + use pallet_balances::Call as BalancesCall; + use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; use sp_core::H256; use sp_runtime::{ - Perbill, testing::{Header, TestXt}, - traits::{BlakeTwo256, IdentityLookup, Extrinsic}, + traits::{BlakeTwo256, Extrinsic, IdentityLookup}, + Perbill, }; - use pallet_balances::Call as BalancesCall; - use sp_std::cell::RefCell; - use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; + use std::cell::RefCell; - const CALL: &::Call = &Call::Balances(BalancesCall::transfer(2, 69)); + const CALL: &::Call = + &Call::Balances(BalancesCall::transfer(2, 69)); impl_outer_dispatch! { pub enum Call for Runtime where origin: Origin { @@ -318,7 +321,7 @@ mod tests { type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; } -thread_local! { + thread_local! { static TRANSACTION_BASE_FEE: RefCell = RefCell::new(0); static TRANSACTION_BYTE_FEE: RefCell = RefCell::new(1); static WEIGHT_TO_FEE: RefCell = RefCell::new(1); @@ -373,10 +376,16 @@ thread_local! { } impl ExtBuilder { - pub fn fees(mut self, base: u64, byte: u64, weight: u64) -> Self { - self.base_fee = base; - self.byte_fee = byte; - self.weight_to_fee = weight; + pub fn base_fee(mut self, base_fee: u64) -> Self { + self.base_fee = base_fee; + self + } + pub fn byte_fee(mut self, byte_fee: u64) -> Self { + self.byte_fee = byte_fee; + self + } + pub fn weight_fee(mut self, weight_to_fee: u64) -> Self { + self.weight_to_fee = weight_to_fee; self } pub fn balance_factor(mut self, factor: u64) -> Self { @@ -416,9 +425,9 @@ thread_local! { #[test] fn signed_extension_transaction_payment_work() { - ExtBuilder::default() - .balance_factor(10) // 100 - .fees(5, 1, 1) // 5 fixed, 1 per byte, 1 per weight + ExtBuilder::default() + .balance_factor(10) + .base_fee(5) .build() .execute_with(|| { @@ -441,9 +450,9 @@ thread_local! { #[test] fn signed_extension_transaction_payment_is_bounded() { - ExtBuilder::default() + ExtBuilder::default() .balance_factor(1000) - .fees(0, 0, 1) + .byte_fee(0) .build() .execute_with(|| { @@ -464,7 +473,7 @@ thread_local! { #[test] fn signed_extension_allows_free_transactions() { ExtBuilder::default() - .fees(100, 1, 1) + .base_fee(100) .balance_factor(0) .build() .execute_with(|| @@ -503,7 +512,7 @@ thread_local! { #[test] fn signed_ext_length_fee_is_also_updated_per_congestion() { ExtBuilder::default() - .fees(5, 1, 1) + .base_fee(5) .balance_factor(10) .build() .execute_with(|| @@ -531,7 +540,8 @@ thread_local! { let ext = xt.encode(); let len = ext.len() as u32; ExtBuilder::default() - .fees(5, 1, 2) + .base_fee(5) + .weight_fee(2) .build() .execute_with(|| { @@ -558,10 +568,11 @@ thread_local! { #[test] fn compute_fee_works_without_multiplier() { ExtBuilder::default() - .fees(100, 10, 1) - .balance_factor(0) - .build() - .execute_with(|| + .base_fee(100) + .byte_fee(10) + .balance_factor(0) + .build() + .execute_with(|| { // Next fee multiplier is zero assert_eq!(NextFeeMultiplier::get(), Fixed64::from_natural(0)); @@ -597,10 +608,11 @@ thread_local! { #[test] fn compute_fee_works_with_multiplier() { ExtBuilder::default() - .fees(100, 10, 1) - .balance_factor(0) - .build() - .execute_with(|| + .base_fee(100) + .byte_fee(10) + .balance_factor(0) + .build() + .execute_with(|| { // Add a next fee multiplier NextFeeMultiplier::put(Fixed64::from_rational(1, 2)); // = 1/2 = .5 @@ -629,10 +641,11 @@ thread_local! { #[test] fn compute_fee_does_not_overflow() { ExtBuilder::default() - .fees(100, 10, 1) - .balance_factor(0) - .build() - .execute_with(|| + .base_fee(100) + .byte_fee(10) + .balance_factor(0) + .build() + .execute_with(|| { // Overflow is handled let dispatch_info = DispatchInfo { diff --git a/frame/treasury/Cargo.toml b/frame/treasury/Cargo.toml index cac17bd8ad679..99071e927635e 100644 --- a/frame/treasury/Cargo.toml +++ b/frame/treasury/Cargo.toml @@ -1,24 +1,25 @@ [package] name = "pallet-treasury" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME pallet to manage treasury" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } -pallet-balances = { version = "2.0.0-dev", default-features = false, path = "../balances" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } +pallet-balances = { version = "2.0.0-alpha.2", default-features = false, path = "../balances" } [dev-dependencies] -sp-io ={ version = "2.0.0-dev", path = "../../primitives/io" } -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } +sp-io ={ version = "2.0.0-alpha.2", path = "../../primitives/io" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } [features] default = ["std"] diff --git a/frame/utility/Cargo.toml b/frame/utility/Cargo.toml index 3514a39739495..46f59a191ae9f 100644 --- a/frame/utility/Cargo.toml +++ b/frame/utility/Cargo.toml @@ -1,25 +1,26 @@ [package] name = "pallet-utility" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME utilities pallet" [dependencies] serde = { version = "1.0.101", optional = true } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../primitives/core" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/core" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } [dev-dependencies] -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -pallet-balances = { version = "2.0.0-dev", path = "../balances" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +pallet-balances = { version = "2.0.0-alpha.2", path = "../balances" } [features] default = ["std"] diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index 76f3ca6bf6261..0b60532c3dd23 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -538,7 +538,7 @@ impl Module { pub fn timepoint() -> Timepoint { Timepoint { height: >::block_number(), - index: >::extrinsic_count(), + index: >::extrinsic_index().unwrap_or_default(), } } diff --git a/frame/vesting/Cargo.toml b/frame/vesting/Cargo.toml index f1bf0812deb90..f01a0f6bf22b9 100644 --- a/frame/vesting/Cargo.toml +++ b/frame/vesting/Cargo.toml @@ -1,26 +1,27 @@ [package] name = "pallet-vesting" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME pallet for manage vesting" [dependencies] serde = { version = "1.0.101", optional = true } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } enumflags2 = { version = "0.6.2" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../support" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../system" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../support" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../system" } [dev-dependencies] -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -pallet-balances = { version = "2.0.0-dev", path = "../balances" } -sp-storage = { version = "2.0.0-dev", path = "../../primitives/storage" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +pallet-balances = { version = "2.0.0-alpha.2", path = "../balances" } +sp-storage = { version = "2.0.0-alpha.2", path = "../../primitives/storage" } hex-literal = "0.2.1" [features] diff --git a/primitives/allocator/Cargo.toml b/primitives/allocator/Cargo.toml index c122931850bc7..944cfa6de19d5 100644 --- a/primitives/allocator/Cargo.toml +++ b/primitives/allocator/Cargo.toml @@ -1,16 +1,18 @@ [package] name = "sp-allocator" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Collection of allocator implementations." +documentation = "https://docs.rs/sp-allocator" [dependencies] -sp-std = { version = "2.0.0-dev", path = "../std", default-features = false } -sp-core = { version = "2.0.0-dev", path = "../core", default-features = false } -sp-wasm-interface = { version = "2.0.0-dev", path = "../wasm-interface", default-features = false } +sp-std = { version = "2.0.0-alpha.2", path = "../std", default-features = false } +sp-core = { version = "2.0.0-alpha.2", path = "../core", default-features = false } +sp-wasm-interface = { version = "2.0.0-alpha.2", path = "../wasm-interface", default-features = false } log = { version = "0.4.8", optional = true } derive_more = { version = "0.99.2", optional = true } diff --git a/primitives/api/Cargo.toml b/primitives/api/Cargo.toml index 503dedc34d89a..a33ff0fa0d754 100644 --- a/primitives/api/Cargo.toml +++ b/primitives/api/Cargo.toml @@ -1,20 +1,21 @@ [package] name = "sp-api" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Substrate runtime api primitives" [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -sp-api-proc-macro = { version = "2.0.0-dev", path = "proc-macro" } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../core" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../std" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../runtime" } -sp-version = { version = "2.0.0-dev", default-features = false, path = "../version" } -sp-state-machine = { version = "0.8.0-dev", optional = true, path = "../../primitives/state-machine" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false } +sp-api-proc-macro = { version = "2.0.0-alpha.2", path = "proc-macro" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../core" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../std" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../runtime" } +sp-version = { version = "2.0.0-alpha.2", default-features = false, path = "../version" } +sp-state-machine = { version = "0.8.0-alpha.2", optional = true, path = "../../primitives/state-machine" } hash-db = { version = "0.15.2", optional = true } [dev-dependencies] diff --git a/primitives/api/proc-macro/Cargo.toml b/primitives/api/proc-macro/Cargo.toml index f9a56842ad661..e031f97ba9bb8 100644 --- a/primitives/api/proc-macro/Cargo.toml +++ b/primitives/api/proc-macro/Cargo.toml @@ -1,11 +1,14 @@ [package] name = "sp-api-proc-macro" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Macros for declaring and implementing runtime apis." +documentation = "https://docs.rs/sp-api-proc-macro" + [lib] proc-macro = true diff --git a/primitives/api/test/Cargo.toml b/primitives/api/test/Cargo.toml index f94f97d2e7a0b..6d2207c178a22 100644 --- a/primitives/api/test/Cargo.toml +++ b/primitives/api/test/Cargo.toml @@ -9,14 +9,15 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -sp-api = { version = "2.0.0-dev", path = "../" } +sp-api = { version = "2.0.0-alpha.2", path = "../" } substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../../test-utils/runtime/client" } -sp-version = { version = "2.0.0-dev", path = "../../version" } -sp-runtime = { version = "2.0.0-dev", path = "../../runtime" } -sp-blockchain = { version = "2.0.0-dev", path = "../../blockchain" } -sp-consensus = { version = "0.8.0-dev", path = "../../../primitives/consensus/common" } -codec = { package = "parity-scale-codec", version = "1.0.0" } -sp-state-machine = { version = "0.8.0-dev", path = "../../../primitives/state-machine" } +sp-version = { version = "2.0.0-alpha.2", path = "../../version" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../runtime" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../blockchain" } +sp-consensus = { version = "0.8.0-alpha.2", path = "../../../primitives/consensus/common" } +sc-block-builder = { version = "0.8.0-alpha.2", path = "../../../client/block-builder" } +codec = { package = "parity-scale-codec", version = "1.2.0" } +sp-state-machine = { version = "0.8.0-alpha.2", path = "../../../primitives/state-machine" } trybuild = "1.0.17" rustversion = "1.0.0" diff --git a/primitives/api/test/tests/runtime_calls.rs b/primitives/api/test/tests/runtime_calls.rs index 66412edae026d..6a3af7469cc0e 100644 --- a/primitives/api/test/tests/runtime_calls.rs +++ b/primitives/api/test/tests/runtime_calls.rs @@ -28,6 +28,7 @@ use sp_state_machine::{ use sp_consensus::SelectChain; use codec::Encode; +use sc_block_builder::BlockBuilderProvider; fn calling_function_with_strat(strat: ExecutionStrategy) { let client = TestClientBuilder::new().set_execution_strategy(strat).build(); diff --git a/primitives/application-crypto/Cargo.toml b/primitives/application-crypto/Cargo.toml index 4459389dc6a28..ee710b29885a3 100644 --- a/primitives/application-crypto/Cargo.toml +++ b/primitives/application-crypto/Cargo.toml @@ -1,19 +1,21 @@ [package] name = "sp-application-crypto" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" description = "Provides facilities for generating application specific crypto wrapper types." license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +documentation = "https://docs.rs/sp-application-crypto" + [dependencies] -sp-core = { version = "2.0.0-dev", default-features = false, path = "../core" } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../core" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../std" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../std" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } [features] default = [ "std" ] @@ -23,7 +25,7 @@ std = [ "full_crypto", "sp-core/std", "codec/std", "serde", "sp-std/std", "sp-io # or Intel SGX. # For the regular wasm runtime builds this should not be used. full_crypto = [ - "sp-core/full_crypto", + "sp-core/full_crypto", # Don't add `panic_handler` and `alloc_error_handler` since they are expected to be provided # by the user anyway. "sp-io/disable_panic_handler", diff --git a/primitives/application-crypto/test/Cargo.toml b/primitives/application-crypto/test/Cargo.toml index cc2fd0abd278d..0ed5355ce2d1e 100644 --- a/primitives/application-crypto/test/Cargo.toml +++ b/primitives/application-crypto/test/Cargo.toml @@ -10,8 +10,8 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../core" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../core" } substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../../test-utils/runtime/client" } -sp-runtime = { version = "2.0.0-dev", path = "../../runtime" } -sp-api = { version = "2.0.0-dev", path = "../../api" } -sp-application-crypto = { version = "2.0.0-dev", path = "../" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../runtime" } +sp-api = { version = "2.0.0-alpha.2", path = "../../api" } +sp-application-crypto = { version = "2.0.0-alpha.2", path = "../" } diff --git a/primitives/arithmetic/Cargo.toml b/primitives/arithmetic/Cargo.toml index f327d091f635e..617e8b8e5ceb8 100644 --- a/primitives/arithmetic/Cargo.toml +++ b/primitives/arithmetic/Cargo.toml @@ -1,19 +1,22 @@ [package] name = "sp-arithmetic" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Minimal fixed point arithmetic primitives and types for runtime." +documentation = "https://docs.rs/sp-arithmetic" + [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } integer-sqrt = "0.1.2" num-traits = { version = "0.2.8", default-features = false } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../std" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../std" } serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-debug-derive = { version = "2.0.0-dev", default-features = false, path = "../../primitives/debug-derive" } +sp-debug-derive = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/debug-derive" } [dev-dependencies] primitive-types = "0.6.2" diff --git a/primitives/authority-discovery/Cargo.toml b/primitives/authority-discovery/Cargo.toml index 765f3a14c4d9e..b4197c56d7e5f 100644 --- a/primitives/authority-discovery/Cargo.toml +++ b/primitives/authority-discovery/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sp-authority-discovery" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] description = "Authority discovery primitives" edition = "2018" @@ -9,11 +9,11 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -sp-application-crypto = { version = "2.0.0-dev", default-features = false, path = "../application-crypto" } -codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../std" } -sp-api = { version = "2.0.0-dev", default-features = false, path = "../api" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../runtime" } +sp-application-crypto = { version = "2.0.0-alpha.2", default-features = false, path = "../application-crypto" } +codec = { package = "parity-scale-codec", default-features = false, version = "1.2.0" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../std" } +sp-api = { version = "2.0.0-alpha.2", default-features = false, path = "../api" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../runtime" } [features] default = ["std"] diff --git a/primitives/authorship/Cargo.toml b/primitives/authorship/Cargo.toml index 8bf4e935a20b3..c5215631cca28 100644 --- a/primitives/authorship/Cargo.toml +++ b/primitives/authorship/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sp-authorship" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] description = "Authorship primitives" edition = "2018" @@ -9,10 +9,10 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -sp-inherents = { version = "2.0.0-dev", default-features = false, path = "../inherents" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../runtime" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../std" } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +sp-inherents = { version = "2.0.0-alpha.2", default-features = false, path = "../inherents" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../runtime" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../std" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } [features] default = [ "std" ] diff --git a/primitives/block-builder/Cargo.toml b/primitives/block-builder/Cargo.toml index c8f6c864498bd..b5cb592d55b41 100644 --- a/primitives/block-builder/Cargo.toml +++ b/primitives/block-builder/Cargo.toml @@ -1,18 +1,19 @@ [package] name = "sp-block-builder" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "The block builder runtime api." [dependencies] -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../runtime" } -sp-api = { version = "2.0.0-dev", default-features = false, path = "../api" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../std" } -codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false } -sp-inherents = { version = "2.0.0-dev", default-features = false, path = "../inherents" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../runtime" } +sp-api = { version = "2.0.0-alpha.2", default-features = false, path = "../api" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../std" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false } +sp-inherents = { version = "2.0.0-alpha.2", default-features = false, path = "../inherents" } [features] default = [ "std" ] diff --git a/primitives/blockchain/Cargo.toml b/primitives/blockchain/Cargo.toml index afaca88fe5600..5fb8ce3574719 100644 --- a/primitives/blockchain/Cargo.toml +++ b/primitives/blockchain/Cargo.toml @@ -1,19 +1,22 @@ [package] name = "sp-blockchain" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Substrate blockchain traits and primitives." +documentation = "https://docs.rs/sp-blockchain" + [dependencies] log = "0.4.8" lru = "0.4.0" parking_lot = "0.10.0" derive_more = "0.99.2" -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-consensus = { version = "0.8.0-dev", path = "../consensus/common" } -sp-runtime = { version = "2.0.0-dev", path = "../runtime" } -sp-block-builder = { version = "2.0.0-dev", path = "../block-builder" } -sp-state-machine = { version = "0.8.0-dev", path = "../state-machine" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-consensus = { version = "0.8.0-alpha.2", path = "../consensus/common" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../runtime" } +sp-block-builder = { version = "2.0.0-alpha.2", path = "../block-builder" } +sp-state-machine = { version = "0.8.0-alpha.2", path = "../state-machine" } diff --git a/primitives/consensus/aura/Cargo.toml b/primitives/consensus/aura/Cargo.toml index 55311ccf7e011..04d411939975f 100644 --- a/primitives/consensus/aura/Cargo.toml +++ b/primitives/consensus/aura/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sp-consensus-aura" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] description = "Primitives for Aura consensus" edition = "2018" @@ -9,13 +9,13 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -sp-application-crypto = { version = "2.0.0-dev", default-features = false, path = "../../application-crypto" } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../std" } -sp-api = { version = "2.0.0-dev", default-features = false, path = "../../api" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../runtime" } -sp-inherents = { version = "2.0.0-dev", default-features = false, path = "../../inherents" } -sp-timestamp = { version = "2.0.0-dev", default-features = false, path = "../../timestamp" } +sp-application-crypto = { version = "2.0.0-alpha.2", default-features = false, path = "../../application-crypto" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../std" } +sp-api = { version = "2.0.0-alpha.2", default-features = false, path = "../../api" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../runtime" } +sp-inherents = { version = "2.0.0-alpha.2", default-features = false, path = "../../inherents" } +sp-timestamp = { version = "2.0.0-alpha.2", default-features = false, path = "../../timestamp" } [features] default = ["std"] diff --git a/primitives/consensus/babe/Cargo.toml b/primitives/consensus/babe/Cargo.toml index e0941f58c73c1..f910b73ed6e00 100644 --- a/primitives/consensus/babe/Cargo.toml +++ b/primitives/consensus/babe/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sp-consensus-babe" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] description = "Primitives for BABE consensus" edition = "2018" @@ -9,15 +9,15 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -sp-application-crypto = { version = "2.0.0-dev", default-features = false, path = "../../application-crypto" } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../std" } +sp-application-crypto = { version = "2.0.0-alpha.2", default-features = false, path = "../../application-crypto" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../std" } schnorrkel = { version = "0.8.5", features = ["preaudit_deprecated"], optional = true } -sp-api = { version = "2.0.0-dev", default-features = false, path = "../../api" } -sp-consensus = { version = "0.8.0-dev", optional = true, path = "../common" } -sp-inherents = { version = "2.0.0-dev", default-features = false, path = "../../inherents" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../runtime" } -sp-timestamp = { version = "2.0.0-dev", default-features = false, path = "../../timestamp" } +sp-api = { version = "2.0.0-alpha.2", default-features = false, path = "../../api" } +sp-consensus = { version = "0.8.0-alpha.2", optional = true, path = "../common" } +sp-inherents = { version = "2.0.0-alpha.2", default-features = false, path = "../../inherents" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../runtime" } +sp-timestamp = { version = "2.0.0-alpha.2", default-features = false, path = "../../timestamp" } [features] default = ["std"] diff --git a/primitives/consensus/common/Cargo.toml b/primitives/consensus/common/Cargo.toml index 56901983fd2fe..e8d3c0c6118d0 100644 --- a/primitives/consensus/common/Cargo.toml +++ b/primitives/consensus/common/Cargo.toml @@ -1,27 +1,29 @@ [package] name = "sp-consensus" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] -description = "Common utilities for substrate consensus" edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Common utilities for building and using consensus engines in substrate." +documentation = "https://docs.rs/sp-consensus/" + [dependencies] derive_more = "0.99.2" -libp2p = { version = "0.16.1", default-features = false } +libp2p = { version = "0.16.2", default-features = false } log = "0.4.8" -sp-core = { path= "../../core" , version = "2.0.0-dev"} -sp-inherents = { version = "2.0.0-dev", path = "../../inherents" } -sp-state-machine = { version = "0.8.0-dev", path = "../../../primitives/state-machine" } +sp-core = { path= "../../core" , version = "2.0.0-alpha.2"} +sp-inherents = { version = "2.0.0-alpha.2", path = "../../inherents" } +sp-state-machine = { version = "0.8.0-alpha.2", path = "../../../primitives/state-machine" } futures = { version = "0.3.1", features = ["thread-pool"] } futures-timer = "3.0.1" futures-diagnose = "1.0" -sp-std = { version = "2.0.0-dev", path = "../../std" } -sp-version = { version = "2.0.0-dev", path = "../../version" } -sp-runtime = { version = "2.0.0-dev", path = "../../runtime" } -codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } +sp-std = { version = "2.0.0-alpha.2", path = "../../std" } +sp-version = { version = "2.0.0-alpha.2", path = "../../version" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../runtime" } +codec = { package = "parity-scale-codec", version = "1.2.0", features = ["derive"] } parking_lot = "0.10.0" serde = { version = "1.0", features = ["derive"] } diff --git a/primitives/consensus/pow/Cargo.toml b/primitives/consensus/pow/Cargo.toml index 25b7f01a80ea6..4abead3258f81 100644 --- a/primitives/consensus/pow/Cargo.toml +++ b/primitives/consensus/pow/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sp-consensus-pow" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] description = "Primitives for Aura consensus" edition = "2018" @@ -9,11 +9,11 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -sp-api = { version = "2.0.0-dev", default-features = false, path = "../../api" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../std" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../runtime" } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../core" } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +sp-api = { version = "2.0.0-alpha.2", default-features = false, path = "../../api" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../std" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../runtime" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../core" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } [features] default = ["std"] diff --git a/primitives/core/Cargo.toml b/primitives/core/Cargo.toml index 1241c277dde01..83ef683a39a79 100644 --- a/primitives/core/Cargo.toml +++ b/primitives/core/Cargo.toml @@ -1,15 +1,17 @@ [package] name = "sp-core" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Shareable Substrate types." +documentation = "https://docs.rs/sp-core" [dependencies] -sp-std = { version = "2.0.0-dev", default-features = false, path = "../std" } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../std" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } rustc-hex = { version = "2.0.1", default-features = false } log = { version = "0.4.8", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } @@ -28,9 +30,9 @@ num-traits = { version = "0.2.8", default-features = false } zeroize = { version = "1.0.0", default-features = false } lazy_static = { version = "1.4.0", default-features = false, optional = true } parking_lot = { version = "0.10.0", optional = true } -sp-debug-derive = { version = "2.0.0-dev", path = "../debug-derive" } -sp-externalities = { version = "0.8.0-dev", optional = true, path = "../externalities" } -sp-storage = { version = "2.0.0-dev", default-features = false, path = "../storage" } +sp-debug-derive = { version = "2.0.0-alpha.2", path = "../debug-derive" } +sp-externalities = { version = "0.8.0-alpha.2", optional = true, path = "../externalities" } +sp-storage = { version = "2.0.0-alpha.2", default-features = false, path = "../storage" } libsecp256k1 = { version = "0.3.2", default-features = false, features = ["hmac"] } parity-util-mem = { version = "0.5.1", default-features = false, features = ["primitive-types"] } @@ -43,10 +45,10 @@ sha2 = { version = "0.8.0", default-features = false, optional = true } hex = { version = "0.4", default-features = false, optional = true } twox-hash = { version = "1.5.0", default-features = false, optional = true } -sp-runtime-interface = { version = "2.0.0-dev", default-features = false, path = "../runtime-interface" } +sp-runtime-interface = { version = "2.0.0-alpha.2", default-features = false, path = "../runtime-interface" } [dev-dependencies] -sp-serializer = { version = "2.0.0-dev", path = "../serializer" } +sp-serializer = { version = "2.0.0-alpha.2", path = "../serializer" } pretty_assertions = "0.6.1" hex-literal = "0.2.1" rand = "0.7.2" diff --git a/primitives/debug-derive/Cargo.toml b/primitives/debug-derive/Cargo.toml index 248b5d449d359..e15ef594d31d3 100644 --- a/primitives/debug-derive/Cargo.toml +++ b/primitives/debug-derive/Cargo.toml @@ -1,11 +1,13 @@ [package] name = "sp-debug-derive" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Macros to derive runtime debug implementation." +documentation = "https://docs.rs/sp-debug-derive" [lib] proc-macro = true diff --git a/primitives/externalities/Cargo.toml b/primitives/externalities/Cargo.toml index 7a8f20a048f09..f462b7670e829 100644 --- a/primitives/externalities/Cargo.toml +++ b/primitives/externalities/Cargo.toml @@ -1,13 +1,15 @@ [package] name = "sp-externalities" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" license = "GPL-3.0" authors = ["Parity Technologies "] edition = "2018" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Substrate externalities abstraction" +documentation = "https://docs.rs/sp-externalities" [dependencies] -sp-storage = { version = "2.0.0-dev", path = "../storage" } -sp-std = { version = "2.0.0-dev", path = "../std" } +sp-storage = { version = "2.0.0-alpha.2", path = "../storage" } +sp-std = { version = "2.0.0-alpha.2", path = "../std" } environmental = { version = "1.1.1" } diff --git a/primitives/externalities/src/lib.rs b/primitives/externalities/src/lib.rs index 431e449846c6e..fa0f9e4454dd2 100644 --- a/primitives/externalities/src/lib.rs +++ b/primitives/externalities/src/lib.rs @@ -203,13 +203,21 @@ pub trait Externalities: ExtensionStore { /// Returns the SCALE encoded hash. fn storage_changes_root(&mut self, parent: &[u8]) -> Result>, ()>; - fn wipe(&mut self) { - unimplemented!() - } + /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + /// Benchmarking related functionality and shouldn't be used anywhere else! + /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + /// + /// Wipes all changes from caches and the database. + /// + /// The state will be reset to genesis. + fn wipe(&mut self); - fn commit(&mut self) { - unimplemented!() - } + /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + /// Benchmarking related functionality and shouldn't be used anywhere else! + /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + /// + /// Commits all changes to the database and clears all caches. + fn commit(&mut self); } /// Extension for the [`Externalities`] trait. diff --git a/primitives/finality-grandpa/Cargo.toml b/primitives/finality-grandpa/Cargo.toml index 62ac64eb0cd93..d36f0e4b52720 100644 --- a/primitives/finality-grandpa/Cargo.toml +++ b/primitives/finality-grandpa/Cargo.toml @@ -1,19 +1,22 @@ [package] name = "sp-finality-grandpa" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Primitives for GRANDPA integration, suitable for WASM compilation." +documentation = "https://docs.rs/sp-finality-grandpa" + [dependencies] -sp-application-crypto = { version = "2.0.0-dev", default-features = false, path = "../application-crypto" } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../std" } +sp-application-crypto = { version = "2.0.0-alpha.2", default-features = false, path = "../application-crypto" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../std" } serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-api = { version = "2.0.0-dev", default-features = false, path = "../api" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../runtime" } +sp-api = { version = "2.0.0-alpha.2", default-features = false, path = "../api" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../runtime" } [features] default = ["std"] diff --git a/primitives/finality-tracker/Cargo.toml b/primitives/finality-tracker/Cargo.toml index 99e471cac1bf2..f89cb24d4a74c 100644 --- a/primitives/finality-tracker/Cargo.toml +++ b/primitives/finality-tracker/Cargo.toml @@ -1,16 +1,17 @@ [package] name = "sp-finality-tracker" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME module that tracks the last finalized block, as perceived by block authors." [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -sp-inherents = { version = "2.0.0-dev", default-features = false, path = "../../primitives/inherents" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false } +sp-inherents = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/inherents" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } [features] default = ["std"] diff --git a/primitives/inherents/Cargo.toml b/primitives/inherents/Cargo.toml index bd315c33cdb50..839edba73de92 100644 --- a/primitives/inherents/Cargo.toml +++ b/primitives/inherents/Cargo.toml @@ -1,17 +1,20 @@ [package] name = "sp-inherents" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Provides types and traits for creating and checking inherents." +documentation = "https://docs.rs/sp-inherents" + [dependencies] parking_lot = { version = "0.10.0", optional = true } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../std" } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../core" } -codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../std" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../core" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } derive_more = { version = "0.99.2", optional = true } [features] diff --git a/primitives/io/Cargo.toml b/primitives/io/Cargo.toml index 7d61398b81e9c..4f740638024bc 100644 --- a/primitives/io/Cargo.toml +++ b/primitives/io/Cargo.toml @@ -1,23 +1,26 @@ [package] name = "sp-io" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "I/O for Substrate runtimes" +documentation = "https://docs.rs/sp-io" + [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false } hash-db = { version = "0.15.2", default-features = false } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../core" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../std" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../core" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../std" } libsecp256k1 = { version = "0.3.4", optional = true } -sp-state-machine = { version = "0.8.0-dev", optional = true, path = "../../primitives/state-machine" } -sp-wasm-interface = { version = "2.0.0-dev", path = "../../primitives/wasm-interface", default-features = false } -sp-runtime-interface = { version = "2.0.0-dev", default-features = false, path = "../runtime-interface" } -sp-trie = { version = "2.0.0-dev", optional = true, path = "../../primitives/trie" } -sp-externalities = { version = "0.8.0-dev", optional = true, path = "../externalities" } +sp-state-machine = { version = "0.8.0-alpha.2", optional = true, path = "../../primitives/state-machine" } +sp-wasm-interface = { version = "2.0.0-alpha.2", path = "../../primitives/wasm-interface", default-features = false } +sp-runtime-interface = { version = "2.0.0-alpha.2", default-features = false, path = "../runtime-interface" } +sp-trie = { version = "2.0.0-alpha.2", optional = true, path = "../../primitives/trie" } +sp-externalities = { version = "0.8.0-alpha.2", optional = true, path = "../externalities" } log = { version = "0.4.8", optional = true } [features] diff --git a/primitives/io/src/lib.rs b/primitives/io/src/lib.rs index 4b520a240a923..aef3eed5aa6d3 100644 --- a/primitives/io/src/lib.rs +++ b/primitives/io/src/lib.rs @@ -915,6 +915,56 @@ pub fn oom(_: core::alloc::Layout) -> ! { #[cfg(feature = "std")] pub type TestExternalities = sp_state_machine::TestExternalities; +#[cfg(feature = "std")] +mod ext_blake2_256 { + use sp_wasm_interface::{Signature, Function, HostFunctions, ValueType, Value, FunctionContext}; + + /// There is a custom `extern function` in `sp_core::hasher` for `ext_blake2_256` hasher. This + /// custom extern was missed to remove and requires us to support this now. This type is a custom + /// implementation for the wasm function in native. + pub struct ExtBlake2_256; + + impl HostFunctions for ExtBlake2_256 { + fn host_functions() -> Vec<&'static dyn Function> { + vec![&ExtBlake2_256] + } + } + + impl Function for ExtBlake2_256 { + fn name(&self) -> &str { + "ext_blake2_256" + } + + fn signature(&self) -> Signature { + Signature::new_with_args(&[ValueType::I32, ValueType::I32, ValueType::I32][..]) + } + + fn execute( + &self, + context: &mut dyn FunctionContext, + args: &mut dyn Iterator, + ) -> sp_wasm_interface::Result> { + let data = args.next().and_then(|v| v.as_i32()) + .ok_or_else(|| "`data` not present or not an `i32`")? as u32; + let len = args.next().and_then(|v| v.as_i32()) + .ok_or_else(|| "`len` not present or not an `i32`")? as u32; + let out = args.next().and_then(|v| v.as_i32()) + .ok_or_else(|| "`out` not present or not an `i32`")? as u32; + + let result: [u8; 32] = if len == 0 { + sp_core::hashing::blake2_256(&[0u8; 0]) + } else { + let mem = context.read_memory(data.into(), len) + .map_err(|_| "Invalid attempt to get data in ext_blake2_256")?; + sp_core::hashing::blake2_256(&mem) + }; + context.write_memory(out.into(), &result) + .map_err(|_| "Invalid attempt to set result in ext_blake2_256")?; + Ok(None) + } + } +} + /// The host functions Substrate provides for the Wasm runtime environment. /// /// All these host functions will be callable from inside the Wasm environment. @@ -929,6 +979,7 @@ pub type SubstrateHostFunctions = ( logging::HostFunctions, sandbox::HostFunctions, crate::trie::HostFunctions, + ext_blake2_256::ExtBlake2_256, ); #[cfg(test)] diff --git a/primitives/keyring/Cargo.toml b/primitives/keyring/Cargo.toml index d712fcdf8eb9b..1ec4ebe547f36 100644 --- a/primitives/keyring/Cargo.toml +++ b/primitives/keyring/Cargo.toml @@ -1,14 +1,17 @@ [package] name = "sp-keyring" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Keyring support code for the runtime. A set of test accounts." +documentation = "https://docs.rs/sp-keyring" + [dependencies] -sp-core = { version = "2.0.0-dev", path = "../core" } -sp-runtime = { version = "2.0.0-dev", path = "../runtime" } +sp-core = { version = "2.0.0-alpha.2", path = "../core" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../runtime" } lazy_static = "1.4.0" strum = { version = "0.16.0", features = ["derive"] } diff --git a/primitives/offchain/Cargo.toml b/primitives/offchain/Cargo.toml index 70e1cffacfefc..45324d368b944 100644 --- a/primitives/offchain/Cargo.toml +++ b/primitives/offchain/Cargo.toml @@ -1,7 +1,7 @@ [package] description = "Substrate offchain workers primitives" name = "sp-offchain" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" license = "GPL-3.0" authors = ["Parity Technologies "] edition = "2018" @@ -9,8 +9,8 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -sp-api = { version = "2.0.0-dev", default-features = false, path = "../api" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../runtime" } +sp-api = { version = "2.0.0-alpha.2", default-features = false, path = "../api" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../runtime" } [features] default = ["std"] diff --git a/primitives/panic-handler/Cargo.toml b/primitives/panic-handler/Cargo.toml index d29f2238e74b1..592107b84f06a 100644 --- a/primitives/panic-handler/Cargo.toml +++ b/primitives/panic-handler/Cargo.toml @@ -1,12 +1,13 @@ [package] name = "sp-panic-handler" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] -description = "Substrate panic handler." edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Custom panic hook with bug report link" +documentation = "https://docs.rs/sp-panic-handler" [dependencies] backtrace = "0.3.38" diff --git a/primitives/phragmen/Cargo.toml b/primitives/phragmen/Cargo.toml index 28f4cce9018ca..6a599bdabd830 100644 --- a/primitives/phragmen/Cargo.toml +++ b/primitives/phragmen/Cargo.toml @@ -1,20 +1,21 @@ [package] name = "sp-phragmen" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "PHRAGMENT primitives" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../std" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../std" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } [dev-dependencies] -substrate-test-utils = { version = "2.0.0-dev", path = "../../test-utils" } -sp-io ={ version = "2.0.0-dev", path = "../../primitives/io" } +substrate-test-utils = { version = "2.0.0-alpha.2", path = "../../test-utils" } +sp-io ={ version = "2.0.0-alpha.2", path = "../../primitives/io" } rand = "0.7.2" [features] diff --git a/primitives/rpc/Cargo.toml b/primitives/rpc/Cargo.toml index 1f464e81a8fa3..13d91e71d34e4 100644 --- a/primitives/rpc/Cargo.toml +++ b/primitives/rpc/Cargo.toml @@ -1,15 +1,16 @@ [package] name = "sp-rpc" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Substrate RPC primitives and utilities." [dependencies] serde = { version = "1.0.101", features = ["derive"] } -sp-core = { version = "2.0.0-dev", path = "../core" } +sp-core = { version = "2.0.0-alpha.2", path = "../core" } [dev-dependencies] serde_json = "1.0.41" diff --git a/primitives/runtime-interface/Cargo.toml b/primitives/runtime-interface/Cargo.toml index b1547fe6520e1..70092c0587fe9 100644 --- a/primitives/runtime-interface/Cargo.toml +++ b/primitives/runtime-interface/Cargo.toml @@ -1,28 +1,30 @@ [package] name = "sp-runtime-interface" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Substrate runtime interface" +documentation = "https://docs.rs/sp-runtime-interface/" [dependencies] -sp-wasm-interface = { version = "2.0.0-dev", path = "../wasm-interface", default-features = false } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../std" } -sp-runtime-interface-proc-macro = { version = "2.0.0-dev", path = "proc-macro" } -sp-externalities = { version = "0.8.0-dev", optional = true, path = "../externalities" } -codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false } +sp-wasm-interface = { version = "2.0.0-alpha.2", path = "../wasm-interface", default-features = false } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../std" } +sp-runtime-interface-proc-macro = { version = "2.0.0-alpha.2", path = "proc-macro" } +sp-externalities = { version = "0.8.0-alpha.2", optional = true, path = "../externalities" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false } static_assertions = "1.0.0" primitive-types = { version = "0.6.2", default-features = false } [dev-dependencies] sp-runtime-interface-test-wasm = { version = "2.0.0-dev", path = "test-wasm" } -sp-state-machine = { version = "0.8.0-dev", path = "../../primitives/state-machine" } -sp-core = { version = "2.0.0-dev", path = "../core" } -sp-io = { version = "2.0.0-dev", path = "../io" } +sp-state-machine = { version = "0.8.0-alpha.2", path = "../../primitives/state-machine" } +sp-core = { version = "2.0.0-alpha.2", path = "../core" } +sp-io = { version = "2.0.0-alpha.2", path = "../io" } rustversion = "1.0.0" -trybuild = "1.0.17" +trybuild = "1.0.23" [features] default = [ "std" ] diff --git a/primitives/runtime-interface/proc-macro/Cargo.toml b/primitives/runtime-interface/proc-macro/Cargo.toml index fe5a132aac527..b18254f62fd15 100644 --- a/primitives/runtime-interface/proc-macro/Cargo.toml +++ b/primitives/runtime-interface/proc-macro/Cargo.toml @@ -1,11 +1,13 @@ [package] name = "sp-runtime-interface-proc-macro" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "This crate provides procedural macros for usage within the context of the Substrate runtime interface." +documentation = "https://docs.rs/sp-runtime-interface-proc-macro" [lib] proc-macro = true diff --git a/primitives/runtime-interface/test-wasm/Cargo.toml b/primitives/runtime-interface/test-wasm/Cargo.toml index 8461509842ad7..b322e529d6673 100644 --- a/primitives/runtime-interface/test-wasm/Cargo.toml +++ b/primitives/runtime-interface/test-wasm/Cargo.toml @@ -7,12 +7,13 @@ build = "build.rs" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +publish = false [dependencies] -sp-runtime-interface = { version = "2.0.0-dev", default-features = false, path = "../" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../std" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../io" } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../core" } +sp-runtime-interface = { version = "2.0.0-alpha.2", default-features = false, path = "../" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../std" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../io" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../core" } [build-dependencies] wasm-builder-runner = { version = "1.0.5", package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner" } diff --git a/primitives/runtime-interface/test-wasm/src/lib.rs b/primitives/runtime-interface/test-wasm/src/lib.rs index 4e99c0f06c199..2e1ab52d67741 100644 --- a/primitives/runtime-interface/test-wasm/src/lib.rs +++ b/primitives/runtime-interface/test-wasm/src/lib.rs @@ -105,23 +105,6 @@ pub trait TestApi { } } -/// Two random external functions from the old runtime interface. -/// This ensures that we still inherently export these functions from the host and that we are still -/// compatible with old wasm runtimes. -#[cfg(not(feature = "std"))] -extern "C" { - pub fn ext_clear_storage(key_data: *const u8, key_len: u32); - pub fn ext_keccak_256(data: *const u8, len: u32, out: *mut u8); -} - -/// Make sure the old runtime interface needs to be imported. -#[no_mangle] -#[cfg(not(feature = "std"))] -pub fn force_old_runtime_interface_import() { - unsafe { ext_clear_storage(sp_std::ptr::null(), 0); } - unsafe { ext_keccak_256(sp_std::ptr::null(), 0, sp_std::ptr::null_mut()); } -} - /// This function is not used, but we require it for the compiler to include `sp-io`. /// `sp-io` is required for its panic and oom handler. #[no_mangle] @@ -248,4 +231,14 @@ wasm_export_functions! { } assert_eq!(0, len); } + + fn test_ext_blake2_256() { + use sp_core::Hasher; + + let data = "hey, hash me please!"; + let hash = sp_core::Blake2Hasher::hash(data.as_bytes()); + + let expected = sp_io::hashing::blake2_256(data.as_bytes()); + assert_eq!(&expected, hash.as_ref()); + } } diff --git a/primitives/runtime-interface/test/Cargo.toml b/primitives/runtime-interface/test/Cargo.toml index 34c5a7ac5f7ee..6694272529239 100644 --- a/primitives/runtime-interface/test/Cargo.toml +++ b/primitives/runtime-interface/test/Cargo.toml @@ -9,9 +9,9 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -sp-runtime-interface = { version = "2.0.0-dev", path = "../" } -sc-executor = { version = "0.8.0-dev", path = "../../../client/executor" } +sp-runtime-interface = { version = "2.0.0-alpha.2", path = "../" } +sc-executor = { version = "0.8.0-alpha.2", path = "../../../client/executor" } sp-runtime-interface-test-wasm = { version = "2.0.0-dev", path = "../test-wasm" } -sp-state-machine = { version = "0.8.0-dev", path = "../../../primitives/state-machine" } -sp-core = { version = "2.0.0-dev", path = "../../core" } -sp-io = { version = "2.0.0-dev", path = "../../io" } +sp-state-machine = { version = "0.8.0-alpha.2", path = "../../../primitives/state-machine" } +sp-core = { version = "2.0.0-alpha.2", path = "../../core" } +sp-io = { version = "2.0.0-alpha.2", path = "../../io" } diff --git a/primitives/runtime-interface/test/src/lib.rs b/primitives/runtime-interface/test/src/lib.rs index 559a4281e09f2..5c5d1db970586 100644 --- a/primitives/runtime-interface/test/src/lib.rs +++ b/primitives/runtime-interface/test/src/lib.rs @@ -33,7 +33,6 @@ fn call_wasm_method(method: &str) -> TestExternalities { ( HF, sp_io::SubstrateHostFunctions, - sc_executor::deprecated_host_interface::SubstrateExternals ) >( method, @@ -128,3 +127,8 @@ fn test_encoded_return_value_memory_is_freed() { fn test_array_return_value_memory_is_freed() { call_wasm_method::("test_array_return_value_memory_is_freed"); } + +#[test] +fn test_ext_blake2_256() { + call_wasm_method::("test_ext_blake2_256"); +} diff --git a/primitives/runtime/Cargo.toml b/primitives/runtime/Cargo.toml index 29736af6e533c..430d29d8e2223 100644 --- a/primitives/runtime/Cargo.toml +++ b/primitives/runtime/Cargo.toml @@ -1,25 +1,28 @@ [package] name = "sp-runtime" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Runtime Modules shared primitive types." +documentation = "https://docs.rs/sp-runtime" + [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } -codec = { package = "parity-scale-codec", version = "1.1.2", default-features = false, features = ["derive"] } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../core" } -sp-application-crypto = { version = "2.0.0-dev", default-features = false, path = "../application-crypto" } -sp-arithmetic = { version = "2.0.0-dev", default-features = false, path = "../arithmetic" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../std" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../io" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../core" } +sp-application-crypto = { version = "2.0.0-alpha.2", default-features = false, path = "../application-crypto" } +sp-arithmetic = { version = "2.0.0-alpha.2", default-features = false, path = "../arithmetic" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../std" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../io" } log = { version = "0.4.8", optional = true } paste = "0.1.6" rand = { version = "0.7.2", optional = true } impl-trait-for-tuples = "0.1.3" -sp-inherents = { version = "2.0.0-dev", default-features = false, path = "../inherents" } +sp-inherents = { version = "2.0.0-alpha.2", default-features = false, path = "../inherents" } parity-util-mem = { version = "0.5.1", default-features = false, features = ["primitive-types"] } [dev-dependencies] diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index fef20c826af12..0932f4e239d00 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -345,6 +345,14 @@ pub trait OnInitialize { fn on_initialize(_n: BlockNumber) {} } +/// The runtime upgrade trait. Implementing this lets you express what should happen +/// when the runtime upgrades, and changes may need to occur to your module. +#[impl_for_tuples(30)] +pub trait OnRuntimeUpgrade { + /// Perform a module upgrade. + fn on_runtime_upgrade() {} +} + /// Off-chain computation trait. /// /// Implementing this trait on a module allows you to perform long-running tasks diff --git a/primitives/sandbox/Cargo.toml b/primitives/sandbox/Cargo.toml index e09bdb8e00609..060801a29e41e 100755 --- a/primitives/sandbox/Cargo.toml +++ b/primitives/sandbox/Cargo.toml @@ -1,19 +1,20 @@ [package] name = "sp-sandbox" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "This crate provides means to instantiate and execute wasm modules." [dependencies] wasmi = { version = "0.6.2", optional = true } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../core" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../std" } -sp-io = { version = "2.0.0-dev", default-features = false, path = "../io" } -sp-wasm-interface = { version = "2.0.0-dev", default-features = false, path = "../wasm-interface" } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../core" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../std" } +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../io" } +sp-wasm-interface = { version = "2.0.0-alpha.2", default-features = false, path = "../wasm-interface" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false } [dev-dependencies] wabt = "0.9.2" diff --git a/primitives/serializer/Cargo.toml b/primitives/serializer/Cargo.toml index b172c1439b2a6..39f78c078b0ca 100644 --- a/primitives/serializer/Cargo.toml +++ b/primitives/serializer/Cargo.toml @@ -1,11 +1,13 @@ [package] name = "sp-serializer" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Substrate customizable serde serializer." +documentation = "https://docs.rs/sp-serializer" [dependencies] serde = "1.0.101" diff --git a/primitives/session/Cargo.toml b/primitives/session/Cargo.toml index a395b44e81e65..d01f7ee440cf1 100644 --- a/primitives/session/Cargo.toml +++ b/primitives/session/Cargo.toml @@ -1,17 +1,18 @@ [package] name = "sp-session" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Primitives for sessions" [dependencies] -sp-api = { version = "2.0.0-dev", default-features = false, path = "../api" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../std" } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../core" } -sp-runtime = { version = "2.0.0-dev", optional = true, path = "../runtime" } +sp-api = { version = "2.0.0-alpha.2", default-features = false, path = "../api" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../std" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../core" } +sp-runtime = { version = "2.0.0-alpha.2", optional = true, path = "../runtime" } [features] default = [ "std" ] diff --git a/primitives/staking/Cargo.toml b/primitives/staking/Cargo.toml index 60945cbf970d6..2f85b8251b0ae 100644 --- a/primitives/staking/Cargo.toml +++ b/primitives/staking/Cargo.toml @@ -1,16 +1,17 @@ [package] name = "sp-staking" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "A crate which contains primitives that are useful for implementation that uses staking approaches in general. Definitions related to sessions, slashing, etc go here." [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../runtime" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../std" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../runtime" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../std" } [features] default = ["std"] diff --git a/primitives/staking/src/offence.rs b/primitives/staking/src/offence.rs index cac1ed065ceb7..06e73f018b765 100644 --- a/primitives/staking/src/offence.rs +++ b/primitives/staking/src/offence.rs @@ -91,14 +91,37 @@ pub trait Offence { ) -> Perbill; } +/// Errors that may happen on offence reports. +#[derive(PartialEq, sp_runtime::RuntimeDebug)] +pub enum OffenceError { + /// The report has already been sumbmitted. + DuplicateReport, + + /// Other error has happened. + Other(u8), +} + +impl sp_runtime::traits::Printable for OffenceError { + fn print(&self) { + "OffenceError".print(); + match self { + Self::DuplicateReport => "DuplicateReport".print(), + Self::Other(e) => { + "Other".print(); + e.print(); + } + } + } +} + /// A trait for decoupling offence reporters from the actual handling of offence reports. pub trait ReportOffence> { /// Report an `offence` and reward given `reporters`. - fn report_offence(reporters: Vec, offence: O); + fn report_offence(reporters: Vec, offence: O) -> Result<(), OffenceError>; } impl> ReportOffence for () { - fn report_offence(_reporters: Vec, _offence: O) {} + fn report_offence(_reporters: Vec, _offence: O) -> Result<(), OffenceError> { Ok(()) } } /// A trait to take action on an offence. diff --git a/primitives/state-machine/Cargo.toml b/primitives/state-machine/Cargo.toml index 9c68298204169..51f311e44af3d 100644 --- a/primitives/state-machine/Cargo.toml +++ b/primitives/state-machine/Cargo.toml @@ -1,12 +1,13 @@ [package] name = "sp-state-machine" -version = "0.8.0-dev" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] description = "Substrate State Machine" edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +documentation = "https://docs.rs/sp-state-machine" [dependencies] log = "0.4.8" @@ -14,13 +15,13 @@ parking_lot = "0.10.0" hash-db = "0.15.2" trie-db = "0.20.0" trie-root = "0.16.0" -sp-trie = { version = "2.0.0-dev", path = "../trie" } -sp-core = { version = "2.0.0-dev", path = "../core" } -sp-panic-handler = { version = "2.0.0-dev", path = "../panic-handler" } -codec = { package = "parity-scale-codec", version = "1.0.0" } +sp-trie = { version = "2.0.0-alpha.2", path = "../trie" } +sp-core = { version = "2.0.0-alpha.2", path = "../core" } +sp-panic-handler = { version = "2.0.0-alpha.2", path = "../panic-handler" } +codec = { package = "parity-scale-codec", version = "1.2.0" } num-traits = "0.2.8" rand = "0.7.2" -sp-externalities = { version = "0.8.0-dev", path = "../externalities" } +sp-externalities = { version = "0.8.0-alpha.2", path = "../externalities" } [dev-dependencies] hex-literal = "0.2.1" diff --git a/primitives/state-machine/src/basic.rs b/primitives/state-machine/src/basic.rs index d905657737a8a..966648bc8241a 100644 --- a/primitives/state-machine/src/basic.rs +++ b/primitives/state-machine/src/basic.rs @@ -298,6 +298,10 @@ impl Externalities for BasicExternalities { fn storage_changes_root(&mut self, _parent: &[u8]) -> Result>, ()> { Ok(None) } + + fn wipe(&mut self) {} + + fn commit(&mut self) {} } impl sp_externalities::ExtensionStore for BasicExternalities { diff --git a/primitives/std/Cargo.toml b/primitives/std/Cargo.toml index 4314281b3b7d4..38a0c713c0563 100644 --- a/primitives/std/Cargo.toml +++ b/primitives/std/Cargo.toml @@ -1,12 +1,15 @@ [package] name = "sp-std" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Lowest-abstraction level for the Substrate runtime: just exports useful primitives from std or client/alloc to be used with any code that depends on the runtime." +documentation = "https://docs.rs/sp-std" + [features] default = ["std"] std = [] diff --git a/primitives/storage/Cargo.toml b/primitives/storage/Cargo.toml index 27c9f991922d6..7e434cdd89821 100644 --- a/primitives/storage/Cargo.toml +++ b/primitives/storage/Cargo.toml @@ -1,18 +1,19 @@ [package] name = "sp-storage" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" description = "Storage related primitives" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +documentation = "https://docs.rs/sp-storage/" [dependencies] -sp-std = { version = "2.0.0-dev", default-features = false, path = "../std" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../std" } serde = { version = "1.0.101", optional = true, features = ["derive"] } impl-serde = { version = "0.2.3", optional = true } -sp-debug-derive = { version = "2.0.0-dev", path = "../debug-derive" } +sp-debug-derive = { version = "2.0.0-alpha.2", path = "../debug-derive" } [features] default = [ "std" ] diff --git a/primitives/test-primitives/Cargo.toml b/primitives/test-primitives/Cargo.toml index 1cff915f3c4d5..1879ca26b7e1d 100644 --- a/primitives/test-primitives/Cargo.toml +++ b/primitives/test-primitives/Cargo.toml @@ -6,13 +6,14 @@ edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +publish = false [dependencies] -sp-application-crypto = { version = "2.0.0-dev", default-features = false, path = "../application-crypto" } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../core" } +sp-application-crypto = { version = "2.0.0-alpha.2", default-features = false, path = "../application-crypto" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../core" } serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../runtime" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../runtime" } parity-util-mem = { version = "0.5.1", default-features = false, features = ["primitive-types"] } [features] diff --git a/primitives/timestamp/Cargo.toml b/primitives/timestamp/Cargo.toml index 1b97f53437fcd..1fc40a113f903 100644 --- a/primitives/timestamp/Cargo.toml +++ b/primitives/timestamp/Cargo.toml @@ -1,18 +1,19 @@ [package] name = "sp-timestamp" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Substrate core types and inherents for timestamps." [dependencies] -sp-api = { version = "2.0.0-dev", default-features = false, path = "../api" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../std" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../runtime" } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-inherents = { version = "2.0.0-dev", default-features = false, path = "../inherents" } +sp-api = { version = "2.0.0-alpha.2", default-features = false, path = "../api" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../std" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../runtime" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-inherents = { version = "2.0.0-alpha.2", default-features = false, path = "../inherents" } impl-trait-for-tuples = "0.1.3" wasm-timer = "0.2" diff --git a/primitives/transaction-pool/Cargo.toml b/primitives/transaction-pool/Cargo.toml index 747cd3472cc0c..69ec59cf5ef92 100644 --- a/primitives/transaction-pool/Cargo.toml +++ b/primitives/transaction-pool/Cargo.toml @@ -1,20 +1,23 @@ [package] name = "sp-transaction-pool" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Transaction pool primitives types & Runtime API." +documentation = "https://docs.rs/sp-transaction-pool" + [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0", optional = true } +codec = { package = "parity-scale-codec", version = "1.2.0", optional = true } derive_more = { version = "0.99.2", optional = true } futures = { version = "0.3.1", optional = true } log = { version = "0.4.8", optional = true } serde = { version = "1.0.101", features = ["derive"], optional = true} -sp-api = { version = "2.0.0-dev", default-features = false, path = "../api" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../runtime" } +sp-api = { version = "2.0.0-alpha.2", default-features = false, path = "../api" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../runtime" } [features] default = [ "std" ] diff --git a/primitives/trie/Cargo.toml b/primitives/trie/Cargo.toml index 6aab0f290b27c..ddce910609d70 100644 --- a/primitives/trie/Cargo.toml +++ b/primitives/trie/Cargo.toml @@ -1,25 +1,26 @@ [package] name = "sp-trie" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] description = "Patricia trie stuff using a parity-scale-codec node format" repository = "https://github.com/paritytech/substrate/" license = "GPL-3.0" edition = "2018" homepage = "https://substrate.dev" +documentation = "https://docs.rs/sp-trie" [[bench]] name = "bench" harness = false [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../std" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../std" } hash-db = { version = "0.15.2", default-features = false } trie-db = { version = "0.20.0", default-features = false } trie-root = { version = "0.16.0", default-features = false } memory-db = { version = "0.19.0", default-features = false } -sp-core = { version = "2.0.0-dev", default-features = false, path = "../core" } +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../core" } [dev-dependencies] trie-bench = "0.20.0" diff --git a/primitives/version/Cargo.toml b/primitives/version/Cargo.toml index 4cd65cd0446c1..edaf940465bd6 100644 --- a/primitives/version/Cargo.toml +++ b/primitives/version/Cargo.toml @@ -1,18 +1,21 @@ [package] name = "sp-version" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Version module for the Substrate runtime; Provides a function that returns the runtime version." +documentation = "https://docs.rs/sp-version" + [dependencies] impl-serde = { version = "0.2.3", optional = true } serde = { version = "1.0.101", optional = true, features = ["derive"] } -codec = { package = "parity-scale-codec", version = "1.1.2", default-features = false, features = ["derive"] } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../std" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../runtime" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../std" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../runtime" } [features] default = ["std"] diff --git a/primitives/wasm-interface/Cargo.toml b/primitives/wasm-interface/Cargo.toml index 5d477ff9557b5..bbe53df258271 100644 --- a/primitives/wasm-interface/Cargo.toml +++ b/primitives/wasm-interface/Cargo.toml @@ -1,17 +1,19 @@ [package] name = "sp-wasm-interface" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Types and traits for interfacing between the host and the wasm runtime." +documentation = "https://docs.rs/sp-wasm-interface" [dependencies] wasmi = { version = "0.6.2", optional = true } impl-trait-for-tuples = "0.1.2" -sp-std = { version = "2.0.0-dev", path = "../std", default-features = false } -codec = { package = "parity-scale-codec", version = "1.1.2", default-features = false, features = ["derive"] } +sp-std = { version = "2.0.0-alpha.2", path = "../std", default-features = false } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } [features] default = [ "std" ] diff --git a/primitives/wasm-interface/src/lib.rs b/primitives/wasm-interface/src/lib.rs index 7bb4469c771ff..eda2ebb1b527a 100644 --- a/primitives/wasm-interface/src/lib.rs +++ b/primitives/wasm-interface/src/lib.rs @@ -170,6 +170,12 @@ impl Pointer { } } +impl From for Pointer { + fn from(ptr: u32) -> Self { + Pointer::new(ptr) + } +} + impl From> for u32 { fn from(ptr: Pointer) -> Self { ptr.ptr diff --git a/test-utils/Cargo.toml b/test-utils/Cargo.toml index 54511bd9e449d..d3477b94a6f95 100644 --- a/test-utils/Cargo.toml +++ b/test-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substrate-test-utils" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" diff --git a/test-utils/client/Cargo.toml b/test-utils/client/Cargo.toml index f4eb93d128f9c..77a614e5fecca 100644 --- a/test-utils/client/Cargo.toml +++ b/test-utils/client/Cargo.toml @@ -6,18 +6,19 @@ edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +publish = false [dependencies] -sc-client-api = { version = "2.0.0-dev", path = "../../client/api" } -sc-client = { version = "0.8.0-dev", path = "../../client/" } -sc-client-db = { version = "0.8.0-dev", features = ["test-helpers"], path = "../../client/db" } -sp-consensus = { version = "0.8.0-dev", path = "../../primitives/consensus/common" } -sc-executor = { version = "0.8.0-dev", path = "../../client/executor" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../../client/api" } +sc-client = { version = "0.8.0-alpha.2", path = "../../client/" } +sc-client-db = { version = "0.8.0-alpha.2", features = ["test-helpers"], path = "../../client/db" } +sp-consensus = { version = "0.8.0-alpha.2", path = "../../primitives/consensus/common" } +sc-executor = { version = "0.8.0-alpha.2", path = "../../client/executor" } futures = "0.3.1" hash-db = "0.15.2" -sp-keyring = { version = "2.0.0-dev", path = "../../primitives/keyring" } -codec = { package = "parity-scale-codec", version = "1.0.0" } -sp-core = { version = "2.0.0-dev", path = "../../primitives/core" } -sp-runtime = { version = "2.0.0-dev", path = "../../primitives/runtime" } -sp-blockchain = { version = "2.0.0-dev", path = "../../primitives/blockchain" } -sp-state-machine = { version = "0.8.0-dev", path = "../../primitives/state-machine" } +sp-keyring = { version = "2.0.0-alpha.2", path = "../../primitives/keyring" } +codec = { package = "parity-scale-codec", version = "1.2.0" } +sp-core = { version = "2.0.0-alpha.2", path = "../../primitives/core" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../primitives/runtime" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../primitives/blockchain" } +sp-state-machine = { version = "0.8.0-alpha.2", path = "../../primitives/state-machine" } diff --git a/test-utils/runtime/Cargo.toml b/test-utils/runtime/Cargo.toml index 44d2a68b49f12..96d91992af69b 100644 --- a/test-utils/runtime/Cargo.toml +++ b/test-utils/runtime/Cargo.toml @@ -7,44 +7,45 @@ build = "build.rs" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +publish = false [dependencies] -sp-application-crypto = { version = "2.0.0-dev", default-features = false, path = "../../primitives/application-crypto" } -sp-consensus-aura = { version = "0.8.0-dev", default-features = false, path = "../../primitives/consensus/aura" } -sp-consensus-babe = { version = "0.8.0-dev", default-features = false, path = "../../primitives/consensus/babe" } -sp-block-builder = { version = "2.0.0-dev", default-features = false, path = "../../primitives/block-builder" } +sp-application-crypto = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/application-crypto" } +sp-consensus-aura = { version = "0.8.0-alpha.2", default-features = false, path = "../../primitives/consensus/aura" } +sp-consensus-babe = { version = "0.8.0-alpha.2", default-features = false, path = "../../primitives/consensus/babe" } +sp-block-builder = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/block-builder" } cfg-if = "0.1.10" -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -frame-executive = { version = "2.0.0-dev", default-features = false, path = "../../frame/executive" } -sp-inherents = { version = "2.0.0-dev", default-features = false, path = "../../primitives/inherents" } -sp-keyring = { version = "2.0.0-dev", optional = true, path = "../../primitives/keyring" } +codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] } +frame-executive = { version = "2.0.0-alpha.2", default-features = false, path = "../../frame/executive" } +sp-inherents = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/inherents" } +sp-keyring = { version = "2.0.0-alpha.2", optional = true, path = "../../primitives/keyring" } log = { version = "0.4.8", optional = true } memory-db = { version = "0.19.0", default-features = false } -sp-offchain = { path = "../../primitives/offchain", default-features = false, version = "2.0.0-dev"} -sp-core = { version = "2.0.0-dev", default-features = false, path = "../../primitives/core" } -sp-std = { version = "2.0.0-dev", default-features = false, path = "../../primitives/std" } -sp-runtime-interface = { path = "../../primitives/runtime-interface", default-features = false, version = "2.0.0-dev"} -sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" } -frame-support = { version = "2.0.0-dev", default-features = false, path = "../../frame/support" } -sp-version = { version = "2.0.0-dev", default-features = false, path = "../../primitives/version" } +sp-offchain = { path = "../../primitives/offchain", default-features = false, version = "2.0.0-alpha.2"} +sp-core = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/core" } +sp-std = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/std" } +sp-runtime-interface = { path = "../../primitives/runtime-interface", default-features = false, version = "2.0.0-alpha.2"} +sp-io = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/io" } +frame-support = { version = "2.0.0-alpha.2", default-features = false, path = "../../frame/support" } +sp-version = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/version" } serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-session = { version = "2.0.0-dev", default-features = false, path = "../../primitives/session" } -sp-api = { version = "2.0.0-dev", default-features = false, path = "../../primitives/api" } -sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" } -pallet-babe = { version = "2.0.0-dev", default-features = false, path = "../../frame/babe" } -frame-system = { version = "2.0.0-dev", default-features = false, path = "../../frame/system" } -frame-system-rpc-runtime-api = { version = "2.0.0-dev", default-features = false, path = "../../frame/system/rpc/runtime-api" } -pallet-timestamp = { version = "2.0.0-dev", default-features = false, path = "../../frame/timestamp" } -sc-client = { version = "0.8.0-dev", optional = true, path = "../../client" } -sp-trie = { version = "2.0.0-dev", default-features = false, path = "../../primitives/trie" } -sp-transaction-pool = { version = "2.0.0-dev", default-features = false, path = "../../primitives/transaction-pool" } +sp-session = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/session" } +sp-api = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/api" } +sp-runtime = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/runtime" } +pallet-babe = { version = "2.0.0-alpha.2", default-features = false, path = "../../frame/babe" } +frame-system = { version = "2.0.0-alpha.2", default-features = false, path = "../../frame/system" } +frame-system-rpc-runtime-api = { version = "2.0.0-alpha.2", default-features = false, path = "../../frame/system/rpc/runtime-api" } +pallet-timestamp = { version = "2.0.0-alpha.2", default-features = false, path = "../../frame/timestamp" } +sc-client = { version = "0.8.0-alpha.2", optional = true, path = "../../client" } +sp-trie = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/trie" } +sp-transaction-pool = { version = "2.0.0-alpha.2", default-features = false, path = "../../primitives/transaction-pool" } trie-db = { version = "0.20.0", default-features = false } parity-util-mem = { version = "0.5.1", default-features = false, features = ["primitive-types"] } [dev-dependencies] -sc-executor = { version = "0.8.0-dev", path = "../../client/executor" } +sc-executor = { version = "0.8.0-alpha.2", path = "../../client/executor" } substrate-test-runtime-client = { version = "2.0.0-dev", path = "./client" } -sp-state-machine = { version = "0.8.0-dev", path = "../../primitives/state-machine" } +sp-state-machine = { version = "0.8.0-alpha.2", path = "../../primitives/state-machine" } [build-dependencies] wasm-builder-runner = { version = "1.0.5", package = "substrate-wasm-builder-runner", path = "../../utils/wasm-builder-runner" } diff --git a/test-utils/runtime/client/Cargo.toml b/test-utils/runtime/client/Cargo.toml index a588219690a72..5f16e77860ba6 100644 --- a/test-utils/runtime/client/Cargo.toml +++ b/test-utils/runtime/client/Cargo.toml @@ -6,16 +6,17 @@ edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +publish = false [dependencies] -sc-block-builder = { version = "0.8.0-dev", path = "../../../client/block-builder" } +sc-block-builder = { version = "0.8.0-alpha.2", path = "../../../client/block-builder" } substrate-test-client = { version = "2.0.0-dev", path = "../../client" } -sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../primitives/core" } substrate-test-runtime = { version = "2.0.0-dev", path = "../../runtime" } -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } -sp-api = { version = "2.0.0-dev", path = "../../../primitives/api" } -sp-blockchain = { version = "2.0.0-dev", path = "../../../primitives/blockchain" } -codec = { package = "parity-scale-codec", version = "1.0.0" } -sc-client-api = { version = "2.0.0-dev", path = "../../../client/api" } -sc-client = { version = "0.8.0-dev", path = "../../../client/" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } +sp-api = { version = "2.0.0-alpha.2", path = "../../../primitives/api" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../../primitives/blockchain" } +codec = { package = "parity-scale-codec", version = "1.2.0" } +sc-client-api = { version = "2.0.0-alpha.2", path = "../../../client/api" } +sc-client = { version = "0.8.0-alpha.2", path = "../../../client/" } futures = "0.3.1" diff --git a/test-utils/runtime/client/src/trait_tests.rs b/test-utils/runtime/client/src/trait_tests.rs index 05db43298fd49..5ceab4355d897 100644 --- a/test-utils/runtime/client/src/trait_tests.rs +++ b/test-utils/runtime/client/src/trait_tests.rs @@ -30,6 +30,7 @@ use substrate_test_client::sp_consensus::BlockOrigin; use substrate_test_runtime::{self, Transfer}; use sp_runtime::generic::BlockId; use sp_runtime::traits::{Block as BlockT, HasherFor}; +use sc_block_builder::BlockBuilderProvider; /// helper to test the `leaves` implementation for various backends pub fn test_leaves_for_backend(backend: Arc) where diff --git a/test-utils/runtime/transaction-pool/Cargo.toml b/test-utils/runtime/transaction-pool/Cargo.toml index dfaeb7227f48b..3e22da468f1e3 100644 --- a/test-utils/runtime/transaction-pool/Cargo.toml +++ b/test-utils/runtime/transaction-pool/Cargo.toml @@ -6,14 +6,15 @@ edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +publish = false [dependencies] substrate-test-runtime-client = { version = "2.0.0-dev", path = "../client" } parking_lot = "0.10.0" -codec = { package = "parity-scale-codec", version = "1.0.0" } -sp-blockchain = { version = "2.0.0-dev", path = "../../../primitives/blockchain" } -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } -sp-transaction-pool = { version = "2.0.0-dev", path = "../../../primitives/transaction-pool" } -sc-transaction-graph = { version = "2.0.0-dev", path = "../../../client/transaction-pool/graph" } +codec = { package = "parity-scale-codec", version = "1.2.0" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../../primitives/blockchain" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } +sp-transaction-pool = { version = "2.0.0-alpha.2", path = "../../../primitives/transaction-pool" } +sc-transaction-graph = { version = "2.0.0-alpha.2", path = "../../../client/transaction-pool/graph" } futures = { version = "0.3.1", features = ["compat"] } derive_more = "0.99.2" diff --git a/utils/browser/Cargo.toml b/utils/browser/Cargo.toml index bd513b8a173ce..e06794c6ccbf3 100644 --- a/utils/browser/Cargo.toml +++ b/utils/browser/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "browser-utils" -version = "0.8.0-dev" +name = "substrate-browser-utils" +version = "0.8.0-alpha.3" authors = ["Parity Technologies "] description = "Utilities for creating a browser light-client." edition = "2018" @@ -12,17 +12,17 @@ repository = "https://github.com/paritytech/substrate/" futures = "0.3" futures01 = { package = "futures", version = "0.1.29" } log = "0.4.8" -libp2p = { version = "0.16.1", default-features = false } +libp2p = { version = "0.16.2", default-features = false } console_error_panic_hook = "0.1.6" console_log = "0.1.2" js-sys = "0.3.34" wasm-bindgen = "0.2.57" wasm-bindgen-futures = "0.4.7" kvdb-web = "0.4" -sc-informant = { version = "0.8.0-dev", path = "../../client/informant" } -sc-service = { version = "0.8.0-dev", path = "../../client/service", default-features = false } -sc-network = { path = "../../client/network" , version = "0.8.0-dev"} -sc-chain-spec = { path = "../../client/chain-spec" , version = "2.0.0-dev"} +sc-informant = { version = "0.8.0-alpha.2", path = "../../client/informant" } +sc-service = { version = "0.8.0-alpha.2", path = "../../client/service", default-features = false } +sc-network = { path = "../../client/network" , version = "0.8.0-alpha.2"} +sc-chain-spec = { path = "../../client/chain-spec" , version = "2.0.0-alpha.2"} # Imported just for the `no_cc` feature clear_on_drop = { version = "0.2.3", features = ["no_cc"] } diff --git a/utils/build-script-utils/Cargo.toml b/utils/build-script-utils/Cargo.toml index d41b85a982fe3..5903d107fbbe1 100644 --- a/utils/build-script-utils/Cargo.toml +++ b/utils/build-script-utils/Cargo.toml @@ -1,10 +1,11 @@ [package] name = "substrate-build-script-utils" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Crate with utility functions for `build.rs` scripts." [dependencies] diff --git a/utils/fork-tree/Cargo.toml b/utils/fork-tree/Cargo.toml index be200007d52a4..8ade20cd7b7e2 100644 --- a/utils/fork-tree/Cargo.toml +++ b/utils/fork-tree/Cargo.toml @@ -1,11 +1,13 @@ [package] name = "fork-tree" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Utility library for managing tree-like ordered data with logic for pruning the tree while finalizing nodes." +documentation = "https://docs.rs/fork-tree" [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "1.2.0", features = ["derive"] } diff --git a/utils/frame/benchmarking-cli/Cargo.toml b/utils/frame/benchmarking-cli/Cargo.toml index 648b37933e777..93c62c3f9653e 100644 --- a/utils/frame/benchmarking-cli/Cargo.toml +++ b/utils/frame/benchmarking-cli/Cargo.toml @@ -1,19 +1,20 @@ [package] name = "frame-benchmarking-cli" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "CLI for benchmarking FRAME" [dependencies] -frame-benchmarking = { version = "2.0.0-dev", path = "../../../frame/benchmarking" } -sc-service = { version = "0.8.0-dev", path = "../../../client/service" } -sc-cli = { version = "0.8.0-dev", path = "../../../client/cli" } -sc-client = { version = "0.8.0-dev", path = "../../../client" } -sc-client-db = { version = "0.8.0-dev", path = "../../../client/db" } -sc-executor = { version = "0.8.0-dev", path = "../../../client/executor" } -sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } +frame-benchmarking = { version = "2.0.0-alpha.2", path = "../../../frame/benchmarking" } +sc-service = { version = "0.8.0-alpha.2", path = "../../../client/service" } +sc-cli = { version = "0.8.0-alpha.2", path = "../../../client/cli" } +sc-client = { version = "0.8.0-alpha.2", path = "../../../client" } +sc-client-db = { version = "0.8.0-alpha.2", path = "../../../client/db" } +sc-executor = { version = "0.8.0-alpha.2", path = "../../../client/executor" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../primitives/runtime" } structopt = "0.3.8" -codec = { version = "1.1.2", package = "parity-scale-codec" } +codec = { version = "1.2.0", package = "parity-scale-codec" } diff --git a/utils/frame/benchmarking-cli/src/lib.rs b/utils/frame/benchmarking-cli/src/lib.rs index 816ce52131081..899419e5de5ad 100644 --- a/utils/frame/benchmarking-cli/src/lib.rs +++ b/utils/frame/benchmarking-cli/src/lib.rs @@ -36,8 +36,16 @@ pub struct BenchmarkCmd { pub extrinsic: String, /// Select how many samples we should take across the variable components. - #[structopt(short, long, default_value = "1")] - pub steps: u32, + #[structopt(short, long, use_delimiter = true)] + pub steps: Vec, + + /// Indicates lowest values for each of the component ranges. + #[structopt(long, use_delimiter = true)] + pub lowest_range_values: Vec, + + /// Indicates highest values for each of the component ranges. + #[structopt(long, use_delimiter = true)] + pub highest_range_values: Vec, /// Select how many repetitions of this benchmark should run. #[structopt(short, long, default_value = "1")] @@ -97,45 +105,57 @@ impl BenchmarkCmd { wasm_method, None, // heap pages ); + let result = StateMachine::<_, _, NumberFor, _>::new( &state, None, &mut changes, &executor, "Benchmark_dispatch_benchmark", - &(&self.pallet, &self.extrinsic, self.steps, self.repeat).encode(), + &( + &self.pallet, + &self.extrinsic, + self.lowest_range_values.clone(), + self.highest_range_values.clone(), + self.steps.clone(), + self.repeat, + ).encode(), Default::default(), ) .execute(strategy.into()) .map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?; - let results = > as Decode>::decode(&mut &result[..]) - .unwrap_or(None); - - if let Some(results) = results { - // Print benchmark metadata - println!( - "Pallet: {:?}, Extrinsic: {:?}, Steps: {:?}, Repeat: {:?}", - self.pallet, - self.extrinsic, - self.steps, - self.repeat, - ); - - // Print the table header - results[0].0.iter().for_each(|param| print!("{:?},", param.0)); - - print!("extrinsic_time,storage_root_time\n"); - // Print the values - results.iter().for_each(|result| { - let parameters = &result.0; - parameters.iter().for_each(|param| print!("{:?},", param.1)); - // Print extrinsic time and storage root time - print!("{:?},{:?}\n", result.1, result.2); - }); - - eprintln!("Done."); - } else { - eprintln!("No Results."); + + let results = , String> as Decode>::decode(&mut &result[..]) + .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))?; + + match results { + Ok(results) => { + // Print benchmark metadata + println!( + "Pallet: {:?}, Extrinsic: {:?}, Lowest values: {:?}, Highest values: {:?}, Steps: {:?}, Repeat: {:?}", + self.pallet, + self.extrinsic, + self.lowest_range_values, + self.highest_range_values, + self.steps, + self.repeat, + ); + + // Print the table header + results[0].0.iter().for_each(|param| print!("{:?},", param.0)); + + print!("extrinsic_time,storage_root_time\n"); + // Print the values + results.iter().for_each(|result| { + let parameters = &result.0; + parameters.iter().for_each(|param| print!("{:?},", param.1)); + // Print extrinsic time and storage root time + print!("{:?},{:?}\n", result.1, result.2); + }); + + eprintln!("Done."); + } + Err(error) => eprintln!("Error: {:?}", error), } Ok(()) diff --git a/utils/frame/rpc/support/Cargo.toml b/utils/frame/rpc/support/Cargo.toml index 51f004489a183..162d25cf9bfcd 100644 --- a/utils/frame/rpc/support/Cargo.toml +++ b/utils/frame/rpc/support/Cargo.toml @@ -1,11 +1,12 @@ [package] name = "substrate-frame-rpc-support" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies ", "Andrew Dirksen "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "Substrate RPC for FRAME's support" [dependencies] futures = { version = "0.3.0", features = ["compat"] } @@ -13,10 +14,10 @@ jsonrpc-client-transports = "14" jsonrpc-core = "14" codec = { package = "parity-scale-codec", version = "1" } serde = "1" -frame-support = { version = "2.0.0-dev", path = "../../../../frame/support" } -sp-storage = { version = "2.0.0-dev", path = "../../../../primitives/storage" } -sc-rpc-api = { version = "0.8.0-dev", path = "../../../../client/rpc-api" } +frame-support = { version = "2.0.0-alpha.2", path = "../../../../frame/support" } +sp-storage = { version = "2.0.0-alpha.2", path = "../../../../primitives/storage" } +sc-rpc-api = { version = "0.8.0-alpha.2", path = "../../../../client/rpc-api" } [dev-dependencies] -frame-system = { version = "2.0.0-dev", path = "../../../../frame/system" } -tokio = "0.1" +frame-system = { version = "2.0.0-alpha.2", path = "../../../../frame/system" } +tokio = "0.2" diff --git a/utils/frame/rpc/support/src/lib.rs b/utils/frame/rpc/support/src/lib.rs index a9982945e7f73..42c10fb2cc2e8 100644 --- a/utils/frame/rpc/support/src/lib.rs +++ b/utils/frame/rpc/support/src/lib.rs @@ -33,9 +33,7 @@ use sc_rpc_api::state::StateClient; /// A typed query on chain state usable from an RPC client. /// /// ```no_run -/// # use futures::compat::Compat; /// # use futures::compat::Future01CompatExt; -/// # use futures::future::FutureExt; /// # use jsonrpc_client_transports::RpcError; /// # use jsonrpc_client_transports::transports::http; /// # use codec::Encode; @@ -49,7 +47,7 @@ use sc_rpc_api::state::StateClient; /// # type Hash = (); /// # /// # fn main() -> Result<(), RpcError> { -/// # tokio::runtime::Runtime::new().unwrap().block_on(Compat::new(test().boxed())) +/// # tokio::runtime::Runtime::new().unwrap().block_on(test()) /// # } /// # /// # struct TestRuntime; diff --git a/utils/frame/rpc/system/Cargo.toml b/utils/frame/rpc/system/Cargo.toml index 88481ac884815..8b1c62ccd70e2 100644 --- a/utils/frame/rpc/system/Cargo.toml +++ b/utils/frame/rpc/system/Cargo.toml @@ -1,29 +1,30 @@ [package] name = "substrate-frame-rpc-system" -version = "2.0.0-dev" +version = "2.0.0-alpha.3" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" +description = "FRAME's system exposed over Substrate RPC" [dependencies] -sc-client = { version = "0.8.0-dev", path = "../../../../client/" } -codec = { package = "parity-scale-codec", version = "1.0.0" } +sc-client = { version = "0.8.0-alpha.2", path = "../../../../client/" } +codec = { package = "parity-scale-codec", version = "1.2.0" } futures = "0.3.1" jsonrpc-core = "14.0.3" jsonrpc-core-client = "14.0.3" jsonrpc-derive = "14.0.3" log = "0.4.8" serde = { version = "1.0.101", features = ["derive"] } -sp-runtime = { version = "2.0.0-dev", path = "../../../../primitives/runtime" } -sp-api = { version = "2.0.0-dev", path = "../../../../primitives/api" } -frame-system-rpc-runtime-api = { version = "2.0.0-dev", path = "../../../../frame/system/rpc/runtime-api" } -sp-core = { version = "2.0.0-dev", path = "../../../../primitives/core" } -sp-blockchain = { version = "2.0.0-dev", path = "../../../../primitives/blockchain" } -sp-transaction-pool = { version = "2.0.0-dev", path = "../../../../primitives/transaction-pool" } +sp-runtime = { version = "2.0.0-alpha.2", path = "../../../../primitives/runtime" } +sp-api = { version = "2.0.0-alpha.2", path = "../../../../primitives/api" } +frame-system-rpc-runtime-api = { version = "2.0.0-alpha.2", path = "../../../../frame/system/rpc/runtime-api" } +sp-core = { version = "2.0.0-alpha.2", path = "../../../../primitives/core" } +sp-blockchain = { version = "2.0.0-alpha.2", path = "../../../../primitives/blockchain" } +sp-transaction-pool = { version = "2.0.0-alpha.2", path = "../../../../primitives/transaction-pool" } [dev-dependencies] substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../../../test-utils/runtime/client" } env_logger = "0.7.0" -sc-transaction-pool = { version = "2.0.0-dev", path = "../../../../client/transaction-pool" } +sc-transaction-pool = { version = "2.0.0-alpha.2", path = "../../../../client/transaction-pool" } diff --git a/utils/prometheus/Cargo.toml b/utils/prometheus/Cargo.toml index 4c7ec546c8efb..bc7750a72083f 100644 --- a/utils/prometheus/Cargo.toml +++ b/utils/prometheus/Cargo.toml @@ -1,7 +1,7 @@ [package] -description = "Prometheus exporter server" -name = "prometheus-exporter" -version = "0.8.0-dev" +description = "Endpoint to expose Prometheus metrics" +name = "substrate-prometheus-endpoint" +version = "0.8.0-alpha.3" license = "GPL-3.0" authors = ["Parity Technologies "] edition = "2018" diff --git a/utils/prometheus/src/lib.rs b/utils/prometheus/src/lib.rs index 1aaeff2a573cb..54b9183bc6392 100644 --- a/utils/prometheus/src/lib.rs +++ b/utils/prometheus/src/lib.rs @@ -65,7 +65,7 @@ mod known_os { Http(hyper::http::Error), /// i/o error. Io(std::io::Error), - #[display(fmt = "Prometheus exporter port {} already in use.", _0)] + #[display(fmt = "Prometheus port {} already in use.", _0)] PortInUse(SocketAddr) } diff --git a/utils/wasm-builder/README.md b/utils/wasm-builder/README.md index 2fd9a6ab4cf80..5f4ca615d5065 100644 --- a/utils/wasm-builder/README.md +++ b/utils/wasm-builder/README.md @@ -50,6 +50,8 @@ By using environment variables, you can configure which WASM binaries are built - `WASM_BUILD_NO_COLOR` - Disable color output of the wasm build. - `WASM_TARGET_DIRECTORY` - Will copy any build wasm binary to the given directory. The path needs to be absolute. +- `WASM_BUILD_TOOLCHAIN` - The toolchain that should be used to build the wasm binaries. The + format needs to be the same as used by cargo, e.g. `nightly-2020-02-20`. Each project can be skipped individually by using the environment variable `SKIP_PROJECT_NAME_WASM_BUILD`. Where `PROJECT_NAME` needs to be replaced by the name of the cargo project, e.g. `node-runtime` will @@ -61,5 +63,8 @@ WASM builder requires the following prerequisites for building the WASM binary: - rust nightly + `wasm32-unknown-unknown` toolchain +If a specific rust nightly is installed with `rustup`, it is important that the wasm target is installed +as well. For example if installing the rust nightly from 20.02.2020 using `rustup install nightly-2020-02-20`, +the wasm target needs to be installed as well `rustup target add wasm32-unknown-unknown --toolchain nightly-2020-02-20`. License: GPL-3.0 diff --git a/utils/wasm-builder/src/lib.rs b/utils/wasm-builder/src/lib.rs index 8500eba4a01f4..195527a122725 100644 --- a/utils/wasm-builder/src/lib.rs +++ b/utils/wasm-builder/src/lib.rs @@ -66,6 +66,8 @@ //! - `WASM_BUILD_NO_COLOR` - Disable color output of the wasm build. //! - `WASM_TARGET_DIRECTORY` - Will copy any build wasm binary to the given directory. The path needs //! to be absolute. +//! - `WASM_BUILD_TOOLCHAIN` - The toolchain that should be used to build the wasm binaries. The +//! format needs to be the same as used by cargo, e.g. `nightly-2020-02-20`. //! //! Each project can be skipped individually by using the environment variable `SKIP_PROJECT_NAME_WASM_BUILD`. //! Where `PROJECT_NAME` needs to be replaced by the name of the cargo project, e.g. `node-runtime` will @@ -77,8 +79,11 @@ //! //! - rust nightly + `wasm32-unknown-unknown` toolchain //! +//! If a specific rust nightly is installed with `rustup`, it is important that the wasm target is installed +//! as well. For example if installing the rust nightly from 20.02.2020 using `rustup install nightly-2020-02-20`, +//! the wasm target needs to be installed as well `rustup target add wasm32-unknown-unknown --toolchain nightly-2020-02-20`. -use std::{env, fs, path::PathBuf, process::{Command, Stdio, self}}; +use std::{env, fs, path::PathBuf, process::{Command, self}, io::BufRead}; mod prerequisites; mod wasm_project; @@ -103,6 +108,9 @@ const WASM_TARGET_DIRECTORY: &str = "WASM_TARGET_DIRECTORY"; /// Environment variable to disable color output of the wasm build. const WASM_BUILD_NO_COLOR: &str = "WASM_BUILD_NO_COLOR"; +/// Environment variable to set the toolchain used to compile the wasm binary. +const WASM_BUILD_TOOLCHAIN: &str = "WASM_BUILD_TOOLCHAIN"; + /// Build the currently built project as wasm binary. /// /// The current project is determined by using the `CARGO_MANIFEST_DIR` environment variable. @@ -178,19 +186,56 @@ fn write_file_if_changed(file: PathBuf, content: String) { /// Get a cargo command that compiles with nightly fn get_nightly_cargo() -> CargoCommand { + let env_cargo = CargoCommand::new( + &env::var("CARGO").expect("`CARGO` env variable is always set by cargo"), + ); let default_cargo = CargoCommand::new("cargo"); - let mut rustup_run_nightly = CargoCommand::new("rustup"); - rustup_run_nightly.args(&["run", "nightly", "cargo"]); + let rustup_run_nightly = CargoCommand::new_with_args("rustup", &["run", "nightly", "cargo"]); + let wasm_toolchain = env::var(WASM_BUILD_TOOLCHAIN).ok(); - if default_cargo.is_nightly() { + // First check if the user requested a specific toolchain + if let Some(cmd) = wasm_toolchain.and_then(|t| get_rustup_nightly(Some(t))) { + cmd + } else if env_cargo.is_nightly() { + env_cargo + } else if default_cargo.is_nightly() { default_cargo - } else if rustup_run_nightly.works() { + } else if rustup_run_nightly.is_nightly() { rustup_run_nightly } else { - default_cargo + // If no command before provided us with a nightly compiler, we try to search one + // with rustup. If that fails as well, we return the default cargo and let the prequisities + // check fail. + get_rustup_nightly(None).unwrap_or(default_cargo) } } +/// Get a nightly from rustup. If `selected` is `Some(_)`, a `CargoCommand` using the given +/// nightly is returned. +fn get_rustup_nightly(selected: Option) -> Option { + let host = format!("-{}", env::var("HOST").expect("`HOST` is always set by cargo")); + + let version = match selected { + Some(selected) => selected, + None => { + let output = Command::new("rustup").args(&["toolchain", "list"]).output().ok()?.stdout; + let lines = output.as_slice().lines(); + + let mut latest_nightly = None; + for line in lines.filter_map(|l| l.ok()) { + if line.starts_with("nightly-") && line.ends_with(&host) { + // Rustup prints them sorted + latest_nightly = Some(line.clone()); + } + } + + latest_nightly?.trim_end_matches(&host).into() + } + }; + + Some(CargoCommand::new_with_args("rustup", &["run", &version, "cargo"])) +} + /// Builder for cargo commands #[derive(Debug)] struct CargoCommand { @@ -203,14 +248,11 @@ impl CargoCommand { CargoCommand { program: program.into(), args: Vec::new() } } - fn arg(&mut self, arg: &str) -> &mut Self { - self.args.push(arg.into()); - self - } - - fn args(&mut self, args: &[&str]) -> &mut Self { - args.into_iter().for_each(|a| { self.arg(a); }); - self + fn new_with_args(program: &str, args: &[&str]) -> Self { + CargoCommand { + program: program.into(), + args: args.iter().map(ToString::to_string).collect(), + } } fn command(&self) -> Command { @@ -219,14 +261,6 @@ impl CargoCommand { cmd } - fn works(&self) -> bool { - self.command() - .stdout(Stdio::null()) - .stderr(Stdio::null()) - .status() - .map(|s| s.success()).unwrap_or(false) - } - /// Check if the supplied cargo command is a nightly version fn is_nightly(&self) -> bool { // `RUSTC_BOOTSTRAP` tells a stable compiler to behave like a nightly. So, when this env diff --git a/utils/wasm-builder/src/wasm_project.rs b/utils/wasm-builder/src/wasm_project.rs index 60be4684ba893..c4f00b9cf4336 100644 --- a/utils/wasm-builder/src/wasm_project.rs +++ b/utils/wasm-builder/src/wasm_project.rs @@ -453,6 +453,7 @@ fn generate_rerun_if_changed_instructions( println!("cargo:rerun-if-env-changed={}", crate::WASM_BUILD_TYPE_ENV); println!("cargo:rerun-if-env-changed={}", crate::WASM_BUILD_RUSTFLAGS_ENV); println!("cargo:rerun-if-env-changed={}", crate::WASM_TARGET_DIRECTORY); + println!("cargo:rerun-if-env-changed={}", crate::WASM_BUILD_TOOLCHAIN); } /// Copy the WASM binary to the target directory set in `WASM_TARGET_DIRECTORY` environment variable.