From bbb45c76dc05b13cc588bc4c1c1dcdc525c03a74 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Mon, 1 Apr 2019 23:52:44 +0200 Subject: [PATCH] fix backwards compatibility for aura seals (#2164) --- substrate/core/consensus/aura/slots/src/lib.rs | 4 +++- substrate/core/consensus/aura/src/lib.rs | 17 ++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/substrate/core/consensus/aura/slots/src/lib.rs b/substrate/core/consensus/aura/slots/src/lib.rs index 5339444130..cfad5b69cd 100644 --- a/substrate/core/consensus/aura/slots/src/lib.rs +++ b/substrate/core/consensus/aura/slots/src/lib.rs @@ -202,7 +202,9 @@ pub enum CheckedHeader { Deferred(H, u64), /// A header which is fully checked, including signature. This is the pre-header /// accompanied by the seal components. - Checked(H, u64, S), + /// + /// Includes the digest item that encoded the seal. + Checked(H, S), } /// A slot duration. Create with `get_or_compute`. diff --git a/substrate/core/consensus/aura/src/lib.rs b/substrate/core/consensus/aura/src/lib.rs index 256bcd43a4..eb785e6162 100644 --- a/substrate/core/consensus/aura/src/lib.rs +++ b/substrate/core/consensus/aura/src/lib.rs @@ -432,7 +432,9 @@ impl SlotWorker for AuraWorker( hash: B::Hash, authorities: &[AuthorityId

], allow_old_seals: bool, -) -> Result, String> +) -> Result>, String> where DigestItemFor: CompatibleDigestItem

, P::Public: AsRef, P::Signature: Decode, @@ -470,7 +472,7 @@ fn check_header( // chain state. let expected_author = match slot_author::

(slot_num, &authorities) { None => return Err("Slot Author not found".to_string()), - Some(author) => author + Some(author) => author, }; let pre_hash = header.hash(); @@ -478,7 +480,7 @@ fn check_header( let public = expected_author; if P::verify(&sig, &to_sign[..], public) { - Ok(CheckedHeader::Checked(header, slot_num, sig)) + Ok(CheckedHeader::Checked(header, digest_item)) } else { Err(format!("Bad signature on {:?}", hash)) } @@ -612,8 +614,9 @@ impl Verifier for AuraVerifier where self.allow_old_seals, )?; match checked_header { - CheckedHeader::Checked(pre_header, slot_num, sig) => { - let item = >::aura_seal(slot_num, sig); + CheckedHeader::Checked(pre_header, seal) => { + let (slot_num, _) = seal.as_aura_seal() + .expect("check_header always returns a seal digest item; qed"); // if the body is passed through, we need to use the runtime // to check that the internally-set timestamp in the inherents @@ -648,7 +651,7 @@ impl Verifier for AuraVerifier where let import_block = ImportBlock { origin, header: pre_header, - post_digests: vec![item], + post_digests: vec![seal], body, finalized: false, justification,