style: Migrate to stable-only rustfmt configuration
- Remove nightly-only features from .rustfmt.toml and vendor/ss58-registry/rustfmt.toml - Removed features: imports_granularity, wrap_comments, comment_width, reorder_impl_items, spaces_around_ranges, binop_separator, match_arm_blocks, trailing_semicolon, trailing_comma - Format all 898 affected files with stable rustfmt - Ensures long-term reliability without nightly toolchain dependency
This commit is contained in:
@@ -363,8 +363,8 @@ pub mod pezpallet {
|
||||
lease_count: 0,
|
||||
};
|
||||
|
||||
if lease_period_start == SlotLeasePeriodStart::Current &&
|
||||
ActiveTemporarySlotCount::<T>::get() < T::MaxTemporarySlotPerLeasePeriod::get()
|
||||
if lease_period_start == SlotLeasePeriodStart::Current
|
||||
&& ActiveTemporarySlotCount::<T>::get() < T::MaxTemporarySlotPerLeasePeriod::get()
|
||||
{
|
||||
// Try to allocate slot directly
|
||||
match Self::configure_slot_lease(
|
||||
@@ -520,8 +520,8 @@ impl<T: Config> Pezpallet<T> {
|
||||
});
|
||||
|
||||
let mut newly_created_lease = 0u32;
|
||||
if active_temp_slots < T::MaxTemporarySlotPerLeasePeriod::get() &&
|
||||
!pending_temp_slots.is_empty()
|
||||
if active_temp_slots < T::MaxTemporarySlotPerLeasePeriod::get()
|
||||
&& !pending_temp_slots.is_empty()
|
||||
{
|
||||
// Sort by lease_count, favoring slots that had no or less turns first
|
||||
// (then by last_lease index, and then Para ID)
|
||||
@@ -625,8 +625,8 @@ impl<T: Config> Pezpallet<T> {
|
||||
err
|
||||
);
|
||||
}
|
||||
<T as slots::Config>::WeightInfo::force_lease() *
|
||||
(T::MaxTemporarySlotPerLeasePeriod::get() as u64)
|
||||
<T as slots::Config>::WeightInfo::force_lease()
|
||||
* (T::MaxTemporarySlotPerLeasePeriod::get() as u64)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -494,8 +494,8 @@ impl<T: Config> Pezpallet<T> {
|
||||
let mut outgoing_winner = Some((bidder.clone(), para, amount));
|
||||
swap(&mut current_winning[range_index], &mut outgoing_winner);
|
||||
if let Some((who, para, _amount)) = outgoing_winner {
|
||||
if auction_status.is_starting() &&
|
||||
current_winning
|
||||
if auction_status.is_starting()
|
||||
&& current_winning
|
||||
.iter()
|
||||
.filter_map(Option::as_ref)
|
||||
.all(|&(ref other, other_para, _)| other != &who || other_para != para)
|
||||
@@ -545,8 +545,8 @@ impl<T: Config> Pezpallet<T> {
|
||||
&mut raw_offset.as_ref(),
|
||||
)
|
||||
.expect("secure hashes should always be bigger than the block number; qed");
|
||||
let offset = (raw_offset_block_number % ending_period) /
|
||||
T::SampleLength::get().max(One::one());
|
||||
let offset = (raw_offset_block_number % ending_period)
|
||||
/ T::SampleLength::get().max(One::one());
|
||||
|
||||
let auction_counter = AuctionCounter::<T>::get();
|
||||
Self::deposit_event(Event::<T>::WinningOffset {
|
||||
@@ -594,9 +594,9 @@ impl<T: Config> Pezpallet<T> {
|
||||
let period_count = LeasePeriodOf::<T>::from(range.len() as u32);
|
||||
|
||||
match T::Leaser::lease_out(para, &leaser, amount, period_begin, period_count) {
|
||||
Err(LeaseError::ReserveFailed) |
|
||||
Err(LeaseError::AlreadyEnded) |
|
||||
Err(LeaseError::NoLeasePeriod) => {
|
||||
Err(LeaseError::ReserveFailed)
|
||||
| Err(LeaseError::AlreadyEnded)
|
||||
| Err(LeaseError::NoLeasePeriod) => {
|
||||
// Should never happen since we just unreserved this amount (and our offset is
|
||||
// from the present period). But if it does, there's not much we can do.
|
||||
},
|
||||
|
||||
@@ -107,14 +107,16 @@ impl StatementKind {
|
||||
/// Convert this to the (English) statement it represents.
|
||||
fn to_text(self) -> &'static [u8] {
|
||||
match self {
|
||||
StatementKind::Regular =>
|
||||
StatementKind::Regular => {
|
||||
&b"I hereby agree to the terms of the statement whose SHA-256 multihash is \
|
||||
Qmc1XYqT6S39WNp2UeiRUrZichUWUPpGEThDE6dAb3f6Ny. (This may be found at the URL: \
|
||||
https://statement.polkadot.network/regular.html)"[..],
|
||||
StatementKind::Saft =>
|
||||
https://statement.polkadot.network/regular.html)"[..]
|
||||
},
|
||||
StatementKind::Saft => {
|
||||
&b"I hereby agree to the terms of the statement whose SHA-256 multihash is \
|
||||
QmXEkMahfhHJPzT3RjkXiZVFi77ZeVeuxtAjhojGRNYckz. (This may be found at the URL: \
|
||||
https://statement.polkadot.network/saft.html)"[..],
|
||||
https://statement.polkadot.network/saft.html)"[..]
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,13 +178,15 @@ impl TryConvert<VersionedLocatableAsset, xcm_builder::LocatableAssetId>
|
||||
asset_id: v4_asset_id.try_into().map_err(|_| asset.clone())?,
|
||||
})
|
||||
},
|
||||
VersionedLocatableAsset::V4 { ref location, ref asset_id } =>
|
||||
VersionedLocatableAsset::V4 { ref location, ref asset_id } => {
|
||||
Ok(xcm_builder::LocatableAssetId {
|
||||
location: location.clone().try_into().map_err(|_| asset.clone())?,
|
||||
asset_id: asset_id.clone().try_into().map_err(|_| asset.clone())?,
|
||||
}),
|
||||
VersionedLocatableAsset::V5 { location, asset_id } =>
|
||||
Ok(xcm_builder::LocatableAssetId { location, asset_id }),
|
||||
})
|
||||
},
|
||||
VersionedLocatableAsset::V5 { location, asset_id } => {
|
||||
Ok(xcm_builder::LocatableAssetId { location, asset_id })
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -936,8 +936,8 @@ fn basic_swap_works() {
|
||||
// ----------------------------------------- para deposit --- crowdloan
|
||||
let crowdloan_deposit = 100;
|
||||
let para_id_deposit = <Test as paras_registrar::Config>::ParaDeposit::get();
|
||||
let code_deposit = configuration::ActiveConfig::<Test>::get().max_code_size *
|
||||
<Test as paras_registrar::Config>::DataDepositPerByte::get();
|
||||
let code_deposit = configuration::ActiveConfig::<Test>::get().max_code_size
|
||||
* <Test as paras_registrar::Config>::DataDepositPerByte::get();
|
||||
|
||||
// Para 2000 has a genesis head size of 10.
|
||||
assert_eq!(
|
||||
|
||||
@@ -163,8 +163,9 @@ impl<T: pezframe_system::Config> Registrar for TestRegistrar<T> {
|
||||
PARATHREADS.with(|x| {
|
||||
let mut parathreads = x.borrow_mut();
|
||||
match parathreads.binary_search(&id) {
|
||||
Ok(_) =>
|
||||
Err(DispatchError::Other("already parathread, so cannot `make_parathread`")),
|
||||
Ok(_) => {
|
||||
Err(DispatchError::Other("already parathread, so cannot `make_parathread`"))
|
||||
},
|
||||
Err(i) => {
|
||||
parathreads.insert(i, id);
|
||||
Ok(())
|
||||
|
||||
@@ -341,16 +341,16 @@ pub mod pezpallet {
|
||||
paras::Pezpallet::<T>::lifecycle(other).ok_or(Error::<T>::NotRegistered)?;
|
||||
// identify which is a lease holding teyrchain and which is a parathread (on-demand
|
||||
// teyrchain)
|
||||
if id_lifecycle == ParaLifecycle::Teyrchain &&
|
||||
other_lifecycle == ParaLifecycle::Parathread
|
||||
if id_lifecycle == ParaLifecycle::Teyrchain
|
||||
&& other_lifecycle == ParaLifecycle::Parathread
|
||||
{
|
||||
Self::do_thread_and_chain_swap(id, other);
|
||||
} else if id_lifecycle == ParaLifecycle::Parathread &&
|
||||
other_lifecycle == ParaLifecycle::Teyrchain
|
||||
} else if id_lifecycle == ParaLifecycle::Parathread
|
||||
&& other_lifecycle == ParaLifecycle::Teyrchain
|
||||
{
|
||||
Self::do_thread_and_chain_swap(other, id);
|
||||
} else if id_lifecycle == ParaLifecycle::Teyrchain &&
|
||||
other_lifecycle == ParaLifecycle::Teyrchain
|
||||
} else if id_lifecycle == ParaLifecycle::Teyrchain
|
||||
&& other_lifecycle == ParaLifecycle::Teyrchain
|
||||
{
|
||||
// If both chains are currently teyrchains, there is nothing funny we
|
||||
// need to do for their lifecycle management, just swap the underlying
|
||||
|
||||
@@ -157,8 +157,9 @@ pub mod pezpallet {
|
||||
let config = configuration::ActiveConfig::<T>::get();
|
||||
dmp::Pezpallet::<T>::queue_downward_message(&config, id, xcm.encode()).map_err(|e| {
|
||||
match e {
|
||||
dmp::QueueDownwardMessageError::ExceedsMaxMessageSize =>
|
||||
Error::<T>::ExceedsMaxMessageSize.into(),
|
||||
dmp::QueueDownwardMessageError::ExceedsMaxMessageSize => {
|
||||
Error::<T>::ExceedsMaxMessageSize.into()
|
||||
},
|
||||
dmp::QueueDownwardMessageError::Unroutable => Error::<T>::Unroutable.into(),
|
||||
}
|
||||
})
|
||||
|
||||
@@ -314,10 +314,11 @@ impl<T: Config> Pezpallet<T> {
|
||||
let mut tracker = alloc::collections::btree_map::BTreeMap::new();
|
||||
Leases::<T>::get(para).into_iter().for_each(|lease| match lease {
|
||||
Some((who, amount)) => match tracker.get(&who) {
|
||||
Some(prev_amount) =>
|
||||
Some(prev_amount) => {
|
||||
if amount > *prev_amount {
|
||||
tracker.insert(who, amount);
|
||||
},
|
||||
}
|
||||
},
|
||||
None => {
|
||||
tracker.insert(who, amount);
|
||||
},
|
||||
@@ -432,12 +433,13 @@ impl<T: Config> Leaser<BlockNumberFor<T>> for Pezpallet<T> {
|
||||
Leases::<T>::get(para)
|
||||
.into_iter()
|
||||
.map(|lease| match lease {
|
||||
Some((who, amount)) =>
|
||||
Some((who, amount)) => {
|
||||
if &who == leaser {
|
||||
amount
|
||||
} else {
|
||||
Zero::zero()
|
||||
},
|
||||
}
|
||||
},
|
||||
None => Zero::zero(),
|
||||
})
|
||||
.max()
|
||||
|
||||
@@ -83,12 +83,13 @@ where
|
||||
maybe_fast_unstake_event
|
||||
})
|
||||
.for_each(|e: pezpallet_fast_unstake::Event<T>| match e {
|
||||
pezpallet_fast_unstake::Event::<T>::Unstaked { result, .. } =>
|
||||
pezpallet_fast_unstake::Event::<T>::Unstaked { result, .. } => {
|
||||
if result.is_ok() {
|
||||
unstaked_ok += 1;
|
||||
} else {
|
||||
unstaked_err += 1
|
||||
},
|
||||
}
|
||||
},
|
||||
pezpallet_fast_unstake::Event::<T>::Slashed { .. } => unstaked_slashed += 1,
|
||||
pezpallet_fast_unstake::Event::<T>::InternalError => unreachable!(),
|
||||
_ => {},
|
||||
|
||||
@@ -65,7 +65,10 @@ pub const HEZ_AIRDROP_ALLOCATION: u128 = 40_000_000 * TYR;
|
||||
// COMPILE-TIME VALIDATION: Ensure allocations sum to 200M genesis supply
|
||||
// ===========================================================================
|
||||
const _: () = assert!(
|
||||
HEZ_FOUNDER_ALLOCATION + HEZ_PRESALE_ALLOCATION + HEZ_TREASURY_ALLOCATION + HEZ_AIRDROP_ALLOCATION
|
||||
HEZ_FOUNDER_ALLOCATION
|
||||
+ HEZ_PRESALE_ALLOCATION
|
||||
+ HEZ_TREASURY_ALLOCATION
|
||||
+ HEZ_AIRDROP_ALLOCATION
|
||||
== 200_000_000 * TYR,
|
||||
"HEZ allocations MUST sum to genesis supply (200M)"
|
||||
);
|
||||
@@ -164,9 +167,9 @@ fn default_teyrchains_host_configuration(
|
||||
allowed_ancestry_len: 0,
|
||||
},
|
||||
node_features: bitvec::vec::BitVec::from_element(
|
||||
(1u8 << (FeatureIndex::ElasticScalingMVP as usize)) |
|
||||
(1u8 << (FeatureIndex::EnableAssignmentsV2 as usize)) |
|
||||
(1u8 << (FeatureIndex::CandidateReceiptV2 as usize)),
|
||||
(1u8 << (FeatureIndex::ElasticScalingMVP as usize))
|
||||
| (1u8 << (FeatureIndex::EnableAssignmentsV2 as usize))
|
||||
| (1u8 << (FeatureIndex::CandidateReceiptV2 as usize)),
|
||||
),
|
||||
scheduler_params: SchedulerParams {
|
||||
lookahead: 3,
|
||||
@@ -189,8 +192,10 @@ fn default_teyrchains_host_configuration_is_consistent() {
|
||||
#[test]
|
||||
fn hez_allocations_sum_to_200m() {
|
||||
// Runtime validation that allocations sum to 200M
|
||||
let total = HEZ_FOUNDER_ALLOCATION + HEZ_PRESALE_ALLOCATION +
|
||||
HEZ_TREASURY_ALLOCATION + HEZ_AIRDROP_ALLOCATION;
|
||||
let total = HEZ_FOUNDER_ALLOCATION
|
||||
+ HEZ_PRESALE_ALLOCATION
|
||||
+ HEZ_TREASURY_ALLOCATION
|
||||
+ HEZ_AIRDROP_ALLOCATION;
|
||||
assert_eq!(total, 200_000_000 * TYR, "HEZ total supply must equal 200M");
|
||||
}
|
||||
|
||||
|
||||
@@ -1025,11 +1025,11 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
|
||||
},
|
||||
ProxyType::Auction => matches!(
|
||||
c,
|
||||
RuntimeCall::Auctions { .. } |
|
||||
RuntimeCall::Crowdloan { .. } |
|
||||
RuntimeCall::Registrar { .. } |
|
||||
RuntimeCall::Multisig(..) |
|
||||
RuntimeCall::Slots { .. }
|
||||
RuntimeCall::Auctions { .. }
|
||||
| RuntimeCall::Crowdloan { .. }
|
||||
| RuntimeCall::Registrar { .. }
|
||||
| RuntimeCall::Multisig(..)
|
||||
| RuntimeCall::Slots { .. }
|
||||
),
|
||||
ProxyType::OnDemandOrdering => matches!(c, RuntimeCall::OnDemandAssignmentProvider(..)),
|
||||
}
|
||||
|
||||
@@ -38,8 +38,9 @@ pub enum AssetTypes {
|
||||
impl From<&Asset> for AssetTypes {
|
||||
fn from(asset: &Asset) -> Self {
|
||||
match asset {
|
||||
Asset { id: AssetId(Location { parents: 0, interior: Here }), .. } =>
|
||||
AssetTypes::Balances,
|
||||
Asset { id: AssetId(Location { parents: 0, interior: Here }), .. } => {
|
||||
AssetTypes::Balances
|
||||
},
|
||||
_ => AssetTypes::Unknown,
|
||||
}
|
||||
}
|
||||
@@ -67,8 +68,9 @@ impl WeighAssets for AssetFilter {
|
||||
// We don't support any NFTs on Pezkuwichain, so these two variants will always match
|
||||
// only 1 kind of fungible asset.
|
||||
Self::Wild(AllOf { .. } | AllOfCounted { .. }) => balances_weight,
|
||||
Self::Wild(AllCounted(count)) =>
|
||||
balances_weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
|
||||
Self::Wild(AllCounted(count)) => {
|
||||
balances_weight.saturating_mul(MAX_ASSETS.min(*count as u64))
|
||||
},
|
||||
Self::Wild(All) => balances_weight.saturating_mul(MAX_ASSETS),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,8 +282,9 @@ impl<T: Config> AssignmentProvider<BlockNumberFor<T>> for Pezpallet<T> {
|
||||
|
||||
match a_type {
|
||||
CoreAssignment::Idle => None,
|
||||
CoreAssignment::Pool =>
|
||||
on_demand::Pezpallet::<T>::pop_assignment_for_core(core_idx),
|
||||
CoreAssignment::Pool => {
|
||||
on_demand::Pezpallet::<T>::pop_assignment_for_core(core_idx)
|
||||
},
|
||||
CoreAssignment::Task(para_id) => Some(Assignment::Bulk((*para_id).into())),
|
||||
}
|
||||
})
|
||||
@@ -291,8 +292,9 @@ impl<T: Config> AssignmentProvider<BlockNumberFor<T>> for Pezpallet<T> {
|
||||
|
||||
fn report_processed(assignment: Assignment) {
|
||||
match assignment {
|
||||
Assignment::Pool { para_id, core_index } =>
|
||||
on_demand::Pezpallet::<T>::report_processed(para_id, core_index),
|
||||
Assignment::Pool { para_id, core_index } => {
|
||||
on_demand::Pezpallet::<T>::report_processed(para_id, core_index)
|
||||
},
|
||||
Assignment::Bulk(_) => {},
|
||||
}
|
||||
}
|
||||
@@ -304,8 +306,9 @@ impl<T: Config> AssignmentProvider<BlockNumberFor<T>> for Pezpallet<T> {
|
||||
/// - `assignment`: The on demand assignment.
|
||||
fn push_back_assignment(assignment: Assignment) {
|
||||
match assignment {
|
||||
Assignment::Pool { para_id, core_index } =>
|
||||
on_demand::Pezpallet::<T>::push_back_assignment(para_id, core_index),
|
||||
Assignment::Pool { para_id, core_index } => {
|
||||
on_demand::Pezpallet::<T>::push_back_assignment(para_id, core_index)
|
||||
},
|
||||
Assignment::Bulk(_) => {
|
||||
// Session changes are rough. We just drop assignments that did not make it on a
|
||||
// session boundary. This seems sensible as bulk is region based. Meaning, even if
|
||||
@@ -325,8 +328,9 @@ impl<T: Config> AssignmentProvider<BlockNumberFor<T>> for Pezpallet<T> {
|
||||
|
||||
fn assignment_duplicated(assignment: &Assignment) {
|
||||
match assignment {
|
||||
Assignment::Pool { para_id, core_index } =>
|
||||
on_demand::Pezpallet::<T>::assignment_duplicated(*para_id, *core_index),
|
||||
Assignment::Pool { para_id, core_index } => {
|
||||
on_demand::Pezpallet::<T>::assignment_duplicated(*para_id, *core_index)
|
||||
},
|
||||
Assignment::Bulk(_) => {},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -837,10 +837,10 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
|
||||
.sum::<usize>()
|
||||
.saturating_sub(self.elastic_paras.len() as usize);
|
||||
|
||||
let used_cores = self.dispute_sessions.len() +
|
||||
self.backed_and_concluding_paras.len() +
|
||||
self.backed_in_inherent_paras.len() +
|
||||
extra_cores;
|
||||
let used_cores = self.dispute_sessions.len()
|
||||
+ self.backed_and_concluding_paras.len()
|
||||
+ self.backed_in_inherent_paras.len()
|
||||
+ extra_cores;
|
||||
|
||||
assert!(used_cores <= max_cores);
|
||||
|
||||
@@ -873,8 +873,8 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
|
||||
(used_cores - extra_cores) as u32,
|
||||
builder.dispute_sessions.as_slice(),
|
||||
);
|
||||
let mut disputed_cores = (builder.backed_and_concluding_paras.len() as u32..
|
||||
((used_cores - extra_cores) as u32))
|
||||
let mut disputed_cores = (builder.backed_and_concluding_paras.len() as u32
|
||||
..((used_cores - extra_cores) as u32))
|
||||
.into_iter()
|
||||
.map(|idx| (idx, 0))
|
||||
.collect::<BTreeMap<_, _>>();
|
||||
|
||||
@@ -158,8 +158,9 @@ where
|
||||
(None, Some(_)) => Ordering::Greater,
|
||||
(Some(_), None) => Ordering::Less,
|
||||
// For local disputes, prioritize those that occur at an earlier height.
|
||||
(Some(a_height), Some(b_height)) =>
|
||||
a_height.cmp(&b_height).then_with(|| a.candidate_hash.cmp(&b.candidate_hash)),
|
||||
(Some(a_height), Some(b_height)) => {
|
||||
a_height.cmp(&b_height).then_with(|| a.candidate_hash.cmp(&b.candidate_hash))
|
||||
},
|
||||
// Prioritize earlier remote disputes using session as rough proxy.
|
||||
(None, None) => {
|
||||
let session_ord = a.session.cmp(&b.session);
|
||||
@@ -682,8 +683,9 @@ impl<BlockNumber: Clone> DisputeStateImporter<BlockNumber> {
|
||||
// We allow backing statements to be imported after an
|
||||
// explicit "for" vote, but not the other way around.
|
||||
match (kind.is_backing(), self.backers.contains(&validator)) {
|
||||
(true, true) | (false, false) =>
|
||||
return Err(VoteImportError::DuplicateStatement),
|
||||
(true, true) | (false, false) => {
|
||||
return Err(VoteImportError::DuplicateStatement)
|
||||
},
|
||||
(false, true) => return Err(VoteImportError::MaliciousBacker),
|
||||
(true, false) => {},
|
||||
}
|
||||
@@ -789,8 +791,8 @@ impl<BlockNumber: Clone> DisputeStateImporter<BlockNumber> {
|
||||
.validators_for
|
||||
.iter_ones()
|
||||
.filter(|i| {
|
||||
self.pre_state.validators_for.get(*i).map_or(false, |b| !*b) ||
|
||||
new_backing_vote(&ValidatorIndex(*i as _))
|
||||
self.pre_state.validators_for.get(*i).map_or(false, |b| !*b)
|
||||
|| new_backing_vote(&ValidatorIndex(*i as _))
|
||||
})
|
||||
.map(|i| ValidatorIndex(i as _))
|
||||
.collect()
|
||||
@@ -1040,15 +1042,15 @@ impl<T: Config> Pezpallet<T> {
|
||||
};
|
||||
|
||||
// Reject disputes which don't have at least one vote on each side.
|
||||
if summary.state.validators_for.count_ones() == 0 ||
|
||||
summary.state.validators_against.count_ones() == 0
|
||||
if summary.state.validators_for.count_ones() == 0
|
||||
|| summary.state.validators_against.count_ones() == 0
|
||||
{
|
||||
return StatementSetFilter::RemoveAll;
|
||||
}
|
||||
|
||||
// Reject disputes containing less votes than needed for confirmation.
|
||||
if (summary.state.validators_for.clone() | &summary.state.validators_against).count_ones() <=
|
||||
byzantine_threshold(summary.state.validators_for.len())
|
||||
if (summary.state.validators_for.clone() | &summary.state.validators_against).count_ones()
|
||||
<= byzantine_threshold(summary.state.validators_for.len())
|
||||
{
|
||||
return StatementSetFilter::RemoveAll;
|
||||
}
|
||||
@@ -1118,15 +1120,15 @@ impl<T: Config> Pezpallet<T> {
|
||||
|
||||
// Reject disputes which don't have at least one vote on each side.
|
||||
ensure!(
|
||||
summary.state.validators_for.count_ones() > 0 &&
|
||||
summary.state.validators_against.count_ones() > 0,
|
||||
summary.state.validators_for.count_ones() > 0
|
||||
&& summary.state.validators_against.count_ones() > 0,
|
||||
Error::<T>::SingleSidedDispute,
|
||||
);
|
||||
|
||||
// Reject disputes containing less votes than needed for confirmation.
|
||||
ensure!(
|
||||
(summary.state.validators_for.clone() | &summary.state.validators_against).count_ones() >
|
||||
byzantine_threshold(summary.state.validators_for.len()),
|
||||
(summary.state.validators_for.clone() | &summary.state.validators_against).count_ones()
|
||||
> byzantine_threshold(summary.state.validators_for.len()),
|
||||
Error::<T>::UnconfirmedDispute,
|
||||
);
|
||||
let backers = summary.backers;
|
||||
@@ -1277,30 +1279,36 @@ fn check_signature(
|
||||
approval_multiple_candidates_enabled: bool,
|
||||
) -> Result<(), ()> {
|
||||
let payload = match statement {
|
||||
DisputeStatement::Valid(ValidDisputeStatementKind::Explicit) =>
|
||||
ExplicitDisputeStatement { valid: true, candidate_hash, session }.signing_payload(),
|
||||
DisputeStatement::Valid(ValidDisputeStatementKind::BackingSeconded(inclusion_parent)) =>
|
||||
DisputeStatement::Valid(ValidDisputeStatementKind::Explicit) => {
|
||||
ExplicitDisputeStatement { valid: true, candidate_hash, session }.signing_payload()
|
||||
},
|
||||
DisputeStatement::Valid(ValidDisputeStatementKind::BackingSeconded(inclusion_parent)) => {
|
||||
CompactStatement::Seconded(candidate_hash).signing_payload(&SigningContext {
|
||||
session_index: session,
|
||||
parent_hash: *inclusion_parent,
|
||||
}),
|
||||
DisputeStatement::Valid(ValidDisputeStatementKind::BackingValid(inclusion_parent)) =>
|
||||
})
|
||||
},
|
||||
DisputeStatement::Valid(ValidDisputeStatementKind::BackingValid(inclusion_parent)) => {
|
||||
CompactStatement::Valid(candidate_hash).signing_payload(&SigningContext {
|
||||
session_index: session,
|
||||
parent_hash: *inclusion_parent,
|
||||
}),
|
||||
DisputeStatement::Valid(ValidDisputeStatementKind::ApprovalChecking) =>
|
||||
ApprovalVote(candidate_hash).signing_payload(session),
|
||||
})
|
||||
},
|
||||
DisputeStatement::Valid(ValidDisputeStatementKind::ApprovalChecking) => {
|
||||
ApprovalVote(candidate_hash).signing_payload(session)
|
||||
},
|
||||
DisputeStatement::Valid(ValidDisputeStatementKind::ApprovalCheckingMultipleCandidates(
|
||||
candidates,
|
||||
)) =>
|
||||
)) => {
|
||||
if approval_multiple_candidates_enabled && candidates.contains(&candidate_hash) {
|
||||
ApprovalVoteMultipleCandidates(candidates).signing_payload(session)
|
||||
} else {
|
||||
return Err(());
|
||||
},
|
||||
DisputeStatement::Invalid(InvalidDisputeStatementKind::Explicit) =>
|
||||
ExplicitDisputeStatement { valid: false, candidate_hash, session }.signing_payload(),
|
||||
}
|
||||
},
|
||||
DisputeStatement::Invalid(InvalidDisputeStatementKind::Explicit) => {
|
||||
ExplicitDisputeStatement { valid: false, candidate_hash, session }.signing_payload()
|
||||
},
|
||||
};
|
||||
|
||||
let start = get_current_time();
|
||||
|
||||
@@ -498,8 +498,9 @@ pub mod pezpallet {
|
||||
match pending.keys.entry(dispute_proof.validator_index) {
|
||||
Entry::Vacant(_) => return Err(Error::<T>::InvalidValidatorIndex.into()),
|
||||
// check that `validator_index` matches `validator_id`
|
||||
Entry::Occupied(e) if e.get() != &dispute_proof.validator_id =>
|
||||
return Err(Error::<T>::ValidatorIndexIdMismatch.into()),
|
||||
Entry::Occupied(e) if e.get() != &dispute_proof.validator_id => {
|
||||
return Err(Error::<T>::ValidatorIndexIdMismatch.into())
|
||||
},
|
||||
Entry::Occupied(e) => {
|
||||
e.remove(); // the report is correct
|
||||
},
|
||||
|
||||
@@ -166,9 +166,9 @@ fn test_dispute_state_flag_from_state() {
|
||||
start: 0,
|
||||
concluded_at: None,
|
||||
}),
|
||||
DisputeStateFlags::AGAINST_SUPERMAJORITY |
|
||||
DisputeStateFlags::CONFIRMED |
|
||||
DisputeStateFlags::AGAINST_BYZANTINE,
|
||||
DisputeStateFlags::AGAINST_SUPERMAJORITY
|
||||
| DisputeStateFlags::CONFIRMED
|
||||
| DisputeStateFlags::AGAINST_BYZANTINE,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -286,9 +286,9 @@ fn test_import_prev_participant_confirmed_slash_for() {
|
||||
assert_eq!(summary.new_participants, bitvec![u8, BitOrderLsb0; 0, 0, 1, 1, 1, 1, 1, 0]);
|
||||
assert_eq!(
|
||||
summary.new_flags,
|
||||
DisputeStateFlags::CONFIRMED |
|
||||
DisputeStateFlags::AGAINST_SUPERMAJORITY |
|
||||
DisputeStateFlags::AGAINST_BYZANTINE,
|
||||
DisputeStateFlags::CONFIRMED
|
||||
| DisputeStateFlags::AGAINST_SUPERMAJORITY
|
||||
| DisputeStateFlags::AGAINST_BYZANTINE,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -300,8 +300,8 @@ fn verify_fee_increase_and_decrease() {
|
||||
let big_message = [0; 10240].to_vec();
|
||||
let msg_len_in_kb = big_message.len().saturating_div(1024) as u32;
|
||||
let result = initial.saturating_mul(
|
||||
Dmp::EXPONENTIAL_FEE_BASE +
|
||||
Dmp::MESSAGE_SIZE_FEE_BASE.saturating_mul(FixedU128::from_u32(msg_len_in_kb)),
|
||||
Dmp::EXPONENTIAL_FEE_BASE
|
||||
+ Dmp::MESSAGE_SIZE_FEE_BASE.saturating_mul(FixedU128::from_u32(msg_len_in_kb)),
|
||||
);
|
||||
queue_downward_message(a, big_message).unwrap();
|
||||
assert_eq!(DeliveryFeeFactor::<Test>::get(a), result);
|
||||
|
||||
@@ -583,13 +583,13 @@ pub mod pezpallet {
|
||||
T::ChannelManager::ensure_origin(origin)?;
|
||||
|
||||
ensure!(
|
||||
HrmpIngressChannelsIndex::<T>::decode_len(para).unwrap_or_default() <=
|
||||
num_inbound as usize,
|
||||
HrmpIngressChannelsIndex::<T>::decode_len(para).unwrap_or_default()
|
||||
<= num_inbound as usize,
|
||||
Error::<T>::WrongWitness
|
||||
);
|
||||
ensure!(
|
||||
HrmpEgressChannelsIndex::<T>::decode_len(para).unwrap_or_default() <=
|
||||
num_outbound as usize,
|
||||
HrmpEgressChannelsIndex::<T>::decode_len(para).unwrap_or_default()
|
||||
<= num_outbound as usize,
|
||||
Error::<T>::WrongWitness
|
||||
);
|
||||
|
||||
@@ -611,8 +611,8 @@ pub mod pezpallet {
|
||||
T::ChannelManager::ensure_origin(origin)?;
|
||||
|
||||
ensure!(
|
||||
HrmpOpenChannelRequestsList::<T>::decode_len().unwrap_or_default() as u32 <=
|
||||
channels,
|
||||
HrmpOpenChannelRequestsList::<T>::decode_len().unwrap_or_default() as u32
|
||||
<= channels,
|
||||
Error::<T>::WrongWitness
|
||||
);
|
||||
|
||||
@@ -635,8 +635,8 @@ pub mod pezpallet {
|
||||
T::ChannelManager::ensure_origin(origin)?;
|
||||
|
||||
ensure!(
|
||||
HrmpCloseChannelRequestsList::<T>::decode_len().unwrap_or_default() as u32 <=
|
||||
channels,
|
||||
HrmpCloseChannelRequestsList::<T>::decode_len().unwrap_or_default() as u32
|
||||
<= channels,
|
||||
Error::<T>::WrongWitness
|
||||
);
|
||||
|
||||
@@ -661,8 +661,8 @@ pub mod pezpallet {
|
||||
) -> DispatchResult {
|
||||
let origin = ensure_teyrchain(<T as Config>::RuntimeOrigin::from(origin))?;
|
||||
ensure!(
|
||||
HrmpOpenChannelRequestsList::<T>::decode_len().unwrap_or_default() as u32 <=
|
||||
open_requests,
|
||||
HrmpOpenChannelRequestsList::<T>::decode_len().unwrap_or_default() as u32
|
||||
<= open_requests,
|
||||
Error::<T>::WrongWitness
|
||||
);
|
||||
Self::cancel_open_request(origin, channel_id.clone())?;
|
||||
@@ -795,8 +795,8 @@ pub mod pezpallet {
|
||||
let current_recipient_deposit = channel.recipient_deposit;
|
||||
|
||||
// nothing to update
|
||||
if current_sender_deposit == new_sender_deposit &&
|
||||
current_recipient_deposit == new_recipient_deposit
|
||||
if current_sender_deposit == new_sender_deposit
|
||||
&& current_recipient_deposit == new_recipient_deposit
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
@@ -1081,8 +1081,8 @@ impl<T: Config> Pezpallet<T> {
|
||||
let recipient_deposit = if system_channel { 0 } else { config.hrmp_recipient_deposit };
|
||||
|
||||
if request.confirmed {
|
||||
if paras::Pezpallet::<T>::is_valid_para(channel_id.sender) &&
|
||||
paras::Pezpallet::<T>::is_valid_para(channel_id.recipient)
|
||||
if paras::Pezpallet::<T>::is_valid_para(channel_id.sender)
|
||||
&& paras::Pezpallet::<T>::is_valid_para(channel_id.recipient)
|
||||
{
|
||||
HrmpChannels::<T>::insert(
|
||||
&channel_id,
|
||||
@@ -1256,8 +1256,9 @@ impl<T: Config> Pezpallet<T> {
|
||||
// the messages must be sorted in ascending order and there must be no two messages
|
||||
// sent to the same recipient. Thus we can check that every recipient is strictly
|
||||
// greater than the previous one.
|
||||
Some(last_recipient) if out_msg.recipient <= last_recipient =>
|
||||
return Err(OutboundHrmpAcceptanceErr::NotSorted { idx }),
|
||||
Some(last_recipient) if out_msg.recipient <= last_recipient => {
|
||||
return Err(OutboundHrmpAcceptanceErr::NotSorted { idx })
|
||||
},
|
||||
_ => last_recipient = Some(out_msg.recipient),
|
||||
}
|
||||
|
||||
|
||||
@@ -154,8 +154,8 @@ fn open_channel_works() {
|
||||
run_to_block(5, Some(vec![4, 5]));
|
||||
Hrmp::hrmp_init_open_channel(para_a_origin.into(), para_b, 2, 8).unwrap();
|
||||
Hrmp::assert_storage_consistency_exhaustive();
|
||||
assert!(System::events().iter().any(|record| record.event ==
|
||||
MockEvent::Hrmp(Event::OpenChannelRequested {
|
||||
assert!(System::events().iter().any(|record| record.event
|
||||
== MockEvent::Hrmp(Event::OpenChannelRequested {
|
||||
sender: para_a,
|
||||
recipient: para_b,
|
||||
proposed_max_capacity: 2,
|
||||
@@ -164,8 +164,8 @@ fn open_channel_works() {
|
||||
|
||||
Hrmp::hrmp_accept_open_channel(para_b_origin.into(), para_a).unwrap();
|
||||
Hrmp::assert_storage_consistency_exhaustive();
|
||||
assert!(System::events().iter().any(|record| record.event ==
|
||||
MockEvent::Hrmp(Event::OpenChannelAccepted { sender: para_a, recipient: para_b })));
|
||||
assert!(System::events().iter().any(|record| record.event
|
||||
== MockEvent::Hrmp(Event::OpenChannelAccepted { sender: para_a, recipient: para_b })));
|
||||
|
||||
// Advance to a block 6, but without session change. That means that the channel has
|
||||
// not been created yet.
|
||||
@@ -198,15 +198,15 @@ fn force_open_channel_works() {
|
||||
Hrmp::force_open_hrmp_channel(RuntimeOrigin::root(), para_a, para_b, 2, 8).unwrap();
|
||||
Hrmp::force_open_hrmp_channel(RuntimeOrigin::root(), para_b, para_a, 2, 8).unwrap();
|
||||
Hrmp::assert_storage_consistency_exhaustive();
|
||||
assert!(System::events().iter().any(|record| record.event ==
|
||||
MockEvent::Hrmp(Event::HrmpChannelForceOpened {
|
||||
assert!(System::events().iter().any(|record| record.event
|
||||
== MockEvent::Hrmp(Event::HrmpChannelForceOpened {
|
||||
sender: para_a,
|
||||
recipient: para_b,
|
||||
proposed_max_capacity: 2,
|
||||
proposed_max_message_size: 8
|
||||
})));
|
||||
assert!(System::events().iter().any(|record| record.event ==
|
||||
MockEvent::Hrmp(Event::HrmpChannelForceOpened {
|
||||
assert!(System::events().iter().any(|record| record.event
|
||||
== MockEvent::Hrmp(Event::HrmpChannelForceOpened {
|
||||
sender: para_b,
|
||||
recipient: para_a,
|
||||
proposed_max_capacity: 2,
|
||||
@@ -252,15 +252,15 @@ fn force_open_channel_without_free_balance_works() {
|
||||
Hrmp::force_open_hrmp_channel(RuntimeOrigin::root(), para_a, para_b, 2, 8).unwrap();
|
||||
Hrmp::force_open_hrmp_channel(RuntimeOrigin::root(), para_b, para_a, 2, 8).unwrap();
|
||||
Hrmp::assert_storage_consistency_exhaustive();
|
||||
assert!(System::events().iter().any(|record| record.event ==
|
||||
MockEvent::Hrmp(Event::HrmpChannelForceOpened {
|
||||
assert!(System::events().iter().any(|record| record.event
|
||||
== MockEvent::Hrmp(Event::HrmpChannelForceOpened {
|
||||
sender: para_a,
|
||||
recipient: para_b,
|
||||
proposed_max_capacity: 2,
|
||||
proposed_max_message_size: 8
|
||||
})));
|
||||
assert!(System::events().iter().any(|record| record.event ==
|
||||
MockEvent::Hrmp(Event::HrmpChannelForceOpened {
|
||||
assert!(System::events().iter().any(|record| record.event
|
||||
== MockEvent::Hrmp(Event::HrmpChannelForceOpened {
|
||||
sender: para_b,
|
||||
recipient: para_a,
|
||||
proposed_max_capacity: 2,
|
||||
@@ -296,8 +296,8 @@ fn force_open_channel_works_with_existing_request() {
|
||||
run_to_block(3, Some(vec![2, 3]));
|
||||
Hrmp::hrmp_init_open_channel(para_a_origin.into(), para_b, 2, 8).unwrap();
|
||||
Hrmp::assert_storage_consistency_exhaustive();
|
||||
assert!(System::events().iter().any(|record| record.event ==
|
||||
MockEvent::Hrmp(Event::OpenChannelRequested {
|
||||
assert!(System::events().iter().any(|record| record.event
|
||||
== MockEvent::Hrmp(Event::OpenChannelRequested {
|
||||
sender: para_a,
|
||||
recipient: para_b,
|
||||
proposed_max_capacity: 2,
|
||||
@@ -315,8 +315,8 @@ fn force_open_channel_works_with_existing_request() {
|
||||
// now force open it.
|
||||
Hrmp::force_open_hrmp_channel(RuntimeOrigin::root(), para_a, para_b, 2, 8).unwrap();
|
||||
Hrmp::assert_storage_consistency_exhaustive();
|
||||
assert!(System::events().iter().any(|record| record.event ==
|
||||
MockEvent::Hrmp(Event::HrmpChannelForceOpened {
|
||||
assert!(System::events().iter().any(|record| record.event
|
||||
== MockEvent::Hrmp(Event::HrmpChannelForceOpened {
|
||||
sender: para_a,
|
||||
recipient: para_b,
|
||||
proposed_max_capacity: 2,
|
||||
@@ -348,8 +348,8 @@ fn open_system_channel_works() {
|
||||
run_to_block(5, Some(vec![4, 5]));
|
||||
Hrmp::establish_system_channel(RuntimeOrigin::signed(1), para_a, para_b).unwrap();
|
||||
Hrmp::assert_storage_consistency_exhaustive();
|
||||
assert!(System::events().iter().any(|record| record.event ==
|
||||
MockEvent::Hrmp(Event::HrmpSystemChannelOpened {
|
||||
assert!(System::events().iter().any(|record| record.event
|
||||
== MockEvent::Hrmp(Event::HrmpSystemChannelOpened {
|
||||
sender: para_a,
|
||||
recipient: para_b,
|
||||
proposed_max_capacity: 2,
|
||||
@@ -484,8 +484,8 @@ fn close_channel_works() {
|
||||
run_to_block(8, Some(vec![8]));
|
||||
assert!(!channel_exists(para_a, para_b));
|
||||
Hrmp::assert_storage_consistency_exhaustive();
|
||||
assert!(System::events().iter().any(|record| record.event ==
|
||||
MockEvent::Hrmp(Event::ChannelClosed {
|
||||
assert!(System::events().iter().any(|record| record.event
|
||||
== MockEvent::Hrmp(Event::ChannelClosed {
|
||||
by_teyrchain: para_b,
|
||||
channel_id: channel_id.clone()
|
||||
})));
|
||||
@@ -1040,16 +1040,16 @@ fn establish_channel_with_system_works() {
|
||||
run_to_block(5, Some(vec![4, 5]));
|
||||
Hrmp::establish_channel_with_system(para_a_origin.into(), para_b).unwrap();
|
||||
Hrmp::assert_storage_consistency_exhaustive();
|
||||
assert!(System::events().iter().any(|record| record.event ==
|
||||
MockEvent::Hrmp(Event::HrmpSystemChannelOpened {
|
||||
assert!(System::events().iter().any(|record| record.event
|
||||
== MockEvent::Hrmp(Event::HrmpSystemChannelOpened {
|
||||
sender: para_a,
|
||||
recipient: para_b,
|
||||
proposed_max_capacity: 1,
|
||||
proposed_max_message_size: 4
|
||||
})));
|
||||
|
||||
assert!(System::events().iter().any(|record| record.event ==
|
||||
MockEvent::Hrmp(Event::HrmpSystemChannelOpened {
|
||||
assert!(System::events().iter().any(|record| record.event
|
||||
== MockEvent::Hrmp(Event::HrmpSystemChannelOpened {
|
||||
sender: para_b,
|
||||
recipient: para_a,
|
||||
proposed_max_capacity: 1,
|
||||
|
||||
@@ -792,8 +792,8 @@ impl<T: Config> Pezpallet<T> {
|
||||
|
||||
match maybe_amount_validated {
|
||||
Ok(amount_validated) => ensure!(
|
||||
amount_validated >=
|
||||
effective_minimum_backing_votes(group_vals.len(), minimum_backing_votes),
|
||||
amount_validated
|
||||
>= effective_minimum_backing_votes(group_vals.len(), minimum_backing_votes),
|
||||
Error::<T>::InsufficientBacking,
|
||||
),
|
||||
Err(()) => {
|
||||
@@ -1274,8 +1274,8 @@ impl<T: Config> CandidateCheckContext<T> {
|
||||
);
|
||||
|
||||
ensure!(
|
||||
backed_candidate_receipt.descriptor.para_head() ==
|
||||
backed_candidate_receipt.commitments.head_data.hash(),
|
||||
backed_candidate_receipt.descriptor.para_head()
|
||||
== backed_candidate_receipt.commitments.head_data.hash(),
|
||||
Error::<T>::ParaHeadMismatch,
|
||||
);
|
||||
|
||||
|
||||
@@ -151,8 +151,8 @@ pub(crate) fn back_candidate(
|
||||
|i| Some(validators[group[i].0 as usize].public().into()),
|
||||
)
|
||||
.ok()
|
||||
.unwrap_or(0) >=
|
||||
threshold;
|
||||
.unwrap_or(0)
|
||||
>= threshold;
|
||||
|
||||
match kind {
|
||||
BackingKind::Unanimous | BackingKind::Threshold => assert!(successfully_backed),
|
||||
@@ -207,8 +207,8 @@ pub(crate) fn run_to_block(
|
||||
}
|
||||
|
||||
pub(crate) fn expected_bits() -> usize {
|
||||
paras::Teyrchains::<Test>::get().len() +
|
||||
configuration::ActiveConfig::<Test>::get().scheduler_params.num_cores as usize
|
||||
paras::Teyrchains::<Test>::get().len()
|
||||
+ configuration::ActiveConfig::<Test>::get().scheduler_params.num_cores as usize
|
||||
}
|
||||
|
||||
fn default_bitfield() -> AvailabilityBitfield {
|
||||
|
||||
@@ -173,16 +173,16 @@ pub mod pezpallet {
|
||||
// - DMP
|
||||
// - UMP
|
||||
// - HRMP
|
||||
let total_weight = configuration::Pezpallet::<T>::initializer_initialize(now) +
|
||||
shared::Pezpallet::<T>::initializer_initialize(now) +
|
||||
paras::Pezpallet::<T>::initializer_initialize(now) +
|
||||
scheduler::Pezpallet::<T>::initializer_initialize(now) +
|
||||
inclusion::Pezpallet::<T>::initializer_initialize(now) +
|
||||
session_info::Pezpallet::<T>::initializer_initialize(now) +
|
||||
T::DisputesHandler::initializer_initialize(now) +
|
||||
T::SlashingHandler::initializer_initialize(now) +
|
||||
dmp::Pezpallet::<T>::initializer_initialize(now) +
|
||||
hrmp::Pezpallet::<T>::initializer_initialize(now);
|
||||
let total_weight = configuration::Pezpallet::<T>::initializer_initialize(now)
|
||||
+ shared::Pezpallet::<T>::initializer_initialize(now)
|
||||
+ paras::Pezpallet::<T>::initializer_initialize(now)
|
||||
+ scheduler::Pezpallet::<T>::initializer_initialize(now)
|
||||
+ inclusion::Pezpallet::<T>::initializer_initialize(now)
|
||||
+ session_info::Pezpallet::<T>::initializer_initialize(now)
|
||||
+ T::DisputesHandler::initializer_initialize(now)
|
||||
+ T::SlashingHandler::initializer_initialize(now)
|
||||
+ dmp::Pezpallet::<T>::initializer_initialize(now)
|
||||
+ hrmp::Pezpallet::<T>::initializer_initialize(now);
|
||||
|
||||
HasInitialized::<T>::set(Some(()));
|
||||
|
||||
|
||||
@@ -615,8 +615,8 @@ where
|
||||
// (queue_size / queue_capacity) - target_queue_utilisation
|
||||
let queue_util_ratio = FixedU128::from_rational(queue_size.into(), queue_capacity.into());
|
||||
let positive = queue_util_ratio >= target_queue_utilisation.into();
|
||||
let queue_util_diff = queue_util_ratio.max(target_queue_utilisation.into()) -
|
||||
queue_util_ratio.min(target_queue_utilisation.into());
|
||||
let queue_util_diff = queue_util_ratio.max(target_queue_utilisation.into())
|
||||
- queue_util_ratio.min(target_queue_utilisation.into());
|
||||
|
||||
// variability * queue_util_diff
|
||||
let var_times_qud = queue_util_diff.saturating_mul(variability.into());
|
||||
@@ -667,8 +667,9 @@ where
|
||||
|
||||
match affinity {
|
||||
None => FreeEntries::<T>::mutate(|entries| entries.push(order)),
|
||||
Some(affinity) =>
|
||||
AffinityEntries::<T>::mutate(affinity.core_index, |entries| entries.push(order)),
|
||||
Some(affinity) => {
|
||||
AffinityEntries::<T>::mutate(affinity.core_index, |entries| entries.push(order))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -729,13 +730,14 @@ where
|
||||
/// `CoreIndex`.
|
||||
fn increase_affinity(para_id: ParaId, core_index: CoreIndex) {
|
||||
ParaIdAffinity::<T>::mutate(para_id, |maybe_affinity| match maybe_affinity {
|
||||
Some(affinity) =>
|
||||
Some(affinity) => {
|
||||
if affinity.core_index == core_index {
|
||||
*maybe_affinity = Some(CoreAffinityCount {
|
||||
core_index,
|
||||
count: affinity.count.saturating_add(1),
|
||||
});
|
||||
},
|
||||
}
|
||||
},
|
||||
None => {
|
||||
*maybe_affinity = Some(CoreAffinityCount { core_index, count: 1 });
|
||||
},
|
||||
|
||||
@@ -221,9 +221,9 @@ impl ParaLifecycle {
|
||||
pub fn is_teyrchain(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
ParaLifecycle::Teyrchain |
|
||||
ParaLifecycle::DowngradingTeyrchain |
|
||||
ParaLifecycle::OffboardingTeyrchain
|
||||
ParaLifecycle::Teyrchain
|
||||
| ParaLifecycle::DowngradingTeyrchain
|
||||
| ParaLifecycle::OffboardingTeyrchain
|
||||
)
|
||||
}
|
||||
|
||||
@@ -233,9 +233,9 @@ impl ParaLifecycle {
|
||||
pub fn is_parathread(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
ParaLifecycle::Parathread |
|
||||
ParaLifecycle::UpgradingParathread |
|
||||
ParaLifecycle::OffboardingParathread
|
||||
ParaLifecycle::Parathread
|
||||
| ParaLifecycle::UpgradingParathread
|
||||
| ParaLifecycle::OffboardingParathread
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1385,8 +1385,9 @@ pub mod pezpallet {
|
||||
let validators = shared::ActiveValidatorKeys::<T>::get();
|
||||
let validator_public = match validators.get(validator_index) {
|
||||
Some(pk) => pk,
|
||||
None =>
|
||||
return InvalidTransaction::Custom(INVALID_TX_BAD_VALIDATOR_IDX).into(),
|
||||
None => {
|
||||
return InvalidTransaction::Custom(INVALID_TX_BAD_VALIDATOR_IDX).into()
|
||||
},
|
||||
};
|
||||
|
||||
let signing_payload = stmt.signing_payload();
|
||||
@@ -1401,10 +1402,12 @@ pub mod pezpallet {
|
||||
|
||||
match active_vote.has_vote(validator_index) {
|
||||
Some(false) => (),
|
||||
Some(true) =>
|
||||
return InvalidTransaction::Custom(INVALID_TX_DOUBLE_VOTE).into(),
|
||||
None =>
|
||||
return InvalidTransaction::Custom(INVALID_TX_BAD_VALIDATOR_IDX).into(),
|
||||
Some(true) => {
|
||||
return InvalidTransaction::Custom(INVALID_TX_DOUBLE_VOTE).into()
|
||||
},
|
||||
None => {
|
||||
return InvalidTransaction::Custom(INVALID_TX_BAD_VALIDATOR_IDX).into()
|
||||
},
|
||||
}
|
||||
|
||||
ValidTransaction::with_tag_prefix("PvfPreCheckingVote")
|
||||
@@ -1419,7 +1422,7 @@ pub mod pezpallet {
|
||||
.propagate(true)
|
||||
.build()
|
||||
},
|
||||
Call::apply_authorized_force_set_current_code { para, new_code } =>
|
||||
Call::apply_authorized_force_set_current_code { para, new_code } => {
|
||||
match Self::validate_code_is_authorized(new_code, para) {
|
||||
Ok(authorized_code) => {
|
||||
let now = pezframe_system::Pezpallet::<T>::block_number();
|
||||
@@ -1432,9 +1435,11 @@ pub mod pezpallet {
|
||||
.propagate(true)
|
||||
.build()
|
||||
},
|
||||
Err(_) =>
|
||||
return InvalidTransaction::Custom(INVALID_TX_UNAUTHORIZED_CODE).into(),
|
||||
},
|
||||
Err(_) => {
|
||||
return InvalidTransaction::Custom(INVALID_TX_UNAUTHORIZED_CODE).into()
|
||||
},
|
||||
}
|
||||
},
|
||||
_ => InvalidTransaction::Call.into(),
|
||||
}
|
||||
}
|
||||
@@ -1500,10 +1505,10 @@ impl<T: Config> Pezpallet<T> {
|
||||
|
||||
/// Called by the initializer to initialize the paras pezpallet.
|
||||
pub(crate) fn initializer_initialize(now: BlockNumberFor<T>) -> Weight {
|
||||
Self::prune_old_code(now) +
|
||||
Self::process_scheduled_upgrade_changes(now) +
|
||||
Self::process_future_code_upgrades_at(now) +
|
||||
Self::prune_expired_authorizations(now)
|
||||
Self::prune_old_code(now)
|
||||
+ Self::process_scheduled_upgrade_changes(now)
|
||||
+ Self::process_future_code_upgrades_at(now)
|
||||
+ Self::prune_expired_authorizations(now)
|
||||
}
|
||||
|
||||
/// Called by the initializer to finalize the paras pezpallet.
|
||||
@@ -1582,8 +1587,8 @@ impl<T: Config> Pezpallet<T> {
|
||||
ParaLifecycles::<T>::insert(¶, ParaLifecycle::Parathread);
|
||||
},
|
||||
// Offboard a lease holding or on-demand teyrchain from the system
|
||||
Some(ParaLifecycle::OffboardingTeyrchain) |
|
||||
Some(ParaLifecycle::OffboardingParathread) => {
|
||||
Some(ParaLifecycle::OffboardingTeyrchain)
|
||||
| Some(ParaLifecycle::OffboardingParathread) => {
|
||||
teyrchains.remove(para);
|
||||
|
||||
Heads::<T>::remove(¶);
|
||||
@@ -1913,8 +1918,8 @@ impl<T: Config> Pezpallet<T> {
|
||||
//
|
||||
// we cannot onboard at the current session, so it must be at least one
|
||||
// session ahead.
|
||||
let onboard_at: SessionIndex = shared::CurrentSessionIndex::<T>::get() +
|
||||
cmp::max(shared::SESSION_DELAY.saturating_sub(sessions_observed), 1);
|
||||
let onboard_at: SessionIndex = shared::CurrentSessionIndex::<T>::get()
|
||||
+ cmp::max(shared::SESSION_DELAY.saturating_sub(sessions_observed), 1);
|
||||
|
||||
ActionsQueue::<T>::mutate(onboard_at, |v| {
|
||||
if let Err(i) = v.binary_search(&id) {
|
||||
|
||||
@@ -2117,8 +2117,8 @@ fn remove_upgrade_cooldown_works() {
|
||||
assert_ok!(Call::<Test>::remove_upgrade_cooldown { para: para_id }
|
||||
.dispatch_bypass_filter(RuntimeOrigin::signed(1)));
|
||||
|
||||
let expected_issuance = issuance -
|
||||
Pezpallet::<Test>::calculate_remove_upgrade_cooldown_cost(next_possible_upgrade_at);
|
||||
let expected_issuance = issuance
|
||||
- Pezpallet::<Test>::calculate_remove_upgrade_cooldown_cost(next_possible_upgrade_at);
|
||||
// Check that we burned the funds
|
||||
assert_eq!(expected_issuance, Balances::total_issuance());
|
||||
|
||||
|
||||
@@ -913,8 +913,8 @@ pub(crate) fn sanitize_bitfields<T: crate::inclusion::Config>(
|
||||
continue;
|
||||
}
|
||||
|
||||
if unchecked_bitfield.unchecked_payload().0.clone() & disputed_bitfield.0.clone() !=
|
||||
all_zeros
|
||||
if unchecked_bitfield.unchecked_payload().0.clone() & disputed_bitfield.0.clone()
|
||||
!= all_zeros
|
||||
{
|
||||
log::trace!(
|
||||
target: LOG_TARGET,
|
||||
@@ -1345,8 +1345,8 @@ fn filter_backed_statements_from_disabled_validators<
|
||||
// By filtering votes we might render the candidate invalid and cause a failure in
|
||||
// [`process_candidates`]. To avoid this we have to perform a sanity check here. If there
|
||||
// are not enough backing votes after filtering we will remove the whole candidate.
|
||||
if bc.validity_votes().len() <
|
||||
effective_minimum_backing_votes(validator_group.len(), minimum_backing_votes)
|
||||
if bc.validity_votes().len()
|
||||
< effective_minimum_backing_votes(validator_group.len(), minimum_backing_votes)
|
||||
{
|
||||
log::debug!(
|
||||
target: LOG_TARGET,
|
||||
|
||||
@@ -1188,9 +1188,9 @@ mod enter {
|
||||
let backed_candidates_weight =
|
||||
backed_candidates_weight::<Test>(&inherent_data.backed_candidates);
|
||||
|
||||
let sum = multi_dispute_statement_sets_weight +
|
||||
signed_bitfields_weight +
|
||||
backed_candidates_weight;
|
||||
let sum = multi_dispute_statement_sets_weight
|
||||
+ signed_bitfields_weight
|
||||
+ backed_candidates_weight;
|
||||
|
||||
println!(
|
||||
"disputes({})={} + bitfields({})={} + candidates({})={} -> {}",
|
||||
|
||||
@@ -148,13 +148,14 @@ where
|
||||
build()
|
||||
},
|
||||
OccupiedCoreAssumption::TimedOut => build(),
|
||||
OccupiedCoreAssumption::Free =>
|
||||
OccupiedCoreAssumption::Free => {
|
||||
if !<inclusion::Pezpallet<Config>>::candidates_pending_availability(para_id).is_empty()
|
||||
{
|
||||
None
|
||||
} else {
|
||||
build()
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,12 +297,15 @@ where
|
||||
.filter_map(|record| extract_event(record.event))
|
||||
.filter_map(|event| {
|
||||
Some(match event {
|
||||
RawEvent::<T>::CandidateBacked(c, h, core, group) =>
|
||||
CandidateEvent::CandidateBacked(c, h, core, group),
|
||||
RawEvent::<T>::CandidateIncluded(c, h, core, group) =>
|
||||
CandidateEvent::CandidateIncluded(c, h, core, group),
|
||||
RawEvent::<T>::CandidateTimedOut(c, h, core) =>
|
||||
CandidateEvent::CandidateTimedOut(c, h, core),
|
||||
RawEvent::<T>::CandidateBacked(c, h, core, group) => {
|
||||
CandidateEvent::CandidateBacked(c, h, core, group)
|
||||
},
|
||||
RawEvent::<T>::CandidateIncluded(c, h, core, group) => {
|
||||
CandidateEvent::CandidateIncluded(c, h, core, group)
|
||||
},
|
||||
RawEvent::<T>::CandidateTimedOut(c, h, core) => {
|
||||
CandidateEvent::CandidateTimedOut(c, h, core)
|
||||
},
|
||||
// Not needed for candidate events.
|
||||
RawEvent::<T>::UpwardMessagesReceived { .. } => return None,
|
||||
RawEvent::<T>::__Ignore(_, _) => unreachable!("__Ignore cannot be used"),
|
||||
@@ -432,8 +436,8 @@ pub fn backing_constraints<T: initializer::Config>(
|
||||
|
||||
// Use the right storage depending on version to ensure #64 doesn't cause issues with this
|
||||
// migration.
|
||||
let min_relay_parent_number = if shared::Pezpallet::<T>::on_chain_storage_version() ==
|
||||
StorageVersion::new(0)
|
||||
let min_relay_parent_number = if shared::Pezpallet::<T>::on_chain_storage_version()
|
||||
== StorageVersion::new(0)
|
||||
{
|
||||
shared::migration::v0::AllowedRelayParents::<T>::get().hypothetical_earliest_block_number(
|
||||
now,
|
||||
@@ -577,8 +581,8 @@ pub fn candidates_pending_availability<T: initializer::Config>(
|
||||
|
||||
/// Implementation for `validation_code_bomb_limit` function from the runtime API
|
||||
pub fn validation_code_bomb_limit<T: initializer::Config>() -> u32 {
|
||||
configuration::ActiveConfig::<T>::get().max_code_size *
|
||||
configuration::MAX_VALIDATION_CODE_COMPRESSION_RATIO
|
||||
configuration::ActiveConfig::<T>::get().max_code_size
|
||||
* configuration::MAX_VALIDATION_CODE_COMPRESSION_RATIO
|
||||
}
|
||||
|
||||
/// Implementation for `scheduling_lookahead` function from the runtime API
|
||||
|
||||
@@ -191,11 +191,12 @@ mod v1 {
|
||||
for (core_index, core) in availability_cores.into_iter().enumerate() {
|
||||
let new_core = if let Some(core) = core {
|
||||
match core {
|
||||
v0::CoreOccupied::Teyrchain =>
|
||||
v0::CoreOccupied::Teyrchain => {
|
||||
v1::CoreOccupied::Paras(v1::ParasEntry::new(
|
||||
V0Assignment { para_id: teyrchains[core_index] },
|
||||
now,
|
||||
)),
|
||||
))
|
||||
},
|
||||
v0::CoreOccupied::Parathread(entry) => v1::CoreOccupied::Paras(
|
||||
v1::ParasEntry::new(V0Assignment { para_id: entry.claim.0 }, now),
|
||||
),
|
||||
@@ -223,8 +224,8 @@ mod v1 {
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<Vec<u8>, pezsp_runtime::DispatchError> {
|
||||
let n: u32 = v0::Scheduled::<T>::get().len() as u32 +
|
||||
v0::AvailabilityCores::<T>::get().iter().filter(|c| c.is_some()).count() as u32;
|
||||
let n: u32 = v0::Scheduled::<T>::get().len() as u32
|
||||
+ v0::AvailabilityCores::<T>::get().iter().filter(|c| c.is_some()).count() as u32;
|
||||
|
||||
log::info!(
|
||||
target: crate::scheduler::LOG_TARGET,
|
||||
@@ -250,8 +251,8 @@ mod v1 {
|
||||
.count();
|
||||
|
||||
ensure!(
|
||||
Pezpallet::<T>::claim_queue_len() as u32 + availability_cores_waiting as u32 ==
|
||||
expected_len,
|
||||
Pezpallet::<T>::claim_queue_len() as u32 + availability_cores_waiting as u32
|
||||
== expected_len,
|
||||
"ClaimQueue and AvailabilityCores should have the correct length",
|
||||
);
|
||||
|
||||
|
||||
@@ -214,8 +214,8 @@ mod check_upward_messages {
|
||||
5
|
||||
);
|
||||
assert!(
|
||||
configuration::ActiveConfig::<Test>::get().max_upward_queue_size <
|
||||
crate::inclusion::MaxUmpMessageLenOf::<Test>::get(),
|
||||
configuration::ActiveConfig::<Test>::get().max_upward_queue_size
|
||||
< crate::inclusion::MaxUmpMessageLenOf::<Test>::get(),
|
||||
"Test will not work"
|
||||
);
|
||||
|
||||
|
||||
@@ -131,9 +131,9 @@ fn default_teyrchains_host_configuration(
|
||||
allowed_ancestry_len: 0,
|
||||
},
|
||||
node_features: bitvec::vec::BitVec::from_element(
|
||||
(1u8 << (FeatureIndex::ElasticScalingMVP as usize)) |
|
||||
(1u8 << (FeatureIndex::EnableAssignmentsV2 as usize)) |
|
||||
(1u8 << (FeatureIndex::CandidateReceiptV2 as usize)),
|
||||
(1u8 << (FeatureIndex::ElasticScalingMVP as usize))
|
||||
| (1u8 << (FeatureIndex::EnableAssignmentsV2 as usize))
|
||||
| (1u8 << (FeatureIndex::CandidateReceiptV2 as usize)),
|
||||
),
|
||||
scheduler_params: SchedulerParams {
|
||||
lookahead: 3,
|
||||
|
||||
@@ -1321,12 +1321,12 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
|
||||
ProxyType::Staking => {
|
||||
matches!(
|
||||
c,
|
||||
RuntimeCall::Staking(..) |
|
||||
RuntimeCall::Session(..) |
|
||||
RuntimeCall::Utility(..) |
|
||||
RuntimeCall::FastUnstake(..) |
|
||||
RuntimeCall::VoterList(..) |
|
||||
RuntimeCall::NominationPools(..)
|
||||
RuntimeCall::Staking(..)
|
||||
| RuntimeCall::Session(..)
|
||||
| RuntimeCall::Utility(..)
|
||||
| RuntimeCall::FastUnstake(..)
|
||||
| RuntimeCall::VoterList(..)
|
||||
| RuntimeCall::NominationPools(..)
|
||||
)
|
||||
},
|
||||
ProxyType::NominationPools => {
|
||||
@@ -1342,33 +1342,33 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
|
||||
ProxyType::Governance => matches!(
|
||||
c,
|
||||
// OpenGov calls
|
||||
RuntimeCall::ConvictionVoting(..) |
|
||||
RuntimeCall::Referenda(..) |
|
||||
RuntimeCall::Whitelist(..)
|
||||
RuntimeCall::ConvictionVoting(..)
|
||||
| RuntimeCall::Referenda(..)
|
||||
| RuntimeCall::Whitelist(..)
|
||||
),
|
||||
ProxyType::IdentityJudgement => matches!(
|
||||
c,
|
||||
RuntimeCall::Identity(pezpallet_identity::Call::provide_judgement { .. }) |
|
||||
RuntimeCall::Utility(..)
|
||||
RuntimeCall::Identity(pezpallet_identity::Call::provide_judgement { .. })
|
||||
| RuntimeCall::Utility(..)
|
||||
),
|
||||
ProxyType::CancelProxy => {
|
||||
matches!(c, RuntimeCall::Proxy(pezpallet_proxy::Call::reject_announcement { .. }))
|
||||
},
|
||||
ProxyType::Auction => matches!(
|
||||
c,
|
||||
RuntimeCall::Auctions(..) |
|
||||
RuntimeCall::Crowdloan(..) |
|
||||
RuntimeCall::Registrar(..) |
|
||||
RuntimeCall::Slots(..)
|
||||
RuntimeCall::Auctions(..)
|
||||
| RuntimeCall::Crowdloan(..)
|
||||
| RuntimeCall::Registrar(..)
|
||||
| RuntimeCall::Slots(..)
|
||||
),
|
||||
ProxyType::ParaRegistration => matches!(
|
||||
c,
|
||||
RuntimeCall::Registrar(paras_registrar::Call::reserve { .. }) |
|
||||
RuntimeCall::Registrar(paras_registrar::Call::register { .. }) |
|
||||
RuntimeCall::Utility(pezpallet_utility::Call::batch { .. }) |
|
||||
RuntimeCall::Utility(pezpallet_utility::Call::batch_all { .. }) |
|
||||
RuntimeCall::Utility(pezpallet_utility::Call::force_batch { .. }) |
|
||||
RuntimeCall::Proxy(pezpallet_proxy::Call::remove_proxy { .. })
|
||||
RuntimeCall::Registrar(paras_registrar::Call::reserve { .. })
|
||||
| RuntimeCall::Registrar(paras_registrar::Call::register { .. })
|
||||
| RuntimeCall::Utility(pezpallet_utility::Call::batch { .. })
|
||||
| RuntimeCall::Utility(pezpallet_utility::Call::batch_all { .. })
|
||||
| RuntimeCall::Utility(pezpallet_utility::Call::force_batch { .. })
|
||||
| RuntimeCall::Proxy(pezpallet_proxy::Call::remove_proxy { .. })
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,9 @@ pub enum AssetTypes {
|
||||
impl From<&Asset> for AssetTypes {
|
||||
fn from(asset: &Asset) -> Self {
|
||||
match asset {
|
||||
Asset { id: AssetId(Location { parents: 0, interior: Here }), .. } =>
|
||||
AssetTypes::Balances,
|
||||
Asset { id: AssetId(Location { parents: 0, interior: Here }), .. } => {
|
||||
AssetTypes::Balances
|
||||
},
|
||||
_ => AssetTypes::Unknown,
|
||||
}
|
||||
}
|
||||
@@ -70,8 +71,9 @@ impl WeighAssets for AssetFilter {
|
||||
// We don't support any NFTs on Zagros, so these two variants will always match
|
||||
// only 1 kind of fungible asset.
|
||||
Self::Wild(AllOf { .. } | AllOfCounted { .. }) => balances_weight,
|
||||
Self::Wild(AllCounted(count)) =>
|
||||
balances_weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
|
||||
Self::Wild(AllCounted(count)) => {
|
||||
balances_weight.saturating_mul(MAX_ASSETS.min(*count as u64))
|
||||
},
|
||||
Self::Wild(All) => balances_weight.saturating_mul(MAX_ASSETS),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user