GRANDPA finality proof draft (#1268)

* grandpa finality proof

* prove GrandpaApi::grandpa_authorities using parent block + some docs

* create justification when consensus data is changed

* generate justifications periodically

* test for ConsensusChanges
This commit is contained in:
Svyatoslav Nikolsky
2019-01-11 21:25:03 +03:00
committed by Gav Wood
parent 677b79765b
commit 616716cb4b
18 changed files with 786 additions and 113 deletions
+21 -7
View File
@@ -104,9 +104,9 @@ pub struct Transfer {
/// Extrinsic for test-runtime.
#[derive(Clone, PartialEq, Eq, Encode, Decode)]
#[cfg_attr(feature = "std", derive(Debug))]
pub struct Extrinsic {
pub transfer: Transfer,
pub signature: Ed25519Signature,
pub enum Extrinsic {
AuthoritiesChange(Vec<Ed25519AuthorityId>),
Transfer(Transfer, Ed25519Signature),
}
#[cfg(feature = "std")]
@@ -121,10 +121,15 @@ impl BlindCheckable for Extrinsic {
type Checked = Self;
fn check(self) -> Result<Self, &'static str> {
if ::runtime_primitives::verify_encoded_lazy(&self.signature, &self.transfer, &self.transfer.from) {
Ok(self)
} else {
Err("bad signature")
match self {
Extrinsic::AuthoritiesChange(new_auth) => Ok(Extrinsic::AuthoritiesChange(new_auth)),
Extrinsic::Transfer(transfer, signature) => {
if ::runtime_primitives::verify_encoded_lazy(&signature, &transfer, &transfer.from) {
Ok(Extrinsic::Transfer(transfer, signature))
} else {
Err("bad signature")
}
},
}
}
}
@@ -135,6 +140,15 @@ impl ExtrinsicT for Extrinsic {
}
}
impl Extrinsic {
pub fn transfer(&self) -> &Transfer {
match self {
Extrinsic::Transfer(ref transfer, _) => transfer,
_ => panic!("cannot convert to transfer ref"),
}
}
}
/// An identifier for an account on this system.
pub type AccountId = H256;
/// A simple hash type for all our hashing.