mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 22:01:04 +00:00
Pass parent hash to the validate_block function
This commit is contained in:
@@ -23,6 +23,7 @@ use runtime_primitives::traits::{
|
|||||||
use executive::ExecuteBlock;
|
use executive::ExecuteBlock;
|
||||||
|
|
||||||
use substrate_trie::{MemoryDB, read_trie_value, delta_trie_root};
|
use substrate_trie::{MemoryDB, read_trie_value, delta_trie_root};
|
||||||
|
use codec::Decode;
|
||||||
|
|
||||||
use rstd::{slice, ptr, cmp, vec::Vec, boxed::Box, mem};
|
use rstd::{slice, ptr, cmp, vec::Vec, boxed::Box, mem};
|
||||||
|
|
||||||
@@ -56,14 +57,14 @@ trait Storage {
|
|||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub fn validate_block<B: BlockT, E: ExecuteBlock<B>>(
|
pub fn validate_block<B: BlockT, E: ExecuteBlock<B>>(
|
||||||
mut block_data: &[u8],
|
mut arguments: &[u8],
|
||||||
) {
|
) {
|
||||||
use codec::Decode;
|
let (parent_hash, block_data): (B::Hash, crate::ParachainBlockData::<B>) = Decode::decode(&mut arguments)
|
||||||
|
|
||||||
let block_data = crate::ParachainBlockData::<B>::decode(&mut block_data)
|
|
||||||
.expect("Could not decode parachain block.");
|
.expect("Could not decode parachain block.");
|
||||||
// TODO: Add `PolkadotInherent`.
|
// TODO: Add `PolkadotInherent`.
|
||||||
let block = B::new(block_data.header, block_data.extrinsics);
|
let block = B::new(block_data.header, block_data.extrinsics);
|
||||||
|
assert!(parent_hash == *block.header().parent_hash(), "Invalid parent hash");
|
||||||
|
|
||||||
let storage = WitnessStorage::<B>::new(
|
let storage = WitnessStorage::<B>::new(
|
||||||
block_data.witness_data,
|
block_data.witness_data,
|
||||||
block_data.witness_data_storage_root,
|
block_data.witness_data_storage_root,
|
||||||
|
|||||||
Reference in New Issue
Block a user