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

Commit

Permalink
Merge branch 'master' into davxy-companion-for-11022
Browse files Browse the repository at this point in the history
  • Loading branch information
davxy committed Mar 23, 2022
2 parents 34d7ce6 + 2fe7a2e commit b75e4ed
Show file tree
Hide file tree
Showing 29 changed files with 86 additions and 71 deletions.
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/consensus/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion client/relay-chain-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion client/relay-chain-rpc-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pallets/collator-selection/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ version = "3.0.0"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
log = { version = "0.4.0", default-features = false }
log = { version = "0.4.16", default-features = false }
codec = { default-features = false, features = ["derive"], package = "parity-scale-codec", version = "3.0.0" }
rand = { version = "0.8.5", features = ["std_rng"], default-features = false }
scale-info = { version = "2.0.0", default-features = false, features = ["derive"] }
Expand Down
21 changes: 11 additions & 10 deletions pallets/collator-selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ pub mod pallet {

let current_count =
<Candidates<T>>::try_mutate(|candidates| -> Result<usize, DispatchError> {
if candidates.into_iter().any(|candidate| candidate.who == who) {
if candidates.iter().any(|candidate| candidate.who == who) {
Err(Error::<T>::AlreadyCandidate)?
} else {
T::Currency::reserve(&who, deposit)?;
Expand Down Expand Up @@ -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<usize, DispatchError> {
let current_count =
Expand All @@ -417,8 +418,8 @@ pub mod pallet {
.iter()
.position(|candidate| candidate.who == *who)
.ok_or(Error::<T>::NotCandidate)?;
T::Currency::unreserve(&who, candidates[index].deposit);
candidates.remove(index);
let candidate = candidates.remove(index);
T::Currency::unreserve(who, candidate.deposit);
<LastAuthoredBlock<T>>::remove(who.clone());
Ok(candidates.len())
})?;
Expand All @@ -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<T::AccountId>) -> Vec<T::AccountId> {
let mut collators = Self::invulnerables();
collators.extend(candidates.into_iter().collect::<Vec<_>>());
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<CandidateInfo<T::AccountId, BalanceOf<T>>>,
) -> Vec<T::AccountId> {
let now = frame_system::Pallet::<T>::block_number();
let kick_threshold = T::KickThreshold::get();
let new_candidates = candidates
candidates
.into_iter()
.filter_map(|c| {
let last_block = <LastAuthoredBlock<T>>::get(c.who.clone());
Expand All @@ -458,8 +461,7 @@ pub mod pallet {
None
}
})
.collect::<Vec<_>>();
new_candidates
.collect()
}
}

Expand Down Expand Up @@ -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::<T>::register_extra_weight_unchecked(
T::WeightInfo::new_session(candidates_len_before as u32, removed as u32),
Expand Down
2 changes: 1 addition & 1 deletion pallets/dmp-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive" ], default-features = false }
log = { version = "0.4.14", default-features = false }
log = { version = "0.4.16", default-features = false }
scale-info = { version = "2.0.0", default-features = false, features = ["derive"] }

# Substrate
Expand Down
2 changes: 1 addition & 1 deletion pallets/parachain-system/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "Base pallet for cumulus-based parachains"
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
environmental = { version = "1.1.2", default-features = false }
impl-trait-for-tuples = "0.2.1"
log = { version = "0.4.14", default-features = false }
log = { version = "0.4.16", default-features = false }
scale-info = { version = "2.0.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.132", optional = true, features = ["derive"] }

Expand Down
4 changes: 2 additions & 2 deletions pallets/parachain-system/proc-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ 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"
quote = "1.0.16"
proc-macro-crate = "1.1.3"

[features]
Expand Down
13 changes: 12 additions & 1 deletion pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -352,6 +352,7 @@ pub mod pallet {
.expect("Invalid messaging state in relay chain state proof");

<ValidationData<T>>::put(&vfp);
<RelayStateProof<T>>::put(relay_chain_state);
<RelevantMessagingState<T>>::put(relevant_messaging_state.clone());
<HostConfiguration<T>>::put(host_config);

Expand Down Expand Up @@ -484,6 +485,16 @@ pub mod pallet {
pub(super) type UpgradeRestrictionSignal<T: Config> =
StorageValue<_, Option<relay_chain::v2::UpgradeRestriction>, 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<T: Config> = StorageValue<_, sp_trie::StorageProof>;

/// The snapshot of some state related to messaging relevant to the current parachain as per
/// the relay parent.
///
Expand Down
2 changes: 1 addition & 1 deletion pallets/session-benchmarking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion pallets/xcmp-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive" ], default-features = false }
log = { version = "0.4.14", default-features = false }
log = { version = "0.4.16", default-features = false }
rand_chacha = { version = "0.3.0", default-features = false }
scale-info = { version = "2.0.0", default-features = false, features = ["derive"] }

Expand Down
38 changes: 19 additions & 19 deletions pallets/xcmp-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,13 +495,15 @@ impl<T: Config> Pallet<T> {
}

let mut s = <OutboundXcmpStatus<T>>::get();
let index = s.iter().position(|item| item.recipient == recipient).unwrap_or_else(|| {
let details = if let Some(details) = s.iter_mut().find(|item| item.recipient == recipient) {
details
} else {
s.push(OutboundChannelDetails::new(recipient));
s.len() - 1
});
let have_active = s[index].last_index > s[index].first_index;
s.last_mut().expect("can't be empty; a new element was just pushed; qed")
};
let have_active = details.last_index > details.first_index;
let appended = have_active &&
<OutboundXcmpMessages<T>>::mutate(recipient, s[index].last_index - 1, |s| {
<OutboundXcmpMessages<T>>::mutate(recipient, details.last_index - 1, |s| {
if XcmpMessageFormat::decode_with_depth_limit(MAX_XCM_DECODE_DEPTH, &mut &s[..]) !=
Ok(format)
{
Expand All @@ -514,15 +516,15 @@ impl<T: Config> Pallet<T> {
return true
});
if appended {
Ok((s[index].last_index - s[index].first_index - 1) as u32)
Ok((details.last_index - details.first_index - 1) as u32)
} else {
// Need to add a new page.
let page_index = s[index].last_index;
s[index].last_index += 1;
let page_index = details.last_index;
details.last_index += 1;
let mut new_page = format.encode();
new_page.extend_from_slice(&data[..]);
<OutboundXcmpMessages<T>>::insert(recipient, page_index, new_page);
let r = (s[index].last_index - s[index].first_index - 1) as u32;
let r = (details.last_index - details.first_index - 1) as u32;
<OutboundXcmpStatus<T>>::put(s);
Ok(r)
}
Expand All @@ -532,8 +534,8 @@ impl<T: Config> Pallet<T> {
/// block.
fn send_signal(dest: ParaId, signal: ChannelSignal) -> Result<(), ()> {
let mut s = <OutboundXcmpStatus<T>>::get();
if let Some(index) = s.iter().position(|item| item.recipient == dest) {
s[index].signals_exist = true;
if let Some(details) = s.iter_mut().find(|item| item.recipient == dest) {
details.signals_exist = true;
} else {
s.push(OutboundChannelDetails::new(dest).with_signals());
}
Expand Down Expand Up @@ -571,9 +573,7 @@ impl<T: Config> Pallet<T> {
let mut shuffled = (0..len).collect::<Vec<_>>();
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
}
Expand All @@ -600,7 +600,7 @@ impl<T: Config> Pallet<T> {
Ok(xcm) => {
let location = (1, Parachain(sender.into()));
match T::XcmExecutor::execute_xcm(location, xcm, max_weight) {
Outcome::Error(e) => (Err(e.clone()), Event::Fail(Some(hash), e)),
Outcome::Error(e) => (Err(e), Event::Fail(Some(hash), e)),
Outcome::Complete(w) => (Ok(w), Event::Success(Some(hash))),
// As far as the caller is concerned, this was dispatched without error, so
// we just report the weight used.
Expand Down Expand Up @@ -750,7 +750,7 @@ impl<T: Config> Pallet<T> {
let suspended = QueueSuspended::<T>::get();

let mut status = <InboundXcmpStatus<T>>::get(); // <- sorted.
if status.len() == 0 {
if status.is_empty() {
return 0
}

Expand Down Expand Up @@ -859,10 +859,10 @@ impl<T: Config> Pallet<T> {

fn suspend_channel(target: ParaId) {
<OutboundXcmpStatus<T>>::mutate(|s| {
if let Some(index) = s.iter().position(|item| item.recipient == target) {
let ok = s[index].state == OutboundState::Ok;
if let Some(details) = s.iter_mut().find(|item| item.recipient == target) {
let ok = details.state == OutboundState::Ok;
debug_assert!(ok, "WARNING: Attempt to suspend channel that was not Ok.");
s[index].state = OutboundState::Suspended;
details.state = OutboundState::Suspended;
} else {
s.push(OutboundChannelDetails::new(target).with_suspended_state());
}
Expand Down
2 changes: 1 addition & 1 deletion parachain-template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ path = "src/main.rs"
[dependencies]
clap = { version = "3.1", features = ["derive"] }
derive_more = "0.99.2"
log = "0.4.14"
log = "0.4.16"
codec = { package = "parity-scale-codec", version = "3.0.0" }
serde = { version = "1.0.132", features = ["derive"] }
hex-literal = "0.3.4"
Expand Down
2 changes: 1 addition & 1 deletion parachain-template/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", bran
[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
hex-literal = { version = "0.3.4", optional = true }
log = { version = "0.4.14", default-features = false }
log = { version = "0.4.16", default-features = false }
scale-info = { version = "2.0.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.132", optional = true, features = ["derive"] }
smallvec = "1.6.1"
Expand Down
4 changes: 2 additions & 2 deletions polkadot-parachains/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-collator"
version = "5.2.0"
version = "5.3.0"
authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs"
edition = "2021"
Expand All @@ -15,7 +15,7 @@ clap = { version = "3.1", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.0.0" }
futures = { version = "0.3.1", features = ["compat"] }
hex-literal = "0.3.4"
log = "0.4.8"
log = "0.4.16"
serde = { version = "1.0.132", features = ["derive"] }

# Local
Expand Down
Loading

0 comments on commit b75e4ed

Please sign in to comment.