mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 10:31:04 +00:00
BEEFY: Define basic fisherman (#4328)
Related to https://github.com/paritytech/polkadot-sdk/pull/1903 For #1903 we will need to add a Fisherman struct. This PR: - defines a basic version of `Fisherman` and moves into it the logic that we have now for reporting double voting equivocations - splits the logic for generating the key ownership proofs into a more generic separate method - renames `EquivocationProof` to `DoubleVotingProof` since later we will introduce a new type of equivocation The PR doesn't contain any functional changes
This commit is contained in:
@@ -306,14 +306,14 @@ pub struct VoteMessage<Number, Id, Signature> {
|
||||
/// BEEFY happens when a voter votes on the same round/block for different payloads.
|
||||
/// Proving is achieved by collecting the signed commitments of conflicting votes.
|
||||
#[derive(Clone, Debug, Decode, Encode, PartialEq, TypeInfo)]
|
||||
pub struct EquivocationProof<Number, Id, Signature> {
|
||||
pub struct DoubleVotingProof<Number, Id, Signature> {
|
||||
/// The first vote in the equivocation.
|
||||
pub first: VoteMessage<Number, Id, Signature>,
|
||||
/// The second vote in the equivocation.
|
||||
pub second: VoteMessage<Number, Id, Signature>,
|
||||
}
|
||||
|
||||
impl<Number, Id, Signature> EquivocationProof<Number, Id, Signature> {
|
||||
impl<Number, Id, Signature> DoubleVotingProof<Number, Id, Signature> {
|
||||
/// Returns the authority id of the equivocator.
|
||||
pub fn offender_id(&self) -> &Id {
|
||||
&self.first.id
|
||||
@@ -347,7 +347,7 @@ where
|
||||
/// Verifies the equivocation proof by making sure that both votes target
|
||||
/// different blocks and that its signatures are valid.
|
||||
pub fn check_equivocation_proof<Number, Id, MsgHash>(
|
||||
report: &EquivocationProof<Number, Id, <Id as RuntimeAppPublic>::Signature>,
|
||||
report: &DoubleVotingProof<Number, Id, <Id as RuntimeAppPublic>::Signature>,
|
||||
) -> bool
|
||||
where
|
||||
Id: BeefyAuthorityId<MsgHash> + PartialEq,
|
||||
@@ -437,7 +437,7 @@ sp_api::decl_runtime_apis! {
|
||||
/// hardcoded to return `None`). Only useful in an offchain context.
|
||||
fn submit_report_equivocation_unsigned_extrinsic(
|
||||
equivocation_proof:
|
||||
EquivocationProof<NumberFor<Block>, AuthorityId, <AuthorityId as RuntimeAppPublic>::Signature>,
|
||||
DoubleVotingProof<NumberFor<Block>, AuthorityId, <AuthorityId as RuntimeAppPublic>::Signature>,
|
||||
key_owner_proof: OpaqueKeyOwnershipProof,
|
||||
) -> Option<()>;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#[cfg(feature = "bls-experimental")]
|
||||
use crate::ecdsa_bls_crypto;
|
||||
use crate::{
|
||||
ecdsa_crypto, AuthorityIdBound, BeefySignatureHasher, Commitment, EquivocationProof, Payload,
|
||||
ecdsa_crypto, AuthorityIdBound, BeefySignatureHasher, Commitment, DoubleVotingProof, Payload,
|
||||
ValidatorSetId, VoteMessage,
|
||||
};
|
||||
use sp_application_crypto::{AppCrypto, AppPair, RuntimeAppPublic, Wraps};
|
||||
@@ -140,7 +140,7 @@ impl From<Keyring<ecdsa_crypto::AuthorityId>> for ecdsa_crypto::Public {
|
||||
pub fn generate_equivocation_proof(
|
||||
vote1: (u64, Payload, ValidatorSetId, &Keyring<ecdsa_crypto::AuthorityId>),
|
||||
vote2: (u64, Payload, ValidatorSetId, &Keyring<ecdsa_crypto::AuthorityId>),
|
||||
) -> EquivocationProof<u64, ecdsa_crypto::Public, ecdsa_crypto::Signature> {
|
||||
) -> DoubleVotingProof<u64, ecdsa_crypto::Public, ecdsa_crypto::Signature> {
|
||||
let signed_vote = |block_number: u64,
|
||||
payload: Payload,
|
||||
validator_set_id: ValidatorSetId,
|
||||
@@ -151,5 +151,5 @@ pub fn generate_equivocation_proof(
|
||||
};
|
||||
let first = signed_vote(vote1.0, vote1.1, vote1.2, vote1.3);
|
||||
let second = signed_vote(vote2.0, vote2.1, vote2.2, vote2.3);
|
||||
EquivocationProof { first, second }
|
||||
DoubleVotingProof { first, second }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user