mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 16:21:02 +00:00
sanity check on validity-votes length (#354)
This commit is contained in:
committed by
Gavin Wood
parent
14cf3142d3
commit
8c4d882407
@@ -737,12 +737,20 @@ impl<T: Trait> Module<T> {
|
|||||||
let mut encoded_implicit = None;
|
let mut encoded_implicit = None;
|
||||||
let mut encoded_explicit = None;
|
let mut encoded_explicit = None;
|
||||||
|
|
||||||
for ((auth_index, _), validity_attestation) in candidate.validator_indices
|
let mut expected_votes_len = 0;
|
||||||
|
for (vote_index, (auth_index, _)) in candidate.validator_indices
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter(|(_, bit)| *bit)
|
.filter(|(_, bit)| *bit)
|
||||||
.zip(candidate.validity_votes.iter())
|
.enumerate()
|
||||||
{
|
{
|
||||||
|
let validity_attestation = match candidate.validity_votes.get(vote_index) {
|
||||||
|
None => return Err("Not enough validity votes"),
|
||||||
|
Some(v) => {
|
||||||
|
expected_votes_len = vote_index + 1;
|
||||||
|
v
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if validator_group.iter().find(|&(idx, _)| *idx == auth_index).is_none() {
|
if validator_group.iter().find(|&(idx, _)| *idx == auth_index).is_none() {
|
||||||
return Err("Attesting validator not on this chain's validation duty.");
|
return Err("Attesting validator not on this chain's validation duty.");
|
||||||
@@ -774,6 +782,11 @@ impl<T: Trait> Module<T> {
|
|||||||
"Candidate validity attestation signature is bad."
|
"Candidate validity attestation signature is bad."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ensure!(
|
||||||
|
candidate.validity_votes.len() == expected_votes_len,
|
||||||
|
"Extra untagged validity votes along with candidate"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user