diff --git a/.github/workflows/release-10_candidate.yml b/.github/workflows/release-10_candidate.yml index acffa6842d49..be12406317fa 100644 --- a/.github/workflows/release-10_candidate.yml +++ b/.github/workflows/release-10_candidate.yml @@ -19,7 +19,7 @@ jobs: # Get last rc tag if exists, else set it to {version}-rc1 version=${GITHUB_REF#refs/heads/release-} echo "$version" - echo "::set-output name=version::$version" + echo "version=$version" >> $GITHUB_OUTPUT git tag -l last_rc=$(git tag -l "$version-rc*" | sort -V | tail -n 1) if [ -n "$last_rc" ]; then @@ -27,11 +27,11 @@ jobs: echo $suffix ((suffix++)) echo $suffix - echo "::set-output name=new_tag::$version-rc$suffix" - echo "::set-output name=first_rc::false" + echo "new_tag=$version-rc$suffix" >> $GITHUB_OUTPUT + echo "first_rc=false" >> $GITHUB_OUTPUT else - echo "::set-output name=new_tag::$version-rc1" - echo "::set-output name=first_rc::true" + echo "new_tag=$version-rc1" >> $GITHUB_OUTPUT + echo "first_rc=true" >> $GITHUB_OUTPUT fi - name: Apply new tag uses: tvdias/github-tagger@ed7350546e3e503b5e942dffd65bc8751a95e49d # v0.0.2 @@ -42,7 +42,7 @@ jobs: repo-token: "${{ secrets.RELEASE_BRANCH_TOKEN }}" tag: ${{ steps.compute_tag.outputs.new_tag }} - id: create-issue - uses: JasonEtco/create-an-issue@9e6213aec58987fa7d2f4deb8b256b99e63107a2 # v2.6.0 + uses: JasonEtco/create-an-issue@e27dddc79c92bc6e4562f268fffa5ed752639abd # v2.9.1 # Only create the issue if it's the first release candidate if: steps.compute_tag.outputs.first_rc == 'true' env: diff --git a/.github/workflows/release-30_publish-draft-release.yml b/.github/workflows/release-30_publish-draft-release.yml index bdb17fa9fc68..356a8daa6b43 100644 --- a/.github/workflows/release-30_publish-draft-release.yml +++ b/.github/workflows/release-30_publish-draft-release.yml @@ -17,8 +17,8 @@ jobs: steps: - id: get-rust-versions run: | - echo "::set-output name=stable::$(rustc +stable --version)" - echo "::set-output name=nightly::$(rustc +nightly --version)" + echo "stable=$(rustc +stable --version)" >> $GITHUB_OUTPUT + echo "nightly=$(rustc +nightly --version)" >> $GITHUB_OUTPUT build-runtimes: runs-on: ubuntu-latest @@ -40,9 +40,8 @@ jobs: - name: Build ${{ matrix.runtime }} runtime id: srtool_build - uses: chevdor/srtool-actions@v0.5.0 + uses: chevdor/srtool-actions@v0.6.0 with: - # This is the default with chevdor/srtool-actions@v0.3.0+ but we make it clear image: paritytech/srtool chain: ${{ matrix.runtime }} @@ -167,7 +166,7 @@ jobs: ls "$RUNTIME_DIR/${{ matrix.runtime }}" runtime_ver=$(ruby script.rb) echo "Found version: >$runtime_ver<" - echo "::set-output name=runtime_ver::$runtime_ver" + echo "runtime_ver=$runtime_ver" >> $GITHUB_OUTPUT - name: Upload compressed ${{ matrix.runtime }} wasm uses: actions/upload-release-asset@v1 diff --git a/Cargo.lock b/Cargo.lock index 7bd0f3bf3d56..1896ef6ca445 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -152,6 +152,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbf688625d06217d5b1bb0ea9d9c44a1635fd0ee3534466388d18203174f4d11" +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + [[package]] name = "ansi_term" version = "0.12.1" @@ -756,6 +762,12 @@ dependencies = [ "serde_json", ] +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + [[package]] name = "cc" version = "1.0.73" @@ -844,6 +856,33 @@ dependencies = [ "winapi", ] +[[package]] +name = "ciborium" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c137568cc60b904a7724001b35ce2630fd00d5d84805fbb608ab89509d788f" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "346de753af073cc87b52b2083a506b38ac176a44cfb05497b622e27be899b369" + +[[package]] +name = "ciborium-ll" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213030a2b5a4e0c0892b6652260cf6ccac84827b83a85a534e178e3906c4cf1b" +dependencies = [ + "ciborium-io", + "half", +] + [[package]] name = "cid" version = "0.8.6" @@ -895,6 +934,18 @@ dependencies = [ "libloading", ] +[[package]] +name = "clap" +version = "3.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" +dependencies = [ + "bitflags", + "clap_lex 0.2.4", + "indexmap", + "textwrap", +] + [[package]] name = "clap" version = "4.0.15" @@ -904,7 +955,7 @@ dependencies = [ "atty", "bitflags", "clap_derive", - "clap_lex", + "clap_lex 0.3.0", "once_cell", "strsim", "termcolor", @@ -923,6 +974,15 @@ dependencies = [ "syn", ] +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", +] + [[package]] name = "clap_lex" version = "0.3.0" @@ -1186,6 +1246,40 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "criterion" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c76e09c1aae2bc52b3d2f29e13c6572553b30c4aa1b8a49fd70de6412654cb" +dependencies = [ + "anes", + "atty", + "cast", + "ciborium", + "clap 3.2.23", + "criterion-plot", + "itertools", + "lazy_static", + "num-traits", + "oorandom", + "regex", + "serde", + "serde_derive", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" +dependencies = [ + "cast", + "itertools", +] + [[package]] name = "crossbeam-channel" version = "0.5.5" @@ -2226,7 +2320,7 @@ dependencies = [ "Inflector", "array-bytes", "chrono", - "clap", + "clap 4.0.15", "comfy-table", "frame-benchmarking", "frame-support", @@ -2817,6 +2911,12 @@ dependencies = [ "tracing", ] +[[package]] +name = "half" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" + [[package]] name = "handlebars" version = "4.2.2" @@ -4808,6 +4908,12 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +[[package]] +name = "oorandom" +version = "11.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" + [[package]] name = "opaque-debug" version = "0.2.3" @@ -6313,7 +6419,7 @@ dependencies = [ name = "polkadot-cli" version = "0.9.33" dependencies = [ - "clap", + "clap 4.0.15", "frame-benchmarking-cli", "futures", "log", @@ -6456,6 +6562,7 @@ dependencies = [ name = "polkadot-erasure-coding" version = "0.9.33" dependencies = [ + "criterion", "parity-scale-codec", "polkadot-node-primitives", "polkadot-primitives", @@ -7570,7 +7677,7 @@ version = "0.9.33" dependencies = [ "assert_matches", "async-trait", - "clap", + "clap 4.0.15", "color-eyre", "futures", "futures-timer", @@ -7716,7 +7823,7 @@ dependencies = [ name = "polkadot-voter-bags" version = "0.9.33" dependencies = [ - "clap", + "clap 4.0.15", "generate-bags", "kusama-runtime", "polkadot-runtime", @@ -8343,7 +8450,7 @@ checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" name = "remote-ext-tests-bags-list" version = "0.9.33" dependencies = [ - "clap", + "clap 4.0.15", "frame-system", "kusama-runtime", "kusama-runtime-constants", @@ -8844,7 +8951,7 @@ source = "git+https://github.com/paritytech/substrate?branch=master#934d42aefb51 dependencies = [ "array-bytes", "chrono", - "clap", + "clap 4.0.15", "fdlimit", "futures", "libp2p", @@ -10972,7 +11079,7 @@ name = "staking-miner" version = "0.9.33" dependencies = [ "assert_cmd", - "clap", + "clap 4.0.15", "exitcode", "frame-election-provider-support", "frame-remote-externalities", @@ -11432,7 +11539,7 @@ dependencies = [ name = "test-parachain-adder-collator" version = "0.9.33" dependencies = [ - "clap", + "clap 4.0.15", "futures", "futures-timer", "log", @@ -11479,7 +11586,7 @@ dependencies = [ name = "test-parachain-undying-collator" version = "0.9.33" dependencies = [ - "clap", + "clap 4.0.15", "futures", "futures-timer", "log", @@ -11525,6 +11632,12 @@ dependencies = [ "sp-weights", ] +[[package]] +name = "textwrap" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" + [[package]] name = "thiserror" version = "1.0.37" @@ -12066,7 +12179,7 @@ name = "try-runtime-cli" version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=master#934d42aefb51b797ee9ef41270bc041b1c1c6025" dependencies = [ - "clap", + "clap 4.0.15", "frame-remote-externalities", "frame-try-runtime", "hex", @@ -13035,6 +13148,7 @@ dependencies = [ "pallet-society", "pallet-staking", "pallet-staking-reward-curve", + "pallet-state-trie-migration", "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", diff --git a/erasure-coding/Cargo.toml b/erasure-coding/Cargo.toml index 6d59b6a4b01d..868d1197efd7 100644 --- a/erasure-coding/Cargo.toml +++ b/erasure-coding/Cargo.toml @@ -12,3 +12,10 @@ parity-scale-codec = { version = "3.1.5", default-features = false, features = [ sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" } thiserror = "1.0.31" + +[dev-dependencies] +criterion = { version = "0.4.0", default-features = false, features = ["cargo_bench_support"] } + +[[bench]] +name = "scaling_with_validators" +harness = false diff --git a/erasure-coding/benches/README.md b/erasure-coding/benches/README.md new file mode 100644 index 000000000000..e643643229e8 --- /dev/null +++ b/erasure-coding/benches/README.md @@ -0,0 +1,39 @@ +### Run benches +``` +$ cd erasure-coding # ensure you are in the right directory +$ cargo bench +``` + +### `scaling_with_validators` + +This benchmark evaluates the performance of constructing the chunks and the erasure root from PoV and +reconstructing the PoV from chunks. You can see the results of running this bench on 5950x below. +Interestingly, with `10_000` chunks (validators) its slower than with `50_000` for both construction +and reconstruction. +``` +construct/200 time: [93.924 ms 94.525 ms 95.214 ms] + thrpt: [52.513 MiB/s 52.896 MiB/s 53.234 MiB/s] +construct/500 time: [111.25 ms 111.52 ms 111.80 ms] + thrpt: [44.721 MiB/s 44.837 MiB/s 44.946 MiB/s] +construct/1000 time: [117.37 ms 118.28 ms 119.21 ms] + thrpt: [41.941 MiB/s 42.273 MiB/s 42.601 MiB/s] +construct/2000 time: [125.05 ms 125.72 ms 126.38 ms] + thrpt: [39.564 MiB/s 39.772 MiB/s 39.983 MiB/s] +construct/10000 time: [270.46 ms 275.11 ms 279.81 ms] + thrpt: [17.869 MiB/s 18.174 MiB/s 18.487 MiB/s] +construct/50000 time: [205.86 ms 209.66 ms 213.64 ms] + thrpt: [23.404 MiB/s 23.848 MiB/s 24.288 MiB/s] + +reconstruct/200 time: [180.73 ms 184.09 ms 187.73 ms] + thrpt: [26.634 MiB/s 27.160 MiB/s 27.666 MiB/s] +reconstruct/500 time: [195.59 ms 198.58 ms 201.76 ms] + thrpt: [24.781 MiB/s 25.179 MiB/s 25.564 MiB/s] +reconstruct/1000 time: [207.92 ms 211.57 ms 215.57 ms] + thrpt: [23.195 MiB/s 23.633 MiB/s 24.048 MiB/s] +reconstruct/2000 time: [218.59 ms 223.68 ms 229.18 ms] + thrpt: [21.817 MiB/s 22.354 MiB/s 22.874 MiB/s] +reconstruct/10000 time: [496.35 ms 505.17 ms 515.42 ms] + thrpt: [9.7008 MiB/s 9.8977 MiB/s 10.074 MiB/s] +reconstruct/50000 time: [276.56 ms 277.53 ms 278.58 ms] + thrpt: [17.948 MiB/s 18.016 MiB/s 18.079 MiB/s] +``` diff --git a/erasure-coding/benches/scaling_with_validators.rs b/erasure-coding/benches/scaling_with_validators.rs new file mode 100644 index 000000000000..d361c23537c2 --- /dev/null +++ b/erasure-coding/benches/scaling_with_validators.rs @@ -0,0 +1,74 @@ +use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; +use polkadot_primitives::v2::Hash; +use std::time::Duration; + +fn chunks(n_validators: usize, pov: &Vec) -> Vec> { + polkadot_erasure_coding::obtain_chunks(n_validators, pov).unwrap() +} + +fn erasure_root(n_validators: usize, pov: &Vec) -> Hash { + let chunks = chunks(n_validators, pov); + polkadot_erasure_coding::branches(&chunks).root() +} + +fn construct_and_reconstruct_5mb_pov(c: &mut Criterion) { + const N_VALIDATORS: [usize; 6] = [200, 500, 1000, 2000, 10_000, 50_000]; + + const KB: usize = 1024; + const MB: usize = 1024 * KB; + + let pov = vec![0xfe; 5 * MB]; + + let mut group = c.benchmark_group("construct"); + for n_validators in N_VALIDATORS { + let expected_root = erasure_root(n_validators, &pov); + + group.throughput(Throughput::Bytes(pov.len() as u64)); + group.bench_with_input( + BenchmarkId::from_parameter(n_validators), + &n_validators, + |b, &n| { + b.iter(|| { + let root = erasure_root(n, &pov); + assert_eq!(root, expected_root); + }); + }, + ); + } + group.finish(); + + let mut group = c.benchmark_group("reconstruct"); + for n_validators in N_VALIDATORS { + let all_chunks = chunks(n_validators, &pov); + + let mut c: Vec<_> = all_chunks.iter().enumerate().map(|(i, c)| (&c[..], i)).collect(); + let last_chunks = c.split_off((c.len() - 1) * 2 / 3); + + group.throughput(Throughput::Bytes(pov.len() as u64)); + group.bench_with_input( + BenchmarkId::from_parameter(n_validators), + &n_validators, + |b, &n| { + b.iter(|| { + let _pov: Vec = + polkadot_erasure_coding::reconstruct(n, last_chunks.clone()).unwrap(); + }); + }, + ); + } + group.finish(); +} + +fn criterion_config() -> Criterion { + Criterion::default() + .sample_size(15) + .warm_up_time(Duration::from_millis(200)) + .measurement_time(Duration::from_secs(3)) +} + +criterion_group!( + name = re_construct; + config = criterion_config(); + targets = construct_and_reconstruct_5mb_pov, +); +criterion_main!(re_construct); diff --git a/erasure-coding/fuzzer/src/round_trip.rs b/erasure-coding/fuzzer/src/round_trip.rs index daa57a566fbb..1284e59f20e3 100644 --- a/erasure-coding/fuzzer/src/round_trip.rs +++ b/erasure-coding/fuzzer/src/round_trip.rs @@ -2,7 +2,7 @@ use polkadot_erasure_coding::*; use primitives::{AvailableData, BlockData, PoV}; use std::sync::Arc; use honggfuzz::fuzz; -use polkadot_primitives::v2::PersistedValidationData; +use polkadot_primitives::PersistedValidationData; fn main() { diff --git a/erasure-coding/src/lib.rs b/erasure-coding/src/lib.rs index 6abd7dce4dd3..50c9ca64e0df 100644 --- a/erasure-coding/src/lib.rs +++ b/erasure-coding/src/lib.rs @@ -26,7 +26,7 @@ use parity_scale_codec::{Decode, Encode}; use polkadot_node_primitives::{AvailableData, Proof}; -use polkadot_primitives::v2::{BlakeTwo256, Hash as H256, HashT}; +use polkadot_primitives::{BlakeTwo256, Hash as H256, HashT}; use sp_core::Blake2Hasher; use sp_trie::{ trie_types::{TrieDBBuilder, TrieDBMutBuilderV0 as TrieDBMutBuilder}, diff --git a/node/client/src/benchmarking.rs b/node/client/src/benchmarking.rs index 17ef63f4ba6e..7ed9bcee5041 100644 --- a/node/client/src/benchmarking.rs +++ b/node/client/src/benchmarking.rs @@ -16,7 +16,7 @@ //! Code related to benchmarking a [`crate::Client`]. -use polkadot_primitives::v2::{AccountId, Balance}; +use polkadot_primitives::{AccountId, Balance}; use sp_core::{Pair, H256}; use sp_keyring::Sr25519Keyring; use sp_runtime::OpaqueExtrinsic; @@ -361,14 +361,14 @@ pub fn benchmark_inherent_data( let timestamp = sp_timestamp::InherentDataProvider::new(d.into()); futures::executor::block_on(timestamp.provide_inherent_data(&mut inherent_data))?; - let para_data = polkadot_primitives::v2::InherentData { + let para_data = polkadot_primitives::InherentData { bitfields: Vec::new(), backed_candidates: Vec::new(), disputes: Vec::new(), parent_header: header, }; - inherent_data.put_data(polkadot_primitives::v2::PARACHAINS_INHERENT_IDENTIFIER, ¶_data)?; + inherent_data.put_data(polkadot_primitives::PARACHAINS_INHERENT_IDENTIFIER, ¶_data)?; Ok(inherent_data) } diff --git a/node/client/src/lib.rs b/node/client/src/lib.rs index 648d1d63155d..d037f60a618c 100644 --- a/node/client/src/lib.rs +++ b/node/client/src/lib.rs @@ -20,8 +20,7 @@ //! There is also the [`Client`] enum that combines all the different clients into one common structure. use polkadot_primitives::{ - runtime_api::ParachainHost, - v2::{AccountId, Balance, Block, BlockNumber, Hash, Header, Nonce}, + runtime_api::ParachainHost, AccountId, Balance, Block, BlockNumber, Hash, Header, Nonce, }; use sc_client_api::{AuxStore, Backend as BackendT, BlockchainEvents, KeyIterator, UsageProvider}; use sc_executor::NativeElseWasmExecutor; diff --git a/node/collation-generation/src/lib.rs b/node/collation-generation/src/lib.rs index 500b500636ba..b3d728f70a48 100644 --- a/node/collation-generation/src/lib.rs +++ b/node/collation-generation/src/lib.rs @@ -30,7 +30,7 @@ use polkadot_node_subsystem_util::{ request_availability_cores, request_persisted_validation_data, request_validation_code, request_validation_code_hash, request_validators, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ collator_signature_payload, CandidateCommitments, CandidateDescriptor, CandidateReceipt, CoreState, Hash, Id as ParaId, OccupiedCoreAssumption, PersistedValidationData, ValidationCodeHash, @@ -177,7 +177,7 @@ async fn handle_new_activations( sender: &mpsc::Sender, ) -> crate::error::Result<()> { // follow the procedure from the guide: - // https://w3f.github.io/parachain-implementers-guide/node/collators/collation-generation.html + // https://paritytech.github.io/polkadot/book/node/collators/collation-generation.html let _overall_timer = metrics.time_new_activations(); diff --git a/node/collation-generation/src/tests.rs b/node/collation-generation/src/tests.rs index ca75666c85e3..05961582a222 100644 --- a/node/collation-generation/src/tests.rs +++ b/node/collation-generation/src/tests.rs @@ -32,7 +32,7 @@ mod handle_new_activations { use polkadot_node_subsystem_test_helpers::{ subsystem_test_harness, TestSubsystemContextHandle, }; - use polkadot_primitives::v2::{ + use polkadot_primitives::{ CollatorPair, Id as ParaId, PersistedValidationData, ScheduledCore, ValidationCode, }; use std::pin::Pin; diff --git a/node/core/approval-voting/src/approval_checking.rs b/node/core/approval-voting/src/approval_checking.rs index 82a9a8c89bf5..aba03ed1ce30 100644 --- a/node/core/approval-voting/src/approval_checking.rs +++ b/node/core/approval-voting/src/approval_checking.rs @@ -18,7 +18,7 @@ use bitvec::{order::Lsb0 as BitOrderLsb0, slice::BitSlice}; use polkadot_node_primitives::approval::DelayTranche; -use polkadot_primitives::v2::ValidatorIndex; +use polkadot_primitives::ValidatorIndex; use crate::{ persisted_entries::{ApprovalEntry, CandidateEntry, TrancheEntry}, @@ -460,7 +460,7 @@ mod tests { use crate::{approval_db, BTreeMap}; use ::test_helpers::{dummy_candidate_receipt, dummy_hash}; use bitvec::{bitvec, order::Lsb0 as BitOrderLsb0, vec::BitVec}; - use polkadot_primitives::v2::GroupIndex; + use polkadot_primitives::GroupIndex; #[test] fn pending_is_not_approved() { diff --git a/node/core/approval-voting/src/approval_db/v1/mod.rs b/node/core/approval-voting/src/approval_db/v1/mod.rs index 858bcb8c36fe..a761b7f20e84 100644 --- a/node/core/approval-voting/src/approval_db/v1/mod.rs +++ b/node/core/approval-voting/src/approval_db/v1/mod.rs @@ -20,7 +20,7 @@ use parity_scale_codec::{Decode, Encode}; use polkadot_node_primitives::approval::{AssignmentCert, DelayTranche}; use polkadot_node_subsystem::{SubsystemError, SubsystemResult}; use polkadot_node_subsystem_util::database::{DBTransaction, Database}; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ BlockNumber, CandidateHash, CandidateReceipt, CoreIndex, GroupIndex, Hash, SessionIndex, ValidatorIndex, ValidatorSignature, }; diff --git a/node/core/approval-voting/src/approval_db/v1/tests.rs b/node/core/approval-voting/src/approval_db/v1/tests.rs index 06923c6a539f..5b6602882e59 100644 --- a/node/core/approval-voting/src/approval_db/v1/tests.rs +++ b/node/core/approval-voting/src/approval_db/v1/tests.rs @@ -22,7 +22,7 @@ use crate::{ ops::{add_block_entry, canonicalize, force_approve, NewCandidateInfo}, }; use polkadot_node_subsystem_util::database::Database; -use polkadot_primitives::v2::Id as ParaId; +use polkadot_primitives::Id as ParaId; use std::{collections::HashMap, sync::Arc}; use ::test_helpers::{dummy_candidate_receipt, dummy_candidate_receipt_bad_sig, dummy_hash}; diff --git a/node/core/approval-voting/src/backend.rs b/node/core/approval-voting/src/backend.rs index 9cb2cb59ec78..3fb90fabe574 100644 --- a/node/core/approval-voting/src/backend.rs +++ b/node/core/approval-voting/src/backend.rs @@ -22,7 +22,7 @@ //! before any commit to the underlying storage is made. use polkadot_node_subsystem::SubsystemResult; -use polkadot_primitives::v2::{BlockNumber, CandidateHash, Hash}; +use polkadot_primitives::{BlockNumber, CandidateHash, Hash}; use std::collections::HashMap; diff --git a/node/core/approval-voting/src/criteria.rs b/node/core/approval-voting/src/criteria.rs index 520a1a745056..6707fc5672aa 100644 --- a/node/core/approval-voting/src/criteria.rs +++ b/node/core/approval-voting/src/criteria.rs @@ -20,7 +20,7 @@ use parity_scale_codec::{Decode, Encode}; use polkadot_node_primitives::approval::{ self as approval_types, AssignmentCert, AssignmentCertKind, DelayTranche, RelayVRFStory, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ AssignmentId, AssignmentPair, CandidateHash, CoreIndex, GroupIndex, IndexedVec, SessionInfo, ValidatorIndex, }; @@ -553,7 +553,7 @@ fn is_in_backing_group( mod tests { use super::*; use polkadot_node_primitives::approval::{VRFOutput, VRFProof}; - use polkadot_primitives::v2::{Hash, ASSIGNMENT_KEY_TYPE_ID}; + use polkadot_primitives::{Hash, ASSIGNMENT_KEY_TYPE_ID}; use sp_application_crypto::sr25519; use sp_core::crypto::Pair as PairT; use sp_keyring::sr25519::Keyring as Sr25519Keyring; diff --git a/node/core/approval-voting/src/import.rs b/node/core/approval-voting/src/import.rs index 2331b50b6bb1..f36b79c7a4e1 100644 --- a/node/core/approval-voting/src/import.rs +++ b/node/core/approval-voting/src/import.rs @@ -44,7 +44,7 @@ use polkadot_node_subsystem_util::{ determine_new_blocks, rolling_session_window::{RollingSessionWindow, SessionWindowUpdate}, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ BlockNumber, CandidateEvent, CandidateHash, CandidateReceipt, ConsensusLog, CoreIndex, GroupIndex, Hash, Header, SessionIndex, }; @@ -617,9 +617,7 @@ pub(crate) mod tests { use polkadot_node_subsystem::messages::{AllMessages, ApprovalVotingMessage}; use polkadot_node_subsystem_test_helpers::make_subsystem_context; use polkadot_node_subsystem_util::database::Database; - use polkadot_primitives::v2::{ - Id as ParaId, IndexedVec, SessionInfo, ValidatorId, ValidatorIndex, - }; + use polkadot_primitives::{Id as ParaId, IndexedVec, SessionInfo, ValidatorId, ValidatorIndex}; pub(crate) use sp_consensus_babe::{ digests::{CompatibleDigestItem, PreDigest, SecondaryVRFPreDigest}, AllowedSlots, BabeEpochConfiguration, Epoch as BabeEpoch, @@ -683,21 +681,21 @@ pub(crate) mod tests { _config: &criteria::Config, _leaving_cores: Vec<( CandidateHash, - polkadot_primitives::v2::CoreIndex, - polkadot_primitives::v2::GroupIndex, + polkadot_primitives::CoreIndex, + polkadot_primitives::GroupIndex, )>, - ) -> HashMap { + ) -> HashMap { HashMap::new() } fn check_assignment_cert( &self, - _claimed_core_index: polkadot_primitives::v2::CoreIndex, - _validator_index: polkadot_primitives::v2::ValidatorIndex, + _claimed_core_index: polkadot_primitives::CoreIndex, + _validator_index: polkadot_primitives::ValidatorIndex, _config: &criteria::Config, _relay_vrf_story: polkadot_node_primitives::approval::RelayVRFStory, _assignment: &polkadot_node_primitives::approval::AssignmentCert, - _backing_group: polkadot_primitives::v2::GroupIndex, + _backing_group: polkadot_primitives::GroupIndex, ) -> Result { Ok(0) } diff --git a/node/core/approval-voting/src/lib.rs b/node/core/approval-voting/src/lib.rs index 14fc87761c42..900d3107b034 100644 --- a/node/core/approval-voting/src/lib.rs +++ b/node/core/approval-voting/src/lib.rs @@ -48,7 +48,7 @@ use polkadot_node_subsystem_util::{ }, TimeoutExt, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ ApprovalVote, BlockNumber, CandidateHash, CandidateIndex, CandidateReceipt, DisputeStatement, GroupIndex, Hash, SessionIndex, SessionInfo, ValidDisputeStatementKind, ValidatorId, ValidatorIndex, ValidatorPair, ValidatorSignature, diff --git a/node/core/approval-voting/src/ops.rs b/node/core/approval-voting/src/ops.rs index 0491009b0740..37f564c34f71 100644 --- a/node/core/approval-voting/src/ops.rs +++ b/node/core/approval-voting/src/ops.rs @@ -20,7 +20,7 @@ use polkadot_node_subsystem::{SubsystemError, SubsystemResult}; use bitvec::order::Lsb0 as BitOrderLsb0; -use polkadot_primitives::v2::{BlockNumber, CandidateHash, CandidateReceipt, GroupIndex, Hash}; +use polkadot_primitives::{BlockNumber, CandidateHash, CandidateReceipt, GroupIndex, Hash}; use std::collections::{hash_map::Entry, BTreeMap, HashMap}; diff --git a/node/core/approval-voting/src/persisted_entries.rs b/node/core/approval-voting/src/persisted_entries.rs index e3ea480816e0..1df0ff91c1a1 100644 --- a/node/core/approval-voting/src/persisted_entries.rs +++ b/node/core/approval-voting/src/persisted_entries.rs @@ -21,7 +21,7 @@ //! data and logic are intertwined. use polkadot_node_primitives::approval::{AssignmentCert, DelayTranche, RelayVRFStory}; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ BlockNumber, CandidateHash, CandidateReceipt, CoreIndex, GroupIndex, Hash, SessionIndex, ValidatorIndex, ValidatorSignature, }; diff --git a/node/core/approval-voting/src/tests.rs b/node/core/approval-voting/src/tests.rs index b9063c8ade25..ee13db7bcf54 100644 --- a/node/core/approval-voting/src/tests.rs +++ b/node/core/approval-voting/src/tests.rs @@ -33,7 +33,7 @@ use polkadot_node_subsystem::{ use polkadot_node_subsystem_test_helpers as test_helpers; use polkadot_node_subsystem_util::TimeoutExt; use polkadot_overseer::HeadSupportsParachains; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ CandidateCommitments, CandidateEvent, CoreIndex, GroupIndex, Header, Id as ParaId, IndexedVec, ValidationCode, ValidatorSignature, }; @@ -227,7 +227,7 @@ struct MockAssignmentCriteria(Compute, Check); impl AssignmentCriteria for MockAssignmentCriteria where - Compute: Fn() -> HashMap, + Compute: Fn() -> HashMap, Check: Fn(ValidatorIndex) -> Result, { fn compute_assignments( @@ -237,31 +237,28 @@ where _config: &criteria::Config, _leaving_cores: Vec<( CandidateHash, - polkadot_primitives::v2::CoreIndex, - polkadot_primitives::v2::GroupIndex, + polkadot_primitives::CoreIndex, + polkadot_primitives::GroupIndex, )>, - ) -> HashMap { + ) -> HashMap { self.0() } fn check_assignment_cert( &self, - _claimed_core_index: polkadot_primitives::v2::CoreIndex, + _claimed_core_index: polkadot_primitives::CoreIndex, validator_index: ValidatorIndex, _config: &criteria::Config, _relay_vrf_story: polkadot_node_primitives::approval::RelayVRFStory, _assignment: &polkadot_node_primitives::approval::AssignmentCert, - _backing_group: polkadot_primitives::v2::GroupIndex, + _backing_group: polkadot_primitives::GroupIndex, ) -> Result { self.1(validator_index) } } impl - MockAssignmentCriteria< - fn() -> HashMap, - F, - > + MockAssignmentCriteria HashMap, F> { fn check_only(f: F) -> Self { MockAssignmentCriteria(Default::default, f) @@ -480,7 +477,7 @@ fn test_harness>( let keystore = LocalKeystore::in_memory(); let _ = keystore.sr25519_generate_new( - polkadot_primitives::v2::PARACHAIN_KEY_TYPE_ID, + polkadot_primitives::PARACHAIN_KEY_TYPE_ID, Some(&Sr25519Keyring::Alice.to_seed()), ); diff --git a/node/core/av-store/src/lib.rs b/node/core/av-store/src/lib.rs index 2bcd337b7491..4509c5712188 100644 --- a/node/core/av-store/src/lib.rs +++ b/node/core/av-store/src/lib.rs @@ -39,7 +39,7 @@ use polkadot_node_subsystem::{ overseer, ActiveLeavesUpdate, FromOrchestra, OverseerSignal, SpawnedSubsystem, SubsystemError, }; use polkadot_node_subsystem_util as util; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ BlockNumber, CandidateEvent, CandidateHash, CandidateReceipt, Hash, Header, ValidatorIndex, }; diff --git a/node/core/av-store/src/tests.rs b/node/core/av-store/src/tests.rs index 7d5d4a5025e5..9efd410ebac2 100644 --- a/node/core/av-store/src/tests.rs +++ b/node/core/av-store/src/tests.rs @@ -30,7 +30,7 @@ use polkadot_node_subsystem::{ }; use polkadot_node_subsystem_test_helpers as test_helpers; use polkadot_node_subsystem_util::{database::Database, TimeoutExt}; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ CandidateHash, CandidateReceipt, CoreIndex, GroupIndex, HeadData, Header, PersistedValidationData, ValidatorId, }; diff --git a/node/core/backing/src/error.rs b/node/core/backing/src/error.rs index 604c6c0a0c37..36d4f859a0a8 100644 --- a/node/core/backing/src/error.rs +++ b/node/core/backing/src/error.rs @@ -19,7 +19,7 @@ use futures::channel::{mpsc, oneshot}; use polkadot_node_subsystem::{messages::ValidationFailed, SubsystemError}; use polkadot_node_subsystem_util::Error as UtilError; -use polkadot_primitives::v2::BackedCandidate; +use polkadot_primitives::BackedCandidate; use crate::LOG_TARGET; diff --git a/node/core/backing/src/lib.rs b/node/core/backing/src/lib.rs index 2f8aa4490f27..dda0c9bdf5a8 100644 --- a/node/core/backing/src/lib.rs +++ b/node/core/backing/src/lib.rs @@ -48,7 +48,7 @@ use polkadot_node_subsystem_util::{ self as util, request_from_runtime, request_session_index_for_child, request_validator_groups, request_validators, Validator, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ BackedCandidate, CandidateCommitments, CandidateHash, CandidateReceipt, CollatorId, CommittedCandidateReceipt, CoreIndex, CoreState, Hash, Id as ParaId, SigningContext, ValidatorId, ValidatorIndex, ValidatorSignature, ValidityAttestation, @@ -587,7 +587,7 @@ async fn make_pov_available( n_validators: usize, pov: Arc, candidate_hash: CandidateHash, - validation_data: polkadot_primitives::v2::PersistedValidationData, + validation_data: polkadot_primitives::PersistedValidationData, expected_erasure_root: Hash, span: Option<&jaeger::Span>, ) -> Result, Error> { diff --git a/node/core/backing/src/tests.rs b/node/core/backing/src/tests.rs index 24f671ec5371..9249d204ddca 100644 --- a/node/core/backing/src/tests.rs +++ b/node/core/backing/src/tests.rs @@ -30,7 +30,7 @@ use polkadot_node_subsystem::{ ActivatedLeaf, ActiveLeavesUpdate, FromOrchestra, LeafStatus, OverseerSignal, }; use polkadot_node_subsystem_test_helpers as test_helpers; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ CandidateDescriptor, CollatorId, GroupRotationInfo, HeadData, PersistedValidationData, ScheduledCore, }; diff --git a/node/core/bitfield-signing/src/lib.rs b/node/core/bitfield-signing/src/lib.rs index 64cbb18cc44c..5de75cadf12e 100644 --- a/node/core/bitfield-signing/src/lib.rs +++ b/node/core/bitfield-signing/src/lib.rs @@ -36,7 +36,7 @@ use polkadot_node_subsystem::{ SpawnedSubsystem, SubsystemError, SubsystemResult, SubsystemSender, }; use polkadot_node_subsystem_util::{self as util, Validator}; -use polkadot_primitives::v2::{AvailabilityBitfield, CoreState, Hash, ValidatorIndex}; +use polkadot_primitives::{AvailabilityBitfield, CoreState, Hash, ValidatorIndex}; use sp_keystore::{Error as KeystoreError, SyncCryptoStorePtr}; use std::{collections::HashMap, iter::FromIterator, time::Duration}; use wasm_timer::{Delay, Instant}; diff --git a/node/core/bitfield-signing/src/tests.rs b/node/core/bitfield-signing/src/tests.rs index 19777c29157f..99b8c4f22b52 100644 --- a/node/core/bitfield-signing/src/tests.rs +++ b/node/core/bitfield-signing/src/tests.rs @@ -17,7 +17,7 @@ use super::*; use futures::{executor::block_on, pin_mut, StreamExt}; use polkadot_node_subsystem::messages::AllMessages; -use polkadot_primitives::v2::{CandidateHash, OccupiedCore}; +use polkadot_primitives::{CandidateHash, OccupiedCore}; use test_helpers::dummy_candidate_descriptor; fn occupied_core(para_id: u32, candidate_hash: CandidateHash) -> CoreState { diff --git a/node/core/candidate-validation/src/lib.rs b/node/core/candidate-validation/src/lib.rs index dd2827e751fe..58d91946830f 100644 --- a/node/core/candidate-validation/src/lib.rs +++ b/node/core/candidate-validation/src/lib.rs @@ -39,7 +39,7 @@ use polkadot_node_subsystem::{ SubsystemSender, }; use polkadot_parachain::primitives::{ValidationParams, ValidationResult as WasmValidationResult}; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ CandidateCommitments, CandidateDescriptor, CandidateReceipt, Hash, OccupiedCoreAssumption, PersistedValidationData, ValidationCode, ValidationCodeHash, }; @@ -295,8 +295,7 @@ where _ => { // The reasoning why this is "failed" and not invalid is because we assume that // during pre-checking voting the relay-chain will pin the code. In case the code - // actually is not there, we issue failed since this looks more like a bug. This - // leads to us abstaining. + // actually is not there, we issue failed since this looks more like a bug. gum::warn!( target: LOG_TARGET, ?relay_parent, @@ -635,7 +634,7 @@ trait ValidationBackend { // Wait a brief delay before retrying. futures_timer::Delay::new(PVF_EXECUTION_RETRY_DELAY).await; - gum::debug!( + gum::warn!( target: LOG_TARGET, ?pvf, "Re-trying failed candidate validation due to AmbiguousWorkerDeath." diff --git a/node/core/candidate-validation/src/tests.rs b/node/core/candidate-validation/src/tests.rs index 476e4ea7f985..445ea118f3d1 100644 --- a/node/core/candidate-validation/src/tests.rs +++ b/node/core/candidate-validation/src/tests.rs @@ -22,7 +22,7 @@ use polkadot_node_core_pvf::PrepareError; use polkadot_node_subsystem::messages::AllMessages; use polkadot_node_subsystem_test_helpers as test_helpers; use polkadot_node_subsystem_util::reexports::SubsystemContext; -use polkadot_primitives::v2::{HeadData, Id as ParaId, UpwardMessage}; +use polkadot_primitives::{HeadData, Id as ParaId, UpwardMessage}; use sp_core::testing::TaskExecutor; use sp_keyring::Sr25519Keyring; diff --git a/node/core/chain-api/src/lib.rs b/node/core/chain-api/src/lib.rs index b218c00c57e5..012c867f3b29 100644 --- a/node/core/chain-api/src/lib.rs +++ b/node/core/chain-api/src/lib.rs @@ -41,7 +41,7 @@ use polkadot_node_subsystem::{ messages::ChainApiMessage, overseer, FromOrchestra, OverseerSignal, SpawnedSubsystem, SubsystemError, SubsystemResult, }; -use polkadot_primitives::v2::Block; +use polkadot_primitives::Block; mod metrics; use self::metrics::Metrics; diff --git a/node/core/chain-api/src/tests.rs b/node/core/chain-api/src/tests.rs index 654458757e70..e8323f041170 100644 --- a/node/core/chain-api/src/tests.rs +++ b/node/core/chain-api/src/tests.rs @@ -6,7 +6,7 @@ use std::collections::BTreeMap; use polkadot_node_primitives::BlockWeight; use polkadot_node_subsystem_test_helpers::{make_subsystem_context, TestSubsystemContextHandle}; -use polkadot_primitives::v2::{BlockNumber, Hash, Header}; +use polkadot_primitives::{BlockNumber, Hash, Header}; use sp_blockchain::Info as BlockInfo; use sp_core::testing::TaskExecutor; diff --git a/node/core/chain-selection/src/backend.rs b/node/core/chain-selection/src/backend.rs index 6c5396a5c64d..3b21e9ea99c9 100644 --- a/node/core/chain-selection/src/backend.rs +++ b/node/core/chain-selection/src/backend.rs @@ -21,7 +21,7 @@ //! [`Backend`], maintaining consistency between queries and temporary writes, //! before any commit to the underlying storage is made. -use polkadot_primitives::v2::{BlockNumber, Hash}; +use polkadot_primitives::{BlockNumber, Hash}; use std::collections::HashMap; diff --git a/node/core/chain-selection/src/db_backend/v1.rs b/node/core/chain-selection/src/db_backend/v1.rs index a037d27baaea..64c4e37b1502 100644 --- a/node/core/chain-selection/src/db_backend/v1.rs +++ b/node/core/chain-selection/src/db_backend/v1.rs @@ -38,7 +38,7 @@ use crate::{ }; use polkadot_node_primitives::BlockWeight; -use polkadot_primitives::v2::{BlockNumber, Hash}; +use polkadot_primitives::{BlockNumber, Hash}; use parity_scale_codec::{Decode, Encode}; use polkadot_node_subsystem_util::database::{DBTransaction, Database}; diff --git a/node/core/chain-selection/src/lib.rs b/node/core/chain-selection/src/lib.rs index 786454fb9891..ed2aced89ef3 100644 --- a/node/core/chain-selection/src/lib.rs +++ b/node/core/chain-selection/src/lib.rs @@ -24,7 +24,7 @@ use polkadot_node_subsystem::{ FromOrchestra, OverseerSignal, SpawnedSubsystem, SubsystemError, }; use polkadot_node_subsystem_util::database::Database; -use polkadot_primitives::v2::{BlockNumber, ConsensusLog, Hash, Header}; +use polkadot_primitives::{BlockNumber, ConsensusLog, Hash, Header}; use futures::{channel::oneshot, future::Either, prelude::*}; use parity_scale_codec::Error as CodecError; diff --git a/node/core/chain-selection/src/tests.rs b/node/core/chain-selection/src/tests.rs index 404b854d894b..55d4007d1770 100644 --- a/node/core/chain-selection/src/tests.rs +++ b/node/core/chain-selection/src/tests.rs @@ -39,7 +39,7 @@ use polkadot_node_subsystem::{ jaeger, messages::AllMessages, ActivatedLeaf, ActiveLeavesUpdate, LeafStatus, }; use polkadot_node_subsystem_test_helpers as test_helpers; -use polkadot_primitives::v2::{BlakeTwo256, ConsensusLog, HashT}; +use polkadot_primitives::{BlakeTwo256, ConsensusLog, HashT}; #[derive(Default)] struct TestBackendInner { diff --git a/node/core/chain-selection/src/tree.rs b/node/core/chain-selection/src/tree.rs index aafd75de5f97..fc94833bc56e 100644 --- a/node/core/chain-selection/src/tree.rs +++ b/node/core/chain-selection/src/tree.rs @@ -25,7 +25,7 @@ use polkadot_node_primitives::BlockWeight; use polkadot_node_subsystem::ChainApiError; -use polkadot_primitives::v2::{BlockNumber, Hash}; +use polkadot_primitives::{BlockNumber, Hash}; use std::collections::HashMap; diff --git a/node/core/dispute-coordinator/src/backend.rs b/node/core/dispute-coordinator/src/backend.rs index 9e8252f01176..9275420d0a3d 100644 --- a/node/core/dispute-coordinator/src/backend.rs +++ b/node/core/dispute-coordinator/src/backend.rs @@ -22,7 +22,7 @@ //! before any commit to the underlying storage is made. use polkadot_node_subsystem::SubsystemResult; -use polkadot_primitives::v2::{CandidateHash, SessionIndex}; +use polkadot_primitives::{CandidateHash, SessionIndex}; use std::collections::HashMap; diff --git a/node/core/dispute-coordinator/src/db/v1.rs b/node/core/dispute-coordinator/src/db/v1.rs index ab571108af37..441ba4e09575 100644 --- a/node/core/dispute-coordinator/src/db/v1.rs +++ b/node/core/dispute-coordinator/src/db/v1.rs @@ -19,7 +19,7 @@ use polkadot_node_primitives::DisputeStatus; use polkadot_node_subsystem::{SubsystemError, SubsystemResult}; use polkadot_node_subsystem_util::database::{DBTransaction, Database}; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ CandidateHash, CandidateReceipt, Hash, InvalidDisputeStatementKind, SessionIndex, ValidDisputeStatementKind, ValidatorIndex, ValidatorSignature, }; @@ -373,7 +373,7 @@ mod tests { use super::*; use ::test_helpers::{dummy_candidate_receipt, dummy_hash}; use polkadot_node_primitives::DISPUTE_WINDOW; - use polkadot_primitives::v2::{Hash, Id as ParaId}; + use polkadot_primitives::{Hash, Id as ParaId}; fn make_db() -> DbBackend { let db = kvdb_memorydb::create(1); diff --git a/node/core/dispute-coordinator/src/import.rs b/node/core/dispute-coordinator/src/import.rs index 6573fd6907a9..4f6edc5fcef0 100644 --- a/node/core/dispute-coordinator/src/import.rs +++ b/node/core/dispute-coordinator/src/import.rs @@ -32,7 +32,7 @@ use polkadot_node_primitives::{ disputes::ValidCandidateVotes, CandidateVotes, DisputeStatus, SignedDisputeStatement, Timestamp, }; use polkadot_node_subsystem_util::rolling_session_window::RollingSessionWindow; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ CandidateReceipt, DisputeStatement, IndexedVec, SessionIndex, SessionInfo, ValidDisputeStatementKind, ValidatorId, ValidatorIndex, ValidatorPair, ValidatorSignature, }; @@ -188,15 +188,14 @@ impl CandidateVoteState { let n_validators = env.validators().len(); - let supermajority_threshold = - polkadot_primitives::v2::supermajority_threshold(n_validators); + let supermajority_threshold = polkadot_primitives::supermajority_threshold(n_validators); // We have a dispute, if we have votes on both sides: let is_disputed = !votes.invalid.is_empty() && !votes.valid.raw().is_empty(); let dispute_status = if is_disputed { let mut status = DisputeStatus::active(); - let byzantine_threshold = polkadot_primitives::v2::byzantine_threshold(n_validators); + let byzantine_threshold = polkadot_primitives::byzantine_threshold(n_validators); let is_confirmed = votes.voted_indices().len() > byzantine_threshold; if is_confirmed { status = status.confirm(); diff --git a/node/core/dispute-coordinator/src/initialized.rs b/node/core/dispute-coordinator/src/initialized.rs index a186ae17e6d8..27064bee8b12 100644 --- a/node/core/dispute-coordinator/src/initialized.rs +++ b/node/core/dispute-coordinator/src/initialized.rs @@ -38,7 +38,7 @@ use polkadot_node_subsystem::{ use polkadot_node_subsystem_util::rolling_session_window::{ RollingSessionWindow, SessionWindowUpdate, SessionsUnavailable, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ BlockNumber, CandidateHash, CandidateReceipt, CompactStatement, DisputeStatement, DisputeStatementSet, Hash, ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidDisputeStatementKind, ValidatorId, ValidatorIndex, diff --git a/node/core/dispute-coordinator/src/lib.rs b/node/core/dispute-coordinator/src/lib.rs index fd7ae67beaa5..1c66c6c6099c 100644 --- a/node/core/dispute-coordinator/src/lib.rs +++ b/node/core/dispute-coordinator/src/lib.rs @@ -42,7 +42,7 @@ use polkadot_node_subsystem_util::{ database::Database, rolling_session_window::{DatabaseParams, RollingSessionWindow}, }; -use polkadot_primitives::v2::{DisputeStatement, ScrapedOnChainVotes, SessionInfo, ValidatorIndex}; +use polkadot_primitives::{DisputeStatement, ScrapedOnChainVotes, SessionInfo, ValidatorIndex}; use crate::{ error::{FatalResult, JfyiError, Result}, diff --git a/node/core/dispute-coordinator/src/participation/mod.rs b/node/core/dispute-coordinator/src/participation/mod.rs index 7167bc7e26e8..78a3a2592075 100644 --- a/node/core/dispute-coordinator/src/participation/mod.rs +++ b/node/core/dispute-coordinator/src/participation/mod.rs @@ -31,7 +31,7 @@ use polkadot_node_subsystem::{ overseer, ActiveLeavesUpdate, RecoveryError, }; use polkadot_node_subsystem_util::runtime::get_validation_code_by_hash; -use polkadot_primitives::v2::{BlockNumber, CandidateHash, CandidateReceipt, Hash, SessionIndex}; +use polkadot_primitives::{BlockNumber, CandidateHash, CandidateReceipt, Hash, SessionIndex}; use crate::LOG_TARGET; diff --git a/node/core/dispute-coordinator/src/participation/queues/mod.rs b/node/core/dispute-coordinator/src/participation/queues/mod.rs index 3452470efcb5..b632e04dbb4f 100644 --- a/node/core/dispute-coordinator/src/participation/queues/mod.rs +++ b/node/core/dispute-coordinator/src/participation/queues/mod.rs @@ -18,7 +18,7 @@ use std::{cmp::Ordering, collections::BTreeMap}; use futures::channel::oneshot; use polkadot_node_subsystem::{messages::ChainApiMessage, overseer}; -use polkadot_primitives::v2::{BlockNumber, CandidateHash, CandidateReceipt, Hash, SessionIndex}; +use polkadot_primitives::{BlockNumber, CandidateHash, CandidateReceipt, Hash, SessionIndex}; use crate::{ error::{FatalError, FatalResult, Result}, diff --git a/node/core/dispute-coordinator/src/participation/queues/tests.rs b/node/core/dispute-coordinator/src/participation/queues/tests.rs index b6af4bd2b55a..164e7b3f011b 100644 --- a/node/core/dispute-coordinator/src/participation/queues/tests.rs +++ b/node/core/dispute-coordinator/src/participation/queues/tests.rs @@ -17,7 +17,7 @@ use crate::ParticipationPriority; use ::test_helpers::{dummy_candidate_receipt, dummy_hash}; use assert_matches::assert_matches; -use polkadot_primitives::v2::{BlockNumber, Hash}; +use polkadot_primitives::{BlockNumber, Hash}; use super::{CandidateComparator, ParticipationRequest, QueueError, Queues}; diff --git a/node/core/dispute-coordinator/src/participation/tests.rs b/node/core/dispute-coordinator/src/participation/tests.rs index bf149a87286f..273c27261081 100644 --- a/node/core/dispute-coordinator/src/participation/tests.rs +++ b/node/core/dispute-coordinator/src/participation/tests.rs @@ -38,7 +38,7 @@ use polkadot_node_subsystem::{ use polkadot_node_subsystem_test_helpers::{ make_subsystem_context, TestSubsystemContext, TestSubsystemContextHandle, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ BlakeTwo256, CandidateCommitments, HashT, Header, PersistedValidationData, ValidationCode, }; diff --git a/node/core/dispute-coordinator/src/scraping/candidates.rs b/node/core/dispute-coordinator/src/scraping/candidates.rs index 2fe797768cc2..c50486f35dc6 100644 --- a/node/core/dispute-coordinator/src/scraping/candidates.rs +++ b/node/core/dispute-coordinator/src/scraping/candidates.rs @@ -1,4 +1,4 @@ -use polkadot_primitives::v2::{BlockNumber, CandidateHash}; +use polkadot_primitives::{BlockNumber, CandidateHash}; use std::collections::{BTreeMap, HashMap, HashSet}; /// Keeps `CandidateHash` in reference counted way. @@ -44,7 +44,7 @@ impl RefCountedCandidates { #[cfg(test)] mod ref_counted_candidates_tests { use super::*; - use polkadot_primitives::v2::{BlakeTwo256, HashT}; + use polkadot_primitives::{BlakeTwo256, HashT}; #[test] fn element_is_removed_when_refcount_reaches_zero() { @@ -131,7 +131,7 @@ impl ScrapedCandidates { #[cfg(test)] mod scraped_candidates_tests { use super::*; - use polkadot_primitives::v2::{BlakeTwo256, HashT}; + use polkadot_primitives::{BlakeTwo256, HashT}; #[test] fn stale_candidates_are_removed() { diff --git a/node/core/dispute-coordinator/src/scraping/mod.rs b/node/core/dispute-coordinator/src/scraping/mod.rs index 29b217e46e4a..c5c63eea586f 100644 --- a/node/core/dispute-coordinator/src/scraping/mod.rs +++ b/node/core/dispute-coordinator/src/scraping/mod.rs @@ -25,7 +25,7 @@ use polkadot_node_subsystem::{ SubsystemSender, }; use polkadot_node_subsystem_util::runtime::{get_candidate_events, get_on_chain_votes}; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ BlockNumber, CandidateEvent, CandidateHash, CandidateReceipt, Hash, ScrapedOnChainVotes, }; diff --git a/node/core/dispute-coordinator/src/scraping/tests.rs b/node/core/dispute-coordinator/src/scraping/tests.rs index 3a6befa2002d..6bdb16d2a54e 100644 --- a/node/core/dispute-coordinator/src/scraping/tests.rs +++ b/node/core/dispute-coordinator/src/scraping/tests.rs @@ -36,7 +36,7 @@ use polkadot_node_subsystem_test_helpers::{ make_subsystem_context, TestSubsystemContext, TestSubsystemContextHandle, TestSubsystemSender, }; use polkadot_node_subsystem_util::{reexports::SubsystemContext, TimeoutExt}; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ BlakeTwo256, BlockNumber, CandidateDescriptor, CandidateEvent, CandidateReceipt, CoreIndex, GroupIndex, Hash, HashT, HeadData, Id as ParaId, }; diff --git a/node/core/dispute-coordinator/src/spam_slots.rs b/node/core/dispute-coordinator/src/spam_slots.rs index c0619bf3a1a5..cdb9e6fb0bdc 100644 --- a/node/core/dispute-coordinator/src/spam_slots.rs +++ b/node/core/dispute-coordinator/src/spam_slots.rs @@ -16,7 +16,7 @@ use std::collections::{BTreeSet, HashMap}; -use polkadot_primitives::v2::{CandidateHash, SessionIndex, ValidatorIndex}; +use polkadot_primitives::{CandidateHash, SessionIndex, ValidatorIndex}; use crate::LOG_TARGET; diff --git a/node/core/dispute-coordinator/src/status.rs b/node/core/dispute-coordinator/src/status.rs index 6332c3653274..a74a02f2b083 100644 --- a/node/core/dispute-coordinator/src/status.rs +++ b/node/core/dispute-coordinator/src/status.rs @@ -15,7 +15,7 @@ // along with Polkadot. If not, see . use polkadot_node_primitives::{dispute_is_inactive, DisputeStatus, Timestamp}; -use polkadot_primitives::v2::{CandidateHash, SessionIndex}; +use polkadot_primitives::{CandidateHash, SessionIndex}; use std::time::{SystemTime, UNIX_EPOCH}; use crate::LOG_TARGET; diff --git a/node/core/dispute-coordinator/src/tests.rs b/node/core/dispute-coordinator/src/tests.rs index 12f7cfd3eb43..766982fa4ecb 100644 --- a/node/core/dispute-coordinator/src/tests.rs +++ b/node/core/dispute-coordinator/src/tests.rs @@ -60,7 +60,7 @@ use polkadot_node_subsystem::{ use polkadot_node_subsystem_test_helpers::{ make_buffered_subsystem_context, TestSubsystemContextHandle, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ ApprovalVote, BlockNumber, CandidateCommitments, CandidateEvent, CandidateHash, CandidateReceipt, CoreIndex, DisputeStatement, GroupIndex, Hash, HeadData, Header, IndexedVec, MultiDisputeStatementSet, ScrapedOnChainVotes, SessionIndex, SessionInfo, SigningContext, @@ -85,7 +85,7 @@ fn make_keystore(seeds: impl Iterator) -> LocalKeystore { for s in seeds { store - .sr25519_generate_new(polkadot_primitives::v2::PARACHAIN_KEY_TYPE_ID, Some(&s)) + .sr25519_generate_new(polkadot_primitives::PARACHAIN_KEY_TYPE_ID, Some(&s)) .unwrap(); } @@ -1803,7 +1803,7 @@ fn supermajority_valid_dispute_may_be_finalized() { .await; let supermajority_threshold = - polkadot_primitives::v2::supermajority_threshold(test_state.validators.len()); + polkadot_primitives::supermajority_threshold(test_state.validators.len()); let (valid_vote, invalid_vote) = generate_opposing_votes_pair( &test_state, @@ -1942,7 +1942,7 @@ fn concluded_supermajority_for_non_active_after_time() { .await; let supermajority_threshold = - polkadot_primitives::v2::supermajority_threshold(test_state.validators.len()); + polkadot_primitives::supermajority_threshold(test_state.validators.len()); let (valid_vote, invalid_vote) = generate_opposing_votes_pair( &test_state, @@ -2059,7 +2059,7 @@ fn concluded_supermajority_against_non_active_after_time() { .await; let supermajority_threshold = - polkadot_primitives::v2::supermajority_threshold(test_state.validators.len()); + polkadot_primitives::supermajority_threshold(test_state.validators.len()); let (valid_vote, invalid_vote) = generate_opposing_votes_pair( &test_state, diff --git a/node/core/parachains-inherent/src/lib.rs b/node/core/parachains-inherent/src/lib.rs index a4df582b17a8..2df6b3de8ab6 100644 --- a/node/core/parachains-inherent/src/lib.rs +++ b/node/core/parachains-inherent/src/lib.rs @@ -28,7 +28,7 @@ use futures::{select, FutureExt}; use polkadot_node_subsystem::{ errors::SubsystemError, messages::ProvisionerMessage, overseer::Handle, }; -use polkadot_primitives::v2::{Block, Hash, InherentData as ParachainsInherentData}; +use polkadot_primitives::{Block, Hash, InherentData as ParachainsInherentData}; use std::{sync::Arc, time}; pub(crate) const LOG_TARGET: &str = "parachain::parachains-inherent"; @@ -140,7 +140,7 @@ impl> sp_inherents::InherentDataProvider .map_err(|e| sp_inherents::Error::Application(Box::new(e)))?; dst_inherent_data - .put_data(polkadot_primitives::v2::PARACHAINS_INHERENT_IDENTIFIER, &inherent_data) + .put_data(polkadot_primitives::PARACHAINS_INHERENT_IDENTIFIER, &inherent_data) } async fn try_handle_error( diff --git a/node/core/provisioner/src/disputes/mod.rs b/node/core/provisioner/src/disputes/mod.rs index bd19e101bb2e..e5649e7b6c04 100644 --- a/node/core/provisioner/src/disputes/mod.rs +++ b/node/core/provisioner/src/disputes/mod.rs @@ -25,7 +25,7 @@ use crate::LOG_TARGET; use futures::channel::oneshot; use polkadot_node_primitives::CandidateVotes; use polkadot_node_subsystem::{messages::DisputeCoordinatorMessage, overseer}; -use polkadot_primitives::v2::{CandidateHash, SessionIndex}; +use polkadot_primitives::{CandidateHash, SessionIndex}; /// Request the relevant dispute statements for a set of disputes identified by `CandidateHash` and the `SessionIndex`. async fn request_votes( diff --git a/node/core/provisioner/src/disputes/prioritized_selection/mod.rs b/node/core/provisioner/src/disputes/prioritized_selection/mod.rs index e92626e3afca..2b5e6b177abf 100644 --- a/node/core/provisioner/src/disputes/prioritized_selection/mod.rs +++ b/node/core/provisioner/src/disputes/prioritized_selection/mod.rs @@ -26,7 +26,7 @@ use polkadot_node_subsystem::{ messages::{DisputeCoordinatorMessage, RuntimeApiMessage, RuntimeApiRequest}, overseer, ActivatedLeaf, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ supermajority_threshold, CandidateHash, DisputeState, DisputeStatement, DisputeStatementSet, Hash, MultiDisputeStatementSet, SessionIndex, ValidDisputeStatementKind, ValidatorIndex, }; diff --git a/node/core/provisioner/src/disputes/prioritized_selection/tests.rs b/node/core/provisioner/src/disputes/prioritized_selection/tests.rs index 982d19356e6a..96b509a59095 100644 --- a/node/core/provisioner/src/disputes/prioritized_selection/tests.rs +++ b/node/core/provisioner/src/disputes/prioritized_selection/tests.rs @@ -25,7 +25,7 @@ use polkadot_node_subsystem::messages::{ AllMessages, DisputeCoordinatorMessage, RuntimeApiMessage, RuntimeApiRequest, }; use polkadot_node_subsystem_test_helpers::TestSubsystemSender; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ CandidateHash, DisputeState, InvalidDisputeStatementKind, SessionIndex, ValidDisputeStatementKind, ValidatorSignature, }; diff --git a/node/core/provisioner/src/disputes/random_selection/mod.rs b/node/core/provisioner/src/disputes/random_selection/mod.rs index 9a827475aa55..e08ee4c109b1 100644 --- a/node/core/provisioner/src/disputes/random_selection/mod.rs +++ b/node/core/provisioner/src/disputes/random_selection/mod.rs @@ -24,7 +24,7 @@ use crate::{metrics, LOG_TARGET}; use futures::channel::oneshot; use polkadot_node_subsystem::{messages::DisputeCoordinatorMessage, overseer}; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ CandidateHash, DisputeStatement, DisputeStatementSet, MultiDisputeStatementSet, SessionIndex, }; use std::collections::HashSet; diff --git a/node/core/provisioner/src/error.rs b/node/core/provisioner/src/error.rs index 9fb958c4f339..de520fc1fe04 100644 --- a/node/core/provisioner/src/error.rs +++ b/node/core/provisioner/src/error.rs @@ -19,7 +19,7 @@ use fatality::Nested; use futures::channel::{mpsc, oneshot}; use polkadot_node_subsystem::errors::{ChainApiError, RuntimeApiError, SubsystemError}; use polkadot_node_subsystem_util as util; -use polkadot_primitives::v2::Hash; +use polkadot_primitives::Hash; pub type FatalResult = std::result::Result; pub type Result = std::result::Result; diff --git a/node/core/provisioner/src/lib.rs b/node/core/provisioner/src/lib.rs index fcb65d66f286..a8f19854073e 100644 --- a/node/core/provisioner/src/lib.rs +++ b/node/core/provisioner/src/lib.rs @@ -37,7 +37,7 @@ use polkadot_node_subsystem::{ use polkadot_node_subsystem_util::{ request_availability_cores, request_persisted_validation_data, TimeoutExt, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ BackedCandidate, BlockNumber, CandidateReceipt, CoreState, Hash, OccupiedCoreAssumption, SignedAvailabilityBitfield, ValidatorIndex, }; diff --git a/node/core/provisioner/src/tests.rs b/node/core/provisioner/src/tests.rs index 08eba8eabe80..ed53f819b0f5 100644 --- a/node/core/provisioner/src/tests.rs +++ b/node/core/provisioner/src/tests.rs @@ -1,7 +1,7 @@ use super::*; use ::test_helpers::{dummy_candidate_descriptor, dummy_hash}; use bitvec::bitvec; -use polkadot_primitives::v2::{OccupiedCore, ScheduledCore}; +use polkadot_primitives::{OccupiedCore, ScheduledCore}; pub fn occupied_core(para_id: u32) -> CoreState { CoreState::Occupied(OccupiedCore { @@ -41,7 +41,7 @@ pub fn scheduled_core(id: u32) -> ScheduledCore { mod select_availability_bitfields { use super::{super::*, default_bitvec, occupied_core}; use futures::executor::block_on; - use polkadot_primitives::v2::{ScheduledCore, SigningContext, ValidatorId, ValidatorIndex}; + use polkadot_primitives::{ScheduledCore, SigningContext, ValidatorId, ValidatorIndex}; use sp_application_crypto::AppKey; use sp_keystore::{testing::KeyStore, CryptoStore, SyncCryptoStorePtr}; use std::sync::Arc; @@ -234,7 +234,7 @@ mod select_candidates { }, }; use polkadot_node_subsystem_test_helpers::TestSubsystemSender; - use polkadot_primitives::v2::{ + use polkadot_primitives::{ BlockNumber, CandidateCommitments, CommittedCandidateReceipt, PersistedValidationData, }; diff --git a/node/core/pvf-checker/src/interest_view.rs b/node/core/pvf-checker/src/interest_view.rs index f6af819e9856..2d537388aa53 100644 --- a/node/core/pvf-checker/src/interest_view.rs +++ b/node/core/pvf-checker/src/interest_view.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use polkadot_primitives::v2::{Hash, ValidationCodeHash}; +use polkadot_primitives::{Hash, ValidationCodeHash}; use std::collections::{ btree_map::{self, BTreeMap}, HashSet, diff --git a/node/core/pvf-checker/src/lib.rs b/node/core/pvf-checker/src/lib.rs index f31f3f728aa6..7e961dcf4b88 100644 --- a/node/core/pvf-checker/src/lib.rs +++ b/node/core/pvf-checker/src/lib.rs @@ -26,7 +26,7 @@ use polkadot_node_subsystem::{ overseer, ActiveLeavesUpdate, FromOrchestra, OverseerSignal, SpawnedSubsystem, SubsystemError, SubsystemResult, SubsystemSender, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ BlockNumber, Hash, PvfCheckStatement, SessionIndex, ValidationCodeHash, ValidatorId, ValidatorIndex, }; @@ -190,16 +190,18 @@ async fn handle_pvf_check( PreCheckOutcome::Valid => Judgement::Valid, PreCheckOutcome::Invalid => Judgement::Invalid, PreCheckOutcome::Failed => { - // Abstain. + // Always vote against in case of failures. Voting against a PVF when encountering a + // timeout (or an unlikely node-specific issue) can be considered safe, since + // there is no slashing for being on the wrong side on a pre-check vote. // - // Returning here will leave the PVF in the view dangling. Since it is there, no new - // pre-checking request will be sent. + // Also, by being more strict here, we can safely be more lenient during preparation and + // avoid the risk of getting slashed there. gum::info!( target: LOG_TARGET, ?validation_code_hash, - "Pre-check failed, abstaining from voting", + "Pre-check failed, voting against", ); - return + Judgement::Invalid }, }; diff --git a/node/core/pvf-checker/src/runtime_api.rs b/node/core/pvf-checker/src/runtime_api.rs index ccdcce4c2c83..b42f5943af56 100644 --- a/node/core/pvf-checker/src/runtime_api.rs +++ b/node/core/pvf-checker/src/runtime_api.rs @@ -21,7 +21,7 @@ use polkadot_node_subsystem::{ messages::{RuntimeApiMessage, RuntimeApiRequest}, SubsystemSender, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ Hash, PvfCheckStatement, SessionIndex, ValidationCodeHash, ValidatorId, ValidatorSignature, }; diff --git a/node/core/pvf-checker/src/tests.rs b/node/core/pvf-checker/src/tests.rs index f47e642ae98d..e1b9b8a5b0db 100644 --- a/node/core/pvf-checker/src/tests.rs +++ b/node/core/pvf-checker/src/tests.rs @@ -25,7 +25,7 @@ use polkadot_node_subsystem::{ ActivatedLeaf, ActiveLeavesUpdate, FromOrchestra, LeafStatus, OverseerSignal, RuntimeApiError, }; use polkadot_node_subsystem_test_helpers::{make_subsystem_context, TestSubsystemContextHandle}; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ BlockNumber, Hash, Header, PvfCheckStatement, SessionIndex, ValidationCode, ValidationCodeHash, ValidatorId, }; @@ -157,7 +157,7 @@ impl TestState { self.active_leaves_update(handle, Some(leaf), None, &[]).await } - async fn deactive_leaves( + async fn deactivate_leaves( &mut self, handle: &mut VirtualOverseer, deactivated: impl IntoIterator, @@ -894,8 +894,8 @@ fn unexpected_pvf_check_judgement() { // Catch the pre-check request, but don't reply just yet. let pre_check = test_state.expect_candidate_precheck(&mut handle).await; - // Now deactive the leaf and reply to the precheck request. - test_state.deactive_leaves(&mut handle, &[block_1.block_hash]).await; + // Now deactivate the leaf and reply to the precheck request. + test_state.deactivate_leaves(&mut handle, &[block_1.block_hash]).await; pre_check.reply(PreCheckOutcome::Invalid); // the subsystem must remain silent. @@ -906,14 +906,17 @@ fn unexpected_pvf_check_judgement() { }); } +// Check that we do not abstain for a nondeterministic failure. Currently, this means the behavior +// is the same as if the pre-check returned `PreCheckOutcome::Invalid`. #[test] -fn abstain_for_nondeterministic_pvfcheck_failure() { +fn dont_abstain_for_nondeterministic_pvfcheck_failure() { test_harness(|mut test_state, mut handle| { async move { + let block_1 = FakeLeaf::new(dummy_hash(), 1, vec![dummy_validation_code_hash(1)]); test_state .activate_leaf_with_session( &mut handle, - FakeLeaf::new(dummy_hash(), 1, vec![dummy_validation_code_hash(1)]), + block_1.clone(), StartsNewSession { session_index: 2, validators: vec![OUR_VALIDATOR] }, ) .await; @@ -922,10 +925,14 @@ fn abstain_for_nondeterministic_pvfcheck_failure() { test_state.expect_session_for_child(&mut handle).await; test_state.expect_validators(&mut handle).await; - test_state - .expect_candidate_precheck(&mut handle) - .await - .reply(PreCheckOutcome::Failed); + // Catch the pre-check request, but don't reply just yet. + let pre_check = test_state.expect_candidate_precheck(&mut handle).await; + + // Now deactivate the leaf and reply to the precheck request. + test_state.deactivate_leaves(&mut handle, &[block_1.block_hash]).await; + pre_check.reply(PreCheckOutcome::Failed); + + // the subsystem must remain silent. test_state.send_conclude(&mut handle).await; } diff --git a/node/core/pvf/src/execute/queue.rs b/node/core/pvf/src/execute/queue.rs index f2f1b4e0cfff..c20099b0e798 100644 --- a/node/core/pvf/src/execute/queue.rs +++ b/node/core/pvf/src/execute/queue.rs @@ -223,32 +223,48 @@ fn handle_job_finish( artifact_id: ArtifactId, result_tx: ResultSender, ) { - let (idle_worker, result) = match outcome { - Outcome::Ok { result_descriptor, duration: _, idle_worker } => { + let (idle_worker, result, duration) = match outcome { + Outcome::Ok { result_descriptor, duration, idle_worker } => { // TODO: propagate the soft timeout - (Some(idle_worker), Ok(result_descriptor)) + (Some(idle_worker), Ok(result_descriptor), Some(duration)) }, Outcome::InvalidCandidate { err, idle_worker } => ( Some(idle_worker), Err(ValidationError::InvalidCandidate(InvalidCandidate::WorkerReportedError(err))), + None, ), Outcome::InternalError { err, idle_worker } => - (Some(idle_worker), Err(ValidationError::InternalError(err))), + (Some(idle_worker), Err(ValidationError::InternalError(err)), None), Outcome::HardTimeout => - (None, Err(ValidationError::InvalidCandidate(InvalidCandidate::HardTimeout))), - Outcome::IoErr => - (None, Err(ValidationError::InvalidCandidate(InvalidCandidate::AmbiguousWorkerDeath))), + (None, Err(ValidationError::InvalidCandidate(InvalidCandidate::HardTimeout)), None), + Outcome::IoErr => ( + None, + Err(ValidationError::InvalidCandidate(InvalidCandidate::AmbiguousWorkerDeath)), + None, + ), }; queue.metrics.execute_finished(); - gum::debug!( - target: LOG_TARGET, - validation_code_hash = ?artifact_id.code_hash, - ?worker, - worker_rip = idle_worker.is_none(), - "execute worker concluded", - ); + if let Err(ref err) = result { + gum::warn!( + target: LOG_TARGET, + ?artifact_id, + ?worker, + worker_rip = idle_worker.is_none(), + "execution worker concluded, error occurred: {:?}", + err + ); + } else { + gum::debug!( + target: LOG_TARGET, + ?artifact_id, + ?worker, + worker_rip = idle_worker.is_none(), + ?duration, + "execute worker concluded successfully", + ); + } // First we send the result. It may fail due to the other end of the channel being dropped, // that's legitimate and we don't treat that as an error. diff --git a/node/core/pvf/src/execute/worker.rs b/node/core/pvf/src/execute/worker.rs index df928efaa642..4b19d4029be5 100644 --- a/node/core/pvf/src/execute/worker.rs +++ b/node/core/pvf/src/execute/worker.rs @@ -142,11 +142,8 @@ pub async fn start_work( target: LOG_TARGET, worker_pid = %pid, validation_code_hash = ?artifact.id.code_hash, - "execution worker exceeded allotted time for execution", + "execution worker exceeded lenient timeout for execution, child worker likely stalled", ); - // TODO: This case is not really a hard timeout as the timeout here in the host is - // lenient. Should fix this as part of - // https://github.com/paritytech/polkadot/issues/3754. Response::TimedOut }, }; diff --git a/node/core/pvf/src/host.rs b/node/core/pvf/src/host.rs index b41ebd3c425b..3514aff1d896 100644 --- a/node/core/pvf/src/host.rs +++ b/node/core/pvf/src/host.rs @@ -525,7 +525,7 @@ async fn handle_execute_pvf( }, ArtifactState::FailedToProcess { last_time_failed, num_failures, error } => { if can_retry_prepare_after_failure(*last_time_failed, *num_failures, error) { - gum::debug!( + gum::warn!( target: LOG_TARGET, ?pvf, ?artifact_id, @@ -550,6 +550,10 @@ async fn handle_execute_pvf( }, ) .await?; + + // Add an execution request that will wait to run after this prepare job has + // finished. + awaiting_prepare.add(artifact_id, execution_timeout, params, result_tx); } else { let _ = result_tx.send(Err(ValidationError::from(error.clone()))); } @@ -595,7 +599,7 @@ async fn handle_heads_up( }, ArtifactState::FailedToProcess { last_time_failed, num_failures, error } => { if can_retry_prepare_after_failure(*last_time_failed, *num_failures, error) { - gum::debug!( + gum::warn!( target: LOG_TARGET, ?active_pvf, ?artifact_id, @@ -724,18 +728,18 @@ async fn handle_prepare_done( Ok(cpu_time_elapsed) => ArtifactState::Prepared { last_time_needed: SystemTime::now(), cpu_time_elapsed }, Err(error) => { - gum::debug!( + let last_time_failed = SystemTime::now(); + let num_failures = *num_failures + 1; + + gum::warn!( target: LOG_TARGET, - artifact_id = ?artifact_id, - num_failures = ?num_failures, - "Failed to process artifact: {}", + ?artifact_id, + time_failed = ?last_time_failed, + %num_failures, + "artifact preparation failed: {}", error ); - ArtifactState::FailedToProcess { - last_time_failed: SystemTime::now(), - num_failures: *num_failures + 1, - error, - } + ArtifactState::FailedToProcess { last_time_failed, num_failures, error } }, }; @@ -931,6 +935,13 @@ mod tests { ValidationHost { to_host_tx } } + async fn poll_and_recv_result(&mut self, result_rx: oneshot::Receiver) -> T + where + T: Send, + { + run_until(&mut self.run, async { result_rx.await.unwrap() }.boxed()).await + } + async fn poll_and_recv_to_prepare_queue(&mut self) -> prepare::ToQueue { let to_prepare_queue_rx = &mut self.to_prepare_queue_rx; run_until(&mut self.run, async { to_prepare_queue_rx.next().await.unwrap() }.boxed()) @@ -991,7 +1002,7 @@ mod tests { futures::select! { _ = Delay::new(Duration::from_millis(500)).fuse() => (), msg = to_sweeper_rx.next().fuse() => { - panic!("the sweeper supposed to be empty, but received: {:?}", msg) + panic!("the sweeper is supposed to be empty, but received: {:?}", msg) } } } @@ -1311,12 +1322,12 @@ mod tests { // Test that multiple prechecking requests do not trigger preparation retries if the first one // failed. #[tokio::test] - async fn test_precheck_prepare_retry() { + async fn test_precheck_prepare_no_retry() { let mut test = Builder::default().build(); let mut host = test.host_handle(); // Submit a precheck request that fails. - let (result_tx, _result_rx) = oneshot::channel(); + let (result_tx, result_rx) = oneshot::channel(); host.precheck_pvf(Pvf::from_discriminator(1), result_tx).await.unwrap(); // The queue received the prepare request. @@ -1333,22 +1344,34 @@ mod tests { .await .unwrap(); + // The result should contain the error. + let result = test.poll_and_recv_result(result_rx).await; + assert_matches!(result, Err(PrepareError::TimedOut)); + // Submit another precheck request. - let (result_tx_2, _result_rx_2) = oneshot::channel(); + let (result_tx_2, result_rx_2) = oneshot::channel(); host.precheck_pvf(Pvf::from_discriminator(1), result_tx_2).await.unwrap(); // Assert the prepare queue is empty. test.poll_ensure_to_prepare_queue_is_empty().await; + // The result should contain the original error. + let result = test.poll_and_recv_result(result_rx_2).await; + assert_matches!(result, Err(PrepareError::TimedOut)); + // Pause for enough time to reset the cooldown for this failed prepare request. futures_timer::Delay::new(PREPARE_FAILURE_COOLDOWN).await; // Submit another precheck request. - let (result_tx_3, _result_rx_3) = oneshot::channel(); + let (result_tx_3, result_rx_3) = oneshot::channel(); host.precheck_pvf(Pvf::from_discriminator(1), result_tx_3).await.unwrap(); // Assert the prepare queue is empty - we do not retry for precheck requests. test.poll_ensure_to_prepare_queue_is_empty().await; + + // The result should still contain the original error. + let result = test.poll_and_recv_result(result_rx_3).await; + assert_matches!(result, Err(PrepareError::TimedOut)); } // Test that multiple execution requests trigger preparation retries if the first one failed due @@ -1359,7 +1382,7 @@ mod tests { let mut host = test.host_handle(); // Submit a execute request that fails. - let (result_tx, _result_rx) = oneshot::channel(); + let (result_tx, result_rx) = oneshot::channel(); host.execute_pvf( Pvf::from_discriminator(1), TEST_EXECUTION_TIMEOUT, @@ -1384,8 +1407,12 @@ mod tests { .await .unwrap(); - // Submit another execute request. - let (result_tx_2, _result_rx_2) = oneshot::channel(); + // The result should contain the error. + let result = test.poll_and_recv_result(result_rx).await; + assert_matches!(result, Err(ValidationError::InternalError(_))); + + // Submit another execute request. We shouldn't try to prepare again, yet. + let (result_tx_2, result_rx_2) = oneshot::channel(); host.execute_pvf( Pvf::from_discriminator(1), TEST_EXECUTION_TIMEOUT, @@ -1399,11 +1426,15 @@ mod tests { // Assert the prepare queue is empty. test.poll_ensure_to_prepare_queue_is_empty().await; + // The result should contain the original error. + let result = test.poll_and_recv_result(result_rx_2).await; + assert_matches!(result, Err(ValidationError::InternalError(_))); + // Pause for enough time to reset the cooldown for this failed prepare request. futures_timer::Delay::new(PREPARE_FAILURE_COOLDOWN).await; // Submit another execute request. - let (result_tx_3, _result_rx_3) = oneshot::channel(); + let (result_tx_3, result_rx_3) = oneshot::channel(); host.execute_pvf( Pvf::from_discriminator(1), TEST_EXECUTION_TIMEOUT, @@ -1419,6 +1450,30 @@ mod tests { test.poll_and_recv_to_prepare_queue().await, prepare::ToQueue::Enqueue { .. } ); + + test.from_prepare_queue_tx + .send(prepare::FromQueue { + artifact_id: artifact_id(1), + result: Ok(Duration::default()), + }) + .await + .unwrap(); + + // Preparation should have been retried and succeeded this time. + let result_tx_3 = assert_matches!( + test.poll_and_recv_to_execute_queue().await, + execute::ToQueue::Enqueue { result_tx, .. } => result_tx + ); + + // Send an error for the execution here, just so we can check the result receiver is still + // alive. + result_tx_3 + .send(Err(ValidationError::InvalidCandidate(InvalidCandidate::AmbiguousWorkerDeath))) + .unwrap(); + assert_matches!( + result_rx_3.now_or_never().unwrap().unwrap(), + Err(ValidationError::InvalidCandidate(InvalidCandidate::AmbiguousWorkerDeath)) + ); } // Test that multiple execution requests don't trigger preparation retries if the first one @@ -1428,8 +1483,8 @@ mod tests { let mut test = Builder::default().build(); let mut host = test.host_handle(); - // Submit a execute request that fails. - let (result_tx, _result_rx) = oneshot::channel(); + // Submit an execute request that fails. + let (result_tx, result_rx) = oneshot::channel(); host.execute_pvf( Pvf::from_discriminator(1), TEST_EXECUTION_TIMEOUT, @@ -1454,8 +1509,15 @@ mod tests { .await .unwrap(); + // The result should contain the error. + let result = test.poll_and_recv_result(result_rx).await; + assert_matches!( + result, + Err(ValidationError::InvalidCandidate(InvalidCandidate::PrepareError(_))) + ); + // Submit another execute request. - let (result_tx_2, _result_rx_2) = oneshot::channel(); + let (result_tx_2, result_rx_2) = oneshot::channel(); host.execute_pvf( Pvf::from_discriminator(1), TEST_EXECUTION_TIMEOUT, @@ -1469,11 +1531,18 @@ mod tests { // Assert the prepare queue is empty. test.poll_ensure_to_prepare_queue_is_empty().await; + // The result should contain the original error. + let result = test.poll_and_recv_result(result_rx_2).await; + assert_matches!( + result, + Err(ValidationError::InvalidCandidate(InvalidCandidate::PrepareError(_))) + ); + // Pause for enough time to reset the cooldown for this failed prepare request. futures_timer::Delay::new(PREPARE_FAILURE_COOLDOWN).await; // Submit another execute request. - let (result_tx_3, _result_rx_3) = oneshot::channel(); + let (result_tx_3, result_rx_3) = oneshot::channel(); host.execute_pvf( Pvf::from_discriminator(1), TEST_EXECUTION_TIMEOUT, @@ -1486,6 +1555,13 @@ mod tests { // Assert the prepare queue is empty - we do not retry for prevalidation errors. test.poll_ensure_to_prepare_queue_is_empty().await; + + // The result should still contain the original error. + let result = test.poll_and_recv_result(result_rx_3).await; + assert_matches!( + result, + Err(ValidationError::InvalidCandidate(InvalidCandidate::PrepareError(_))) + ); } // Test that multiple heads-up requests trigger preparation retries if the first one failed. diff --git a/node/core/runtime-api/src/cache.rs b/node/core/runtime-api/src/cache.rs index d202b46d0da3..9efc31328692 100644 --- a/node/core/runtime-api/src/cache.rs +++ b/node/core/runtime-api/src/cache.rs @@ -19,7 +19,7 @@ use std::{collections::btree_map::BTreeMap, num::NonZeroUsize}; use lru::LruCache; use sp_consensus_babe::Epoch; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ AuthorityDiscoveryId, BlockNumber, CandidateCommitments, CandidateEvent, CandidateHash, CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, OccupiedCoreAssumption, PersistedValidationData, diff --git a/node/core/runtime-api/src/lib.rs b/node/core/runtime-api/src/lib.rs index de42ace3af0c..3d016305bc64 100644 --- a/node/core/runtime-api/src/lib.rs +++ b/node/core/runtime-api/src/lib.rs @@ -28,7 +28,7 @@ use polkadot_node_subsystem::{ overseer, FromOrchestra, OverseerSignal, SpawnedSubsystem, SubsystemError, SubsystemResult, }; use polkadot_node_subsystem_types::RuntimeApiSubsystemClient; -use polkadot_primitives::v2::Hash; +use polkadot_primitives::Hash; use cache::{RequestResult, RequestResultCache}; use futures::{channel::oneshot, prelude::*, select, stream::FuturesUnordered}; diff --git a/node/core/runtime-api/src/tests.rs b/node/core/runtime-api/src/tests.rs index 81629d5b2754..f1cf1c7f4692 100644 --- a/node/core/runtime-api/src/tests.rs +++ b/node/core/runtime-api/src/tests.rs @@ -21,14 +21,11 @@ use polkadot_node_primitives::{BabeAllowedSlots, BabeEpoch, BabeEpochConfigurati use polkadot_node_subsystem::SpawnGlue; use polkadot_node_subsystem_test_helpers::make_subsystem_context; use polkadot_primitives::{ - runtime_api::ParachainHost, - v2::{ - AuthorityDiscoveryId, Block, CandidateEvent, CommittedCandidateReceipt, CoreState, - GroupRotationInfo, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, - OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, - SessionIndex, SessionInfo, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, - ValidatorSignature, - }, + runtime_api::ParachainHost, AuthorityDiscoveryId, Block, CandidateEvent, + CommittedCandidateReceipt, CoreState, GroupRotationInfo, Id as ParaId, InboundDownwardMessage, + InboundHrmpMessage, OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, + ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidationCode, ValidationCodeHash, + ValidatorId, ValidatorIndex, ValidatorSignature, }; use sp_api::ProvideRuntimeApi; use sp_authority_discovery::AuthorityDiscoveryApi; @@ -115,7 +112,7 @@ sp_api::mock_impl_runtime_apis! { fn check_validation_outputs( &self, para_id: ParaId, - _commitments: polkadot_primitives::v2::CandidateCommitments, + _commitments: polkadot_primitives::CandidateCommitments, ) -> bool { self.validation_outputs_results .get(¶_id) @@ -223,7 +220,7 @@ sp_api::mock_impl_runtime_apis! { } fn submit_report_equivocation_unsigned_extrinsic( - _equivocation_proof: sp_consensus_babe::EquivocationProof, + _equivocation_proof: sp_consensus_babe::EquivocationProof, _key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof, ) -> Option<()> { None @@ -452,7 +449,7 @@ fn requests_check_validation_outputs() { let relay_parent = [1; 32].into(); let para_a = ParaId::from(5_u32); let para_b = ParaId::from(6_u32); - let commitments = polkadot_primitives::v2::CandidateCommitments::default(); + let commitments = polkadot_primitives::CandidateCommitments::default(); let spawner = sp_core::testing::TaskExecutor::new(); runtime_api.validation_outputs_results.insert(para_a, false); diff --git a/node/gum/src/lib.rs b/node/gum/src/lib.rs index 261f1037de7f..9cc6e9ff6620 100644 --- a/node/gum/src/lib.rs +++ b/node/gum/src/lib.rs @@ -27,7 +27,7 @@ pub use tracing::{enabled, event, Level}; pub use jaeger::hash_to_trace_identifier; #[doc(hidden)] -pub use polkadot_primitives::v2::{CandidateHash, Hash}; +pub use polkadot_primitives::{CandidateHash, Hash}; pub use gum_proc_macro::{debug, error, info, trace, warn}; diff --git a/node/gum/src/tests.rs b/node/gum/src/tests.rs index c4077c7615c7..8ca7e3124bdc 100644 --- a/node/gum/src/tests.rs +++ b/node/gum/src/tests.rs @@ -15,7 +15,7 @@ // along with Polkadot. If not, see . use super::*; -pub use polkadot_primitives::v2::{CandidateHash, Hash}; +pub use polkadot_primitives::{CandidateHash, Hash}; #[derive(Default, Debug)] struct Y { diff --git a/node/jaeger/src/spans.rs b/node/jaeger/src/spans.rs index 56902571b88c..de85867d169f 100644 --- a/node/jaeger/src/spans.rs +++ b/node/jaeger/src/spans.rs @@ -17,7 +17,7 @@ //! Polkadot Jaeger span definitions. //! //! ```rust -//! # use polkadot_primitives::v2::{CandidateHash, Hash}; +//! # use polkadot_primitives::{CandidateHash, Hash}; //! # fn main() { //! use polkadot_node_jaeger as jaeger; //! @@ -51,7 +51,7 @@ //! over the course of a function, for this purpose use the non-consuming //! `fn` variants, i.e. //! ```rust -//! # use polkadot_primitives::v2::{CandidateHash, Hash}; +//! # use polkadot_primitives::{CandidateHash, Hash}; //! # fn main() { //! # use polkadot_node_jaeger as jaeger; //! @@ -85,9 +85,7 @@ use parity_scale_codec::Encode; use polkadot_node_primitives::PoV; -use polkadot_primitives::v2::{ - BlakeTwo256, CandidateHash, Hash, HashT, Id as ParaId, ValidatorIndex, -}; +use polkadot_primitives::{BlakeTwo256, CandidateHash, Hash, HashT, Id as ParaId, ValidatorIndex}; use sc_network::PeerId; use std::{fmt, sync::Arc}; diff --git a/node/malus/src/variants/common.rs b/node/malus/src/variants/common.rs index 610b43bc33a4..d92a7315467a 100644 --- a/node/malus/src/variants/common.rs +++ b/node/malus/src/variants/common.rs @@ -28,7 +28,7 @@ use polkadot_node_subsystem::{ overseer, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ CandidateCommitments, CandidateDescriptor, CandidateReceipt, PersistedValidationData, }; diff --git a/node/malus/src/variants/suggest_garbage_candidate.rs b/node/malus/src/variants/suggest_garbage_candidate.rs index 86b0c49e7125..146348f00123 100644 --- a/node/malus/src/variants/suggest_garbage_candidate.rs +++ b/node/malus/src/variants/suggest_garbage_candidate.rs @@ -33,7 +33,7 @@ use polkadot_cli::{ }; use polkadot_node_core_candidate_validation::find_validation_data; use polkadot_node_primitives::{AvailableData, BlockData, PoV}; -use polkadot_primitives::v2::CandidateDescriptor; +use polkadot_primitives::CandidateDescriptor; use polkadot_node_subsystem_util::request_validators; use sp_core::traits::SpawnNamed; @@ -53,7 +53,7 @@ use crate::{ // Import extra types relevant to the particular // subsystem. use polkadot_node_subsystem::{messages::CandidateBackingMessage, SpawnGlue}; -use polkadot_primitives::v2::CandidateReceipt; +use polkadot_primitives::CandidateReceipt; use std::sync::Arc; @@ -166,11 +166,11 @@ where }; let (collator_id, collator_signature) = { - use polkadot_primitives::v2::CollatorPair; + use polkadot_primitives::CollatorPair; use sp_core::crypto::Pair; let collator_pair = CollatorPair::generate().0; - let signature_payload = polkadot_primitives::v2::collator_signature_payload( + let signature_payload = polkadot_primitives::collator_signature_payload( &relay_parent, &candidate.descriptor().para_id, &validation_data_hash, diff --git a/node/metrics/src/runtime/mod.rs b/node/metrics/src/runtime/mod.rs index 2497d63703c8..9ea1b04ec3b2 100644 --- a/node/metrics/src/runtime/mod.rs +++ b/node/metrics/src/runtime/mod.rs @@ -24,7 +24,7 @@ #![cfg(feature = "runtime-metrics")] use codec::Decode; -use primitives::v2::{ +use primitives::{ metric_definitions::{CounterDefinition, CounterVecDefinition}, RuntimeMetricLabelValues, RuntimeMetricOp, RuntimeMetricUpdate, }; diff --git a/node/metrics/src/runtime/parachain.rs b/node/metrics/src/runtime/parachain.rs index d69a7fef97e3..b51fb49c16fc 100644 --- a/node/metrics/src/runtime/parachain.rs +++ b/node/metrics/src/runtime/parachain.rs @@ -18,7 +18,7 @@ //! All of the metrics have a correspondent runtime metric definition. use crate::runtime::RuntimeMetricsProvider; -use primitives::v2::metric_definitions::{ +use primitives::metric_definitions::{ PARACHAIN_CREATE_INHERENT_BITFIELDS_SIGNATURE_CHECKS, PARACHAIN_INHERENT_DATA_BITFIELDS_PROCESSED, PARACHAIN_INHERENT_DATA_CANDIDATES_PROCESSED, PARACHAIN_INHERENT_DATA_DISPUTE_SETS_INCLUDED, PARACHAIN_INHERENT_DATA_DISPUTE_SETS_PROCESSED, diff --git a/node/metrics/src/tests.rs b/node/metrics/src/tests.rs index 932cc7b68be7..23ebcef13788 100644 --- a/node/metrics/src/tests.rs +++ b/node/metrics/src/tests.rs @@ -18,7 +18,7 @@ use hyper::{Client, Uri}; use polkadot_test_service::{node_config, run_validator_node, test_prometheus_config}; -use primitives::v2::metric_definitions::PARACHAIN_INHERENT_DATA_BITFIELDS_PROCESSED; +use primitives::metric_definitions::PARACHAIN_INHERENT_DATA_BITFIELDS_PROCESSED; use sc_client_api::{execution_extensions::ExecutionStrategies, ExecutionStrategy}; use sp_keyring::AccountKeyring::*; use std::collections::HashMap; diff --git a/node/network/approval-distribution/src/lib.rs b/node/network/approval-distribution/src/lib.rs index bf8a60fcefba..3c6ed8661e0e 100644 --- a/node/network/approval-distribution/src/lib.rs +++ b/node/network/approval-distribution/src/lib.rs @@ -37,7 +37,7 @@ use polkadot_node_subsystem::{ }, overseer, ActiveLeavesUpdate, FromOrchestra, OverseerSignal, SpawnedSubsystem, SubsystemError, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ BlockNumber, CandidateIndex, Hash, SessionIndex, ValidatorIndex, ValidatorSignature, }; use rand::{CryptoRng, Rng, SeedableRng}; diff --git a/node/network/approval-distribution/src/tests.rs b/node/network/approval-distribution/src/tests.rs index 567cf22f23f1..459b9d4899fb 100644 --- a/node/network/approval-distribution/src/tests.rs +++ b/node/network/approval-distribution/src/tests.rs @@ -29,7 +29,7 @@ use polkadot_node_primitives::approval::{ use polkadot_node_subsystem::messages::{network_bridge_event, AllMessages, ApprovalCheckError}; use polkadot_node_subsystem_test_helpers as test_helpers; use polkadot_node_subsystem_util::TimeoutExt as _; -use polkadot_primitives::v2::{AuthorityDiscoveryId, BlakeTwo256, HashT}; +use polkadot_primitives::{AuthorityDiscoveryId, BlakeTwo256, HashT}; use polkadot_primitives_test_helpers::dummy_signature; use rand::SeedableRng; use sp_authority_discovery::AuthorityPair as AuthorityDiscoveryPair; diff --git a/node/network/availability-distribution/src/error.rs b/node/network/availability-distribution/src/error.rs index 13c126360a6d..f4fe86a58732 100644 --- a/node/network/availability-distribution/src/error.rs +++ b/node/network/availability-distribution/src/error.rs @@ -19,7 +19,7 @@ use fatality::Nested; use polkadot_node_network_protocol::request_response::outgoing::RequestError; -use polkadot_primitives::v2::SessionIndex; +use polkadot_primitives::SessionIndex; use futures::channel::oneshot; diff --git a/node/network/availability-distribution/src/pov_requester/mod.rs b/node/network/availability-distribution/src/pov_requester/mod.rs index f32a4bd4821d..2d9f53e63f5f 100644 --- a/node/network/availability-distribution/src/pov_requester/mod.rs +++ b/node/network/availability-distribution/src/pov_requester/mod.rs @@ -30,7 +30,7 @@ use polkadot_node_subsystem::{ overseer, }; use polkadot_node_subsystem_util::runtime::RuntimeInfo; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ AuthorityDiscoveryId, CandidateHash, Hash, Id as ParaId, ValidatorIndex, }; @@ -141,7 +141,7 @@ mod tests { AllMessages, AvailabilityDistributionMessage, RuntimeApiMessage, RuntimeApiRequest, }; use polkadot_node_subsystem_test_helpers as test_helpers; - use polkadot_primitives::v2::{CandidateHash, Hash, ValidatorIndex}; + use polkadot_primitives::{CandidateHash, Hash, ValidatorIndex}; use test_helpers::mock::make_ferdie_keystore; use super::*; diff --git a/node/network/availability-distribution/src/requester/fetch_task/mod.rs b/node/network/availability-distribution/src/requester/fetch_task/mod.rs index c6356c9ccd5f..09e12aece47f 100644 --- a/node/network/availability-distribution/src/requester/fetch_task/mod.rs +++ b/node/network/availability-distribution/src/requester/fetch_task/mod.rs @@ -33,7 +33,7 @@ use polkadot_node_subsystem::{ messages::{AvailabilityStoreMessage, IfDisconnected, NetworkBridgeTxMessage}, overseer, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ AuthorityDiscoveryId, BlakeTwo256, CandidateHash, GroupIndex, Hash, HashT, OccupiedCore, SessionIndex, }; diff --git a/node/network/availability-distribution/src/requester/fetch_task/tests.rs b/node/network/availability-distribution/src/requester/fetch_task/tests.rs index 7bc91c0a4d12..2f271ebcf361 100644 --- a/node/network/availability-distribution/src/requester/fetch_task/tests.rs +++ b/node/network/availability-distribution/src/requester/fetch_task/tests.rs @@ -31,7 +31,7 @@ use sp_keyring::Sr25519Keyring; use polkadot_node_network_protocol::request_response::{v1, Recipient}; use polkadot_node_primitives::{BlockData, PoV, Proof}; use polkadot_node_subsystem::messages::AllMessages; -use polkadot_primitives::v2::{CandidateHash, ValidatorIndex}; +use polkadot_primitives::{CandidateHash, ValidatorIndex}; use super::*; use crate::{metrics::Metrics, tests::mock::get_valid_chunk_data}; diff --git a/node/network/availability-distribution/src/requester/mod.rs b/node/network/availability-distribution/src/requester/mod.rs index 105efd2f8948..088937b6e995 100644 --- a/node/network/availability-distribution/src/requester/mod.rs +++ b/node/network/availability-distribution/src/requester/mod.rs @@ -37,7 +37,7 @@ use polkadot_node_subsystem::{ overseer, ActivatedLeaf, ActiveLeavesUpdate, LeafStatus, }; use polkadot_node_subsystem_util::runtime::{get_occupied_cores, RuntimeInfo}; -use polkadot_primitives::v2::{CandidateHash, Hash, OccupiedCore, SessionIndex}; +use polkadot_primitives::{CandidateHash, Hash, OccupiedCore, SessionIndex}; use super::{FatalError, Metrics, Result, LOG_TARGET}; diff --git a/node/network/availability-distribution/src/requester/session_cache.rs b/node/network/availability-distribution/src/requester/session_cache.rs index cf01e448b70b..836634fea332 100644 --- a/node/network/availability-distribution/src/requester/session_cache.rs +++ b/node/network/availability-distribution/src/requester/session_cache.rs @@ -21,9 +21,7 @@ use rand::{seq::SliceRandom, thread_rng}; use polkadot_node_subsystem::overseer; use polkadot_node_subsystem_util::runtime::RuntimeInfo; -use polkadot_primitives::v2::{ - AuthorityDiscoveryId, GroupIndex, Hash, SessionIndex, ValidatorIndex, -}; +use polkadot_primitives::{AuthorityDiscoveryId, GroupIndex, Hash, SessionIndex, ValidatorIndex}; use crate::{ error::{Error, Result}, diff --git a/node/network/availability-distribution/src/requester/tests.rs b/node/network/availability-distribution/src/requester/tests.rs index bd39e7748ca8..59db97176a76 100644 --- a/node/network/availability-distribution/src/requester/tests.rs +++ b/node/network/availability-distribution/src/requester/tests.rs @@ -21,7 +21,7 @@ use futures::FutureExt; use polkadot_node_network_protocol::jaeger; use polkadot_node_primitives::{BlockData, ErasureChunk, PoV}; use polkadot_node_subsystem_util::runtime::RuntimeInfo; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ BlockNumber, CoreState, GroupIndex, Hash, Id as ParaId, ScheduledCore, SessionIndex, SessionInfo, }; diff --git a/node/network/availability-distribution/src/responder.rs b/node/network/availability-distribution/src/responder.rs index 53c363823f72..daf0c3175bf3 100644 --- a/node/network/availability-distribution/src/responder.rs +++ b/node/network/availability-distribution/src/responder.rs @@ -27,7 +27,7 @@ use polkadot_node_network_protocol::{ }; use polkadot_node_primitives::{AvailableData, ErasureChunk}; use polkadot_node_subsystem::{jaeger, messages::AvailabilityStoreMessage, SubsystemSender}; -use polkadot_primitives::v2::{CandidateHash, ValidatorIndex}; +use polkadot_primitives::{CandidateHash, ValidatorIndex}; use crate::{ error::{JfyiError, Result}, diff --git a/node/network/availability-distribution/src/tests/mock.rs b/node/network/availability-distribution/src/tests/mock.rs index 15ea1ab1bc53..bbceea0701af 100644 --- a/node/network/availability-distribution/src/tests/mock.rs +++ b/node/network/availability-distribution/src/tests/mock.rs @@ -22,7 +22,7 @@ use sp_keyring::Sr25519Keyring; use polkadot_erasure_coding::{branches, obtain_chunks_v1 as obtain_chunks}; use polkadot_node_primitives::{AvailableData, BlockData, ErasureChunk, PoV, Proof}; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ CandidateCommitments, CandidateDescriptor, CandidateHash, CommittedCandidateReceipt, GroupIndex, Hash, HeadData, Id as ParaId, IndexedVec, OccupiedCore, PersistedValidationData, SessionInfo, ValidatorIndex, diff --git a/node/network/availability-distribution/src/tests/mod.rs b/node/network/availability-distribution/src/tests/mod.rs index ebbc436a00dd..39f8287e840a 100644 --- a/node/network/availability-distribution/src/tests/mod.rs +++ b/node/network/availability-distribution/src/tests/mod.rs @@ -19,7 +19,7 @@ use std::collections::HashSet; use futures::{executor, future, Future}; use polkadot_node_network_protocol::request_response::{IncomingRequest, ReqProtocolNames}; -use polkadot_primitives::v2::{CoreState, Hash}; +use polkadot_primitives::{CoreState, Hash}; use sp_keystore::SyncCryptoStorePtr; use polkadot_node_subsystem_test_helpers as test_helpers; diff --git a/node/network/availability-distribution/src/tests/state.rs b/node/network/availability-distribution/src/tests/state.rs index be77aa2d023c..6dc035d4849d 100644 --- a/node/network/availability-distribution/src/tests/state.rs +++ b/node/network/availability-distribution/src/tests/state.rs @@ -47,7 +47,7 @@ use polkadot_node_subsystem::{ ActivatedLeaf, ActiveLeavesUpdate, FromOrchestra, LeafStatus, OverseerSignal, }; use polkadot_node_subsystem_test_helpers as test_helpers; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ CandidateHash, CoreState, GroupIndex, Hash, Id as ParaId, ScheduledCore, SessionInfo, ValidatorIndex, }; diff --git a/node/network/availability-recovery/src/lib.rs b/node/network/availability-recovery/src/lib.rs index 38acfbe88ff9..a504021def59 100644 --- a/node/network/availability-recovery/src/lib.rs +++ b/node/network/availability-recovery/src/lib.rs @@ -56,7 +56,7 @@ use polkadot_node_subsystem::{ SubsystemResult, }; use polkadot_node_subsystem_util::request_session_info; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ AuthorityDiscoveryId, BlakeTwo256, BlockNumber, CandidateHash, CandidateReceipt, GroupIndex, Hash, HashT, IndexedVec, SessionIndex, SessionInfo, ValidatorId, ValidatorIndex, }; diff --git a/node/network/availability-recovery/src/tests.rs b/node/network/availability-recovery/src/tests.rs index c77278f645c1..0f25b502b6cd 100644 --- a/node/network/availability-recovery/src/tests.rs +++ b/node/network/availability-recovery/src/tests.rs @@ -36,7 +36,7 @@ use polkadot_node_subsystem::{ }; use polkadot_node_subsystem_test_helpers::{make_subsystem_context, TestSubsystemContextHandle}; use polkadot_node_subsystem_util::TimeoutExt; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ AuthorityDiscoveryId, Hash, HeadData, IndexedVec, PersistedValidationData, ValidatorId, }; use polkadot_primitives_test_helpers::{dummy_candidate_receipt, dummy_hash}; diff --git a/node/network/bitfield-distribution/src/lib.rs b/node/network/bitfield-distribution/src/lib.rs index 1bd9230a3787..63a9c4ccf091 100644 --- a/node/network/bitfield-distribution/src/lib.rs +++ b/node/network/bitfield-distribution/src/lib.rs @@ -37,7 +37,7 @@ use polkadot_node_subsystem::{ }; use polkadot_node_subsystem_util::{self as util}; -use polkadot_primitives::v2::{Hash, SignedAvailabilityBitfield, SigningContext, ValidatorId}; +use polkadot_primitives::{Hash, SignedAvailabilityBitfield, SigningContext, ValidatorId}; use rand::{CryptoRng, Rng, SeedableRng}; use std::collections::{HashMap, HashSet}; diff --git a/node/network/bitfield-distribution/src/tests.rs b/node/network/bitfield-distribution/src/tests.rs index 5eb610fe8508..67acc5a65592 100644 --- a/node/network/bitfield-distribution/src/tests.rs +++ b/node/network/bitfield-distribution/src/tests.rs @@ -31,7 +31,7 @@ use polkadot_node_subsystem::{ }; use polkadot_node_subsystem_test_helpers::make_subsystem_context; use polkadot_node_subsystem_util::TimeoutExt; -use polkadot_primitives::v2::{AvailabilityBitfield, Signed, ValidatorIndex}; +use polkadot_primitives::{AvailabilityBitfield, Signed, ValidatorIndex}; use rand_chacha::ChaCha12Rng; use sp_application_crypto::AppKey; use sp_authority_discovery::AuthorityPair as AuthorityDiscoveryPair; diff --git a/node/network/bridge/src/network.rs b/node/network/bridge/src/network.rs index ec7623bb2e1d..28a84a19b321 100644 --- a/node/network/bridge/src/network.rs +++ b/node/network/bridge/src/network.rs @@ -36,7 +36,7 @@ use polkadot_node_network_protocol::{ request_response::{OutgoingRequest, Recipient, ReqProtocolNames, Requests}, PeerId, UnifiedReputationChange as Rep, }; -use polkadot_primitives::v2::{AuthorityDiscoveryId, Block, Hash}; +use polkadot_primitives::{AuthorityDiscoveryId, Block, Hash}; use crate::validator_discovery::AuthorityDiscovery; diff --git a/node/network/bridge/src/rx/mod.rs b/node/network/bridge/src/rx/mod.rs index 1d3052d3a218..6059f41c08c2 100644 --- a/node/network/bridge/src/rx/mod.rs +++ b/node/network/bridge/src/rx/mod.rs @@ -45,7 +45,7 @@ use polkadot_node_subsystem::{ overseer, ActivatedLeaf, ActiveLeavesUpdate, FromOrchestra, OverseerSignal, SpawnedSubsystem, }; -use polkadot_primitives::v2::{AuthorityDiscoveryId, BlockNumber, Hash, ValidatorIndex}; +use polkadot_primitives::{AuthorityDiscoveryId, BlockNumber, Hash, ValidatorIndex}; /// Peer set info for network initialization. /// diff --git a/node/network/bridge/src/rx/tests.rs b/node/network/bridge/src/rx/tests.rs index d4353c0342a5..cfbf8ac35fc3 100644 --- a/node/network/bridge/src/rx/tests.rs +++ b/node/network/bridge/src/rx/tests.rs @@ -46,7 +46,7 @@ use polkadot_node_subsystem_test_helpers::{ SingleItemSink, SingleItemStream, TestSubsystemContextHandle, }; use polkadot_node_subsystem_util::metered; -use polkadot_primitives::v2::{AuthorityDiscoveryId, Hash}; +use polkadot_primitives::{AuthorityDiscoveryId, Hash}; use sc_network::Multiaddr; use sp_keyring::Sr25519Keyring; diff --git a/node/network/bridge/src/tx/tests.rs b/node/network/bridge/src/tx/tests.rs index c001457d592b..bfc7200d15ec 100644 --- a/node/network/bridge/src/tx/tests.rs +++ b/node/network/bridge/src/tx/tests.rs @@ -32,7 +32,7 @@ use polkadot_node_network_protocol::{ use polkadot_node_subsystem::{FromOrchestra, OverseerSignal}; use polkadot_node_subsystem_test_helpers::TestSubsystemContextHandle; use polkadot_node_subsystem_util::metered; -use polkadot_primitives::v2::{AuthorityDiscoveryId, Hash}; +use polkadot_primitives::{AuthorityDiscoveryId, Hash}; use polkadot_primitives_test_helpers::dummy_collator_signature; use sc_network::Multiaddr; use sp_keyring::Sr25519Keyring; diff --git a/node/network/bridge/src/validator_discovery.rs b/node/network/bridge/src/validator_discovery.rs index f7cb805428b5..88096c08ce17 100644 --- a/node/network/bridge/src/validator_discovery.rs +++ b/node/network/bridge/src/validator_discovery.rs @@ -30,7 +30,7 @@ use polkadot_node_network_protocol::{ peer_set::{PeerSet, PeerSetProtocolNames, PerPeerSet}, PeerId, }; -use polkadot_primitives::v2::AuthorityDiscoveryId; +use polkadot_primitives::AuthorityDiscoveryId; const LOG_TARGET: &str = "parachain::validator-discovery"; @@ -173,7 +173,7 @@ mod tests { request_response::{outgoing::Requests, ReqProtocolNames}, PeerId, }; - use polkadot_primitives::v2::Hash; + use polkadot_primitives::Hash; use sc_network::{Event as NetworkEvent, IfDisconnected, ProtocolName}; use sp_keyring::Sr25519Keyring; use std::collections::{HashMap, HashSet}; diff --git a/node/network/collator-protocol/src/collator_side/mod.rs b/node/network/collator-protocol/src/collator_side/mod.rs index f7b27583a6dd..cb4a3b4a8f52 100644 --- a/node/network/collator-protocol/src/collator_side/mod.rs +++ b/node/network/collator-protocol/src/collator_side/mod.rs @@ -47,7 +47,7 @@ use polkadot_node_subsystem_util::{ runtime::{get_availability_cores, get_group_rotation_info, RuntimeInfo}, TimeoutExt, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ AuthorityDiscoveryId, CandidateHash, CandidateReceipt, CollatorPair, CoreIndex, CoreState, GroupIndex, Hash, Id as ParaId, SessionIndex, }; diff --git a/node/network/collator-protocol/src/collator_side/tests.rs b/node/network/collator-protocol/src/collator_side/tests.rs index 6575259b37b3..d7e7d45fadac 100644 --- a/node/network/collator-protocol/src/collator_side/tests.rs +++ b/node/network/collator-protocol/src/collator_side/tests.rs @@ -43,7 +43,7 @@ use polkadot_node_subsystem::{ }; use polkadot_node_subsystem_test_helpers as test_helpers; use polkadot_node_subsystem_util::TimeoutExt; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ AuthorityDiscoveryId, CollatorPair, GroupIndex, GroupRotationInfo, IndexedVec, ScheduledCore, SessionIndex, SessionInfo, ValidatorId, ValidatorIndex, }; diff --git a/node/network/collator-protocol/src/collator_side/validators_buffer.rs b/node/network/collator-protocol/src/collator_side/validators_buffer.rs index 5bb31c72d6c5..054d8960b77f 100644 --- a/node/network/collator-protocol/src/collator_side/validators_buffer.rs +++ b/node/network/collator-protocol/src/collator_side/validators_buffer.rs @@ -37,7 +37,7 @@ use std::{ use bitvec::{bitvec, vec::BitVec}; -use polkadot_primitives::v2::{AuthorityDiscoveryId, GroupIndex, Hash, SessionIndex}; +use polkadot_primitives::{AuthorityDiscoveryId, GroupIndex, Hash, SessionIndex}; /// The ring buffer stores at most this many unique validator groups. /// diff --git a/node/network/collator-protocol/src/lib.rs b/node/network/collator-protocol/src/lib.rs index b71acc127c88..388121cfc049 100644 --- a/node/network/collator-protocol/src/lib.rs +++ b/node/network/collator-protocol/src/lib.rs @@ -34,7 +34,7 @@ use polkadot_node_network_protocol::{ request_response::{v1 as request_v1, IncomingRequestReceiver}, PeerId, UnifiedReputationChange as Rep, }; -use polkadot_primitives::v2::CollatorPair; +use polkadot_primitives::CollatorPair; use polkadot_node_subsystem::{ errors::SubsystemError, messages::NetworkBridgeTxMessage, overseer, SpawnedSubsystem, diff --git a/node/network/collator-protocol/src/validator_side/mod.rs b/node/network/collator-protocol/src/validator_side/mod.rs index 1442fbcc2bcb..5d5417fb3001 100644 --- a/node/network/collator-protocol/src/validator_side/mod.rs +++ b/node/network/collator-protocol/src/validator_side/mod.rs @@ -53,7 +53,7 @@ use polkadot_node_subsystem::{ overseer, FromOrchestra, OverseerSignal, PerLeafSpan, SubsystemSender, }; use polkadot_node_subsystem_util::metrics::{self, prometheus}; -use polkadot_primitives::v2::{CandidateReceipt, CollatorId, Hash, Id as ParaId}; +use polkadot_primitives::{CandidateReceipt, CollatorId, Hash, Id as ParaId}; use crate::error::Result; diff --git a/node/network/collator-protocol/src/validator_side/tests.rs b/node/network/collator-protocol/src/validator_side/tests.rs index ae8644cea521..7b25ff7be616 100644 --- a/node/network/collator-protocol/src/validator_side/tests.rs +++ b/node/network/collator-protocol/src/validator_side/tests.rs @@ -32,7 +32,7 @@ use polkadot_node_primitives::BlockData; use polkadot_node_subsystem::messages::{AllMessages, RuntimeApiMessage, RuntimeApiRequest}; use polkadot_node_subsystem_test_helpers as test_helpers; use polkadot_node_subsystem_util::TimeoutExt; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ CollatorPair, CoreState, GroupIndex, GroupRotationInfo, OccupiedCore, ScheduledCore, ValidatorId, ValidatorIndex, }; @@ -133,7 +133,7 @@ fn test_harness>(test: impl FnOnce(TestHarne let keystore = TestKeyStore::new(); keystore .sr25519_generate_new( - polkadot_primitives::v2::PARACHAIN_KEY_TYPE_ID, + polkadot_primitives::PARACHAIN_KEY_TYPE_ID, Some(&Sr25519Keyring::Alice.to_seed()), ) .unwrap(); diff --git a/node/network/dispute-distribution/src/lib.rs b/node/network/dispute-distribution/src/lib.rs index babdb303bbda..f3325a11a659 100644 --- a/node/network/dispute-distribution/src/lib.rs +++ b/node/network/dispute-distribution/src/lib.rs @@ -156,7 +156,7 @@ impl DisputeDistributionSubsystem where AD: AuthorityDiscovery + Clone, { - /// Create a new instance of the availability distribution. + /// Create a new instance of the dispute distribution. pub fn new( keystore: SyncCryptoStorePtr, req_receiver: IncomingRequestReceiver, diff --git a/node/network/dispute-distribution/src/receiver/batches/batch.rs b/node/network/dispute-distribution/src/receiver/batches/batch.rs index eebed25ed790..cb08df4595f9 100644 --- a/node/network/dispute-distribution/src/receiver/batches/batch.rs +++ b/node/network/dispute-distribution/src/receiver/batches/batch.rs @@ -22,7 +22,7 @@ use polkadot_node_network_protocol::{ PeerId, }; use polkadot_node_primitives::SignedDisputeStatement; -use polkadot_primitives::v2::{CandidateReceipt, ValidatorIndex}; +use polkadot_primitives::{CandidateReceipt, ValidatorIndex}; use crate::receiver::{BATCH_COLLECTING_INTERVAL, MIN_KEEP_BATCH_ALIVE_VOTES}; diff --git a/node/network/dispute-distribution/src/receiver/batches/mod.rs b/node/network/dispute-distribution/src/receiver/batches/mod.rs index b343b55e0b04..8e3e157c92d6 100644 --- a/node/network/dispute-distribution/src/receiver/batches/mod.rs +++ b/node/network/dispute-distribution/src/receiver/batches/mod.rs @@ -22,7 +22,7 @@ use std::{ use futures::future::pending; use polkadot_node_network_protocol::request_response::DISPUTE_REQUEST_TIMEOUT; -use polkadot_primitives::v2::{CandidateHash, CandidateReceipt}; +use polkadot_primitives::{CandidateHash, CandidateReceipt}; use crate::{ receiver::batches::{batch::TickResult, waiting_queue::PendingWake}, diff --git a/node/network/dispute-distribution/src/receiver/error.rs b/node/network/dispute-distribution/src/receiver/error.rs index 4477335440d0..57e3222b89e7 100644 --- a/node/network/dispute-distribution/src/receiver/error.rs +++ b/node/network/dispute-distribution/src/receiver/error.rs @@ -22,7 +22,7 @@ use fatality::Nested; use gum::CandidateHash; use polkadot_node_network_protocol::{request_response::incoming, PeerId}; use polkadot_node_subsystem_util::runtime; -use polkadot_primitives::v2::AuthorityDiscoveryId; +use polkadot_primitives::AuthorityDiscoveryId; use crate::LOG_TARGET; diff --git a/node/network/dispute-distribution/src/receiver/peer_queues.rs b/node/network/dispute-distribution/src/receiver/peer_queues.rs index 138b59c3f867..fc3b969731cd 100644 --- a/node/network/dispute-distribution/src/receiver/peer_queues.rs +++ b/node/network/dispute-distribution/src/receiver/peer_queues.rs @@ -19,7 +19,7 @@ use std::collections::{hash_map::Entry, HashMap, VecDeque}; use futures::future::pending; use futures_timer::Delay; use polkadot_node_network_protocol::request_response::{v1::DisputeRequest, IncomingRequest}; -use polkadot_primitives::v2::AuthorityDiscoveryId; +use polkadot_primitives::AuthorityDiscoveryId; use crate::RECEIVE_RATE_LIMIT; diff --git a/node/network/dispute-distribution/src/sender/mod.rs b/node/network/dispute-distribution/src/sender/mod.rs index d373b1861f19..629c4913b78e 100644 --- a/node/network/dispute-distribution/src/sender/mod.rs +++ b/node/network/dispute-distribution/src/sender/mod.rs @@ -31,7 +31,7 @@ use polkadot_node_subsystem::{ messages::DisputeCoordinatorMessage, overseer, ActiveLeavesUpdate, SubsystemSender, }; use polkadot_node_subsystem_util::{nesting_sender::NestingSender, runtime::RuntimeInfo}; -use polkadot_primitives::v2::{CandidateHash, Hash, SessionIndex}; +use polkadot_primitives::{CandidateHash, Hash, SessionIndex}; /// For each ongoing dispute we have a `SendTask` which takes care of it. /// diff --git a/node/network/dispute-distribution/src/sender/send_task.rs b/node/network/dispute-distribution/src/sender/send_task.rs index 20d72efc145c..7e01bc1774ac 100644 --- a/node/network/dispute-distribution/src/sender/send_task.rs +++ b/node/network/dispute-distribution/src/sender/send_task.rs @@ -28,7 +28,7 @@ use polkadot_node_network_protocol::{ }; use polkadot_node_subsystem::{messages::NetworkBridgeTxMessage, overseer}; use polkadot_node_subsystem_util::{metrics, nesting_sender::NestingSender, runtime::RuntimeInfo}; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ AuthorityDiscoveryId, CandidateHash, Hash, SessionIndex, ValidatorIndex, }; diff --git a/node/network/dispute-distribution/src/tests/mock.rs b/node/network/dispute-distribution/src/tests/mock.rs index bc64734d57a0..6478940c9024 100644 --- a/node/network/dispute-distribution/src/tests/mock.rs +++ b/node/network/dispute-distribution/src/tests/mock.rs @@ -33,7 +33,7 @@ use sp_keyring::Sr25519Keyring; use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; use polkadot_node_primitives::{DisputeMessage, SignedDisputeStatement}; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ AuthorityDiscoveryId, CandidateHash, CandidateReceipt, Hash, SessionIndex, SessionInfo, ValidatorId, ValidatorIndex, }; @@ -210,7 +210,7 @@ impl MockAuthorityDiscovery { impl AuthorityDiscovery for MockAuthorityDiscovery { async fn get_addresses_by_authority_id( &mut self, - _authority: polkadot_primitives::v2::AuthorityDiscoveryId, + _authority: polkadot_primitives::AuthorityDiscoveryId, ) -> Option> { panic!("Not implemented"); } @@ -218,7 +218,7 @@ impl AuthorityDiscovery for MockAuthorityDiscovery { async fn get_authority_ids_by_peer_id( &mut self, peer_id: polkadot_node_network_protocol::PeerId, - ) -> Option> { + ) -> Option> { for (a, p) in self.peer_ids.iter() { if p == &peer_id { let result = diff --git a/node/network/dispute-distribution/src/tests/mod.rs b/node/network/dispute-distribution/src/tests/mod.rs index 42709ecd5475..ca5f49f4a394 100644 --- a/node/network/dispute-distribution/src/tests/mod.rs +++ b/node/network/dispute-distribution/src/tests/mod.rs @@ -56,7 +56,7 @@ use polkadot_node_subsystem::{ use polkadot_node_subsystem_test_helpers::{ mock::make_ferdie_keystore, subsystem_test_harness, TestSubsystemContextHandle, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ AuthorityDiscoveryId, CandidateHash, CandidateReceipt, Hash, SessionIndex, SessionInfo, }; diff --git a/node/network/gossip-support/src/lib.rs b/node/network/gossip-support/src/lib.rs index 36459f9c8dab..03d0e2150892 100644 --- a/node/network/gossip-support/src/lib.rs +++ b/node/network/gossip-support/src/lib.rs @@ -51,9 +51,7 @@ use polkadot_node_subsystem::{ overseer, ActiveLeavesUpdate, FromOrchestra, OverseerSignal, SpawnedSubsystem, SubsystemError, }; use polkadot_node_subsystem_util as util; -use polkadot_primitives::v2::{ - AuthorityDiscoveryId, Hash, SessionIndex, SessionInfo, ValidatorIndex, -}; +use polkadot_primitives::{AuthorityDiscoveryId, Hash, SessionIndex, SessionInfo, ValidatorIndex}; #[cfg(test)] mod tests; diff --git a/node/network/gossip-support/src/tests.rs b/node/network/gossip-support/src/tests.rs index 4b2b91f7cdba..797d653e7724 100644 --- a/node/network/gossip-support/src/tests.rs +++ b/node/network/gossip-support/src/tests.rs @@ -37,7 +37,7 @@ use polkadot_node_subsystem::{ }; use polkadot_node_subsystem_test_helpers as test_helpers; use polkadot_node_subsystem_util::TimeoutExt as _; -use polkadot_primitives::v2::{GroupIndex, IndexedVec}; +use polkadot_primitives::{GroupIndex, IndexedVec}; use test_helpers::mock::make_ferdie_keystore; use super::*; @@ -121,14 +121,14 @@ impl MockAuthorityDiscovery { impl AuthorityDiscovery for MockAuthorityDiscovery { async fn get_addresses_by_authority_id( &mut self, - authority: polkadot_primitives::v2::AuthorityDiscoveryId, + authority: polkadot_primitives::AuthorityDiscoveryId, ) -> Option> { self.addrs.get(&authority).cloned() } async fn get_authority_ids_by_peer_id( &mut self, peer_id: polkadot_node_network_protocol::PeerId, - ) -> Option> { + ) -> Option> { self.authorities.get(&peer_id).cloned() } } diff --git a/node/network/protocol/src/authority_discovery.rs b/node/network/protocol/src/authority_discovery.rs index 4c7a7bc801b0..57a8532376cd 100644 --- a/node/network/protocol/src/authority_discovery.rs +++ b/node/network/protocol/src/authority_discovery.rs @@ -22,7 +22,7 @@ use async_trait::async_trait; use sc_authority_discovery::Service as AuthorityDiscoveryService; -use polkadot_primitives::v2::AuthorityDiscoveryId; +use polkadot_primitives::AuthorityDiscoveryId; use sc_network::{Multiaddr, PeerId}; /// An abstraction over the authority discovery service. diff --git a/node/network/protocol/src/grid_topology.rs b/node/network/protocol/src/grid_topology.rs index 2ae43c07c355..6e0512dd59a0 100644 --- a/node/network/protocol/src/grid_topology.rs +++ b/node/network/protocol/src/grid_topology.rs @@ -30,7 +30,7 @@ //! use crate::PeerId; -use polkadot_primitives::v2::{AuthorityDiscoveryId, SessionIndex, ValidatorIndex}; +use polkadot_primitives::{AuthorityDiscoveryId, SessionIndex, ValidatorIndex}; use rand::{CryptoRng, Rng}; use std::{ collections::{hash_map, HashMap, HashSet}, diff --git a/node/network/protocol/src/lib.rs b/node/network/protocol/src/lib.rs index 744217133eed..63024e0fd3f6 100644 --- a/node/network/protocol/src/lib.rs +++ b/node/network/protocol/src/lib.rs @@ -20,7 +20,7 @@ #![warn(missing_docs)] use parity_scale_codec::{Decode, Encode}; -use polkadot_primitives::v2::{BlockNumber, Hash}; +use polkadot_primitives::{BlockNumber, Hash}; use std::{collections::HashMap, fmt}; #[doc(hidden)] @@ -139,7 +139,7 @@ impl std::ops::Deref for OurView { /// /// ``` /// # use polkadot_node_network_protocol::our_view; -/// # use polkadot_primitives::v2::Hash; +/// # use polkadot_primitives::Hash; /// let our_view = our_view![Hash::repeat_byte(1), Hash::repeat_byte(2)]; /// ``` #[macro_export] @@ -173,7 +173,7 @@ pub struct View { /// /// ``` /// # use polkadot_node_network_protocol::view; -/// # use polkadot_primitives::v2::Hash; +/// # use polkadot_primitives::Hash; /// let view = view![Hash::repeat_byte(1), Hash::repeat_byte(2)]; /// ``` #[macro_export] @@ -398,7 +398,7 @@ impl_versioned_try_from!( pub mod v1 { use parity_scale_codec::{Decode, Encode}; - use polkadot_primitives::v2::{ + use polkadot_primitives::{ CandidateHash, CandidateIndex, CollatorId, CollatorSignature, CompactStatement, Hash, Id as ParaId, UncheckedSignedAvailabilityBitfield, ValidatorIndex, ValidatorSignature, }; diff --git a/node/network/protocol/src/peer_set.rs b/node/network/protocol/src/peer_set.rs index 22eddc44c42f..faeea10e4cea 100644 --- a/node/network/protocol/src/peer_set.rs +++ b/node/network/protocol/src/peer_set.rs @@ -17,7 +17,7 @@ //! All peersets and protocols used for parachains. use derive_more::Display; -use polkadot_primitives::v2::Hash; +use polkadot_primitives::Hash; use sc_network_common::{ config::{NonDefaultSetConfig, SetConfig}, protocol::ProtocolName, diff --git a/node/network/protocol/src/request_response/mod.rs b/node/network/protocol/src/request_response/mod.rs index 6ce0c883cc6c..555c50fd5913 100644 --- a/node/network/protocol/src/request_response/mod.rs +++ b/node/network/protocol/src/request_response/mod.rs @@ -35,7 +35,7 @@ use std::{collections::HashMap, time::Duration, u64}; use futures::channel::mpsc; -use polkadot_primitives::v2::{MAX_CODE_SIZE, MAX_POV_SIZE}; +use polkadot_primitives::{MAX_CODE_SIZE, MAX_POV_SIZE}; use strum::{EnumIter, IntoEnumIterator}; pub use sc_network::{config as network, config::RequestResponseConfig, ProtocolName}; diff --git a/node/network/protocol/src/request_response/outgoing.rs b/node/network/protocol/src/request_response/outgoing.rs index b93c4e93cd31..8aa174eb69a7 100644 --- a/node/network/protocol/src/request_response/outgoing.rs +++ b/node/network/protocol/src/request_response/outgoing.rs @@ -21,7 +21,7 @@ use parity_scale_codec::{Decode, Encode, Error as DecodingError}; use sc_network as network; use sc_network::PeerId; -use polkadot_primitives::v2::AuthorityDiscoveryId; +use polkadot_primitives::AuthorityDiscoveryId; use super::{v1, IsRequest, Protocol}; diff --git a/node/network/protocol/src/request_response/v1.rs b/node/network/protocol/src/request_response/v1.rs index 52458d6822d9..ca8f59a8396d 100644 --- a/node/network/protocol/src/request_response/v1.rs +++ b/node/network/protocol/src/request_response/v1.rs @@ -21,7 +21,7 @@ use parity_scale_codec::{Decode, Encode}; use polkadot_node_primitives::{ AvailableData, DisputeMessage, ErasureChunk, PoV, Proof, UncheckedDisputeMessage, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ CandidateHash, CandidateReceipt, CommittedCandidateReceipt, Hash, Id as ParaId, ValidatorIndex, }; diff --git a/node/network/statement-distribution/src/error.rs b/node/network/statement-distribution/src/error.rs index 01b2efd53b86..86cbbc8a9877 100644 --- a/node/network/statement-distribution/src/error.rs +++ b/node/network/statement-distribution/src/error.rs @@ -20,7 +20,7 @@ use polkadot_node_network_protocol::PeerId; use polkadot_node_subsystem::SubsystemError; use polkadot_node_subsystem_util::runtime; -use polkadot_primitives::v2::{CandidateHash, Hash}; +use polkadot_primitives::{CandidateHash, Hash}; use crate::LOG_TARGET; diff --git a/node/network/statement-distribution/src/lib.rs b/node/network/statement-distribution/src/lib.rs index 271072ab1031..769c50322061 100644 --- a/node/network/statement-distribution/src/lib.rs +++ b/node/network/statement-distribution/src/lib.rs @@ -45,7 +45,7 @@ use polkadot_node_subsystem::{ overseer, ActiveLeavesUpdate, FromOrchestra, OverseerSignal, PerLeafSpan, SpawnedSubsystem, SubsystemError, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ AuthorityDiscoveryId, CandidateHash, CommittedCandidateReceipt, CompactStatement, Hash, IndexedVec, SignedStatement, SigningContext, UncheckedSignedStatement, ValidatorId, ValidatorIndex, ValidatorSignature, diff --git a/node/network/statement-distribution/src/requester.rs b/node/network/statement-distribution/src/requester.rs index 24ffa5e41742..941c6772e546 100644 --- a/node/network/statement-distribution/src/requester.rs +++ b/node/network/statement-distribution/src/requester.rs @@ -30,7 +30,7 @@ use polkadot_node_network_protocol::{ }; use polkadot_node_subsystem::{Span, Stage}; use polkadot_node_subsystem_util::TimeoutExt; -use polkadot_primitives::v2::{CandidateHash, CommittedCandidateReceipt, Hash}; +use polkadot_primitives::{CandidateHash, CommittedCandidateReceipt, Hash}; use crate::{metrics::Metrics, COST_WRONG_HASH, LOG_TARGET}; diff --git a/node/network/statement-distribution/src/responder.rs b/node/network/statement-distribution/src/responder.rs index 776652c04e7a..8db38385e581 100644 --- a/node/network/statement-distribution/src/responder.rs +++ b/node/network/statement-distribution/src/responder.rs @@ -29,7 +29,7 @@ use polkadot_node_network_protocol::{ }, PeerId, UnifiedReputationChange as Rep, }; -use polkadot_primitives::v2::{CandidateHash, CommittedCandidateReceipt, Hash}; +use polkadot_primitives::{CandidateHash, CommittedCandidateReceipt, Hash}; use crate::LOG_TARGET; diff --git a/node/network/statement-distribution/src/tests.rs b/node/network/statement-distribution/src/tests.rs index c1636557fdca..87a7cd7a35fe 100644 --- a/node/network/statement-distribution/src/tests.rs +++ b/node/network/statement-distribution/src/tests.rs @@ -35,7 +35,7 @@ use polkadot_node_subsystem::{ ActivatedLeaf, LeafStatus, }; use polkadot_node_subsystem_test_helpers::mock::make_ferdie_keystore; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ GroupIndex, Hash, Id as ParaId, IndexedVec, SessionInfo, ValidationCode, ValidatorId, }; use polkadot_primitives_test_helpers::{ diff --git a/node/overseer/examples/minimal-example.rs b/node/overseer/examples/minimal-example.rs index be6779819eb7..31c38eea07e8 100644 --- a/node/overseer/examples/minimal-example.rs +++ b/node/overseer/examples/minimal-example.rs @@ -32,7 +32,7 @@ use polkadot_overseer::{ gen::{FromOrchestra, SpawnedSubsystem}, HeadSupportsParachains, SubsystemError, }; -use polkadot_primitives::v2::{CandidateReceipt, Hash}; +use polkadot_primitives::{CandidateReceipt, Hash}; struct AlwaysSupportsParachains; diff --git a/node/overseer/src/lib.rs b/node/overseer/src/lib.rs index 6253f8b3e264..e66563df826a 100644 --- a/node/overseer/src/lib.rs +++ b/node/overseer/src/lib.rs @@ -72,7 +72,7 @@ use futures::{channel::oneshot, future::BoxFuture, select, Future, FutureExt, St use lru::LruCache; use client::{BlockImportNotification, BlockchainEvents, FinalityNotification}; -use polkadot_primitives::v2::{Block, BlockNumber, Hash}; +use polkadot_primitives::{Block, BlockNumber, Hash}; use self::messages::{BitfieldSigningMessage, PvfCheckerMessage}; use polkadot_node_subsystem_types::messages::{ @@ -370,7 +370,7 @@ pub async fn forward_events>(client: Arc

, mut hand /// # use std::time::Duration; /// # use futures::{executor, pin_mut, select, FutureExt}; /// # use futures_timer::Delay; -/// # use polkadot_primitives::v2::Hash; +/// # use polkadot_primitives::Hash; /// # use polkadot_overseer::{ /// # self as overseer, /// # OverseerSignal, diff --git a/node/overseer/src/tests.rs b/node/overseer/src/tests.rs index ca84f033b599..b9f813ff1dce 100644 --- a/node/overseer/src/tests.rs +++ b/node/overseer/src/tests.rs @@ -29,7 +29,7 @@ use polkadot_node_subsystem_types::{ messages::{NetworkBridgeEvent, RuntimeApiRequest}, ActivatedLeaf, LeafStatus, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ CandidateHash, CandidateReceipt, CollatorPair, InvalidDisputeStatementKind, SessionIndex, ValidDisputeStatementKind, ValidatorIndex, }; diff --git a/node/primitives/src/approval.rs b/node/primitives/src/approval.rs index ab9a4ce012bd..809dc57bcbc7 100644 --- a/node/primitives/src/approval.rs +++ b/node/primitives/src/approval.rs @@ -20,7 +20,7 @@ pub use sp_consensus_babe::Slot; pub use sp_consensus_vrf::schnorrkel::{Randomness, VRFOutput, VRFProof}; use parity_scale_codec::{Decode, Encode}; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ BlockNumber, CandidateHash, CandidateIndex, CoreIndex, Hash, Header, SessionIndex, ValidatorIndex, ValidatorSignature, }; diff --git a/node/primitives/src/disputes/message.rs b/node/primitives/src/disputes/message.rs index 02b33434b9b2..4a1650ed8ced 100644 --- a/node/primitives/src/disputes/message.rs +++ b/node/primitives/src/disputes/message.rs @@ -24,7 +24,7 @@ use thiserror::Error; use parity_scale_codec::{Decode, Encode}; use super::{InvalidDisputeVote, SignedDisputeStatement, ValidDisputeVote}; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ CandidateReceipt, DisputeStatement, SessionIndex, SessionInfo, ValidatorIndex, }; diff --git a/node/primitives/src/disputes/mod.rs b/node/primitives/src/disputes/mod.rs index bad2ddbffc46..ebda150a3387 100644 --- a/node/primitives/src/disputes/mod.rs +++ b/node/primitives/src/disputes/mod.rs @@ -25,7 +25,7 @@ use sp_application_crypto::AppKey; use sp_keystore::{CryptoStore, Error as KeystoreError, SyncCryptoStorePtr}; use super::{Statement, UncheckedSignedFullStatement}; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ CandidateHash, CandidateReceipt, DisputeStatement, InvalidDisputeStatementKind, SessionIndex, SigningContext, ValidDisputeStatementKind, ValidatorId, ValidatorIndex, ValidatorSignature, }; diff --git a/node/primitives/src/lib.rs b/node/primitives/src/lib.rs index 9af65b3d601e..2d76a14c115d 100644 --- a/node/primitives/src/lib.rs +++ b/node/primitives/src/lib.rs @@ -29,7 +29,7 @@ use futures::Future; use parity_scale_codec::{Decode, Encode, Error as CodecError, Input}; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ BlakeTwo256, BlockNumber, CandidateCommitments, CandidateHash, CollatorPair, CommittedCandidateReceipt, CompactStatement, EncodeAs, Hash, HashT, HeadData, Id as ParaId, OutboundHrmpMessage, PersistedValidationData, SessionIndex, Signed, UncheckedSigned, @@ -312,7 +312,7 @@ impl MaybeCompressedPoV { /// - contains a proof of validity. #[derive(Clone, Encode, Decode)] #[cfg(not(target_os = "unknown"))] -pub struct Collation { +pub struct Collation { /// Messages destined to be interpreted by the Relay chain itself. pub upward_messages: Vec, /// The horizontal messages sent by the parachain. diff --git a/node/service/chain-specs/kusama.json b/node/service/chain-specs/kusama.json index 581f40aff4d6..b7fe4c293f8b 100644 --- a/node/service/chain-specs/kusama.json +++ b/node/service/chain-specs/kusama.json @@ -19,7 +19,7 @@ "/dns/kusama-bootnode-0.paritytech.net/tcp/30333/p2p/12D3KooWSueCPH3puP2PcvqPJdNaDNF3jMZjtJtDiSy35pWrbt5h", "/dns/kusama-bootnode-0.paritytech.net/tcp/30334/ws/p2p/12D3KooWSueCPH3puP2PcvqPJdNaDNF3jMZjtJtDiSy35pWrbt5h", "/dns/kusama-bootnode-1.paritytech.net/tcp/30333/p2p/12D3KooWQKqane1SqWJNWMQkbia9qiMWXkcHtAdfW5eVF8hbwEDw", - "/dns/kusama-bootnode.dwellir.com/tcp/30333/ws/p2p/12D3KooWFj2ndawdYyk2spc42Y2arYwb2TUoHLHFAsKuHRzWXwoJ", + "/dns/kusama-boot.dwellir.com/tcp/443/wss/p2p/12D3KooWFj2ndawdYyk2spc42Y2arYwb2TUoHLHFAsKuHRzWXwoJ", "/dns/boot.stake.plus/tcp/31333/p2p/12D3KooWLa1UyG5xLPds2GbiRBCTJjpsVwRWHWN7Dff14yiNJRpR", "/dns/boot.stake.plus/tcp/31334/wss/p2p/12D3KooWLa1UyG5xLPds2GbiRBCTJjpsVwRWHWN7Dff14yiNJRpR", "/dns/boot-node.helikon.io/tcp/7060/p2p/12D3KooWL4KPqfAsPE2aY1g5Zo1CxsDwcdJ7mmAghK7cg6M2fdbD", diff --git a/node/service/chain-specs/polkadot.json b/node/service/chain-specs/polkadot.json index 8fc8ac63ba32..9b9a19193dac 100644 --- a/node/service/chain-specs/polkadot.json +++ b/node/service/chain-specs/polkadot.json @@ -19,7 +19,7 @@ "/dns/p2p.5.polkadot.network/tcp/30333/p2p/12D3KooWSRjL9LcEQd5u2fQTbyLxTEHq1tUFgQ6amXSp8Eu7TfKP", "/dns/cc1-0.parity.tech/tcp/30333/p2p/12D3KooWSz8r2WyCdsfWHgPyvD8GKQdJ1UAiRmrcrs8sQB3fe2KU", "/dns/cc1-1.parity.tech/tcp/30333/p2p/12D3KooWFN2mhgpkJsDBuNuE5427AcDrsib8EoqGMZmkxWwx3Md4", - "/dns/polkadot-bootnode.dwellir.com/tcp/30333/ws/p2p/12D3KooWKvdDyRKqUfSAaUCbYiLwKY8uK3wDWpCuy2FiDLbkPTDJ", + "/dns/polkadot-boot.dwellir.com/tcp/443/wss/p2p/12D3KooWKvdDyRKqUfSAaUCbYiLwKY8uK3wDWpCuy2FiDLbkPTDJ", "/dns/boot.stake.plus/tcp/30333/p2p/12D3KooWKT4ZHNxXH4icMjdrv7EwWBkfbz5duxE5sdJKKeWFYi5n", "/dns/boot.stake.plus/tcp/30334/wss/p2p/12D3KooWKT4ZHNxXH4icMjdrv7EwWBkfbz5duxE5sdJKKeWFYi5n", "/dns/boot-node.helikon.io/tcp/7070/p2p/12D3KooWS9ZcvRxyzrSf6p63QfTCWs12nLoNKhGux865crgxVA4H", diff --git a/node/service/src/chain_spec.rs b/node/service/src/chain_spec.rs index 8650499d064c..1f59c5ec4b3d 100644 --- a/node/service/src/chain_spec.rs +++ b/node/service/src/chain_spec.rs @@ -25,7 +25,7 @@ use kusama_runtime as kusama; use kusama_runtime_constants::currency::UNITS as KSM; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use pallet_staking::Forcing; -use polkadot_primitives::v2::{AccountId, AccountPublic, AssignmentId, ValidatorId}; +use polkadot_primitives::{AccountId, AccountPublic, AssignmentId, ValidatorId}; #[cfg(feature = "polkadot-native")] use polkadot_runtime as polkadot; #[cfg(feature = "polkadot-native")] @@ -67,9 +67,9 @@ const DEFAULT_PROTOCOL_ID: &str = "dot"; #[serde(rename_all = "camelCase")] pub struct Extensions { /// Block numbers with known hashes. - pub fork_blocks: sc_client_api::ForkBlocks, + pub fork_blocks: sc_client_api::ForkBlocks, /// Known bad block hashes. - pub bad_blocks: sc_client_api::BadBlocks, + pub bad_blocks: sc_client_api::BadBlocks, /// The light sync state. /// /// This value will be set by the `sync-state rpc` implementation. @@ -172,10 +172,9 @@ pub fn wococo_config() -> Result { feature = "polkadot-native" ))] fn default_parachains_host_configuration( -) -> polkadot_runtime_parachains::configuration::HostConfiguration< - polkadot_primitives::v2::BlockNumber, -> { - use polkadot_primitives::v2::{MAX_CODE_SIZE, MAX_POV_SIZE}; +) -> polkadot_runtime_parachains::configuration::HostConfiguration +{ + use polkadot_primitives::{MAX_CODE_SIZE, MAX_POV_SIZE}; polkadot_runtime_parachains::configuration::HostConfiguration { validation_upgrade_cooldown: 2u32, @@ -570,7 +569,7 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi }, paras: Default::default(), registrar: westend_runtime::RegistrarConfig { - next_free_para_id: polkadot_primitives::v2::LOWEST_PUBLIC_ID, + next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID, }, xcm_pallet: Default::default(), nomination_pools: Default::default(), @@ -1074,7 +1073,7 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime:: config: default_parachains_host_configuration(), }, registrar: rococo_runtime::RegistrarConfig { - next_free_para_id: polkadot_primitives::v2::LOWEST_PUBLIC_ID, + next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID, }, xcm_pallet: Default::default(), nis_counterpart_balances: Default::default(), @@ -1547,7 +1546,7 @@ pub fn westend_testnet_genesis( }, paras: Default::default(), registrar: westend_runtime::RegistrarConfig { - next_free_para_id: polkadot_primitives::v2::LOWEST_PUBLIC_ID, + next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID, }, xcm_pallet: Default::default(), nomination_pools: Default::default(), @@ -1631,7 +1630,7 @@ pub fn rococo_testnet_genesis( }, paras: rococo_runtime::ParasConfig { paras: vec![] }, registrar: rococo_runtime::RegistrarConfig { - next_free_para_id: polkadot_primitives::v2::LOWEST_PUBLIC_ID, + next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID, }, xcm_pallet: Default::default(), nis_counterpart_balances: Default::default(), diff --git a/node/service/src/grandpa_support.rs b/node/service/src/grandpa_support.rs index 2e31737d97c3..14507e87a2d8 100644 --- a/node/service/src/grandpa_support.rs +++ b/node/service/src/grandpa_support.rs @@ -23,7 +23,7 @@ use sp_runtime::traits::{Block as BlockT, Header as _, NumberFor}; use crate::HeaderProvider; #[cfg(feature = "full-node")] -use polkadot_primitives::v2::{Block, Hash}; +use polkadot_primitives::{Block, Hash}; /// Returns the block hash of the block at the given `target_number` by walking /// backwards from the given `current_header`. diff --git a/node/service/src/lib.rs b/node/service/src/lib.rs index 4cd937b1d7de..9b3fce1b3364 100644 --- a/node/service/src/lib.rs +++ b/node/service/src/lib.rs @@ -101,7 +101,7 @@ pub use polkadot_client::{ AbstractClient, Client, ClientHandle, ExecuteWithClient, FullBackend, FullClient, RuntimeApiCollection, }; -pub use polkadot_primitives::v2::{Block, BlockId, BlockNumber, CollatorPair, Hash, Id as ParaId}; +pub use polkadot_primitives::{Block, BlockId, BlockNumber, CollatorPair, Hash, Id as ParaId}; pub use sc_client_api::{Backend, CallExecutor, ExecutionStrategy}; pub use sc_consensus::{BlockImport, LongestChain}; use sc_executor::NativeElseWasmExecutor; diff --git a/node/service/src/relay_chain_selection.rs b/node/service/src/relay_chain_selection.rs index 890e4c16ec8f..2ac5e0ca7f5f 100644 --- a/node/service/src/relay_chain_selection.rs +++ b/node/service/src/relay_chain_selection.rs @@ -45,9 +45,7 @@ use polkadot_node_subsystem::messages::{ }; use polkadot_node_subsystem_util::metrics::{self, prometheus}; use polkadot_overseer::{AllMessages, Handle}; -use polkadot_primitives::v2::{ - Block as PolkadotBlock, BlockNumber, Hash, Header as PolkadotHeader, -}; +use polkadot_primitives::{Block as PolkadotBlock, BlockNumber, Hash, Header as PolkadotHeader}; use std::sync::Arc; /// The maximum amount of unfinalized blocks we are willing to allow due to approval checking @@ -56,7 +54,7 @@ use std::sync::Arc; /// This is a safety net that should be removed at some point in the future. // In sync with `MAX_HEADS_LOOK_BACK` in `approval-voting` // and `MAX_BATCH_SCRAPE_ANCESTORS` in `dispute-coordinator`. -const MAX_FINALITY_LAG: polkadot_primitives::v2::BlockNumber = PRIMITIVES_MAX_FINALITY_LAG; +const MAX_FINALITY_LAG: polkadot_primitives::BlockNumber = PRIMITIVES_MAX_FINALITY_LAG; const LOG_TARGET: &str = "parachain::chain-selection"; diff --git a/node/service/src/tests.rs b/node/service/src/tests.rs index 0997097ed996..68412f96fa45 100644 --- a/node/service/src/tests.rs +++ b/node/service/src/tests.rs @@ -40,7 +40,7 @@ use polkadot_node_subsystem::messages::{ ApprovalVotingMessage, ChainSelectionMessage, DisputeCoordinatorMessage, HighestApprovedAncestorBlock, }; -use polkadot_primitives::v2::{Block, BlockNumber, Hash, Header}; +use polkadot_primitives::{Block, BlockNumber, Hash, Header}; use polkadot_node_subsystem_test_helpers::TestSubsystemSender; use polkadot_overseer::{SubsystemContext, SubsystemSender}; diff --git a/node/subsystem-test-helpers/src/lib.rs b/node/subsystem-test-helpers/src/lib.rs index dd207039091a..871f1c5b6d63 100644 --- a/node/subsystem-test-helpers/src/lib.rs +++ b/node/subsystem-test-helpers/src/lib.rs @@ -437,7 +437,7 @@ mod tests { use futures::executor::block_on; use polkadot_node_subsystem::messages::CollatorProtocolMessage; use polkadot_overseer::{dummy::dummy_overseer_builder, Handle, HeadSupportsParachains}; - use polkadot_primitives::v2::Hash; + use polkadot_primitives::Hash; use sp_core::traits::SpawnNamed; struct AlwaysSupportsParachains; diff --git a/node/subsystem-test-helpers/src/mock.rs b/node/subsystem-test-helpers/src/mock.rs index 17692dda7ea2..dffc65b75695 100644 --- a/node/subsystem-test-helpers/src/mock.rs +++ b/node/subsystem-test-helpers/src/mock.rs @@ -21,7 +21,7 @@ use sp_application_crypto::AppKey; use sp_keyring::Sr25519Keyring; use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; -use polkadot_primitives::v2::{AuthorityDiscoveryId, ValidatorId}; +use polkadot_primitives::{AuthorityDiscoveryId, ValidatorId}; /// Get mock keystore with `Ferdie` key. pub fn make_ferdie_keystore() -> SyncCryptoStorePtr { diff --git a/node/subsystem-types/src/lib.rs b/node/subsystem-types/src/lib.rs index b5a8c67fc581..576507367095 100644 --- a/node/subsystem-types/src/lib.rs +++ b/node/subsystem-types/src/lib.rs @@ -24,7 +24,7 @@ use std::{fmt, sync::Arc}; -pub use polkadot_primitives::v2::{BlockNumber, Hash}; +pub use polkadot_primitives::{BlockNumber, Hash}; use smallvec::SmallVec; pub mod errors; diff --git a/node/subsystem-types/src/messages.rs b/node/subsystem-types/src/messages.rs index bf1dbe552f5f..a4699783d6d2 100644 --- a/node/subsystem-types/src/messages.rs +++ b/node/subsystem-types/src/messages.rs @@ -38,7 +38,7 @@ use polkadot_node_primitives::{ CollationSecondedSignal, DisputeMessage, DisputeStatus, ErasureChunk, PoV, SignedDisputeStatement, SignedFullStatement, ValidationResult, }; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ AuthorityDiscoveryId, BackedCandidate, BlockNumber, CandidateEvent, CandidateHash, CandidateIndex, CandidateReceipt, CollatorId, CommittedCandidateReceipt, CoreState, DisputeState, GroupIndex, GroupRotationInfo, Hash, Header as BlockHeader, Id as ParaId, @@ -554,7 +554,7 @@ pub enum RuntimeApiRequest { /// Sends back `true` if the validation outputs pass all acceptance criteria checks. CheckValidationOutputs( ParaId, - polkadot_primitives::v2::CandidateCommitments, + polkadot_primitives::CandidateCommitments, RuntimeApiSender, ), /// Get the session index that a child of the block will have. @@ -584,7 +584,7 @@ pub enum RuntimeApiRequest { /// Get information about the BABE epoch the block was included in. CurrentBabeEpoch(RuntimeApiSender), /// Get all disputes in relation to a relay parent. - FetchOnChainVotes(RuntimeApiSender>), + FetchOnChainVotes(RuntimeApiSender>), /// Submits a PVF pre-checking statement into the transaction pool. SubmitPvfCheckStatement(PvfCheckStatement, ValidatorSignature, RuntimeApiSender<()>), /// Returns code hashes of PVFs that require pre-checking by validators in the active set. diff --git a/node/subsystem-types/src/messages/network_bridge_event.rs b/node/subsystem-types/src/messages/network_bridge_event.rs index 06654153357a..cc9f21b5582e 100644 --- a/node/subsystem-types/src/messages/network_bridge_event.rs +++ b/node/subsystem-types/src/messages/network_bridge_event.rs @@ -22,7 +22,7 @@ use polkadot_node_network_protocol::{ grid_topology::SessionGridTopology, peer_set::ProtocolVersion, ObservedRole, OurView, View, WrongVariant, }; -use polkadot_primitives::v2::{AuthorityDiscoveryId, SessionIndex, ValidatorIndex}; +use polkadot_primitives::{AuthorityDiscoveryId, SessionIndex, ValidatorIndex}; /// A struct indicating new gossip topology. #[derive(Debug, Clone, PartialEq)] diff --git a/node/subsystem-types/src/runtime_client.rs b/node/subsystem-types/src/runtime_client.rs index 259c94fd4e51..9a55462b8852 100644 --- a/node/subsystem-types/src/runtime_client.rs +++ b/node/subsystem-types/src/runtime_client.rs @@ -16,14 +16,11 @@ use async_trait::async_trait; use polkadot_primitives::{ - runtime_api::ParachainHost, - v2::{ - Block, BlockId, BlockNumber, CandidateCommitments, CandidateEvent, CandidateHash, - CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Hash, Id, - InboundDownwardMessage, InboundHrmpMessage, OccupiedCoreAssumption, - PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, SessionIndex, SessionInfo, - ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, - }, + runtime_api::ParachainHost, Block, BlockId, BlockNumber, CandidateCommitments, CandidateEvent, + CandidateHash, CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Hash, Id, + InboundDownwardMessage, InboundHrmpMessage, OccupiedCoreAssumption, PersistedValidationData, + PvfCheckStatement, ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidationCode, + ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, }; use sp_api::{ApiError, ApiExt, ProvideRuntimeApi}; use sp_authority_discovery::AuthorityDiscoveryApi; @@ -157,7 +154,7 @@ pub trait RuntimeApiSubsystemClient { &self, at: Hash, index: SessionIndex, - ) -> Result, ApiError>; + ) -> Result, ApiError>; /// Submits a PVF pre-checking statement into the transaction pool. /// @@ -370,7 +367,7 @@ where &self, at: Hash, index: SessionIndex, - ) -> Result, ApiError> { + ) -> Result, ApiError> { #[allow(deprecated)] self.runtime_api().session_info_before_version_2(&BlockId::Hash(at), index) } diff --git a/node/subsystem-util/src/determine_new_blocks.rs b/node/subsystem-util/src/determine_new_blocks.rs index aad1625798c2..5a032c38aa1e 100644 --- a/node/subsystem-util/src/determine_new_blocks.rs +++ b/node/subsystem-util/src/determine_new_blocks.rs @@ -18,7 +18,7 @@ use futures::{channel::oneshot, prelude::*}; use polkadot_node_subsystem::{messages::ChainApiMessage, SubsystemSender}; -use polkadot_primitives::v2::{BlockNumber, Hash, Header}; +use polkadot_primitives::{BlockNumber, Hash, Header}; /// Given a new chain-head hash, this determines the hashes of all new blocks we should track /// metadata for, given this head. diff --git a/node/subsystem-util/src/lib.rs b/node/subsystem-util/src/lib.rs index 293577279eb8..ca41ae232461 100644 --- a/node/subsystem-util/src/lib.rs +++ b/node/subsystem-util/src/lib.rs @@ -40,7 +40,7 @@ pub use polkadot_node_metrics::{metrics, Metronome}; use futures::channel::{mpsc, oneshot}; use parity_scale_codec::Encode; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ AuthorityDiscoveryId, CandidateEvent, CommittedCandidateReceipt, CoreState, EncodeAs, GroupIndex, GroupRotationInfo, Hash, Id as ParaId, OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, SessionIndex, SessionInfo, Signed, diff --git a/node/subsystem-util/src/nesting_sender.rs b/node/subsystem-util/src/nesting_sender.rs index 34ff7d84cbf1..75f8da9a0cd2 100644 --- a/node/subsystem-util/src/nesting_sender.rs +++ b/node/subsystem-util/src/nesting_sender.rs @@ -196,10 +196,10 @@ where // Helper traits and implementations: -impl Clone for NestingSender +impl Clone for NestingSender where M: 'static, - M1: 'static, + Mnested: 'static, { fn clone(&self) -> Self { Self { sender: self.sender.clone(), conversion: self.conversion.clone() } diff --git a/node/subsystem-util/src/rolling_session_window.rs b/node/subsystem-util/src/rolling_session_window.rs index 4ebfad405b5b..500ce755692b 100644 --- a/node/subsystem-util/src/rolling_session_window.rs +++ b/node/subsystem-util/src/rolling_session_window.rs @@ -24,7 +24,7 @@ use kvdb::{DBKey, DBOp}; use parity_scale_codec::{Decode, Encode}; pub use polkadot_node_primitives::{new_session_window_size, SessionWindowSize}; -use polkadot_primitives::v2::{BlockNumber, Hash, SessionIndex, SessionInfo}; +use polkadot_primitives::{BlockNumber, Hash, SessionIndex, SessionInfo}; use std::sync::Arc; use futures::channel::oneshot; @@ -594,7 +594,7 @@ mod tests { SubsystemContext, }; use polkadot_node_subsystem_test_helpers::make_subsystem_context; - use polkadot_primitives::v2::Header; + use polkadot_primitives::Header; use sp_core::testing::TaskExecutor; const SESSION_DATA_COL: u32 = 0; diff --git a/node/subsystem-util/src/runtime/error.rs b/node/subsystem-util/src/runtime/error.rs index 67e69c91c1bd..90a988d786ea 100644 --- a/node/subsystem-util/src/runtime/error.rs +++ b/node/subsystem-util/src/runtime/error.rs @@ -20,7 +20,7 @@ use futures::channel::oneshot; use polkadot_node_subsystem::errors::RuntimeApiError; -use polkadot_primitives::v2::SessionIndex; +use polkadot_primitives::SessionIndex; #[allow(missing_docs)] #[fatality::fatality(splitable)] diff --git a/node/subsystem-util/src/runtime/mod.rs b/node/subsystem-util/src/runtime/mod.rs index 5b8baad0f94f..0d3132ec1fda 100644 --- a/node/subsystem-util/src/runtime/mod.rs +++ b/node/subsystem-util/src/runtime/mod.rs @@ -26,7 +26,7 @@ use sp_core::crypto::ByteArray; use sp_keystore::{CryptoStore, SyncCryptoStorePtr}; use polkadot_node_subsystem::{messages::RuntimeApiMessage, overseer, SubsystemSender}; -use polkadot_primitives::v2::{ +use polkadot_primitives::{ CandidateEvent, CoreState, EncodeAs, GroupIndex, GroupRotationInfo, Hash, IndexedVec, OccupiedCore, ScrapedOnChainVotes, SessionIndex, SessionInfo, Signed, SigningContext, UncheckedSigned, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, diff --git a/node/test/client/src/block_builder.rs b/node/test/client/src/block_builder.rs index 058d469a26a1..74a5157c7de9 100644 --- a/node/test/client/src/block_builder.rs +++ b/node/test/client/src/block_builder.rs @@ -16,7 +16,7 @@ use crate::{Client, FullBackend}; use parity_scale_codec::{Decode, Encode}; -use polkadot_primitives::v2::{Block, InherentData as ParachainsInherentData}; +use polkadot_primitives::{Block, InherentData as ParachainsInherentData}; use polkadot_test_runtime::{GetLastTimestamp, UncheckedExtrinsic}; use sc_block_builder::{BlockBuilder, BlockBuilderProvider}; use sp_api::ProvideRuntimeApi; @@ -111,7 +111,7 @@ impl InitPolkadotBlockBuilder for Client { inherent_data .put_data( - polkadot_primitives::v2::PARACHAINS_INHERENT_IDENTIFIER, + polkadot_primitives::PARACHAINS_INHERENT_IDENTIFIER, ¶chains_inherent_data, ) .expect("Put parachains inherent data"); diff --git a/node/test/client/src/lib.rs b/node/test/client/src/lib.rs index 1370ec295788..2f698a09b94e 100644 --- a/node/test/client/src/lib.rs +++ b/node/test/client/src/lib.rs @@ -20,7 +20,7 @@ mod block_builder; -use polkadot_primitives::v2::Block; +use polkadot_primitives::Block; use sc_service::client; use sp_core::storage::Storage; use sp_runtime::BuildStorage; diff --git a/node/test/service/src/chain_spec.rs b/node/test/service/src/chain_spec.rs index 1d8b300e4e27..e02bfc541495 100644 --- a/node/test/service/src/chain_spec.rs +++ b/node/test/service/src/chain_spec.rs @@ -19,7 +19,7 @@ use babe_primitives::AuthorityId as BabeId; use grandpa::AuthorityId as GrandpaId; use pallet_staking::Forcing; -use polkadot_primitives::v2::{AccountId, AssignmentId, ValidatorId, MAX_CODE_SIZE, MAX_POV_SIZE}; +use polkadot_primitives::{AccountId, AssignmentId, ValidatorId, MAX_CODE_SIZE, MAX_POV_SIZE}; use polkadot_service::chain_spec::{ get_account_id_from_seed, get_from_seed, polkadot_chain_spec_properties, Extensions, }; diff --git a/node/test/service/src/lib.rs b/node/test/service/src/lib.rs index 831f0c85aaaa..352959236ef0 100644 --- a/node/test/service/src/lib.rs +++ b/node/test/service/src/lib.rs @@ -25,7 +25,7 @@ use futures::future::Future; use polkadot_node_primitives::{CollationGenerationConfig, CollatorFn}; use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProtocolMessage}; use polkadot_overseer::Handle; -use polkadot_primitives::v2::{Balance, CollatorPair, HeadData, Id as ParaId, ValidationCode}; +use polkadot_primitives::{Balance, CollatorPair, HeadData, Id as ParaId, ValidationCode}; use polkadot_runtime_common::BlockHashCount; use polkadot_runtime_parachains::paras::{ParaGenesisArgs, ParaKind}; use polkadot_service::{ @@ -381,7 +381,7 @@ pub fn construct_extrinsic( UncheckedExtrinsic::new_signed( function.clone(), polkadot_test_runtime::Address::Id(caller.public().into()), - polkadot_primitives::v2::Signature::Sr25519(signature.clone()), + polkadot_primitives::Signature::Sr25519(signature.clone()), extra.clone(), ) } diff --git a/parachain/test-parachains/adder/collator/src/lib.rs b/parachain/test-parachains/adder/collator/src/lib.rs index 1ab0fb1a4660..701f08a2b87a 100644 --- a/parachain/test-parachains/adder/collator/src/lib.rs +++ b/parachain/test-parachains/adder/collator/src/lib.rs @@ -23,7 +23,7 @@ use polkadot_node_primitives::{ Collation, CollationResult, CollationSecondedSignal, CollatorFn, MaybeCompressedPoV, PoV, Statement, }; -use polkadot_primitives::v2::{CollatorId, CollatorPair}; +use polkadot_primitives::{CollatorId, CollatorPair}; use sp_core::{traits::SpawnNamed, Pair}; use std::{ collections::HashMap, @@ -248,7 +248,7 @@ mod tests { use futures::executor::block_on; use polkadot_parachain::primitives::{ValidationParams, ValidationResult}; - use polkadot_primitives::v2::PersistedValidationData; + use polkadot_primitives::PersistedValidationData; #[test] fn collator_works() { diff --git a/parachain/test-parachains/adder/collator/src/main.rs b/parachain/test-parachains/adder/collator/src/main.rs index e0845f68720d..a953624df3b4 100644 --- a/parachain/test-parachains/adder/collator/src/main.rs +++ b/parachain/test-parachains/adder/collator/src/main.rs @@ -19,7 +19,7 @@ use polkadot_cli::{Error, Result}; use polkadot_node_primitives::CollationGenerationConfig; use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProtocolMessage}; -use polkadot_primitives::v2::Id as ParaId; +use polkadot_primitives::Id as ParaId; use sc_cli::{Error as SubstrateCliError, SubstrateCli}; use sp_core::hexdisplay::HexDisplay; use test_parachain_adder_collator::Collator; diff --git a/parachain/test-parachains/adder/collator/tests/integration.rs b/parachain/test-parachains/adder/collator/tests/integration.rs index c8ef0a40b2ae..a62f2a88c83c 100644 --- a/parachain/test-parachains/adder/collator/tests/integration.rs +++ b/parachain/test-parachains/adder/collator/tests/integration.rs @@ -23,7 +23,7 @@ const PUPPET_EXE: &str = env!("CARGO_BIN_EXE_adder_collator_puppet_worker"); #[substrate_test_utils::test(flavor = "multi_thread")] async fn collating_using_adder_collator() { - use polkadot_primitives::v2::Id as ParaId; + use polkadot_primitives::Id as ParaId; use sp_keyring::AccountKeyring::*; let mut builder = sc_cli::LoggerBuilder::new(""); diff --git a/parachain/test-parachains/undying/collator/src/lib.rs b/parachain/test-parachains/undying/collator/src/lib.rs index 5d1a53f60cb3..2f4799c001de 100644 --- a/parachain/test-parachains/undying/collator/src/lib.rs +++ b/parachain/test-parachains/undying/collator/src/lib.rs @@ -23,7 +23,7 @@ use polkadot_node_primitives::{ maybe_compress_pov, Collation, CollationResult, CollationSecondedSignal, CollatorFn, MaybeCompressedPoV, PoV, Statement, }; -use polkadot_primitives::v2::{CollatorId, CollatorPair, Hash}; +use polkadot_primitives::{CollatorId, CollatorPair, Hash}; use sp_core::Pair; use std::{ collections::HashMap, @@ -330,7 +330,7 @@ mod tests { use super::*; use futures::executor::block_on; use polkadot_parachain::primitives::{ValidationParams, ValidationResult}; - use polkadot_primitives::v2::{Hash, PersistedValidationData}; + use polkadot_primitives::{Hash, PersistedValidationData}; #[test] fn collator_works() { diff --git a/parachain/test-parachains/undying/collator/src/main.rs b/parachain/test-parachains/undying/collator/src/main.rs index e352235679ce..e28e1e25cf63 100644 --- a/parachain/test-parachains/undying/collator/src/main.rs +++ b/parachain/test-parachains/undying/collator/src/main.rs @@ -19,7 +19,7 @@ use polkadot_cli::{Error, Result}; use polkadot_node_primitives::CollationGenerationConfig; use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProtocolMessage}; -use polkadot_primitives::v2::Id as ParaId; +use polkadot_primitives::Id as ParaId; use sc_cli::{Error as SubstrateCliError, SubstrateCli}; use sp_core::hexdisplay::HexDisplay; use test_parachain_undying_collator::Collator; diff --git a/parachain/test-parachains/undying/collator/tests/integration.rs b/parachain/test-parachains/undying/collator/tests/integration.rs index cf00ffa35125..c6f56e5faf6e 100644 --- a/parachain/test-parachains/undying/collator/tests/integration.rs +++ b/parachain/test-parachains/undying/collator/tests/integration.rs @@ -22,7 +22,7 @@ const PUPPET_EXE: &str = env!("CARGO_BIN_EXE_undying_collator_puppet_worker"); // If this test is failing, make sure to run all tests with the `real-overseer` feature being enabled. #[substrate_test_utils::test(flavor = "multi_thread")] async fn collating_using_undying_collator() { - use polkadot_primitives::v2::Id as ParaId; + use polkadot_primitives::Id as ParaId; use sp_keyring::AccountKeyring::*; let mut builder = sc_cli::LoggerBuilder::new(""); diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 168b5795b040..0cd7d6d3ff5f 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -30,3 +30,33 @@ pub mod vstaging; // `runtime_api` contains the actual API implementation. It contains stable and // unstable functions. pub mod runtime_api; + +// Current primitives not requiring versioning are exported here. +// Primitives requiring versioning must not be exported and must be referred by an exact version. +pub use v2::{ + byzantine_threshold, check_candidate_backing, collator_signature_payload, metric_definitions, + supermajority_threshold, well_known_keys, AbridgedHostConfiguration, AbridgedHrmpChannel, + AccountId, AccountIndex, AccountPublic, ApprovalVote, AssignmentId, AuthorityDiscoveryId, + AvailabilityBitfield, BackedCandidate, Balance, BlakeTwo256, Block, BlockId, BlockNumber, + CandidateCommitments, CandidateDescriptor, CandidateEvent, CandidateHash, CandidateIndex, + CandidateReceipt, CheckedDisputeStatementSet, CheckedMultiDisputeStatementSet, CollatorId, + CollatorSignature, CommittedCandidateReceipt, CompactStatement, ConsensusLog, CoreIndex, + CoreOccupied, CoreState, DisputeState, DisputeStatement, DisputeStatementSet, DownwardMessage, + EncodeAs, ExplicitDisputeStatement, GroupIndex, GroupRotationInfo, Hash, HashT, HeadData, + Header, HrmpChannelId, Id, InboundDownwardMessage, InboundHrmpMessage, IndexedVec, + InherentData, InvalidDisputeStatementKind, Moment, MultiDisputeStatementSet, Nonce, + OccupiedCore, OccupiedCoreAssumption, OldV1SessionInfo, OutboundHrmpMessage, ParathreadClaim, + ParathreadEntry, PersistedValidationData, PvfCheckStatement, RuntimeMetricLabel, + RuntimeMetricLabelValue, RuntimeMetricLabelValues, RuntimeMetricLabels, RuntimeMetricOp, + RuntimeMetricUpdate, ScheduledCore, ScrapedOnChainVotes, SessionIndex, SessionInfo, Signature, + Signed, SignedAvailabilityBitfield, SignedAvailabilityBitfields, SignedStatement, + SigningContext, Slot, UncheckedSigned, UncheckedSignedAvailabilityBitfield, + UncheckedSignedAvailabilityBitfields, UncheckedSignedStatement, UpgradeGoAhead, + UpgradeRestriction, UpwardMessage, ValidDisputeStatementKind, ValidationCode, + ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, ValidityAttestation, + ValidityError, ASSIGNMENT_KEY_TYPE_ID, LOWEST_PUBLIC_ID, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, + MAX_POV_SIZE, PARACHAINS_INHERENT_IDENTIFIER, PARACHAIN_KEY_TYPE_ID, +}; + +#[cfg(feature = "std")] +pub use v2::{AssignmentPair, CollatorPair, ValidatorPair}; diff --git a/primitives/src/v2/mod.rs b/primitives/src/v2/mod.rs index 606ffd59920c..0a600f6b318a 100644 --- a/primitives/src/v2/mod.rs +++ b/primitives/src/v2/mod.rs @@ -35,7 +35,7 @@ use sp_arithmetic::traits::{BaseArithmetic, Saturating}; pub use runtime_primitives::traits::{BlakeTwo256, Hash as HashT}; // Export some core primitives. -pub use polkadot_core_primitives::v2::{ +pub use polkadot_core_primitives::{ AccountId, AccountIndex, AccountPublic, Balance, Block, BlockId, BlockNumber, CandidateHash, ChainId, DownwardMessage, Hash, Header, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OutboundHrmpMessage, Remark, Signature, UncheckedExtrinsic, diff --git a/primitives/test-helpers/src/lib.rs b/primitives/test-helpers/src/lib.rs index 8873d69cdb2f..e734caeb35ba 100644 --- a/primitives/test-helpers/src/lib.rs +++ b/primitives/test-helpers/src/lib.rs @@ -21,7 +21,7 @@ //! //! Note that `dummy_` prefixed values are meant to be fillers, that should not matter, and will //! contain randomness based data. -use polkadot_primitives::v2::{ +use polkadot_primitives::{ CandidateCommitments, CandidateDescriptor, CandidateReceipt, CollatorId, CollatorSignature, CommittedCandidateReceipt, Hash, HeadData, Id as ParaId, ValidationCode, ValidationCodeHash, ValidatorId, @@ -159,7 +159,7 @@ pub fn make_valid_candidate_descriptor>( collator: Sr25519Keyring, ) -> CandidateDescriptor { let validation_code_hash = validation_code_hash.into(); - let payload = polkadot_primitives::v2::collator_signature_payload::( + let payload = polkadot_primitives::collator_signature_payload::( &relay_parent, ¶_id, &persisted_validation_data_hash, @@ -190,7 +190,7 @@ pub fn resign_candidate_descriptor_with_collator>( collator: Sr25519Keyring, ) { descriptor.collator = collator.public().into(); - let payload = polkadot_primitives::v2::collator_signature_payload::( + let payload = polkadot_primitives::collator_signature_payload::( &descriptor.relay_parent, &descriptor.para_id, &descriptor.persisted_validation_data_hash, @@ -256,6 +256,6 @@ impl rand::RngCore for AlwaysZeroRng { } } -pub fn dummy_signature() -> polkadot_primitives::v2::ValidatorSignature { +pub fn dummy_signature() -> polkadot_primitives::ValidatorSignature { sp_core::crypto::UncheckedFrom::unchecked_from([1u8; 64]) } diff --git a/roadmap/implementers-guide/src/node/utility/pvf-prechecker.md b/roadmap/implementers-guide/src/node/utility/pvf-prechecker.md index fd75ce9e3804..90193ec00e18 100644 --- a/roadmap/implementers-guide/src/node/utility/pvf-prechecker.md +++ b/roadmap/implementers-guide/src/node/utility/pvf-prechecker.md @@ -16,14 +16,25 @@ To be relevant for the subsystem, a PVF must be returned by the [`pvfs_require_p When a PVF just becomes relevant, the subsystem will send a message to the [Candidate Validation] subsystem asking for the pre-check. -Upon receving a message from the candidate-validation subsystem, the pre-checker will note down that the PVF has its judgement and will also sign and submit a [`PvfCheckStatement`][PvfCheckStatement] via the [`submit_pvf_check_statement` runtime API][PVF pre-checking runtime API]. In case, a judgement was received for a PVF that is no longer in view it is ignored. It is possible that the candidate validation was not able to check the PVF. In that case, the PVF pre-checker will abstain and won't submit any check statements. +Upon receving a message from the candidate-validation subsystem, the pre-checker will note down that the PVF has its judgement and will also sign and submit a [`PvfCheckStatement`][PvfCheckStatement] via the [`submit_pvf_check_statement` runtime API][PVF pre-checking runtime API]. In case, a judgement was received for a PVF that is no longer in view it is ignored. -Since a vote only is valid during [one session][overview], the subsystem will have to resign and submit the statements for for the new session. The new session is assumed to be started if at least one of the leaves has a greater session index that was previously observed in any of the leaves. +Since a vote only is valid during [one session][overview], the subsystem will have to resign and submit the statements for the new session. The new session is assumed to be started if at least one of the leaves has a greater session index that was previously observed in any of the leaves. -The subsystem tracks all the statement that it submitted within a session. If for some reason a PVF became irrelevant and then becomes relevant again, the subsystem will not submit a new statement for that PVF within the same session. +The subsystem tracks all the statements that it submitted within a session. If for some reason a PVF became irrelevant and then becomes relevant again, the subsystem will not submit a new statement for that PVF within the same session. If the node is not in the active validator set, it will still perform all the checks. However, it will only submit the check statements when the node is in the active validator set. +### Rejecting failed PVFs + +It is possible that the candidate validation was not able to check the PVF, e.g. if it timed out. In that case, the PVF pre-checker will vote against it. This is considered safe, as there is no slashing for being on the wrong side of a pre-check vote. + +Rejecting instead of abstaining is better in several ways: + +1. Conclusion is reached faster - we have actual votes, instead of relying on a timeout. +1. Being strict in pre-checking makes it safer to be more lenient in preparation errors afterwards. Hence we have more leeway in avoiding raising dubious disputes, without making things less secure. + +Also, if we only abstain, an attacker can specially craft a PVF wasm blob so that it will fail on e.g. 50% of the validators. In that case a supermajority will never be reached and the vote will repeat multiple times, most likely with the same result (since all votes are cleared on a session change). This is avoided by rejecting failed PVFs, and by only requiring 1/3 of validators to reject a PVF to reach a decision. + [overview]: ../../pvf-prechecking.md [Runtime API]: runtime-api.md [PVF pre-checking runtime API]: ../../runtime-api/pvf-prechecking.md diff --git a/roadmap/implementers-guide/src/pvf-prechecking.md b/roadmap/implementers-guide/src/pvf-prechecking.md index 4dce61d2a83b..fd2ca12330bd 100644 --- a/roadmap/implementers-guide/src/pvf-prechecking.md +++ b/roadmap/implementers-guide/src/pvf-prechecking.md @@ -29,9 +29,9 @@ The problem is solved by having a pre-checking process which is run when a new v Before any of those operations finish, the PVF pre-checking vote is initiated. The PVF pre-checking vote is identified by the PVF code hash that is being voted on. If there is already PVF pre-checking process running, then no new PVF pre-checking vote will be started. Instead, the operation just subscribes to the existing vote. -The pre-checking vote can be concluded either by obtaining a supermajority or if it expires. +The pre-checking vote can be concluded either by obtaining a threshold of votes for a decision, or if it expires. The threshold to accept is a supermajority of 2/3 of validators. We reject once a supermajority is no longer possible. -Each validator checks the list of PVFs available for voting. The vote is binary, i.e. accept or reject a given PVF. As soon as the supermajority of votes are collected for one of the sides of the vote, the voting is concluded in that direction and the effects of the voting are enacted. +Each validator checks the list of PVFs available for voting. The vote is binary, i.e. accept or reject a given PVF. As soon as the threshold of votes are collected for one of the sides of the vote, the voting is concluded in that direction and the effects of the voting are enacted. Only validators from the active set can participate in the vote. The set of active validators can change each session. That's why we reset the votes each session. A voting that observed a certain number of sessions will be rejected. diff --git a/roadmap/implementers-guide/src/runtime/disputes.md b/roadmap/implementers-guide/src/runtime/disputes.md index 1f1debee9cd4..b775bfbfcf0e 100644 --- a/roadmap/implementers-guide/src/runtime/disputes.md +++ b/roadmap/implementers-guide/src/runtime/disputes.md @@ -123,4 +123,19 @@ applied: as a measure not to import one sided disputes. A dispute is raised only if there are two opposing votes so if the client is not sending them the dispute is a potential spam. 4. Remove unconfirmed disputes - if a dispute contains less votes than the byzantine threshold it is removed. This is - also a spam precaution. A legitimate client will send only confirmed disputes to the runtime. \ No newline at end of file + also a spam precaution. A legitimate client will send only confirmed disputes to the runtime. + +# Rewards and slashing + +After the disputes are filtered the validators participating in the disputes are rewarded and more importantly the +offenders are slashed. Generally there can be two types of punishments: +* "against valid" - the offender claimed that a valid candidate is invalid. +* "for invalid" - the offender claimed that an invalid candidate is valid. + +A dispute might be inconclusive. This means that it has timed out without being confirmed. A confirmed dispute is one +containing votes more than the byzantine threshold (1/3 of the active validators). Validators participating in +inconclusive disputes are not slashed. Thanks to the applied filtering (described in the previous section) one can be +confident that there are no spam disputes in the runtime. So if a validator is not voting it is due to another reason +(e.g. being under DoS attack). There is no reason to punish such validators with a slash. + +*Implementation note*: Slashing is performed in `process_checked_dispute_data` from `Disputes` pallet. \ No newline at end of file diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 43efefcae15b..40e4a35b7791 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -21,7 +21,7 @@ use std::sync::Arc; use jsonrpsee::RpcModule; -use polkadot_primitives::v2::{AccountId, Balance, Block, BlockNumber, Hash, Nonce}; +use polkadot_primitives::{AccountId, Balance, Block, BlockNumber, Hash, Nonce}; use sc_client_api::AuxStore; use sc_consensus_babe::{BabeConfiguration, Epoch}; use sc_finality_grandpa::FinalityProofProvider; diff --git a/runtime/common/src/assigned_slots.rs b/runtime/common/src/assigned_slots.rs index e7da8c7407cf..5186b255168a 100644 --- a/runtime/common/src/assigned_slots.rs +++ b/runtime/common/src/assigned_slots.rs @@ -32,7 +32,7 @@ use frame_support::{pallet_prelude::*, traits::Currency}; use frame_system::pallet_prelude::*; pub use pallet::*; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use primitives::v2::Id as ParaId; +use primitives::Id as ParaId; use runtime_parachains::{ configuration, paras::{self}, @@ -549,7 +549,7 @@ mod tests { use frame_support::{assert_noop, assert_ok, parameter_types}; use frame_system::EnsureRoot; use pallet_balances; - use primitives::v2::{BlockNumber, Header}; + use primitives::{BlockNumber, Header}; use runtime_parachains::{ configuration as parachains_configuration, paras as parachains_paras, shared as parachains_shared, diff --git a/runtime/common/src/auctions.rs b/runtime/common/src/auctions.rs index bdbd9d4cae97..aafc273e7138 100644 --- a/runtime/common/src/auctions.rs +++ b/runtime/common/src/auctions.rs @@ -30,7 +30,7 @@ use frame_support::{ }; pub use pallet::*; use parity_scale_codec::Decode; -use primitives::v2::Id as ParaId; +use primitives::Id as ParaId; use sp_runtime::traits::{CheckedSub, One, Saturating, Zero}; use sp_std::{mem::swap, prelude::*}; @@ -684,7 +684,7 @@ mod tests { }; use frame_system::{EnsureRoot, EnsureSignedBy}; use pallet_balances; - use primitives::v2::{BlockNumber, Header, Id as ParaId}; + use primitives::{BlockNumber, Header, Id as ParaId}; use sp_core::H256; use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use std::{cell::RefCell, collections::BTreeMap}; diff --git a/runtime/common/src/claims.rs b/runtime/common/src/claims.rs index a07bf37079d3..3c40aab11dc7 100644 --- a/runtime/common/src/claims.rs +++ b/runtime/common/src/claims.rs @@ -23,7 +23,7 @@ use frame_support::{ }; pub use pallet::*; use parity_scale_codec::{Decode, Encode}; -use primitives::v2::ValidityError; +use primitives::ValidityError; use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{self, Deserialize, Deserializer, Serialize, Serializer}; diff --git a/runtime/common/src/crowdloan/migration.rs b/runtime/common/src/crowdloan/migration.rs index 468c2a572b51..a46e72cc1a51 100644 --- a/runtime/common/src/crowdloan/migration.rs +++ b/runtime/common/src/crowdloan/migration.rs @@ -22,20 +22,21 @@ use frame_support::{ Twox64Concat, }; -pub struct MigrateToTrackInactive(sp_std::marker::PhantomData); -impl OnRuntimeUpgrade for MigrateToTrackInactive { +pub struct MigrateToTrackInactiveV2(sp_std::marker::PhantomData); +impl OnRuntimeUpgrade for MigrateToTrackInactiveV2 { fn on_runtime_upgrade() -> Weight { let onchain_version = Pallet::::on_chain_storage_version(); - if onchain_version == 0 { + if onchain_version == 1 { let mut translated = 0u64; - for index in Funds::::iter_keys() { - let b = CurrencyOf::::total_balance(&Pallet::::fund_account_id(index.into())); + for item in Funds::::iter_values() { + let b = + CurrencyOf::::total_balance(&Pallet::::fund_account_id(item.fund_index)); CurrencyOf::::deactivate(b); translated.saturating_inc(); } - StorageVersion::new(1).put::>(); + StorageVersion::new(2).put::>(); log::info!(target: "runtime::crowdloan", "Summed {} funds, storage to version 1", translated); T::DbWeight::get().reads_writes(translated * 2 + 1, translated * 2 + 1) } else { @@ -46,9 +47,9 @@ impl OnRuntimeUpgrade for MigrateToTrackInactive { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, &'static str> { - let total = Funds::::iter_keys() - .map(|index| { - CurrencyOf::::total_balance(&Pallet::::fund_account_id(index.into())) + let total = Funds::::iter_values() + .map(|item| { + CurrencyOf::::total_balance(&Pallet::::fund_account_id(item.fund_index)) }) .fold(BalanceOf::::zero(), |a, i| a.saturating_add(i)); Ok((total, CurrencyOf::::active_issuance()).encode()) diff --git a/runtime/common/src/crowdloan/mod.rs b/runtime/common/src/crowdloan/mod.rs index 711bf0b7b33b..e8ef2ee0344f 100644 --- a/runtime/common/src/crowdloan/mod.rs +++ b/runtime/common/src/crowdloan/mod.rs @@ -51,8 +51,6 @@ pub mod migration; -// TODO: Expose the total amount held. - use crate::{ slot_range::SlotRange, traits::{Auctioneer, Registrar}, @@ -70,7 +68,7 @@ use frame_support::{ }; pub use pallet::*; use parity_scale_codec::{Decode, Encode}; -use primitives::v2::Id as ParaId; +use primitives::Id as ParaId; use scale_info::TypeInfo; use sp_runtime::{ traits::{ @@ -866,7 +864,7 @@ mod tests { assert_noop, assert_ok, parameter_types, traits::{OnFinalize, OnInitialize}, }; - use primitives::v2::Id as ParaId; + use primitives::Id as ParaId; use sp_core::H256; use std::{cell::RefCell, collections::BTreeMap, sync::Arc}; // The testing primitives are very useful for avoiding having to work with signatures diff --git a/runtime/common/src/impls.rs b/runtime/common/src/impls.rs index 51dbdd80c781..77b168fb7a4f 100644 --- a/runtime/common/src/impls.rs +++ b/runtime/common/src/impls.rs @@ -18,7 +18,7 @@ use crate::NegativeImbalance; use frame_support::traits::{Currency, Imbalance, OnUnbalanced}; -use primitives::v2::Balance; +use primitives::Balance; use sp_runtime::Perquintill; /// Logic for the author to get a portion of fees. @@ -26,8 +26,8 @@ pub struct ToAuthor(sp_std::marker::PhantomData); impl OnUnbalanced> for ToAuthor where R: pallet_balances::Config + pallet_authorship::Config, - ::AccountId: From, - ::AccountId: Into, + ::AccountId: From, + ::AccountId: Into, { fn on_nonzero_unbalanced(amount: NegativeImbalance) { if let Some(author) = >::author() { @@ -41,8 +41,8 @@ impl OnUnbalanced> for DealWithFees where R: pallet_balances::Config + pallet_treasury::Config + pallet_authorship::Config, pallet_treasury::Pallet: OnUnbalanced>, - ::AccountId: From, - ::AccountId: Into, + ::AccountId: From, + ::AccountId: Into, { fn on_unbalanceds(mut fees_then_tips: impl Iterator>) { if let Some(fees) = fees_then_tips.next() { @@ -105,7 +105,7 @@ mod tests { dispatch::DispatchClass, parameter_types, traits::FindAuthor, weights::Weight, PalletId, }; use frame_system::limits; - use primitives::v2::AccountId; + use primitives::AccountId; use sp_core::H256; use sp_runtime::{ testing::Header, diff --git a/runtime/common/src/integration_tests.rs b/runtime/common/src/integration_tests.rs index eb9c4496e59a..4a4ebe7dc462 100644 --- a/runtime/common/src/integration_tests.rs +++ b/runtime/common/src/integration_tests.rs @@ -31,9 +31,7 @@ use frame_support::{ use frame_support_test::TestRandomness; use frame_system::EnsureRoot; use parity_scale_codec::Encode; -use primitives::v2::{ - BlockNumber, HeadData, Header, Id as ParaId, ValidationCode, LOWEST_PUBLIC_ID, -}; +use primitives::{BlockNumber, HeadData, Header, Id as ParaId, ValidationCode, LOWEST_PUBLIC_ID}; use runtime_parachains::{ configuration, origin, paras, shared, Origin as ParaOrigin, ParaLifecycle, }; diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 7d7a789d828c..6f8818e87e00 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -43,7 +43,7 @@ use frame_support::{ weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}, }; use frame_system::limits; -use primitives::v2::{AssignmentId, Balance, BlockNumber, ValidatorId}; +use primitives::{AssignmentId, Balance, BlockNumber, ValidatorId}; use sp_runtime::{FixedPointNumber, Perbill, Perquintill}; use static_assertions::const_assert; @@ -158,7 +158,7 @@ macro_rules! impl_runtime_weights { /// /// This must only be used as long as the balance type is `u128`. pub type CurrencyToVote = frame_support::traits::U128CurrencyToVote; -static_assertions::assert_eq_size!(primitives::v2::Balance, u128); +static_assertions::assert_eq_size!(primitives::Balance, u128); /// A placeholder since there is currently no provided session key handler for parachain validator /// keys. diff --git a/runtime/common/src/mock.rs b/runtime/common/src/mock.rs index 54cac99146e7..79bee1bbbc16 100644 --- a/runtime/common/src/mock.rs +++ b/runtime/common/src/mock.rs @@ -22,7 +22,7 @@ use frame_support::{ weights::Weight, }; use parity_scale_codec::{Decode, Encode}; -use primitives::v2::{HeadData, Id as ParaId, ValidationCode}; +use primitives::{HeadData, Id as ParaId, ValidationCode}; use sp_runtime::{traits::SaturatedConversion, Permill}; use std::{cell::RefCell, collections::HashMap}; diff --git a/runtime/common/src/paras_registrar.rs b/runtime/common/src/paras_registrar.rs index c66c33ca21bd..9588d2ce833c 100644 --- a/runtime/common/src/paras_registrar.rs +++ b/runtime/common/src/paras_registrar.rs @@ -24,7 +24,7 @@ use frame_support::{ traits::{Currency, Get, ReservableCurrency}, }; use frame_system::{self, ensure_root, ensure_signed}; -use primitives::v2::{HeadData, Id as ParaId, ValidationCode, LOWEST_PUBLIC_ID}; +use primitives::{HeadData, Id as ParaId, ValidationCode, LOWEST_PUBLIC_ID}; use runtime_parachains::{ configuration, ensure_parachain, paras::{self, ParaGenesisArgs}, @@ -663,7 +663,7 @@ mod tests { }; use frame_system::limits; use pallet_balances::Error as BalancesError; - use primitives::v2::{Balance, BlockNumber, Header}; + use primitives::{Balance, BlockNumber, Header}; use runtime_parachains::{configuration, origin, shared}; use sp_core::H256; use sp_io::TestExternalities; @@ -1289,7 +1289,7 @@ mod benchmarking { use crate::traits::Registrar as RegistrarT; use frame_support::assert_ok; use frame_system::RawOrigin; - use primitives::v2::{MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE}; + use primitives::{MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE}; use runtime_parachains::{paras, shared, Origin as ParaOrigin}; use sp_runtime::traits::Bounded; diff --git a/runtime/common/src/paras_sudo_wrapper.rs b/runtime/common/src/paras_sudo_wrapper.rs index 8cb402c0930e..5cf6e74e28a6 100644 --- a/runtime/common/src/paras_sudo_wrapper.rs +++ b/runtime/common/src/paras_sudo_wrapper.rs @@ -20,7 +20,7 @@ use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; pub use pallet::*; use parity_scale_codec::Encode; -use primitives::v2::Id as ParaId; +use primitives::Id as ParaId; use runtime_parachains::{ configuration, dmp, hrmp, paras::{self, ParaGenesisArgs}, diff --git a/runtime/common/src/slots/mod.rs b/runtime/common/src/slots/mod.rs index 62637d582b55..e5e94a898d3e 100644 --- a/runtime/common/src/slots/mod.rs +++ b/runtime/common/src/slots/mod.rs @@ -31,7 +31,7 @@ use frame_support::{ }; use frame_system::pallet_prelude::*; pub use pallet::*; -use primitives::v2::Id as ParaId; +use primitives::Id as ParaId; use sp_runtime::traits::{CheckedConversion, CheckedSub, Saturating, Zero}; use sp_std::prelude::*; @@ -506,7 +506,7 @@ mod tests { use frame_support::{assert_noop, assert_ok, parameter_types}; use frame_system::EnsureRoot; use pallet_balances; - use primitives::v2::{BlockNumber, Header}; + use primitives::{BlockNumber, Header}; use sp_core::H256; use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; diff --git a/runtime/common/src/traits.rs b/runtime/common/src/traits.rs index bb05a2ff9081..48d1ecfc6b4a 100644 --- a/runtime/common/src/traits.rs +++ b/runtime/common/src/traits.rs @@ -20,7 +20,7 @@ use frame_support::{ dispatch::DispatchResult, traits::{Currency, ReservableCurrency}, }; -use primitives::v2::{HeadData, Id as ParaId, ValidationCode}; +use primitives::{HeadData, Id as ParaId, ValidationCode}; use sp_std::vec::*; /// Parachain registration API. diff --git a/runtime/kusama/constants/src/lib.rs b/runtime/kusama/constants/src/lib.rs index 923f71b94dd8..73ca3d31652b 100644 --- a/runtime/kusama/constants/src/lib.rs +++ b/runtime/kusama/constants/src/lib.rs @@ -20,7 +20,7 @@ pub mod weights; /// Money matters. pub mod currency { - use primitives::v2::Balance; + use primitives::Balance; /// The existential deposit. pub const EXISTENTIAL_DEPOSIT: Balance = 1 * CENTS; @@ -38,7 +38,7 @@ pub mod currency { /// Time and blocks. pub mod time { - use primitives::v2::{BlockNumber, Moment}; + use primitives::{BlockNumber, Moment}; use runtime_common::prod_or_fast; pub const MILLISECS_PER_BLOCK: Moment = 6000; pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK; @@ -63,7 +63,7 @@ pub mod fee { use frame_support::weights::{ WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }; - use primitives::v2::Balance; + use primitives::Balance; use smallvec::smallvec; pub use sp_runtime::Perbill; diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 8cf3e95f79bb..dcb9a452a715 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -22,7 +22,7 @@ use pallet_nis::WithMaximumOf; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use primitives::v2::{ +use primitives::{ AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CommittedCandidateReceipt, CoreState, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, @@ -1324,7 +1324,7 @@ impl pallet_nomination_pools::Config for Runtime { construct_runtime! { pub enum Runtime where Block = Block, - NodeBlock = primitives::v2::Block, + NodeBlock = primitives::Block, UncheckedExtrinsic = UncheckedExtrinsic { // Basic stuff; balances is uncallable initially. @@ -1484,8 +1484,10 @@ impl Get<&'static str> for StakingMigrationV11OldPallet { /// /// Should be cleared after every release. pub type Migrations = ( + pallet_balances::migration::ResetInactive, + // We need to apply this migration again, because `ResetInactive` resets the state again. pallet_balances::migration::MigrateToTrackInactive, - crowdloan::migration::MigrateToTrackInactive, + crowdloan::migration::MigrateToTrackInactiveV2, pallet_referenda::migration::v1::MigrateV0ToV1, pallet_referenda::migration::v1::MigrateV0ToV1< Runtime, @@ -1668,7 +1670,7 @@ sp_api::impl_runtime_apis! { fn check_validation_outputs( para_id: ParaId, - outputs: primitives::v2::CandidateCommitments, + outputs: primitives::CandidateCommitments, ) -> bool { parachains_runtime_api_impl::check_validation_outputs::(para_id, outputs) } @@ -1720,8 +1722,8 @@ sp_api::impl_runtime_apis! { } fn submit_pvf_check_statement( - stmt: primitives::v2::PvfCheckStatement, - signature: primitives::v2::ValidatorSignature, + stmt: primitives::PvfCheckStatement, + signature: primitives::ValidatorSignature, ) { parachains_runtime_api_impl::submit_pvf_check_statement::(stmt, signature) } diff --git a/runtime/metrics/src/with_runtime_metrics.rs b/runtime/metrics/src/with_runtime_metrics.rs index 439b0f3801a2..ae641a512e47 100644 --- a/runtime/metrics/src/with_runtime_metrics.rs +++ b/runtime/metrics/src/with_runtime_metrics.rs @@ -23,7 +23,7 @@ const TRACING_TARGET: &'static str = "metrics"; use parity_scale_codec::Encode; -use primitives::v2::{ +use primitives::{ metric_definitions::{CounterDefinition, CounterVecDefinition}, RuntimeMetricLabelValues, RuntimeMetricOp, RuntimeMetricUpdate, }; diff --git a/runtime/metrics/src/without_runtime_metrics.rs b/runtime/metrics/src/without_runtime_metrics.rs index 27381a0a2aa1..4ee2c865b7ce 100644 --- a/runtime/metrics/src/without_runtime_metrics.rs +++ b/runtime/metrics/src/without_runtime_metrics.rs @@ -18,7 +18,7 @@ //! provide a dummy implementation for the native runtime to avoid cluttering the runtime code //! with `#[cfg(feature = "runtime-metrics")]`. -use primitives::v2::metric_definitions::{CounterDefinition, CounterVecDefinition}; +use primitives::metric_definitions::{CounterDefinition, CounterVecDefinition}; /// A dummy `Counter`. pub struct Counter; diff --git a/runtime/parachains/src/builder.rs b/runtime/parachains/src/builder.rs index 2ebdcda5322b..9fa954066c1c 100644 --- a/runtime/parachains/src/builder.rs +++ b/runtime/parachains/src/builder.rs @@ -22,7 +22,7 @@ use crate::{ }; use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec}; use frame_support::pallet_prelude::*; -use primitives::v2::{ +use primitives::{ collator_signature_payload, AvailabilityBitfield, BackedCandidate, CandidateCommitments, CandidateDescriptor, CandidateHash, CollatorId, CollatorSignature, CommittedCandidateReceipt, CompactStatement, CoreIndex, CoreOccupied, DisputeStatement, DisputeStatementSet, GroupIndex, diff --git a/runtime/parachains/src/configuration.rs b/runtime/parachains/src/configuration.rs index b360c108e428..1c918d9d7cd5 100644 --- a/runtime/parachains/src/configuration.rs +++ b/runtime/parachains/src/configuration.rs @@ -22,7 +22,7 @@ use crate::shared; use frame_support::{pallet_prelude::*, weights::constants::WEIGHT_REF_TIME_PER_MILLIS}; use frame_system::pallet_prelude::*; use parity_scale_codec::{Decode, Encode}; -use primitives::v2::{Balance, SessionIndex, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MAX_POV_SIZE}; +use primitives::{Balance, SessionIndex, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MAX_POV_SIZE}; use sp_runtime::traits::Zero; use sp_std::prelude::*; @@ -1148,7 +1148,7 @@ pub mod pallet { fn integrity_test() { assert_eq!( &ActiveConfig::::hashed_key(), - primitives::v2::well_known_keys::ACTIVE_CONFIG, + primitives::well_known_keys::ACTIVE_CONFIG, "`well_known_keys::ACTIVE_CONFIG` doesn't match key of `ActiveConfig`! Make sure that the name of the\ configuration pallet is `Configuration` in the runtime!", ); diff --git a/runtime/parachains/src/configuration/migration.rs b/runtime/parachains/src/configuration/migration.rs index 14c38bf3550b..6445e9ec292c 100644 --- a/runtime/parachains/src/configuration/migration.rs +++ b/runtime/parachains/src/configuration/migration.rs @@ -31,7 +31,7 @@ pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(4); pub mod v4 { use super::*; use frame_support::{traits::OnRuntimeUpgrade, weights::constants::WEIGHT_REF_TIME_PER_MILLIS}; - use primitives::v2::{Balance, SessionIndex}; + use primitives::{Balance, SessionIndex}; #[cfg(feature = "try-runtime")] use sp_std::prelude::*; @@ -272,9 +272,8 @@ mod tests { // doesn't need to be read and also leaving it as one line allows to easily copy it. let raw_config = hex_literal::hex!["0000a000005000000a00000000c8000000c800000a0000000a000000100e0000580200000000500000c800000700e8764817020040011e00000000000000005039278c0400000000000000000000005039278c0400000000000000000000e8030000009001001e00000000000000009001008070000000000000000000000a0000000a0000000a00000001000000010500000001c8000000060000005802000002000000580200000200000059000000000000001e000000280000000700c817a80402004001000200000014000000"]; - let v3 = - v4::OldHostConfiguration::::decode(&mut &raw_config[..]) - .unwrap(); + let v3 = v4::OldHostConfiguration::::decode(&mut &raw_config[..]) + .unwrap(); // We check only a sample of the values here. If we missed any fields or messed up data types // that would skew all the fields coming after. @@ -297,7 +296,7 @@ mod tests { // We specify only the picked fields and the rest should be provided by the `Default` // implementation. That implementation is copied over between the two types and should work // fine. - let v3 = v4::OldHostConfiguration:: { + let v3 = v4::OldHostConfiguration:: { ump_max_individual_weight: Weight::from_parts(0x71616e6f6e0au64, 0x71616e6f6e0au64), needed_approvals: 69, thread_availability_period: 55, diff --git a/runtime/parachains/src/configuration/tests.rs b/runtime/parachains/src/configuration/tests.rs index d9d0ae6ea267..aedeacd81e2f 100644 --- a/runtime/parachains/src/configuration/tests.rs +++ b/runtime/parachains/src/configuration/tests.rs @@ -533,7 +533,7 @@ fn verify_externally_accessible() { // This test verifies that the value can be accessed through the well known keys and the // host configuration decodes into the abridged version. - use primitives::v2::{well_known_keys, AbridgedHostConfiguration}; + use primitives::{well_known_keys, AbridgedHostConfiguration}; new_test_ext(Default::default()).execute_with(|| { let ground_truth = HostConfiguration::default(); diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index f802c0dfd217..8d4094f0a109 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -21,7 +21,7 @@ use bitvec::{bitvec, order::Lsb0 as BitOrderLsb0}; use frame_support::{ensure, traits::Get, weights::Weight}; use frame_system::pallet_prelude::*; use parity_scale_codec::{Decode, Encode}; -use primitives::v2::{ +use primitives::{ byzantine_threshold, supermajority_threshold, ApprovalVote, CandidateHash, CheckedDisputeStatementSet, CheckedMultiDisputeStatementSet, CompactStatement, ConsensusLog, DisputeState, DisputeStatement, DisputeStatementSet, ExplicitDisputeStatement, diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index b79286aa1c99..fd127d7f0789 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -50,7 +50,7 @@ use frame_support::{ }; use parity_scale_codec::{Decode, Encode}; -use primitives::v2::{CandidateHash, SessionIndex, ValidatorId, ValidatorIndex}; +use primitives::{CandidateHash, SessionIndex, ValidatorId, ValidatorIndex}; use scale_info::TypeInfo; use sp_runtime::{ traits::Convert, @@ -512,7 +512,7 @@ pub mod pallet { ensure_none(origin)?; // check the membership proof to extract the offender's id - let key = (primitives::v2::PARACHAIN_KEY_TYPE_ID, dispute_proof.validator_id.clone()); + let key = (primitives::PARACHAIN_KEY_TYPE_ID, dispute_proof.validator_id.clone()); let offender = T::KeyOwnerProofSystem::check_proof(key, key_owner_proof) .ok_or(Error::::InvalidKeyOwnershipProof)?; @@ -664,7 +664,7 @@ fn is_known_offence( key_owner_proof: &T::KeyOwnerProof, ) -> Result<(), TransactionValidityError> { // check the membership proof to extract the offender's id - let key = (primitives::v2::PARACHAIN_KEY_TYPE_ID, dispute_proof.validator_id.clone()); + let key = (primitives::PARACHAIN_KEY_TYPE_ID, dispute_proof.validator_id.clone()); let offender = T::KeyOwnerProofSystem::check_proof(key, key_owner_proof.clone()) .ok_or(InvalidTransaction::BadProof)?; diff --git a/runtime/parachains/src/disputes/slashing/benchmarking.rs b/runtime/parachains/src/disputes/slashing/benchmarking.rs index 9e199b75d9bb..0b328e3e5797 100644 --- a/runtime/parachains/src/disputes/slashing/benchmarking.rs +++ b/runtime/parachains/src/disputes/slashing/benchmarking.rs @@ -21,7 +21,7 @@ use frame_benchmarking::{benchmarks, whitelist_account}; use frame_support::traits::{OnFinalize, OnInitialize}; use frame_system::RawOrigin; use pallet_staking::testing_utils::create_validators; -use primitives::v2::{Hash, PARACHAIN_KEY_TYPE_ID}; +use primitives::{Hash, PARACHAIN_KEY_TYPE_ID}; use sp_runtime::traits::{One, StaticLookup}; use sp_session::MembershipProof; diff --git a/runtime/parachains/src/disputes/tests.rs b/runtime/parachains/src/disputes/tests.rs index 7a3396f51b25..8e9e0097f703 100644 --- a/runtime/parachains/src/disputes/tests.rs +++ b/runtime/parachains/src/disputes/tests.rs @@ -28,7 +28,7 @@ use frame_support::{ assert_err, assert_noop, assert_ok, traits::{OnFinalize, OnInitialize}, }; -use primitives::v2::BlockNumber; +use primitives::BlockNumber; use sp_core::{crypto::CryptoType, Pair}; const VOTE_FOR: VoteKind = VoteKind::ExplicitValid; diff --git a/runtime/parachains/src/dmp.rs b/runtime/parachains/src/dmp.rs index ed64624f9f33..8b2bb85a37ba 100644 --- a/runtime/parachains/src/dmp.rs +++ b/runtime/parachains/src/dmp.rs @@ -19,7 +19,7 @@ use crate::{ initializer, }; use frame_support::pallet_prelude::*; -use primitives::v2::{DownwardMessage, Hash, Id as ParaId, InboundDownwardMessage}; +use primitives::{DownwardMessage, Hash, Id as ParaId, InboundDownwardMessage}; use sp_runtime::traits::{BlakeTwo256, Hash as HashT, SaturatedConversion}; use sp_std::{fmt, prelude::*}; use xcm::latest::SendError; diff --git a/runtime/parachains/src/dmp/tests.rs b/runtime/parachains/src/dmp/tests.rs index af2ec1d6a98f..b19c2db0914a 100644 --- a/runtime/parachains/src/dmp/tests.rs +++ b/runtime/parachains/src/dmp/tests.rs @@ -18,7 +18,7 @@ use super::*; use crate::mock::{new_test_ext, Configuration, Dmp, MockGenesisConfig, Paras, System}; use hex_literal::hex; use parity_scale_codec::Encode; -use primitives::v2::BlockNumber; +use primitives::BlockNumber; pub(crate) fn run_to_block(to: BlockNumber, new_session: Option>) { while System::block_number() < to { @@ -184,7 +184,7 @@ fn queue_downward_message_critical() { #[test] fn verify_dmq_mqc_head_is_externally_accessible() { use hex_literal::hex; - use primitives::v2::well_known_keys; + use primitives::well_known_keys; let a = ParaId::from(2020); diff --git a/runtime/parachains/src/hrmp.rs b/runtime/parachains/src/hrmp.rs index 4476f1f4a4da..d72043dcd3ae 100644 --- a/runtime/parachains/src/hrmp.rs +++ b/runtime/parachains/src/hrmp.rs @@ -21,7 +21,7 @@ use crate::{ use frame_support::{pallet_prelude::*, traits::ReservableCurrency}; use frame_system::pallet_prelude::*; use parity_scale_codec::{Decode, Encode}; -use primitives::v2::{ +use primitives::{ Balance, Hash, HrmpChannelId, Id as ParaId, InboundHrmpMessage, OutboundHrmpMessage, SessionIndex, }; diff --git a/runtime/parachains/src/hrmp/tests.rs b/runtime/parachains/src/hrmp/tests.rs index 85cdc459ffb9..ec91b1c47378 100644 --- a/runtime/parachains/src/hrmp/tests.rs +++ b/runtime/parachains/src/hrmp/tests.rs @@ -23,7 +23,7 @@ use crate::{ paras::ParaKind, }; use frame_support::{assert_noop, assert_ok, traits::Currency as _}; -use primitives::v2::BlockNumber; +use primitives::BlockNumber; use std::collections::BTreeMap; fn run_to_block(to: BlockNumber, new_session: Option>) { @@ -418,7 +418,7 @@ fn check_sent_messages() { #[test] fn verify_externally_accessible() { - use primitives::v2::{well_known_keys, AbridgedHrmpChannel}; + use primitives::{well_known_keys, AbridgedHrmpChannel}; let para_a = 20.into(); let para_b = 21.into(); diff --git a/runtime/parachains/src/inclusion/mod.rs b/runtime/parachains/src/inclusion/mod.rs index 1df6c141e9df..da63abe3a433 100644 --- a/runtime/parachains/src/inclusion/mod.rs +++ b/runtime/parachains/src/inclusion/mod.rs @@ -27,7 +27,7 @@ use crate::{ use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec}; use frame_support::pallet_prelude::*; use parity_scale_codec::{Decode, Encode}; -use primitives::v2::{ +use primitives::{ AvailabilityBitfield, BackedCandidate, CandidateCommitments, CandidateDescriptor, CandidateHash, CandidateReceipt, CommittedCandidateReceipt, CoreIndex, GroupIndex, Hash, HeadData, Id as ParaId, SigningContext, UncheckedSignedAvailabilityBitfields, ValidatorId, @@ -574,7 +574,7 @@ impl Pallet { // check the signatures in the backing and that it is a majority. { - let maybe_amount_validated = primitives::v2::check_candidate_backing( + let maybe_amount_validated = primitives::check_candidate_backing( &backed_candidate, &signing_context, group_vals.len(), @@ -691,7 +691,7 @@ impl Pallet { /// Run the acceptance criteria checks on the given candidate commitments. pub(crate) fn check_validation_outputs_for_runtime_api( para_id: ParaId, - validation_outputs: primitives::v2::CandidateCommitments, + validation_outputs: primitives::CandidateCommitments, ) -> bool { // This function is meant to be called from the runtime APIs against the relay-parent, hence // `relay_parent_number` is equal to `now`. @@ -1037,11 +1037,11 @@ impl CandidateCheckContext { &self, para_id: ParaId, head_data: &HeadData, - new_validation_code: &Option, + new_validation_code: &Option, processed_downward_messages: u32, - upward_messages: &[primitives::v2::UpwardMessage], + upward_messages: &[primitives::UpwardMessage], hrmp_watermark: T::BlockNumber, - horizontal_messages: &[primitives::v2::OutboundHrmpMessage], + horizontal_messages: &[primitives::OutboundHrmpMessage], ) -> Result<(), AcceptanceCheckErr> { ensure!( head_data.0.len() <= self.config.max_head_data_size as _, diff --git a/runtime/parachains/src/inclusion/tests.rs b/runtime/parachains/src/inclusion/tests.rs index 00369fb67e75..818058d460f8 100644 --- a/runtime/parachains/src/inclusion/tests.rs +++ b/runtime/parachains/src/inclusion/tests.rs @@ -30,7 +30,7 @@ use assert_matches::assert_matches; use frame_support::assert_noop; use futures::executor::block_on; use keyring::Sr25519Keyring; -use primitives::v2::{ +use primitives::{ BlockNumber, CandidateCommitments, CandidateDescriptor, CollatorId, CompactStatement as Statement, Hash, SignedAvailabilityBitfield, SignedStatement, UncheckedSignedAvailabilityBitfield, ValidationCode, ValidatorId, ValidityAttestation, @@ -91,7 +91,7 @@ pub(crate) fn collator_sign_candidate( ) { candidate.descriptor.collator = collator.public().into(); - let payload = primitives::v2::collator_signature_payload( + let payload = primitives::collator_signature_payload( &candidate.descriptor.relay_parent, &candidate.descriptor.para_id, &candidate.descriptor.persisted_validation_data_hash, @@ -146,7 +146,7 @@ pub(crate) async fn back_candidate( let backed = BackedCandidate { candidate, validity_votes, validator_indices }; let successfully_backed = - primitives::v2::check_candidate_backing(&backed, signing_context, group.len(), |i| { + primitives::check_candidate_backing(&backed, signing_context, group.len(), |i| { Some(validators[group[i].0 as usize].public().into()) }) .ok() diff --git a/runtime/parachains/src/initializer.rs b/runtime/parachains/src/initializer.rs index 85546559b7de..60b95cf0db9c 100644 --- a/runtime/parachains/src/initializer.rs +++ b/runtime/parachains/src/initializer.rs @@ -30,7 +30,7 @@ use frame_support::{ }; use frame_system::limits::BlockWeights; use parity_scale_codec::{Decode, Encode}; -use primitives::v2::{BlockNumber, ConsensusLog, SessionIndex, ValidatorId}; +use primitives::{BlockNumber, ConsensusLog, SessionIndex, ValidatorId}; use scale_info::TypeInfo; use sp_std::prelude::*; diff --git a/runtime/parachains/src/initializer/benchmarking.rs b/runtime/parachains/src/initializer/benchmarking.rs index 7c6a633790c2..ff9667e603d6 100644 --- a/runtime/parachains/src/initializer/benchmarking.rs +++ b/runtime/parachains/src/initializer/benchmarking.rs @@ -17,7 +17,7 @@ use super::*; use frame_benchmarking::benchmarks; use frame_system::RawOrigin; -use primitives::v2::ConsensusLog; +use primitives::ConsensusLog; use sp_runtime::DigestItem; // Random large number for the digest diff --git a/runtime/parachains/src/initializer/tests.rs b/runtime/parachains/src/initializer/tests.rs index d1d884200527..c9522330a4cd 100644 --- a/runtime/parachains/src/initializer/tests.rs +++ b/runtime/parachains/src/initializer/tests.rs @@ -18,7 +18,7 @@ use super::*; use crate::mock::{ new_test_ext, Configuration, Dmp, Initializer, MockGenesisConfig, Paras, SessionInfo, System, }; -use primitives::v2::{HeadData, Id as ParaId}; +use primitives::{HeadData, Id as ParaId}; use test_helpers::dummy_validation_code; use crate::paras::ParaKind; diff --git a/runtime/parachains/src/lib.rs b/runtime/parachains/src/lib.rs index 3d73a4049ed4..c45f0d446015 100644 --- a/runtime/parachains/src/lib.rs +++ b/runtime/parachains/src/lib.rs @@ -50,7 +50,7 @@ mod mock; pub use origin::{ensure_parachain, Origin}; pub use paras::ParaLifecycle; -use primitives::v2::{HeadData, Id as ParaId, ValidationCode}; +use primitives::{HeadData, Id as ParaId, ValidationCode}; use sp_runtime::DispatchResult; /// Schedule a para to be initialized at the start of the next session with the given genesis data. @@ -66,7 +66,7 @@ pub fn schedule_para_initialize( /// Schedule a para to be cleaned up at the start of the next session. /// /// See [`paras::Pallet::schedule_para_cleanup`] for more details. -pub fn schedule_para_cleanup(id: primitives::v2::Id) -> Result<(), ()> { +pub fn schedule_para_cleanup(id: primitives::Id) -> Result<(), ()> { >::schedule_para_cleanup(id).map_err(|_| ()) } diff --git a/runtime/parachains/src/metrics.rs b/runtime/parachains/src/metrics.rs index 1368bdbfbbf4..66fde11b8513 100644 --- a/runtime/parachains/src/metrics.rs +++ b/runtime/parachains/src/metrics.rs @@ -17,7 +17,7 @@ //! Runtime declaration of the parachain metrics. use polkadot_runtime_metrics::{Counter, CounterVec}; -use primitives::v2::metric_definitions::{ +use primitives::metric_definitions::{ PARACHAIN_CREATE_INHERENT_BITFIELDS_SIGNATURE_CHECKS, PARACHAIN_INHERENT_DATA_BITFIELDS_PROCESSED, PARACHAIN_INHERENT_DATA_CANDIDATES_PROCESSED, PARACHAIN_INHERENT_DATA_DISPUTE_SETS_INCLUDED, PARACHAIN_INHERENT_DATA_DISPUTE_SETS_PROCESSED, diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index bf7901c2d9a3..15c84daad002 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -30,7 +30,7 @@ use frame_support::{ }; use frame_support_test::TestRandomness; use parity_scale_codec::Decode; -use primitives::v2::{ +use primitives::{ AuthorityDiscoveryId, Balance, BlockNumber, CandidateHash, Header, Moment, SessionIndex, UpwardMessage, ValidatorIndex, }; diff --git a/runtime/parachains/src/origin.rs b/runtime/parachains/src/origin.rs index 282afca6aef0..aa8096982569 100644 --- a/runtime/parachains/src/origin.rs +++ b/runtime/parachains/src/origin.rs @@ -16,7 +16,7 @@ //! Declaration of the parachain specific origin and a pallet that hosts it. -use primitives::v2::Id as ParaId; +use primitives::Id as ParaId; use sp_runtime::traits::BadOrigin; use sp_std::result; diff --git a/runtime/parachains/src/paras/benchmarking.rs b/runtime/parachains/src/paras/benchmarking.rs index 9970937f4558..e1ecd98ab4d0 100644 --- a/runtime/parachains/src/paras/benchmarking.rs +++ b/runtime/parachains/src/paras/benchmarking.rs @@ -18,7 +18,7 @@ use super::*; use crate::configuration::HostConfiguration; use frame_benchmarking::benchmarks; use frame_system::RawOrigin; -use primitives::v2::{HeadData, Id as ParaId, ValidationCode, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE}; +use primitives::{HeadData, Id as ParaId, ValidationCode, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE}; use sp_runtime::traits::{One, Saturating}; mod pvf_check; diff --git a/runtime/parachains/src/paras/benchmarking/pvf_check.rs b/runtime/parachains/src/paras/benchmarking/pvf_check.rs index e1400ac4297d..a16c016531ee 100644 --- a/runtime/parachains/src/paras/benchmarking/pvf_check.rs +++ b/runtime/parachains/src/paras/benchmarking/pvf_check.rs @@ -18,7 +18,7 @@ use crate::{configuration, paras::*, shared::Pallet as ParasShared}; use frame_system::RawOrigin; -use primitives::v2::{HeadData, Id as ParaId, ValidationCode, ValidatorId, ValidatorIndex}; +use primitives::{HeadData, Id as ParaId, ValidationCode, ValidatorId, ValidatorIndex}; use sp_application_crypto::RuntimeAppPublic; // Constants for the benchmarking @@ -170,7 +170,8 @@ where } /// Generates a list of votes combined with signatures for the active validator set. The number of -/// votes is equal to the minimum number of votes required to reach the supermajority. +/// votes is equal to the minimum number of votes required to reach the threshold for either accept +/// or reject. fn generate_statements( vote_outcome: VoteOutcome, ) -> impl Iterator @@ -179,7 +180,11 @@ where { let validators = ParasShared::::active_validator_keys(); - let required_votes = primitives::v2::supermajority_threshold(validators.len()); + let accept_threshold = primitives::supermajority_threshold(validators.len()); + let required_votes = match vote_outcome { + VoteOutcome::Accept => accept_threshold, + VoteOutcome::Reject => validators.len() - accept_threshold, + }; (0..required_votes).map(move |validator_index| { let stmt = PvfCheckStatement { accept: vote_outcome == VoteOutcome::Accept, diff --git a/runtime/parachains/src/paras/mod.rs b/runtime/parachains/src/paras/mod.rs index 0fca9a004099..f372a88713e6 100644 --- a/runtime/parachains/src/paras/mod.rs +++ b/runtime/parachains/src/paras/mod.rs @@ -73,13 +73,14 @@ //! //! # PVF Pre-checking //! -//! As was mentioned above, a brand new validation code should go through a process of approval. -//! As part of this process, validators from the active set will take the validation code and -//! check if it is malicious. Once they did that and have their judgement, either accept or reject, -//! they issue a statement in a form of an unsigned extrinsic. This extrinsic is processed by this -//! pallet. Once supermajority is gained for accept, then the process that initiated the check -//! is resumed (as mentioned before this can be either upgrading of validation code or onboarding). -//! If supermajority is gained for reject, then the process is canceled. +//! As was mentioned above, a brand new validation code should go through a process of approval. As +//! part of this process, validators from the active set will take the validation code and check if +//! it is malicious. Once they did that and have their judgement, either accept or reject, they +//! issue a statement in a form of an unsigned extrinsic. This extrinsic is processed by this +//! pallet. Once supermajority is gained for accept, then the process that initiated the check is +//! resumed (as mentioned before this can be either upgrading of validation code or onboarding). If +//! getting a supermajority becomes impossible (>1/3 of validators have already voted against), then +//! we reject. //! //! Below is a state diagram that depicts states of a single PVF pre-checking vote. //! @@ -92,8 +93,8 @@ //! │ │ │ //! │ ┌───────┐ //! │ │ │ -//! └─▶│ init │────supermajority ┌──────────┐ -//! │ │ against │ │ +//! └─▶│ init │──── >1/3 against ┌──────────┐ +//! │ │ │ │ │ //! └───────┘ └──────────▶│ rejected │ //! ▲ │ │ │ //! │ │ session └──────────┘ @@ -111,7 +112,7 @@ use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec}; use frame_support::{pallet_prelude::*, traits::EstimateNextSessionRotation}; use frame_system::pallet_prelude::*; use parity_scale_codec::{Decode, Encode}; -use primitives::v2::{ +use primitives::{ ConsensusLog, HeadData, Id as ParaId, PvfCheckStatement, SessionIndex, UpgradeGoAhead, UpgradeRestriction, ValidationCode, ValidationCodeHash, ValidatorSignature, }; @@ -452,12 +453,14 @@ impl PvfCheckActiveVoteState { /// Returns `None` if the quorum is not reached, or the direction of the decision. fn quorum(&self, n_validators: usize) -> Option { - let q_threshold = primitives::v2::supermajority_threshold(n_validators); - // NOTE: counting the reject votes is deliberately placed first. This is to err on the safe. - if self.votes_reject.count_ones() >= q_threshold { - Some(PvfCheckOutcome::Rejected) - } else if self.votes_accept.count_ones() >= q_threshold { + let accept_threshold = primitives::supermajority_threshold(n_validators); + // At this threshold, a supermajority is no longer possible, so we reject. + let reject_threshold = n_validators - accept_threshold; + + if self.votes_accept.count_ones() >= accept_threshold { Some(PvfCheckOutcome::Accepted) + } else if self.votes_reject.count_ones() > reject_threshold { + Some(PvfCheckOutcome::Rejected) } else { None } @@ -1011,7 +1014,7 @@ pub mod pallet { } if let Some(outcome) = active_vote.quorum(validators.len()) { - // The supermajority quorum has been achieved. + // The quorum has been achieved. // // Remove the PVF vote from the active map and finalize the PVF checking according // to the outcome. diff --git a/runtime/parachains/src/paras/tests.rs b/runtime/parachains/src/paras/tests.rs index f110e2a0d38a..df639b495fb9 100644 --- a/runtime/parachains/src/paras/tests.rs +++ b/runtime/parachains/src/paras/tests.rs @@ -17,7 +17,7 @@ use super::*; use frame_support::{assert_err, assert_ok, assert_storage_noop}; use keyring::Sr25519Keyring; -use primitives::v2::{BlockNumber, ValidatorId, PARACHAIN_KEY_TYPE_ID}; +use primitives::{BlockNumber, ValidatorId, PARACHAIN_KEY_TYPE_ID}; use sc_keystore::LocalKeystore; use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; use std::sync::Arc; @@ -114,10 +114,7 @@ fn check_code_is_not_stored(validation_code: &ValidationCode) { /// An utility for checking that certain events were deposited. struct EventValidator { events: Vec< - frame_system::EventRecord< - ::RuntimeEvent, - primitives::v2::Hash, - >, + frame_system::EventRecord<::RuntimeEvent, primitives::Hash>, >, } @@ -1252,15 +1249,24 @@ fn pvf_check_upgrade_reject() { Paras::schedule_code_upgrade(a, new_code.clone(), RELAY_PARENT, &Configuration::config()); check_code_is_stored(&new_code); - // Supermajority of validators vote against `new_code`. PVF should be rejected. - IntoIterator::into_iter([0, 1, 2, 3]) - .map(|i| PvfCheckStatement { - accept: false, - subject: new_code.hash(), - session_index: EXPECTED_SESSION, - validator_index: i.into(), - }) - .for_each(sign_and_include_pvf_check_statement); + // 1/3 of validators vote against `new_code`. PVF should not be rejected yet. + sign_and_include_pvf_check_statement(PvfCheckStatement { + accept: false, + subject: new_code.hash(), + session_index: EXPECTED_SESSION, + validator_index: 0.into(), + }); + + // Verify that the new code is not yet discarded. + check_code_is_stored(&new_code); + + // >1/3 of validators vote against `new_code`. PVF should be rejected. + sign_and_include_pvf_check_statement(PvfCheckStatement { + accept: false, + subject: new_code.hash(), + session_index: EXPECTED_SESSION, + validator_index: 1.into(), + }); // Verify that the new code is discarded. check_code_is_not_stored(&new_code); @@ -1694,7 +1700,7 @@ fn add_trusted_validation_code_enacts_existing_pvf_vote() { #[test] fn verify_upgrade_go_ahead_signal_is_externally_accessible() { - use primitives::v2::well_known_keys; + use primitives::well_known_keys; let a = ParaId::from(2020); @@ -1710,7 +1716,7 @@ fn verify_upgrade_go_ahead_signal_is_externally_accessible() { #[test] fn verify_upgrade_restriction_signal_is_externally_accessible() { - use primitives::v2::well_known_keys; + use primitives::well_known_keys; let a = ParaId::from(2020); diff --git a/runtime/parachains/src/paras_inherent/mod.rs b/runtime/parachains/src/paras_inherent/mod.rs index 9ee51abd9932..ee6666b0060b 100644 --- a/runtime/parachains/src/paras_inherent/mod.rs +++ b/runtime/parachains/src/paras_inherent/mod.rs @@ -39,7 +39,7 @@ use frame_support::{ }; use frame_system::pallet_prelude::*; use pallet_babe::{self, ParentBlockRandomness}; -use primitives::v2::{ +use primitives::{ BackedCandidate, CandidateHash, CandidateReceipt, CheckedDisputeStatementSet, CheckedMultiDisputeStatementSet, CoreIndex, DisputeStatementSet, InherentData as ParachainsInherentData, MultiDisputeStatementSet, ScrapedOnChainVotes, diff --git a/runtime/parachains/src/paras_inherent/tests.rs b/runtime/parachains/src/paras_inherent/tests.rs index 86d2f1c10537..fb7fd571b004 100644 --- a/runtime/parachains/src/paras_inherent/tests.rs +++ b/runtime/parachains/src/paras_inherent/tests.rs @@ -139,7 +139,7 @@ mod enter { #[test] fn test_session_is_tracked_in_on_chain_scraping() { use crate::disputes::run_to_block; - use primitives::v2::{ + use primitives::{ DisputeStatement, DisputeStatementSet, ExplicitDisputeStatement, InvalidDisputeStatementKind, ValidDisputeStatementKind, }; @@ -859,8 +859,8 @@ mod enter { } } -fn default_header() -> primitives::v2::Header { - primitives::v2::Header { +fn default_header() -> primitives::Header { + primitives::Header { parent_hash: Default::default(), number: 0, state_root: Default::default(), @@ -876,7 +876,7 @@ mod sanitizers { back_candidate, collator_sign_candidate, BackingKind, TestCandidateBuilder, }; use bitvec::order::Lsb0; - use primitives::v2::{ + use primitives::{ AvailabilityBitfield, GroupIndex, Hash, Id as ParaId, SignedAvailabilityBitfield, ValidatorIndex, }; @@ -885,7 +885,7 @@ mod sanitizers { use crate::mock::Test; use futures::executor::block_on; use keyring::Sr25519Keyring; - use primitives::v2::PARACHAIN_KEY_TYPE_ID; + use primitives::PARACHAIN_KEY_TYPE_ID; use sc_keystore::LocalKeystore; use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; use std::sync::Arc; diff --git a/runtime/parachains/src/reward_points.rs b/runtime/parachains/src/reward_points.rs index 1d1d8748f1c2..e3945558f26c 100644 --- a/runtime/parachains/src/reward_points.rs +++ b/runtime/parachains/src/reward_points.rs @@ -23,7 +23,7 @@ use crate::{session_info, shared}; use frame_support::traits::{Defensive, ValidatorSet}; -use primitives::v2::{SessionIndex, ValidatorIndex}; +use primitives::{SessionIndex, ValidatorIndex}; use sp_std::collections::btree_set::BTreeSet; /// The amount of era points given by backing a candidate that is included. diff --git a/runtime/parachains/src/runtime_api_impl/v2.rs b/runtime/parachains/src/runtime_api_impl/v2.rs index 57345a819de0..15b91d57d923 100644 --- a/runtime/parachains/src/runtime_api_impl/v2.rs +++ b/runtime/parachains/src/runtime_api_impl/v2.rs @@ -21,7 +21,7 @@ use crate::{ configuration, dmp, hrmp, inclusion, initializer, paras, paras_inherent, scheduler, session_info, shared, }; -use primitives::v2::{ +use primitives::{ AuthorityDiscoveryId, CandidateEvent, CommittedCandidateReceipt, CoreIndex, CoreOccupied, CoreState, GroupIndex, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, OccupiedCore, OccupiedCoreAssumption, PersistedValidationData, @@ -256,7 +256,7 @@ pub fn assumed_validation_data( /// Implementation for the `check_validation_outputs` function of the runtime API. pub fn check_validation_outputs( para_id: ParaId, - outputs: primitives::v2::CandidateCommitments, + outputs: primitives::CandidateCommitments, ) -> bool { >::check_validation_outputs_for_runtime_api(para_id, outputs) } diff --git a/runtime/parachains/src/runtime_api_impl/vstaging.rs b/runtime/parachains/src/runtime_api_impl/vstaging.rs index 7ae235c8133a..2191fb304e1c 100644 --- a/runtime/parachains/src/runtime_api_impl/vstaging.rs +++ b/runtime/parachains/src/runtime_api_impl/vstaging.rs @@ -17,7 +17,7 @@ //! Put implementations of functions from staging APIs here. use crate::disputes; -use primitives::v2::{CandidateHash, DisputeState, SessionIndex}; +use primitives::{CandidateHash, DisputeState, SessionIndex}; use sp_std::prelude::*; /// Implementation for `get_session_disputes` function from the runtime API diff --git a/runtime/parachains/src/scheduler.rs b/runtime/parachains/src/scheduler.rs index 6eb1b732705f..3c671b9e86e3 100644 --- a/runtime/parachains/src/scheduler.rs +++ b/runtime/parachains/src/scheduler.rs @@ -36,7 +36,7 @@ //! over time. use frame_support::pallet_prelude::*; -use primitives::v2::{ +use primitives::{ CollatorId, CoreIndex, CoreOccupied, GroupIndex, GroupRotationInfo, Id as ParaId, ParathreadClaim, ParathreadEntry, ScheduledCore, ValidatorIndex, }; diff --git a/runtime/parachains/src/scheduler/tests.rs b/runtime/parachains/src/scheduler/tests.rs index 40ff9db82871..1d679eca1b39 100644 --- a/runtime/parachains/src/scheduler/tests.rs +++ b/runtime/parachains/src/scheduler/tests.rs @@ -18,7 +18,7 @@ use super::*; use frame_support::assert_ok; use keyring::Sr25519Keyring; -use primitives::v2::{BlockNumber, CollatorId, SessionIndex, ValidatorId}; +use primitives::{BlockNumber, CollatorId, SessionIndex, ValidatorId}; use crate::{ configuration::HostConfiguration, diff --git a/runtime/parachains/src/session_info.rs b/runtime/parachains/src/session_info.rs index cbd67a200a16..1ba865cf4a26 100644 --- a/runtime/parachains/src/session_info.rs +++ b/runtime/parachains/src/session_info.rs @@ -27,7 +27,7 @@ use frame_support::{ pallet_prelude::*, traits::{OneSessionHandler, ValidatorSet, ValidatorSetWithIdentification}, }; -use primitives::v2::{AssignmentId, AuthorityDiscoveryId, SessionIndex, SessionInfo}; +use primitives::{AssignmentId, AuthorityDiscoveryId, SessionIndex, SessionInfo}; use sp_std::vec::Vec; pub use pallet::*; diff --git a/runtime/parachains/src/session_info/tests.rs b/runtime/parachains/src/session_info/tests.rs index 7bf68736b572..b3e14340dbcb 100644 --- a/runtime/parachains/src/session_info/tests.rs +++ b/runtime/parachains/src/session_info/tests.rs @@ -25,7 +25,7 @@ use crate::{ util::take_active_subset, }; use keyring::Sr25519Keyring; -use primitives::v2::{BlockNumber, ValidatorId, ValidatorIndex}; +use primitives::{BlockNumber, ValidatorId, ValidatorIndex}; fn run_to_block( to: BlockNumber, diff --git a/runtime/parachains/src/shared.rs b/runtime/parachains/src/shared.rs index 5f5d44509ed2..70e23644d232 100644 --- a/runtime/parachains/src/shared.rs +++ b/runtime/parachains/src/shared.rs @@ -20,7 +20,7 @@ //! dependent on any of the other pallets. use frame_support::pallet_prelude::*; -use primitives::v2::{SessionIndex, ValidatorId, ValidatorIndex}; +use primitives::{SessionIndex, ValidatorId, ValidatorIndex}; use sp_std::vec::Vec; use rand::{seq::SliceRandom, SeedableRng}; diff --git a/runtime/parachains/src/ump.rs b/runtime/parachains/src/ump.rs index d7ecad3797b2..b0acefbc6065 100644 --- a/runtime/parachains/src/ump.rs +++ b/runtime/parachains/src/ump.rs @@ -20,7 +20,7 @@ use crate::{ }; use frame_support::{pallet_prelude::*, traits::EnsureOrigin}; use frame_system::pallet_prelude::*; -use primitives::v2::{Id as ParaId, UpwardMessage}; +use primitives::{Id as ParaId, UpwardMessage}; use sp_std::{collections::btree_map::BTreeMap, fmt, marker::PhantomData, mem, prelude::*}; use xcm::latest::Outcome; diff --git a/runtime/parachains/src/ump/tests.rs b/runtime/parachains/src/ump/tests.rs index 23c5159eab0f..5113570e06a5 100644 --- a/runtime/parachains/src/ump/tests.rs +++ b/runtime/parachains/src/ump/tests.rs @@ -269,7 +269,7 @@ fn verify_relay_dispatch_queue_size_is_externally_accessible() { // keys and is decodable into a (u32, u32). use parity_scale_codec::Decode as _; - use primitives::v2::well_known_keys; + use primitives::well_known_keys; let a = ParaId::from(228); let msg = vec![1, 2, 3]; diff --git a/runtime/parachains/src/util.rs b/runtime/parachains/src/util.rs index e4c538ed2c66..b4e552d4c9b6 100644 --- a/runtime/parachains/src/util.rs +++ b/runtime/parachains/src/util.rs @@ -17,7 +17,7 @@ //! Utilities that don't belong to any particular module but may draw //! on all modules. -use primitives::v2::{Id as ParaId, PersistedValidationData, ValidatorIndex}; +use primitives::{Id as ParaId, PersistedValidationData, ValidatorIndex}; use sp_std::{collections::btree_set::BTreeSet, vec::Vec}; use crate::{configuration, hrmp, paras}; @@ -103,7 +103,7 @@ mod tests { use sp_std::vec::Vec; use crate::util::{split_active_subset, take_active_subset}; - use primitives::v2::ValidatorIndex; + use primitives::ValidatorIndex; #[test] fn take_active_subset_is_compatible_with_split_active_subset() { diff --git a/runtime/polkadot/constants/src/lib.rs b/runtime/polkadot/constants/src/lib.rs index be37482968a8..68b2fdcd306e 100644 --- a/runtime/polkadot/constants/src/lib.rs +++ b/runtime/polkadot/constants/src/lib.rs @@ -22,7 +22,7 @@ pub use self::currency::DOLLARS; /// Money matters. pub mod currency { - use primitives::v2::Balance; + use primitives::Balance; /// The existential deposit. pub const EXISTENTIAL_DEPOSIT: Balance = 100 * CENTS; @@ -39,7 +39,7 @@ pub mod currency { /// Time and blocks. pub mod time { - use primitives::v2::{BlockNumber, Moment}; + use primitives::{BlockNumber, Moment}; use runtime_common::prod_or_fast; pub const MILLISECS_PER_BLOCK: Moment = 6000; pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK; @@ -64,7 +64,7 @@ pub mod fee { use frame_support::weights::{ WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }; - use primitives::v2::Balance; + use primitives::Balance; use smallvec::smallvec; pub use sp_runtime::Perbill; diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index dc32a91c7ace..3a1c211bf028 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -53,7 +53,7 @@ use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use pallet_session::historical as session_historical; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use primitives::v2::{ +use primitives::{ AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CommittedCandidateReceipt, CoreState, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, @@ -1469,7 +1469,7 @@ impl frame_support::traits::OnRuntimeUpgrade for InitiateNominationPools { construct_runtime! { pub enum Runtime where Block = Block, - NodeBlock = primitives::v2::Block, + NodeBlock = primitives::Block, UncheckedExtrinsic = UncheckedExtrinsic { // Basic stuff; balances is uncallable initially. @@ -1601,8 +1601,10 @@ impl Get<&'static str> for StakingMigrationV11OldPallet { /// /// Should be cleared after every release. pub type Migrations = ( + pallet_balances::migration::ResetInactive, + // We need to apply this migration again, because `ResetInactive` resets the state again. pallet_balances::migration::MigrateToTrackInactive, - crowdloan::migration::MigrateToTrackInactive, + crowdloan::migration::MigrateToTrackInactiveV2, pallet_scheduler::migration::v4::CleanupAgendas, pallet_staking::migrations::v13::MigrateToV13, parachains_disputes::migration::v1::MigrateToV1, @@ -1780,7 +1782,7 @@ sp_api::impl_runtime_apis! { fn check_validation_outputs( para_id: ParaId, - outputs: primitives::v2::CandidateCommitments, + outputs: primitives::CandidateCommitments, ) -> bool { parachains_runtime_api_impl::check_validation_outputs::(para_id, outputs) } @@ -1832,8 +1834,8 @@ sp_api::impl_runtime_apis! { } fn submit_pvf_check_statement( - stmt: primitives::v2::PvfCheckStatement, - signature: primitives::v2::ValidatorSignature, + stmt: primitives::PvfCheckStatement, + signature: primitives::ValidatorSignature, ) { parachains_runtime_api_impl::submit_pvf_check_statement::(stmt, signature) } diff --git a/runtime/rococo/constants/src/lib.rs b/runtime/rococo/constants/src/lib.rs index 7893cada961d..0683bc377e13 100644 --- a/runtime/rococo/constants/src/lib.rs +++ b/runtime/rococo/constants/src/lib.rs @@ -20,7 +20,7 @@ pub mod weights; /// Money matters. pub mod currency { - use primitives::v2::Balance; + use primitives::Balance; /// The existential deposit. pub const EXISTENTIAL_DEPOSIT: Balance = 1 * CENTS; @@ -37,7 +37,7 @@ pub mod currency { /// Time and blocks. pub mod time { - use primitives::v2::{BlockNumber, Moment}; + use primitives::{BlockNumber, Moment}; use runtime_common::prod_or_fast; pub const MILLISECS_PER_BLOCK: Moment = 6000; pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK; @@ -65,7 +65,7 @@ pub mod fee { use frame_support::weights::{ WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }; - use primitives::v2::Balance; + use primitives::Balance; use smallvec::smallvec; pub use sp_runtime::Perbill; diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 38d5ce28d167..7329301a43bb 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -22,7 +22,7 @@ use pallet_nis::WithMaximumOf; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use primitives::v2::{ +use primitives::{ AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, @@ -1330,7 +1330,7 @@ impl pallet_sudo::Config for Runtime { construct_runtime! { pub enum Runtime where Block = Block, - NodeBlock = primitives::v2::Block, + NodeBlock = primitives::Block, UncheckedExtrinsic = UncheckedExtrinsic { // Basic stuff; balances is uncallable initially. @@ -1481,8 +1481,10 @@ pub type UncheckedExtrinsic = /// /// Should be cleared after every release. pub type Migrations = ( + pallet_balances::migration::ResetInactive, + // We need to apply this migration again, because `ResetInactive` resets the state again. pallet_balances::migration::MigrateToTrackInactive, - crowdloan::migration::MigrateToTrackInactive, + crowdloan::migration::MigrateToTrackInactiveV2, pallet_scheduler::migration::v4::CleanupAgendas, parachains_disputes::migration::v1::MigrateToV1, parachains_configuration::migration::v4::MigrateToV4, @@ -1671,7 +1673,7 @@ sp_api::impl_runtime_apis! { fn check_validation_outputs( para_id: ParaId, - outputs: primitives::v2::CandidateCommitments, + outputs: primitives::CandidateCommitments, ) -> bool { parachains_runtime_api_impl::check_validation_outputs::(para_id, outputs) } @@ -1723,8 +1725,8 @@ sp_api::impl_runtime_apis! { } fn submit_pvf_check_statement( - stmt: primitives::v2::PvfCheckStatement, - signature: primitives::v2::ValidatorSignature + stmt: primitives::PvfCheckStatement, + signature: primitives::ValidatorSignature ) { parachains_runtime_api_impl::submit_pvf_check_statement::(stmt, signature) } diff --git a/runtime/test-runtime/constants/src/lib.rs b/runtime/test-runtime/constants/src/lib.rs index 0594062b4ddc..ca329accec88 100644 --- a/runtime/test-runtime/constants/src/lib.rs +++ b/runtime/test-runtime/constants/src/lib.rs @@ -20,7 +20,7 @@ pub mod weights; /// Money matters. pub mod currency { - use primitives::v2::Balance; + use primitives::Balance; pub const DOTS: Balance = 1_000_000_000_000; pub const DOLLARS: Balance = DOTS; @@ -30,7 +30,7 @@ pub mod currency { /// Time and blocks. pub mod time { - use primitives::v2::{BlockNumber, Moment}; + use primitives::{BlockNumber, Moment}; // Testnet pub const MILLISECS_PER_BLOCK: Moment = 6000; pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK; @@ -55,7 +55,7 @@ pub mod fee { use frame_support::weights::{ WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }; - use primitives::v2::Balance; + use primitives::Balance; use smallvec::smallvec; pub use sp_runtime::Perbill; diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 83c0b3b05b53..8d95ce9b7674 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -44,7 +44,7 @@ use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId}; use pallet_session::historical as session_historical; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; use polkadot_runtime_parachains::reward_points::RewardValidatorsWithEraPoints; -use primitives::v2::{ +use primitives::{ AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CommittedCandidateReceipt, CoreState, GroupRotationInfo, Hash as HashT, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, @@ -670,7 +670,7 @@ pub mod pallet_test_notifier { construct_runtime! { pub enum Runtime where Block = Block, - NodeBlock = primitives::v2::Block, + NodeBlock = primitives::Block, UncheckedExtrinsic = UncheckedExtrinsic { // Basic stuff; balances is uncallable initially. @@ -856,7 +856,7 @@ sp_api::impl_runtime_apis! { fn check_validation_outputs( para_id: ParaId, - outputs: primitives::v2::CandidateCommitments, + outputs: primitives::CandidateCommitments, ) -> bool { runtime_impl::check_validation_outputs::(para_id, outputs) } @@ -904,8 +904,8 @@ sp_api::impl_runtime_apis! { } fn submit_pvf_check_statement( - stmt: primitives::v2::PvfCheckStatement, - signature: primitives::v2::ValidatorSignature, + stmt: primitives::PvfCheckStatement, + signature: primitives::ValidatorSignature, ) { runtime_impl::submit_pvf_check_statement::(stmt, signature) } diff --git a/runtime/westend/Cargo.toml b/runtime/westend/Cargo.toml index 76f45bd5306e..024a8f3e89c0 100644 --- a/runtime/westend/Cargo.toml +++ b/runtime/westend/Cargo.toml @@ -65,6 +65,7 @@ pallet-session = { git = "https://github.com/paritytech/substrate", branch = "ma pallet-society = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-staking-reward-curve = { package = "pallet-staking-reward-curve", git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-state-trie-migration = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-sudo = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } @@ -155,6 +156,7 @@ std = [ "pallet-session/std", "pallet-society/std", "pallet-staking/std", + "pallet-state-trie-migration/std", "pallet-sudo/std", "pallet-timestamp/std", "pallet-treasury/std", @@ -255,6 +257,7 @@ try-runtime = [ "pallet-session/try-runtime", "pallet-society/try-runtime", "pallet-staking/try-runtime", + "pallet-state-trie-migration/try-runtime", "pallet-sudo/try-runtime", "pallet-timestamp/try-runtime", "pallet-treasury/try-runtime", diff --git a/runtime/westend/constants/src/lib.rs b/runtime/westend/constants/src/lib.rs index d3fa1c501c3e..e7d1a627713f 100644 --- a/runtime/westend/constants/src/lib.rs +++ b/runtime/westend/constants/src/lib.rs @@ -20,7 +20,7 @@ pub mod weights; /// Money matters. pub mod currency { - use primitives::v2::Balance; + use primitives::Balance; /// The existential deposit. pub const EXISTENTIAL_DEPOSIT: Balance = 1 * CENTS; @@ -37,7 +37,7 @@ pub mod currency { /// Time and blocks. pub mod time { - use primitives::v2::{BlockNumber, Moment}; + use primitives::{BlockNumber, Moment}; use runtime_common::prod_or_fast; pub const MILLISECS_PER_BLOCK: Moment = 6000; @@ -62,7 +62,7 @@ pub mod fee { use frame_support::weights::{ WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }; - use primitives::v2::Balance; + use primitives::Balance; use smallvec::smallvec; pub use sp_runtime::Perbill; diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index b10f76a2700d..ac1b82637941 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -35,7 +35,7 @@ use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use pallet_session::historical as session_historical; use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, RuntimeDispatchInfo}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use primitives::v2::{ +use primitives::{ AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, @@ -116,7 +116,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { #[cfg(feature = "disable-runtime-api")] apis: sp_version::create_apis_vec![[]], transaction_version: 15, - state_version: 0, + state_version: 1, }; /// The BABE epoch configuration at genesis. @@ -1085,10 +1085,30 @@ impl pallet_nomination_pools::Config for Runtime { type MaxPointsToBalance = MaxPointsToBalance; } +parameter_types! { + // The deposit configuration for the singed migration. Specially if you want to allow any signed account to do the migration (see `SignedFilter`, these deposits should be high) + pub const MigrationSignedDepositPerItem: Balance = 1 * CENTS; + pub const MigrationSignedDepositBase: Balance = 20 * CENTS * 100; + pub const MigrationMaxKeyLen: u32 = 512; +} + +impl pallet_state_trie_migration::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type SignedDepositPerItem = MigrationSignedDepositPerItem; + type SignedDepositBase = MigrationSignedDepositBase; + type ControlOrigin = EnsureRoot; + type SignedFilter = frame_support::traits::NeverEnsureOrigin; + + // Use same weights as substrate ones. + type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight; + type MaxKeyLen = MigrationMaxKeyLen; +} + construct_runtime! { pub enum Runtime where Block = Block, - NodeBlock = primitives::v2::Block, + NodeBlock = primitives::Block, UncheckedExtrinsic = UncheckedExtrinsic { // Basic stuff; balances is uncallable initially. @@ -1153,6 +1173,9 @@ construct_runtime! { // Fast unstake pallet: extension to staking. FastUnstake: pallet_fast_unstake = 30, + // State trie migration pallet, only temporary. + StateTrieMigration: pallet_state_trie_migration = 35, + // Parachains pallets. Start indices at 40 to leave room. ParachainsOrigin: parachains_origin::{Pallet, Origin} = 41, Configuration: parachains_configuration::{Pallet, Call, Storage, Config} = 42, @@ -1215,12 +1238,15 @@ impl Get<&'static str> for StakingMigrationV11OldPallet { /// /// Should be cleared after every release. pub type Migrations = ( + pallet_balances::migration::ResetInactive, + // We need to apply this migration again, because `ResetInactive` resets the state again. pallet_balances::migration::MigrateToTrackInactive, - crowdloan::migration::MigrateToTrackInactive, + crowdloan::migration::MigrateToTrackInactiveV2, pallet_scheduler::migration::v4::CleanupAgendas, pallet_staking::migrations::v13::MigrateToV13, parachains_disputes::migration::v1::MigrateToV1, parachains_configuration::migration::v4::MigrateToV4, + init_state_migration::InitMigrate, ); /// Unchecked extrinsic type as expected by this runtime. @@ -1379,7 +1405,7 @@ sp_api::impl_runtime_apis! { fn check_validation_outputs( para_id: ParaId, - outputs: primitives::v2::CandidateCommitments, + outputs: primitives::CandidateCommitments, ) -> bool { parachains_runtime_api_impl::check_validation_outputs::(para_id, outputs) } @@ -1841,3 +1867,46 @@ mod remote_tests { ext.execute_with(|| Runtime::on_runtime_upgrade(true)); } } + +mod init_state_migration { + use super::Runtime; + use frame_support::traits::OnRuntimeUpgrade; + use pallet_state_trie_migration::{AutoLimits, MigrationLimits, MigrationProcess}; + #[cfg(not(feature = "std"))] + use sp_std::prelude::*; + + /// Initialize an automatic migration process. + pub struct InitMigrate; + impl OnRuntimeUpgrade for InitMigrate { + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, &'static str> { + frame_support::ensure!( + AutoLimits::::get().is_none(), + "Automigration already started." + ); + Ok(Default::default()) + } + + fn on_runtime_upgrade() -> frame_support::weights::Weight { + if MigrationProcess::::get() == Default::default() && + AutoLimits::::get().is_none() + { + AutoLimits::::put(Some(MigrationLimits { item: 160, size: 204800 })); + log::info!("Automatic trie migration started."); + ::DbWeight::get().reads_writes(2, 1) + } else { + log::info!("Automatic trie migration not started."); + ::DbWeight::get().reads(2) + } + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(_state: Vec) -> Result<(), &'static str> { + frame_support::ensure!( + AutoLimits::::get().is_some(), + "Automigration started." + ); + Ok(()) + } + } +} diff --git a/scripts/ci/gitlab/pipeline/publish.yml b/scripts/ci/gitlab/pipeline/publish.yml index 3484fcae336e..ed6c991c2f63 100644 --- a/scripts/ci/gitlab/pipeline/publish.yml +++ b/scripts/ci/gitlab/pipeline/publish.yml @@ -214,3 +214,38 @@ publish-rustdoc: - echo "___Rustdoc was successfully published to https://paritytech.github.io/polkadot/___" after_script: - rm -rf .git/ ./* + +.update-substrate-template-repository: + stage: publish + extends: .kubernetes-env + variables: + GIT_STRATEGY: none + rules: + # The template is only updated for FINAL releases + # i.e. the rule should not cover RC or patch releases + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+$/ # e.g. v1.0 + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/ # e.g. v1.0.0 + script: + - git clone --depth=1 --branch="$PIPELINE_SCRIPTS_TAG" https://github.com/paritytech/pipeline-scripts + - export POLKADOT_BRANCH="polkadot-v$CI_COMMIT_TAG" + - git clone --depth=1 --branch="$POLKADOT_BRANCH" https://github.com/paritytech/substrate + - cd substrate + - ../pipeline-scripts/update_substrate_template.sh + --repo-name "$TARGET_REPOSITORY" + --template-path "$TEMPLATE_PATH" + --github-api-token "$GITHUB_TOKEN" + --polkadot-branch "$POLKADOT_BRANCH" + +# Ref: https://github.com/paritytech/opstooling/issues/111 +update-node-template: + extends: .update-substrate-template-repository + variables: + TARGET_REPOSITORY: substrate-node-template + TEMPLATE_PATH: bin/node-template + +# Ref: https://github.com/paritytech/opstooling/issues/111 +update-parachain-template: + extends: .update-substrate-template-repository + variables: + TARGET_REPOSITORY: substrate-parachain-template + TEMPLATE_PATH: parachain-template diff --git a/scripts/ci/gitlab/pipeline/weights.yml b/scripts/ci/gitlab/pipeline/weights.yml index 38b223ce57ab..ed2e2594b432 100644 --- a/scripts/ci/gitlab/pipeline/weights.yml +++ b/scripts/ci/gitlab/pipeline/weights.yml @@ -2,6 +2,11 @@ # Here are all jobs that are executed during "weights" stage update_polkadot_weights: &update-weights + # The update-weights pipeline defaults to `interruptible: false` so that we'll be able to + # reach and run the benchmarking jobs despite the "Auto-cancel redundant pipelines" CI setting. + # The setting is relevant because future pipelines (e.g. created for new commits or other schedules) + # might otherwise cancel the benchmark jobs early. + interruptible: false stage: weights timeout: 1d when: manual diff --git a/statement-table/src/generic.rs b/statement-table/src/generic.rs index d899c54d1d53..c33151d5c156 100644 --- a/statement-table/src/generic.rs +++ b/statement-table/src/generic.rs @@ -30,7 +30,7 @@ use std::{ hash::Hash, }; -use primitives::v2::{ValidatorSignature, ValidityAttestation as PrimitiveValidityAttestation}; +use primitives::{ValidatorSignature, ValidityAttestation as PrimitiveValidityAttestation}; use parity_scale_codec::{Decode, Encode}; diff --git a/statement-table/src/lib.rs b/statement-table/src/lib.rs index a3fbbb1fdaaa..ba4d1a1163bf 100644 --- a/statement-table/src/lib.rs +++ b/statement-table/src/lib.rs @@ -21,7 +21,7 @@ pub use generic::{Context, Table}; /// Concrete instantiations suitable for v2 primitives. pub mod v2 { use crate::generic; - use primitives::v2::{ + use primitives::{ CandidateHash, CommittedCandidateReceipt, CompactStatement as PrimitiveStatement, Id, ValidatorIndex, ValidatorSignature, };