mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 17:31:03 +00:00
Don't pass validators' public keys with attestations (#186)
* Don't pass validators' public keys with attestations * Update statement-table's Misbehaviour typedef * Update network/router * Expand MessageValidationData * Try to fix tests * Extend ApiContext * Remove 'index_mapping' from the SessionParams * Construct index_mapping from authorities * Move index_mapping to TableContext * Add test for index_mapping order
This commit is contained in:
committed by
Robert Habermeier
parent
36dd42523d
commit
e8fcb43fcf
@@ -393,9 +393,10 @@ impl<T: Trait> Module<T> {
|
||||
|
||||
// track which voters have voted already, 1 bit per authority.
|
||||
let mut track_voters = bitvec![0; authorities.len()];
|
||||
for (auth_id, validity_attestation) in &candidate.validity_votes {
|
||||
for (auth_index, validity_attestation) in &candidate.validity_votes {
|
||||
let auth_index = *auth_index as usize;
|
||||
// protect against double-votes.
|
||||
match validator_group.iter().find(|&(idx, _)| &authorities[*idx] == auth_id) {
|
||||
match validator_group.iter().find(|&(idx, _)| *idx == auth_index) {
|
||||
None => return Err("Attesting validator not on this chain's validation duty."),
|
||||
Some(&(idx, _)) => {
|
||||
if track_voters.get(idx) {
|
||||
@@ -427,7 +428,7 @@ impl<T: Trait> Module<T> {
|
||||
};
|
||||
|
||||
ensure!(
|
||||
sig.verify(&payload[..], &auth_id),
|
||||
sig.verify(&payload[..], &authorities[auth_index]),
|
||||
"Candidate validity attestation signature is bad."
|
||||
);
|
||||
}
|
||||
@@ -479,7 +480,7 @@ mod tests {
|
||||
use substrate_trie::NodeCodec;
|
||||
use sr_primitives::{generic, BuildStorage};
|
||||
use sr_primitives::traits::{BlakeTwo256, IdentityLookup};
|
||||
use primitives::{parachain::{CandidateReceipt, HeadData, ValidityAttestation}, SessionKey};
|
||||
use primitives::{parachain::{CandidateReceipt, HeadData, ValidityAttestation, ValidatorIndex}, SessionKey};
|
||||
use keyring::{AuthorityKeyring, AccountKeyring};
|
||||
use {consensus, timestamp};
|
||||
|
||||
@@ -590,7 +591,7 @@ mod tests {
|
||||
let payload = localized_payload(statement, parent_hash);
|
||||
let signature = key.sign(&payload[..]).into();
|
||||
|
||||
candidate.validity_votes.push((authorities[idx].clone(), if vote_implicit {
|
||||
candidate.validity_votes.push((idx as ValidatorIndex, if vote_implicit {
|
||||
ValidityAttestation::Implicit(signature)
|
||||
} else {
|
||||
ValidityAttestation::Explicit(signature)
|
||||
|
||||
Reference in New Issue
Block a user