From 1acb47fc2b02ac6c19c059994f924d7635d85af4 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 14:59:49 -0400 Subject: [PATCH] verifier supports both digest types --- nimbus-consensus/src/import_queue.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/nimbus-consensus/src/import_queue.rs b/nimbus-consensus/src/import_queue.rs index f770047b..bedede78 100644 --- a/nimbus-consensus/src/import_queue.rs +++ b/nimbus-consensus/src/import_queue.rs @@ -76,24 +76,20 @@ where debug!(target: crate::LOG_TARGET, "🪲 Signature according to verifier is {:?}", signature); - // Grab the digest from the runtime - //TODO use the trait. Maybe this code should move to the trait. - let consensus_digest = block_params.header + // Grab the author information from either the preruntime digest or the consensus digest + //TODO use the trait + let claimed_author = block_params.header .digest() .logs .iter() - .find(|digest| { + .find_map(|digest| { match *digest { - DigestItem::Consensus(id, _) if id == b"nmbs" => true, - _ => false, + DigestItem::Consensus(id, ref author_id) if id == *b"nmbs" => Some(author_id.clone()), + DigestItem::PreRuntime(id, ref author_id) if id == *b"nmbs" => Some(author_id.clone()), + _ => None, } }) - .expect("A single consensus digest should be added by the runtime when executing the author inherent."); - - let claimed_author = match *consensus_digest { - DigestItem::Consensus(id, ref author_id) if id == *b"nmbs" => author_id.clone(), - _ => panic!("Expected consensus digest to contains author id bytes"), - }; + .expect("Expected one consensus or pre-runtime digest that contains author id bytes"); debug!(target: crate::LOG_TARGET, "🪲 Claimed Author according to verifier is {:?}", claimed_author);