Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

use strong key in parachains module KeyOwnerProofSystem #951

Merged
merged 1 commit into from
Mar 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions runtime/common/src/parachains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl<Proof: Parameter + GetSessionNumber> DoubleVoteReport<Proof> {
) -> Result<(), DoubleVoteValidityError> {
let first = self.first.clone();
let second = self.second.clone();
let id = self.identity.encode();
let id = self.identity.clone();

T::KeyOwnerProofSystem::check_proof((PARACHAIN_KEY_TYPE_ID, id), self.proof.clone())
.ok_or(DoubleVoteValidityError::InvalidProof)?;
Expand Down Expand Up @@ -251,7 +251,7 @@ pub trait Trait: attestations::Trait + session::historical::Trait {

/// Compute and check proofs of historical key owners.
type KeyOwnerProofSystem: KeyOwnerProofSystem<
(KeyTypeId, Vec<u8>),
(KeyTypeId, ValidatorId),
Proof = Self::Proof,
IdentificationTuple = Self::IdentificationTuple,
>;
Expand Down Expand Up @@ -486,7 +486,7 @@ decl_module! {
pub fn report_double_vote(
origin,
report: DoubleVoteReport<
<T::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, Vec<u8>)>>::Proof,
<T::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, ValidatorId)>>::Proof,
>,
) -> DispatchResult {
let reporter = ensure_signed(origin)?;
Expand All @@ -500,7 +500,7 @@ decl_module! {
// We have already checked this proof in `SignedExtension`, but we need
// this here to get the full identification of the offender.
let offender = T::KeyOwnerProofSystem::check_proof(
(PARACHAIN_KEY_TYPE_ID, identity.encode()),
(PARACHAIN_KEY_TYPE_ID, identity),
proof,
).ok_or("Invalid/outdated key ownership proof.")?;

Expand Down Expand Up @@ -1468,8 +1468,10 @@ mod tests {
type Registrar = registrar::Module<Test>;
type MaxCodeSize = MaxCodeSize;
type MaxHeadDataSize = MaxHeadDataSize;
type Proof = <Historical as KeyOwnerProofSystem<(KeyTypeId, Vec<u8>)>>::Proof;
type IdentificationTuple = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, Vec<u8>)>>::IdentificationTuple;
type Proof =
<Historical as KeyOwnerProofSystem<(KeyTypeId, ValidatorId)>>::Proof;
type IdentificationTuple =
<Historical as KeyOwnerProofSystem<(KeyTypeId, ValidatorId)>>::IdentificationTuple;
type ReportOffence = Offences;
type BlockHashConversion = sp_runtime::traits::Identity;
type KeyOwnerProofSystem = Historical;
Expand Down