grandpa: missing equivocation reporting nits (#5953)

* primitives: move reporting key type to common key types

* session: remove useless methods on MembershipProof

* grandpa: remove std special-casing when checking signatures

* grandpa: add some more docs

* grandpa: use proper error types rather than strings
This commit is contained in:
André Silva
2020-05-12 12:17:33 +01:00
committed by GitHub
parent 871761694e
commit ab208837fa
6 changed files with 32 additions and 41 deletions
+2
View File
@@ -1006,6 +1006,8 @@ pub mod key_types {
pub const AUTHORITY_DISCOVERY: KeyTypeId = KeyTypeId(*b"audi");
/// Key type for staking, built-in. Identified as `stak`.
pub const STAKING: KeyTypeId = KeyTypeId(*b"stak");
/// Key type for equivocation reporting, built-in. Identified as `fish`.
pub const REPORTING: KeyTypeId = KeyTypeId(*b"fish");
/// A key type ID useful for tests.
pub const DUMMY: KeyTypeId = KeyTypeId(*b"dumy");
}
@@ -352,21 +352,11 @@ where
H: Encode,
N: Encode,
{
use sp_application_crypto::RuntimeAppPublic;
localized_payload_with_buffer(round, set_id, message, buf);
#[cfg(not(feature = "std"))]
let verify = || {
use sp_application_crypto::RuntimeAppPublic;
id.verify(&buf, signature)
};
#[cfg(feature = "std")]
let verify = || {
use sp_application_crypto::Pair;
AuthorityPair::verify(signature, &buf, &id)
};
if verify() {
if id.verify(&buf, signature) {
Ok(())
} else {
#[cfg(feature = "std")]
@@ -501,7 +491,10 @@ sp_api::decl_runtime_apis! {
/// provide the equivocation proof and a key ownership proof (should be
/// obtained using `generate_key_ownership_proof`). This method will
/// sign the extrinsic with any reporting keys available in the keystore
/// and will push the transaction to the pool.
/// and will push the transaction to the pool. This method returns `None`
/// when creation of the extrinsic fails, either due to unavailability
/// of keys to sign, or because equivocation reporting is disabled for
/// the given runtime (i.e. this method is hardcoded to return `None`).
/// Only useful in an offchain context.
fn submit_report_equivocation_extrinsic(
equivocation_proof: EquivocationProof<Block::Hash, NumberFor<Block>>,
-12
View File
@@ -63,18 +63,6 @@ pub struct MembershipProof {
pub validator_count: ValidatorCount,
}
impl MembershipProof {
/// Returns a session this proof was generated for.
pub fn session(&self) -> SessionIndex {
self.session
}
/// Returns the validator count of the session this proof was generated for.
pub fn validator_count(&self) -> ValidatorCount {
self.validator_count
}
}
/// Generate the initial session keys with the given seeds, at the given block and store them in
/// the client's keystore.
#[cfg(feature = "std")]