diff --git a/Cargo.lock b/Cargo.lock index e15695252b..0f51b4f39e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2464,9 +2464,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2626afccd7561a06cf1367e2950c4718ea04565e20fb5029b6c7d8ad09abcf" +checksum = "21e50f3adc76d6a43f5ed73b698a87d0760ca74617f60f7c3b879003536fdd28" [[package]] name = "ecdsa" @@ -6835,9 +6835,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.1.0" +version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8483b84fb12de1dc23bf95d26030d16cea56391d136db0db37f749508104e3e6" +checksum = "e8b44461635bbb1a0300f100a841e571e7d919c81c73075ef5d152ffdb521066" dependencies = [ "arrayvec 0.7.2", "bitvec", @@ -6849,9 +6849,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.1.0" +version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7259388ceb4c23bc09caef272c9e7a732b3b8f9fbd0b41f0009a91d6548cc1d9" +checksum = "c45ed1f39709f5a89338fab50e59816b2e8815f5bb58276e7ddf9afd495f73f8" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -11992,9 +11992,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.87" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e59d925cf59d8151f25a3bedf97c9c157597c9df7324d32d68991cc399ed08b" +checksum = "ea297be220d52398dcc07ce15a209fce436d361735ac1db700cab3b6cdfb9f54" dependencies = [ "proc-macro2", "quote", diff --git a/client/consensus/common/Cargo.toml b/client/consensus/common/Cargo.toml index f243967c24..8cc6e7591a 100644 --- a/client/consensus/common/Cargo.toml +++ b/client/consensus/common/Cargo.toml @@ -10,7 +10,7 @@ futures = { version = "0.3.8", features = ["compat"] } codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive" ] } tracing = "0.1.32" async-trait = "0.1.52" -dyn-clone = "1.0.4" +dyn-clone = "1.0.5" # Substrate sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/client/relay-chain-interface/Cargo.toml b/client/relay-chain-interface/Cargo.toml index 8725e8c28b..9403e89e79 100644 --- a/client/relay-chain-interface/Cargo.toml +++ b/client/relay-chain-interface/Cargo.toml @@ -24,4 +24,4 @@ derive_more = "0.99.2" async-trait = "0.1.52" thiserror = "1.0.30" jsonrpsee-core = "0.9.0" -parity-scale-codec = "3.0.0" +parity-scale-codec = "3.1.2" diff --git a/client/relay-chain-rpc-interface/Cargo.toml b/client/relay-chain-rpc-interface/Cargo.toml index 1b9e038c0b..295b84e866 100644 --- a/client/relay-chain-rpc-interface/Cargo.toml +++ b/client/relay-chain-rpc-interface/Cargo.toml @@ -21,7 +21,7 @@ sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "master futures = "0.3.21" futures-timer = "3.0.2" -parity-scale-codec = "3.0.0" +parity-scale-codec = "3.1.2" parking_lot = "0.12.0" jsonrpsee = { version = "0.9.0", features = ["client"] } tracing = "0.1.32" diff --git a/pallets/collator-selection/src/lib.rs b/pallets/collator-selection/src/lib.rs index 53a619442b..fab70a3d0d 100644 --- a/pallets/collator-selection/src/lib.rs +++ b/pallets/collator-selection/src/lib.rs @@ -368,7 +368,7 @@ pub mod pallet { let current_count = >::try_mutate(|candidates| -> Result { - if candidates.into_iter().any(|candidate| candidate.who == who) { + if candidates.iter().any(|candidate| candidate.who == who) { Err(Error::::AlreadyCandidate)? } else { T::Currency::reserve(&who, deposit)?; @@ -409,6 +409,7 @@ pub mod pallet { pub fn account_id() -> T::AccountId { T::PotId::get().into_account() } + /// Removes a candidate if they exist and sends them back their deposit fn try_remove_candidate(who: &T::AccountId) -> Result { let current_count = @@ -417,8 +418,8 @@ pub mod pallet { .iter() .position(|candidate| candidate.who == *who) .ok_or(Error::::NotCandidate)?; - T::Currency::unreserve(&who, candidates[index].deposit); - candidates.remove(index); + let candidate = candidates.remove(index); + T::Currency::unreserve(who, candidate.deposit); >::remove(who.clone()); Ok(candidates.len()) })?; @@ -431,16 +432,18 @@ pub mod pallet { /// This is done on the fly, as frequent as we are told to do so, as the session manager. pub fn assemble_collators(candidates: Vec) -> Vec { let mut collators = Self::invulnerables(); - collators.extend(candidates.into_iter().collect::>()); + collators.extend(candidates); collators } - /// Kicks out and candidates that did not produce a block in the kick threshold. + + /// Kicks out candidates that did not produce a block in the kick threshold + /// and refund their deposits. pub fn kick_stale_candidates( candidates: Vec>>, ) -> Vec { let now = frame_system::Pallet::::block_number(); let kick_threshold = T::KickThreshold::get(); - let new_candidates = candidates + candidates .into_iter() .filter_map(|c| { let last_block = >::get(c.who.clone()); @@ -458,8 +461,7 @@ pub mod pallet { None } }) - .collect::>(); - new_candidates + .collect() } } @@ -503,9 +505,8 @@ pub mod pallet { let candidates = Self::candidates(); let candidates_len_before = candidates.len(); let active_candidates = Self::kick_stale_candidates(candidates); - let active_candidates_len = active_candidates.len(); + let removed = candidates_len_before - active_candidates.len(); let result = Self::assemble_collators(active_candidates); - let removed = candidates_len_before - active_candidates_len; frame_system::Pallet::::register_extra_weight_unchecked( T::WeightInfo::new_session(candidates_len_before as u32, removed as u32), diff --git a/pallets/parachain-system/proc-macro/Cargo.toml b/pallets/parachain-system/proc-macro/Cargo.toml index c016a2531b..89cd7c662e 100644 --- a/pallets/parachain-system/proc-macro/Cargo.toml +++ b/pallets/parachain-system/proc-macro/Cargo.toml @@ -9,7 +9,7 @@ description = "Proc macros provided by the parachain-system pallet" proc-macro = true [dependencies] -syn = "1.0.81" +syn = "1.0.89" proc-macro2 = "1.0.36" quote = "1.0.9" proc-macro-crate = "1.1.3" diff --git a/pallets/parachain-system/src/lib.rs b/pallets/parachain-system/src/lib.rs index 91c646ae92..c327f29b99 100644 --- a/pallets/parachain-system/src/lib.rs +++ b/pallets/parachain-system/src/lib.rs @@ -310,7 +310,7 @@ pub mod pallet { let relay_state_proof = RelayChainStateProof::new( T::SelfParaId::get(), vfp.relay_parent_storage_root, - relay_chain_state, + relay_chain_state.clone(), ) .expect("Invalid relay chain state proof"); @@ -352,6 +352,7 @@ pub mod pallet { .expect("Invalid messaging state in relay chain state proof"); >::put(&vfp); + >::put(relay_chain_state); >::put(relevant_messaging_state.clone()); >::put(host_config); @@ -484,6 +485,16 @@ pub mod pallet { pub(super) type UpgradeRestrictionSignal = StorageValue<_, Option, ValueQuery>; + /// The state proof for the last relay parent block. + /// + /// This field is meant to be updated each block with the validation data inherent. Therefore, + /// before processing of the inherent, e.g. in `on_initialize` this data may be stale. + /// + /// This data is also absent from the genesis. + #[pallet::storage] + #[pallet::getter(fn relay_state_proof)] + pub(super) type RelayStateProof = StorageValue<_, sp_trie::StorageProof>; + /// The snapshot of some state related to messaging relevant to the current parachain as per /// the relay parent. /// diff --git a/pallets/session-benchmarking/Cargo.toml b/pallets/session-benchmarking/Cargo.toml index 70bb01b3c0..ba0f8cf441 100644 --- a/pallets/session-benchmarking/Cargo.toml +++ b/pallets/session-benchmarking/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -parity-scale-codec = { version = "3.0.0", default-features = false } +parity-scale-codec = { version = "3.1.2", default-features = false } sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/pallets/xcmp-queue/src/lib.rs b/pallets/xcmp-queue/src/lib.rs index f7e52a6756..0bdd385282 100644 --- a/pallets/xcmp-queue/src/lib.rs +++ b/pallets/xcmp-queue/src/lib.rs @@ -575,9 +575,7 @@ impl Pallet { let mut shuffled = (0..len).collect::>(); for i in 0..len { let j = (rng.next_u32() as usize) % len; - let a = shuffled[i]; - shuffled[i] = shuffled[j]; - shuffled[j] = a; + shuffled.as_mut_slice().swap(i, j); } shuffled } diff --git a/primitives/parachain-inherent/src/client_side.rs b/primitives/parachain-inherent/src/client_side.rs index 99c27bc824..000094f070 100644 --- a/primitives/parachain-inherent/src/client_side.rs +++ b/primitives/parachain-inherent/src/client_side.rs @@ -93,6 +93,9 @@ async fn collect_relay_storage_proof( .unwrap_or_default(); let mut relevant_keys = Vec::new(); + relevant_keys.push(relay_well_known_keys::CURRENT_BLOCK_RANDOMNESS.to_vec()); + relevant_keys.push(relay_well_known_keys::ONE_EPOCH_AGO_RANDOMNESS.to_vec()); + relevant_keys.push(relay_well_known_keys::TWO_EPOCHS_AGO_RANDOMNESS.to_vec()); relevant_keys.push(relay_well_known_keys::CURRENT_SLOT.to_vec()); relevant_keys.push(relay_well_known_keys::ACTIVE_CONFIG.to_vec()); relevant_keys.push(relay_well_known_keys::dmq_mqc_head(para_id)); diff --git a/scripts/benchmarks.sh b/scripts/benchmarks.sh index 5ca8d4d460..9bf416a1bd 100755 --- a/scripts/benchmarks.sh +++ b/scripts/benchmarks.sh @@ -35,7 +35,7 @@ do --extrinsic='*' \ --steps=$steps \ --repeat=$repeat \ - --json \ + --json-file=./bench-statemine.json \ --header=./file_header.txt \ --output=$statemineOutput @@ -47,7 +47,7 @@ do --extrinsic='*' \ --steps=$steps \ --repeat=$repeat \ - --json \ + --json-file=./bench-statemint.json \ --header=./file_header.txt \ --output=$statemintOutput @@ -59,7 +59,7 @@ do --extrinsic='*' \ --steps=$steps \ --repeat=$repeat \ - --json \ + --json-file=./bench-westmint.json \ --header=./file_header.txt \ --output=$westmintOutput done