Companion to "Updating scale to v3" (#4958)

* Updating dependencies

* Adapting code to scale v3

* Upgrade bitvec to 1.0.0

* Fix bitvec arithmetics

* Update Cargo.lock

* Update sp-io

* Fixing the build

* Yanked scale-info 2.0.0

Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
wigy
2022-02-25 13:07:06 +01:00
committed by GitHub
parent d0c9f75a0b
commit e8cb6cdaac
106 changed files with 680 additions and 556 deletions
+6 -6
View File
@@ -257,7 +257,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
group_idx: GroupIndex,
core_idx: CoreIndex,
candidate_hash: CandidateHash,
availability_votes: BitVec<BitOrderLsb0, u8>,
availability_votes: BitVec<u8, BitOrderLsb0>,
) -> inclusion::CandidatePendingAvailability<T::Hash, T::BlockNumber> {
inclusion::CandidatePendingAvailability::<T::Hash, T::BlockNumber>::new(
core_idx, // core
@@ -280,7 +280,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
para_id: ParaId,
core_idx: CoreIndex,
group_idx: GroupIndex,
availability_votes: BitVec<BitOrderLsb0, u8>,
availability_votes: BitVec<u8, BitOrderLsb0>,
candidate_hash: CandidateHash,
) {
let candidate_availability = Self::candidate_availability_mock(
@@ -304,7 +304,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
/// Create an `AvailabilityBitfield` where `concluding` is a map where each key is a core index
/// that is concluding and `cores` is the total number of cores in the system.
fn availability_bitvec(concluding: &BTreeMap<u32, u32>, cores: u32) -> AvailabilityBitfield {
let mut bitfields = bitvec::bitvec![bitvec::order::Lsb0, u8; 0; 0];
let mut bitfields = bitvec::bitvec![u8, bitvec::order::Lsb0; 0; 0];
for i in 0..cores {
if concluding.get(&(i as u32)).is_some() {
bitfields.push(true);
@@ -373,9 +373,9 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
}
/// Create a bitvec of `validators` length with all yes votes.
fn validator_availability_votes_yes(validators: usize) -> BitVec<bitvec::order::Lsb0, u8> {
fn validator_availability_votes_yes(validators: usize) -> BitVec<u8, bitvec::order::Lsb0> {
// every validator confirms availability.
bitvec::bitvec![bitvec::order::Lsb0, u8; 1; validators as usize]
bitvec::bitvec![u8, bitvec::order::Lsb0; 1; validators as usize]
}
/// Setup session 1 and create `self.validators_map` and `self.validators`.
@@ -565,7 +565,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
BackedCandidate::<T::Hash> {
candidate,
validity_votes,
validator_indices: bitvec::bitvec![bitvec::order::Lsb0, u8; 1; group_validators.len()],
validator_indices: bitvec::bitvec![u8, bitvec::order::Lsb0; 1; group_validators.len()],
}
})
.collect()
+14 -24
View File
@@ -530,11 +530,7 @@ impl DisputeStateFlags {
let supermajority_threshold = supermajority_threshold(n);
let mut flags = DisputeStateFlags::default();
let all_participants = {
let mut a = state.validators_for.clone();
*a |= state.validators_against.iter().by_val();
a
};
let all_participants = state.validators_for.clone() | state.validators_against.clone();
if all_participants.count_ones() > byzantine_threshold {
flags |= DisputeStateFlags::CONFIRMED;
}
@@ -567,7 +563,7 @@ struct ImportSummary<BlockNumber> {
// Validators to slash for being (wrongly) on the FOR side.
slash_for: Vec<ValidatorIndex>,
// New participants in the dispute.
new_participants: bitvec::vec::BitVec<BitOrderLsb0, u8>,
new_participants: bitvec::vec::BitVec<u8, BitOrderLsb0>,
// Difference in state flags from previous.
new_flags: DisputeStateFlags,
}
@@ -597,14 +593,14 @@ struct ImportUndo {
struct DisputeStateImporter<BlockNumber> {
state: DisputeState<BlockNumber>,
now: BlockNumber,
new_participants: bitvec::vec::BitVec<BitOrderLsb0, u8>,
new_participants: bitvec::vec::BitVec<u8, BitOrderLsb0>,
pre_flags: DisputeStateFlags,
}
impl<BlockNumber: Clone> DisputeStateImporter<BlockNumber> {
fn new(state: DisputeState<BlockNumber>, now: BlockNumber) -> Self {
let pre_flags = DisputeStateFlags::from_state(&state);
let new_participants = bitvec::bitvec![BitOrderLsb0, u8; 0; state.validators_for.len()];
let new_participants = bitvec::bitvec![u8, BitOrderLsb0; 0; state.validators_for.len()];
DisputeStateImporter { state, now, new_participants, pre_flags }
}
@@ -675,16 +671,10 @@ impl<BlockNumber: Clone> DisputeStateImporter<BlockNumber> {
.collect()
},
(false, true) => {
let prev_participants = {
// all participants
let mut a = self.state.validators_for.clone();
*a |= self.state.validators_against.iter().by_val();
// which are not new participants
*a &= self.new_participants.iter().by_val().map(|b| !b);
a
};
// all participants, which are not new participants
let prev_participants = (self.state.validators_for.clone() |
self.state.validators_against.clone()) &
!self.new_participants.clone();
prev_participants
.iter_ones()
@@ -942,8 +932,8 @@ impl<T: Config> Pallet<T> {
dispute_state
} else {
DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 0; n_validators],
validators_against: bitvec![BitOrderLsb0, u8; 0; n_validators],
validators_for: bitvec![u8, BitOrderLsb0; 0; n_validators],
validators_against: bitvec![u8, BitOrderLsb0; 0; n_validators],
start: now,
concluded_at: None,
}
@@ -1106,8 +1096,8 @@ impl<T: Config> Pallet<T> {
(
true,
DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 0; n_validators],
validators_against: bitvec![BitOrderLsb0, u8; 0; n_validators],
validators_for: bitvec![u8, BitOrderLsb0; 0; n_validators],
validators_against: bitvec![u8, BitOrderLsb0; 0; n_validators],
start: now,
concluded_at: None,
},
@@ -1271,10 +1261,10 @@ fn has_supermajority_against<BlockNumber>(dispute: &DisputeState<BlockNumber>) -
fn decrement_spam<BlockNumber>(
spam_slots: &mut [u32],
dispute: &DisputeState<BlockNumber>,
) -> bitvec::vec::BitVec<BitOrderLsb0, u8> {
) -> bitvec::vec::BitVec<u8, BitOrderLsb0> {
let byzantine_threshold = byzantine_threshold(spam_slots.len());
let participating = dispute.validators_for.clone() | dispute.validators_against.iter().by_val();
let participating = dispute.validators_for.clone() | dispute.validators_against.clone();
let decrement_spam = participating.count_ones() <= byzantine_threshold;
for validator_index in participating.iter_ones() {
if decrement_spam {
@@ -105,8 +105,8 @@ fn test_contains_duplicates_in_sorted_iter() {
fn test_dispute_state_flag_from_state() {
assert_eq!(
DisputeStateFlags::from_state(&DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 0, 0, 0, 0, 0, 0, 0, 0],
validators_against: bitvec![BitOrderLsb0, u8; 0, 0, 0, 0, 0, 0, 0, 0],
validators_for: bitvec![u8, BitOrderLsb0; 0, 0, 0, 0, 0, 0, 0, 0],
validators_against: bitvec![u8, BitOrderLsb0; 0, 0, 0, 0, 0, 0, 0, 0],
start: 0,
concluded_at: None,
}),
@@ -115,8 +115,8 @@ fn test_dispute_state_flag_from_state() {
assert_eq!(
DisputeStateFlags::from_state(&DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 1, 1, 1, 1, 1, 0, 0],
validators_against: bitvec![BitOrderLsb0, u8; 0, 0, 0, 0, 0, 0, 0],
validators_for: bitvec![u8, BitOrderLsb0; 1, 1, 1, 1, 1, 0, 0],
validators_against: bitvec![u8, BitOrderLsb0; 0, 0, 0, 0, 0, 0, 0],
start: 0,
concluded_at: None,
}),
@@ -125,8 +125,8 @@ fn test_dispute_state_flag_from_state() {
assert_eq!(
DisputeStateFlags::from_state(&DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 0, 0, 0, 0, 0, 0, 0],
validators_against: bitvec![BitOrderLsb0, u8; 1, 1, 1, 1, 1, 0, 0],
validators_for: bitvec![u8, BitOrderLsb0; 0, 0, 0, 0, 0, 0, 0],
validators_against: bitvec![u8, BitOrderLsb0; 1, 1, 1, 1, 1, 0, 0],
start: 0,
concluded_at: None,
}),
@@ -138,8 +138,8 @@ fn test_dispute_state_flag_from_state() {
fn test_import_new_participant_spam_inc() {
let mut importer = DisputeStateImporter::new(
DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 1, 0, 0, 0, 0, 0, 0, 0],
validators_against: bitvec![BitOrderLsb0, u8; 0, 0, 0, 0, 0, 0, 0, 0],
validators_for: bitvec![u8, BitOrderLsb0; 1, 0, 0, 0, 0, 0, 0, 0],
validators_against: bitvec![u8, BitOrderLsb0; 0, 0, 0, 0, 0, 0, 0, 0],
start: 0,
concluded_at: None,
},
@@ -165,8 +165,8 @@ fn test_import_new_participant_spam_inc() {
assert_eq!(
summary.state,
DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 1, 0, 1, 0, 0, 0, 0, 0],
validators_against: bitvec![BitOrderLsb0, u8; 1, 0, 1, 0, 0, 0, 0, 0],
validators_for: bitvec![u8, BitOrderLsb0; 1, 0, 1, 0, 0, 0, 0, 0],
validators_against: bitvec![u8, BitOrderLsb0; 1, 0, 1, 0, 0, 0, 0, 0],
start: 0,
concluded_at: None,
},
@@ -174,15 +174,15 @@ fn test_import_new_participant_spam_inc() {
assert_eq!(summary.spam_slot_changes, vec![(ValidatorIndex(2), SpamSlotChange::Inc)]);
assert!(summary.slash_for.is_empty());
assert!(summary.slash_against.is_empty());
assert_eq!(summary.new_participants, bitvec![BitOrderLsb0, u8; 0, 0, 1, 0, 0, 0, 0, 0]);
assert_eq!(summary.new_participants, bitvec![u8, BitOrderLsb0; 0, 0, 1, 0, 0, 0, 0, 0]);
}
#[test]
fn test_import_prev_participant_spam_dec_confirmed() {
let mut importer = DisputeStateImporter::new(
DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 1, 0, 0, 0, 0, 0, 0, 0],
validators_against: bitvec![BitOrderLsb0, u8; 0, 1, 0, 0, 0, 0, 0, 0],
validators_for: bitvec![u8, BitOrderLsb0; 1, 0, 0, 0, 0, 0, 0, 0],
validators_against: bitvec![u8, BitOrderLsb0; 0, 1, 0, 0, 0, 0, 0, 0],
start: 0,
concluded_at: None,
},
@@ -195,8 +195,8 @@ fn test_import_prev_participant_spam_dec_confirmed() {
assert_eq!(
summary.state,
DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 1, 0, 1, 0, 0, 0, 0, 0],
validators_against: bitvec![BitOrderLsb0, u8; 0, 1, 0, 0, 0, 0, 0, 0],
validators_for: bitvec![u8, BitOrderLsb0; 1, 0, 1, 0, 0, 0, 0, 0],
validators_against: bitvec![u8, BitOrderLsb0; 0, 1, 0, 0, 0, 0, 0, 0],
start: 0,
concluded_at: None,
},
@@ -207,7 +207,7 @@ fn test_import_prev_participant_spam_dec_confirmed() {
);
assert!(summary.slash_for.is_empty());
assert!(summary.slash_against.is_empty());
assert_eq!(summary.new_participants, bitvec![BitOrderLsb0, u8; 0, 0, 1, 0, 0, 0, 0, 0]);
assert_eq!(summary.new_participants, bitvec![u8, BitOrderLsb0; 0, 0, 1, 0, 0, 0, 0, 0]);
assert_eq!(summary.new_flags, DisputeStateFlags::CONFIRMED);
}
@@ -215,8 +215,8 @@ fn test_import_prev_participant_spam_dec_confirmed() {
fn test_import_prev_participant_spam_dec_confirmed_slash_for() {
let mut importer = DisputeStateImporter::new(
DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 1, 0, 0, 0, 0, 0, 0, 0],
validators_against: bitvec![BitOrderLsb0, u8; 0, 1, 0, 0, 0, 0, 0, 0],
validators_for: bitvec![u8, BitOrderLsb0; 1, 0, 0, 0, 0, 0, 0, 0],
validators_against: bitvec![u8, BitOrderLsb0; 0, 1, 0, 0, 0, 0, 0, 0],
start: 0,
concluded_at: None,
},
@@ -234,8 +234,8 @@ fn test_import_prev_participant_spam_dec_confirmed_slash_for() {
assert_eq!(
summary.state,
DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 1, 0, 1, 0, 0, 0, 0, 0],
validators_against: bitvec![BitOrderLsb0, u8; 0, 1, 1, 1, 1, 1, 1, 0],
validators_for: bitvec![u8, BitOrderLsb0; 1, 0, 1, 0, 0, 0, 0, 0],
validators_against: bitvec![u8, BitOrderLsb0; 0, 1, 1, 1, 1, 1, 1, 0],
start: 0,
concluded_at: Some(0),
},
@@ -246,7 +246,7 @@ fn test_import_prev_participant_spam_dec_confirmed_slash_for() {
);
assert_eq!(summary.slash_for, vec![ValidatorIndex(0), ValidatorIndex(2)]);
assert!(summary.slash_against.is_empty());
assert_eq!(summary.new_participants, bitvec![BitOrderLsb0, u8; 0, 0, 1, 1, 1, 1, 1, 0]);
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,
@@ -257,8 +257,8 @@ fn test_import_prev_participant_spam_dec_confirmed_slash_for() {
fn test_import_slash_against() {
let mut importer = DisputeStateImporter::new(
DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 1, 0, 1, 0, 0, 0, 0, 0],
validators_against: bitvec![BitOrderLsb0, u8; 0, 1, 0, 0, 0, 0, 0, 0],
validators_for: bitvec![u8, BitOrderLsb0; 1, 0, 1, 0, 0, 0, 0, 0],
validators_against: bitvec![u8, BitOrderLsb0; 0, 1, 0, 0, 0, 0, 0, 0],
start: 0,
concluded_at: None,
},
@@ -275,8 +275,8 @@ fn test_import_slash_against() {
assert_eq!(
summary.state,
DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 1, 0, 1, 1, 1, 0, 1, 1],
validators_against: bitvec![BitOrderLsb0, u8; 0, 1, 0, 0, 0, 1, 0, 0],
validators_for: bitvec![u8, BitOrderLsb0; 1, 0, 1, 1, 1, 0, 1, 1],
validators_against: bitvec![u8, BitOrderLsb0; 0, 1, 0, 0, 0, 1, 0, 0],
start: 0,
concluded_at: Some(0),
},
@@ -284,7 +284,7 @@ fn test_import_slash_against() {
assert!(summary.spam_slot_changes.is_empty());
assert!(summary.slash_for.is_empty());
assert_eq!(summary.slash_against, vec![ValidatorIndex(1), ValidatorIndex(5)]);
assert_eq!(summary.new_participants, bitvec![BitOrderLsb0, u8; 0, 0, 0, 1, 1, 1, 1, 1]);
assert_eq!(summary.new_participants, bitvec![u8, BitOrderLsb0; 0, 0, 0, 1, 1, 1, 1, 1]);
assert_eq!(summary.new_flags, DisputeStateFlags::FOR_SUPERMAJORITY);
}
@@ -1021,8 +1021,8 @@ fn test_provide_multi_dispute_success_and_other() {
5,
candidate_hash.clone(),
DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 0, 0, 0, 0, 0, 1, 0],
validators_against: bitvec![BitOrderLsb0, u8; 1, 1, 1, 0, 1, 0, 1],
validators_for: bitvec![u8, BitOrderLsb0; 0, 0, 0, 0, 0, 1, 0],
validators_against: bitvec![u8, BitOrderLsb0; 1, 1, 1, 0, 1, 0, 1],
start: 6,
concluded_at: Some(6), // 5 vote against
}
@@ -1031,8 +1031,8 @@ fn test_provide_multi_dispute_success_and_other() {
3,
candidate_hash.clone(),
DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 1, 1, 0, 1, 1, 0, 1],
validators_against: bitvec![BitOrderLsb0, u8; 0, 0, 1, 0, 0, 1, 0],
validators_for: bitvec![u8, BitOrderLsb0; 1, 1, 0, 1, 1, 0, 1],
validators_against: bitvec![u8, BitOrderLsb0; 0, 0, 1, 0, 0, 1, 0],
start: 6,
concluded_at: Some(6), // 5 vote for
}
@@ -1041,8 +1041,8 @@ fn test_provide_multi_dispute_success_and_other() {
4,
candidate_hash.clone(),
DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 0, 0, 0, 1, 0, 0, 0],
validators_against: bitvec![BitOrderLsb0, u8; 0, 0, 1, 0, 0, 0, 0],
validators_for: bitvec![u8, BitOrderLsb0; 0, 0, 0, 1, 0, 0, 0],
validators_against: bitvec![u8, BitOrderLsb0; 0, 0, 1, 0, 0, 0, 0],
start: 6,
concluded_at: None,
}
@@ -1154,8 +1154,8 @@ fn test_revert_and_freeze_merges() {
fn test_has_supermajority_against() {
assert_eq!(
has_supermajority_against(&DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 1, 1, 0, 0, 0, 0, 0, 0],
validators_against: bitvec![BitOrderLsb0, u8; 1, 1, 1, 1, 1, 0, 0, 0],
validators_for: bitvec![u8, BitOrderLsb0; 1, 1, 0, 0, 0, 0, 0, 0],
validators_against: bitvec![u8, BitOrderLsb0; 1, 1, 1, 1, 1, 0, 0, 0],
start: 0,
concluded_at: None,
}),
@@ -1164,8 +1164,8 @@ fn test_has_supermajority_against() {
assert_eq!(
has_supermajority_against(&DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 1, 1, 0, 0, 0, 0, 0, 0],
validators_against: bitvec![BitOrderLsb0, u8; 1, 1, 1, 1, 1, 1, 0, 0],
validators_for: bitvec![u8, BitOrderLsb0; 1, 1, 0, 0, 0, 0, 0, 0],
validators_against: bitvec![u8, BitOrderLsb0; 1, 1, 1, 1, 1, 1, 0, 0],
start: 0,
concluded_at: None,
}),
@@ -1180,23 +1180,23 @@ fn test_decrement_spam() {
// Test confirm is no-op
let mut spam_slots = original_spam_slots.clone();
let dispute_state_confirm = DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 1, 1, 0, 0, 0, 0, 0, 0],
validators_against: bitvec![BitOrderLsb0, u8; 1, 0, 1, 0, 0, 0, 0, 0],
validators_for: bitvec![u8, BitOrderLsb0; 1, 1, 0, 0, 0, 0, 0, 0],
validators_against: bitvec![u8, BitOrderLsb0; 1, 0, 1, 0, 0, 0, 0, 0],
start: 0,
concluded_at: None,
};
assert_eq!(DisputeStateFlags::from_state(&dispute_state_confirm), DisputeStateFlags::CONFIRMED);
assert_eq!(
decrement_spam(spam_slots.as_mut(), &dispute_state_confirm),
bitvec![BitOrderLsb0, u8; 1, 1, 1, 0, 0, 0, 0, 0],
bitvec![u8, BitOrderLsb0; 1, 1, 1, 0, 0, 0, 0, 0],
);
assert_eq!(spam_slots, original_spam_slots);
// Test not confirm is decreasing spam
let mut spam_slots = original_spam_slots.clone();
let dispute_state_no_confirm = DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 1, 0, 0, 0, 0, 0, 0, 0],
validators_against: bitvec![BitOrderLsb0, u8; 1, 0, 1, 0, 0, 0, 0, 0],
validators_for: bitvec![u8, BitOrderLsb0; 1, 0, 0, 0, 0, 0, 0, 0],
validators_against: bitvec![u8, BitOrderLsb0; 1, 0, 1, 0, 0, 0, 0, 0],
start: 0,
concluded_at: None,
};
@@ -1206,7 +1206,7 @@ fn test_decrement_spam() {
);
assert_eq!(
decrement_spam(spam_slots.as_mut(), &dispute_state_no_confirm),
bitvec![BitOrderLsb0, u8; 1, 0, 1, 0, 0, 0, 0, 0],
bitvec![u8, BitOrderLsb0; 1, 0, 1, 0, 0, 0, 0, 0],
);
assert_eq!(spam_slots, vec![0, 1, 1, 3, 4, 5, 6, 7]);
}
@@ -2090,8 +2090,8 @@ fn filter_removes_concluded_ancient() {
&1,
&candidate_hash_a,
DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 0; 4],
validators_against: bitvec![BitOrderLsb0, u8; 1; 4],
validators_for: bitvec![u8, BitOrderLsb0; 0; 4],
validators_against: bitvec![u8, BitOrderLsb0; 1; 4],
start: 0,
concluded_at: Some(0),
},
@@ -2101,8 +2101,8 @@ fn filter_removes_concluded_ancient() {
&1,
&candidate_hash_b,
DisputeState {
validators_for: bitvec![BitOrderLsb0, u8; 0; 4],
validators_against: bitvec![BitOrderLsb0, u8; 1; 4],
validators_for: bitvec![u8, BitOrderLsb0; 0; 4],
validators_against: bitvec![u8, BitOrderLsb0; 1; 4],
start: 0,
concluded_at: Some(1),
},
@@ -78,9 +78,9 @@ pub struct CandidatePendingAvailability<H, N> {
/// The candidate descriptor.
descriptor: CandidateDescriptor<H>,
/// The received availability votes. One bit per validator.
availability_votes: BitVec<BitOrderLsb0, u8>,
availability_votes: BitVec<u8, BitOrderLsb0>,
/// The backers of the candidate pending availability.
backers: BitVec<BitOrderLsb0, u8>,
backers: BitVec<u8, BitOrderLsb0>,
/// The block number of the relay-parent of the receipt.
relay_parent_number: N,
/// The block number of the relay-chain block this was backed in.
@@ -91,7 +91,7 @@ pub struct CandidatePendingAvailability<H, N> {
impl<H, N> CandidatePendingAvailability<H, N> {
/// Get the availability votes on the candidate.
pub(crate) fn availability_votes(&self) -> &BitVec<BitOrderLsb0, u8> {
pub(crate) fn availability_votes(&self) -> &BitVec<u8, BitOrderLsb0> {
&self.availability_votes
}
@@ -120,8 +120,8 @@ impl<H, N> CandidatePendingAvailability<H, N> {
core: CoreIndex,
hash: CandidateHash,
descriptor: CandidateDescriptor<H>,
availability_votes: BitVec<BitOrderLsb0, u8>,
backers: BitVec<BitOrderLsb0, u8>,
availability_votes: BitVec<u8, BitOrderLsb0>,
backers: BitVec<u8, BitOrderLsb0>,
relay_parent_number: N,
backed_in_number: N,
backing_group: GroupIndex,
@@ -544,7 +544,7 @@ impl<T: Config> Pallet<T> {
}
let para_id = backed_candidate.descriptor().para_id;
let mut backers = bitvec::bitvec![BitOrderLsb0, u8; 0; validators.len()];
let mut backers = bitvec::bitvec![u8, BitOrderLsb0; 0; validators.len()];
for (i, assignment) in scheduled[skip..].iter().enumerate() {
check_assignment_in_order(assignment)?;
@@ -649,8 +649,8 @@ impl<T: Config> Pallet<T> {
let para_id = candidate.descriptor().para_id;
// initialize all availability votes to 0.
let availability_votes: BitVec<BitOrderLsb0, u8> =
bitvec::bitvec![BitOrderLsb0, u8; 0; validators.len()];
let availability_votes: BitVec<u8, BitOrderLsb0> =
bitvec::bitvec![u8, BitOrderLsb0; 0; validators.len()];
Self::deposit_event(Event::<T>::CandidateBacked(
candidate.candidate.to_plain(),
@@ -721,8 +721,8 @@ impl<T: Config> Pallet<T> {
fn enact_candidate(
relay_parent_number: T::BlockNumber,
receipt: CommittedCandidateReceipt<T::Hash>,
backers: BitVec<BitOrderLsb0, u8>,
availability_votes: BitVec<BitOrderLsb0, u8>,
backers: BitVec<u8, BitOrderLsb0>,
availability_votes: BitVec<u8, BitOrderLsb0>,
core_index: CoreIndex,
backing_group: GroupIndex,
) -> Weight {
@@ -113,7 +113,7 @@ pub(crate) async fn back_candidate(
signing_context: &SigningContext,
kind: BackingKind,
) -> BackedCandidate {
let mut validator_indices = bitvec::bitvec![BitOrderLsb0, u8; 0; group.len()];
let mut validator_indices = bitvec::bitvec![u8, BitOrderLsb0; 0; group.len()];
let threshold = minimum_backing_votes(group.len());
let signing = match kind {
@@ -201,18 +201,18 @@ pub(crate) fn expected_bits() -> usize {
}
fn default_bitfield() -> AvailabilityBitfield {
AvailabilityBitfield(bitvec::bitvec![BitOrderLsb0, u8; 0; expected_bits()])
AvailabilityBitfield(bitvec::bitvec![u8, BitOrderLsb0; 0; expected_bits()])
}
fn default_availability_votes() -> BitVec<BitOrderLsb0, u8> {
bitvec::bitvec![BitOrderLsb0, u8; 0; ParasShared::active_validator_keys().len()]
fn default_availability_votes() -> BitVec<u8, BitOrderLsb0> {
bitvec::bitvec![u8, BitOrderLsb0; 0; ParasShared::active_validator_keys().len()]
}
fn default_backing_bitfield() -> BitVec<BitOrderLsb0, u8> {
bitvec::bitvec![BitOrderLsb0, u8; 0; ParasShared::active_validator_keys().len()]
fn default_backing_bitfield() -> BitVec<u8, BitOrderLsb0> {
bitvec::bitvec![u8, BitOrderLsb0; 0; ParasShared::active_validator_keys().len()]
}
fn backing_bitfield(v: &[usize]) -> BitVec<BitOrderLsb0, u8> {
fn backing_bitfield(v: &[usize]) -> BitVec<u8, BitOrderLsb0> {
let mut b = default_backing_bitfield();
for i in v {
b.set(*i, true);
+4 -4
View File
@@ -339,8 +339,8 @@ struct PvfCheckActiveVoteState<BlockNumber> {
// makes a vote. Once a 1 is set for either of the vectors, that validator cannot vote anymore.
// Since the active validator set changes each session, the bit vectors are reinitialized as
// well: zeroed and resized so that each validator gets its own bit.
votes_accept: BitVec<BitOrderLsb0, u8>,
votes_reject: BitVec<BitOrderLsb0, u8>,
votes_accept: BitVec<u8, BitOrderLsb0>,
votes_reject: BitVec<u8, BitOrderLsb0>,
/// The number of session changes this PVF vote has observed. Therefore, this number is
/// increased at each session boundary. When created, it is initialized with 0.
@@ -359,8 +359,8 @@ impl<BlockNumber> PvfCheckActiveVoteState<BlockNumber> {
causes.push(cause);
Self {
created_at: now,
votes_accept: bitvec::bitvec![BitOrderLsb0, u8; 0; n_validators],
votes_reject: bitvec::bitvec![BitOrderLsb0, u8; 0; n_validators],
votes_accept: bitvec::bitvec![u8, BitOrderLsb0; 0; n_validators],
votes_reject: bitvec::bitvec![u8, BitOrderLsb0; 0; n_validators],
age: 0,
causes,
}
@@ -81,10 +81,10 @@ const LOG_TARGET: &str = "runtime::inclusion-inherent";
/// A bitfield concerning concluded disputes for candidates
/// associated to the core index equivalent to the bit position.
#[derive(Default, PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
pub(crate) struct DisputedBitfield(pub(crate) BitVec<bitvec::order::Lsb0, u8>);
pub(crate) struct DisputedBitfield(pub(crate) BitVec<u8, bitvec::order::Lsb0>);
impl From<BitVec<bitvec::order::Lsb0, u8>> for DisputedBitfield {
fn from(inner: BitVec<bitvec::order::Lsb0, u8>) -> Self {
impl From<BitVec<u8, bitvec::order::Lsb0>> for DisputedBitfield {
fn from(inner: BitVec<u8, bitvec::order::Lsb0>) -> Self {
Self(inner)
}
}
@@ -93,7 +93,7 @@ impl From<BitVec<bitvec::order::Lsb0, u8>> for DisputedBitfield {
impl DisputedBitfield {
/// Create a new bitfield, where each bit is set to `false`.
pub fn zeros(n: usize) -> Self {
Self::from(BitVec::<bitvec::order::Lsb0, u8>::repeat(false, n))
Self::from(BitVec::<u8, bitvec::order::Lsb0>::repeat(false, n))
}
}
@@ -964,7 +964,7 @@ pub(crate) fn sanitize_bitfields<T: crate::inclusion::Config>(
return vec![]
}
let all_zeros = BitVec::<bitvec::order::Lsb0, u8>::repeat(false, expected_bits);
let all_zeros = BitVec::<u8, bitvec::order::Lsb0>::repeat(false, expected_bits);
let signing_context = SigningContext { parent_hash, session_index };
for unchecked_bitfield in unchecked_bitfields {
// Find and skip invalid bitfields.
@@ -925,10 +925,10 @@ mod sanitizers {
let validator_public = validator_pubkeys(&validators);
let unchecked_bitfields = [
BitVec::<Lsb0, u8>::repeat(true, expected_bits),
BitVec::<Lsb0, u8>::repeat(true, expected_bits),
BitVec::<u8, Lsb0>::repeat(true, expected_bits),
BitVec::<u8, Lsb0>::repeat(true, expected_bits),
{
let mut bv = BitVec::<Lsb0, u8>::repeat(false, expected_bits);
let mut bv = BitVec::<u8, Lsb0>::repeat(false, expected_bits);
bv.set(expected_bits - 1, true);
bv
},
+2 -2
View File
@@ -89,7 +89,7 @@ fn upward_message_id(data: &[u8]) -> MessageId {
impl<XcmExecutor: xcm::latest::ExecuteXcm<C::Call>, C: Config> UmpSink for XcmSink<XcmExecutor, C> {
fn process_upward_message(
origin: ParaId,
data: &[u8],
mut data: &[u8],
max_weight: Weight,
) -> Result<Weight, (MessageId, Weight)> {
use parity_scale_codec::DecodeLimit;
@@ -101,7 +101,7 @@ impl<XcmExecutor: xcm::latest::ExecuteXcm<C::Call>, C: Config> UmpSink for XcmSi
let id = upward_message_id(&data[..]);
let maybe_msg = VersionedXcm::<C::Call>::decode_all_with_depth_limit(
xcm::MAX_XCM_DECODE_DEPTH,
&mut &data[..],
&mut data,
)
.map(Xcm::<C::Call>::try_from);
match maybe_msg {