diff --git a/node/src/da_block_import.rs b/node/src/da_block_import.rs index ff80fdd15..9bcccd9c6 100644 --- a/node/src/da_block_import.rs +++ b/node/src/da_block_import.rs @@ -26,6 +26,7 @@ use sc_consensus::{ use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_consensus::{BlockOrigin, Error as ConsensusError}; +use sp_core::H256; use sp_runtime::traits::Block as BlockT; #[derive(Constructor)] @@ -51,7 +52,7 @@ impl Clone for BlockImport { #[async_trait::async_trait] impl BlockImportT for BlockImport where - B: BlockT, + B: BlockT, BE: Backend, I: BlockImportT + Clone + Send + Sync, I::Error: Into, @@ -82,7 +83,7 @@ where let extrinsics = block.body.as_ref().unwrap_or(&vec![]).clone(); - let best_hash = self.client.info().best_hash; + let parent_hash = ::Hash::from(block.header.parent_hash); let extension = &block.header.extension.clone(); let (block_number, import_block_hash) = (block.header.number, block.post_hash()); @@ -98,7 +99,7 @@ where let success = build_data_root_and_extension( self, - best_hash, + parent_hash, import_block_hash, extrinsics, extension, @@ -133,7 +134,7 @@ where fn build_data_root_and_extension( block_import: &BlockImport, - best_hash: ::Hash, + parent_hash: ::Hash, import_block_hash: ::Hash, extrinsics: Vec, extension: &avail_core::header::HeaderExtension, @@ -166,13 +167,19 @@ where let data_root = block_import .client .runtime_api() - .build_data_root(best_hash, extrinsics.clone()) + .build_data_root(parent_hash, extrinsics.clone()) .map_err(|e| ClientImport(format!("Data root cannot be calculated: {e:?}")))?; block_import .client .runtime_api() - .build_extension(best_hash, extrinsics, data_root, block_length, block_number) + .build_extension( + parent_hash, + extrinsics, + data_root, + block_length, + block_number, + ) .map_err(|e| ClientImport(format!("Build extension fails due to: {e:?}")))? }, _ => { @@ -198,14 +205,14 @@ where let data_root = block_import .client .runtime_api() - .build_data_root_v2(best_hash, successful_extrinsics.clone()) + .build_data_root_v2(parent_hash, successful_extrinsics.clone()) .map_err(|e| ClientImport(format!("Data root cannot be calculated: {e:?}")))?; block_import .client .runtime_api() .build_versioned_extension( - best_hash, + parent_hash, successful_extrinsics, data_root, block_length,