mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 05:11:02 +00:00
Use GrandpaJustification instead of Vec<u8> in Pallet API (#847)
* Stop passing raw encoded justifications to pallet API By having the API accept a struct-ified justification we are able to better utilize the justifications fields for weight calculations. * Update relayer code to use decoded justifications * Add justification to `expect()` statement * Fix some imports * Make justification wrapper contain decoded justification * Rename some fields * Get rid of warnings * Appease Clippy * Only decode justification once at init time * Remove unnecessary method * Remove justification wrapper This became kinda unnecessary since we could implement the FinalityProof trait on GrandpaJustification directly.
This commit is contained in:
committed by
Bastian Köcher
parent
904b9f4da5
commit
67cdca8aa4
@@ -215,6 +215,8 @@ where
|
||||
/// proof. If the header enacts an authority set change the change will be applied once the
|
||||
/// header has been finalized.
|
||||
pub fn import_finality_proof(&mut self, hash: H::Hash, proof: FinalityProof) -> Result<(), FinalizationError> {
|
||||
use codec::Decode;
|
||||
|
||||
// Make sure that we've previously imported this header
|
||||
let header = self
|
||||
.storage
|
||||
@@ -233,11 +235,15 @@ where
|
||||
"We verified the correctness of the authority list during header import,
|
||||
before writing them to storage. This must always be valid.",
|
||||
);
|
||||
|
||||
let justification = bp_header_chain::justification::GrandpaJustification::<H>::decode(&mut proof.0.as_slice())
|
||||
.map_err(|_| FinalizationError::InvalidJustification)?;
|
||||
|
||||
verify_justification::<H>(
|
||||
(hash, *header.number()),
|
||||
current_authority_set.set_id,
|
||||
&voter_set,
|
||||
&proof.0,
|
||||
&justification,
|
||||
)
|
||||
.map_err(|_| FinalizationError::InvalidJustification)?;
|
||||
log::trace!("Received valid justification for {:?}", header);
|
||||
|
||||
Reference in New Issue
Block a user