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:
@@ -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"
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user