@@ -927,39 +927,22 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
927
927
BlockOrigin :: Genesis | BlockOrigin :: NetworkInitialSync | BlockOrigin :: File => false ,
928
928
} ;
929
929
930
- let storage_changes = match & body {
931
- Some ( body) => {
932
- self . backend . begin_state_operation ( & mut operation. op , BlockId :: Hash ( parent_hash) ) ?;
933
-
934
- // ensure parent block is finalized to maintain invariant that
935
- // finality is called sequentially.
936
- if finalized {
937
- self . apply_finality_with_block_hash ( operation, parent_hash, None , info. best_hash , make_notifications) ?;
938
- }
930
+ self . backend . begin_state_operation ( & mut operation. op , BlockId :: Hash ( parent_hash) ) ?;
939
931
940
- // FIXME #1232: correct path logic for when to execute this function
941
- let ( storage_update, changes_update, storage_changes) = self . block_execution (
942
- & operation. op ,
943
- & import_headers,
944
- origin,
945
- hash,
946
- & body,
947
- ) ?;
932
+ // ensure parent block is finalized to maintain invariant that
933
+ // finality is called sequentially.
934
+ if finalized {
935
+ self . apply_finality_with_block_hash ( operation, parent_hash, None , info. best_hash , make_notifications) ?;
936
+ }
948
937
949
- operation. op . update_cache ( new_cache) ;
950
- if let Some ( storage_update) = storage_update {
951
- operation. op . update_db_storage ( storage_update) ?;
952
- }
953
- if let Some ( storage_changes) = storage_changes. clone ( ) {
954
- operation. op . update_storage ( storage_changes. 0 , storage_changes. 1 ) ?;
955
- }
956
- if let Some ( Some ( changes_update) ) = changes_update {
957
- operation. op . update_changes_trie ( changes_update) ?;
958
- }
959
- storage_changes
960
- } ,
961
- None => Default :: default ( )
962
- } ;
938
+ // FIXME #1232: correct path logic for when to execute this function
939
+ let ( storage_update, changes_update, storage_changes) = self . block_execution (
940
+ & operation. op ,
941
+ & import_headers,
942
+ origin,
943
+ hash,
944
+ body. clone ( ) ,
945
+ ) ?;
963
946
964
947
let is_new_best = finalized || match fork_choice {
965
948
ForkChoiceStrategy :: LongestChain => import_headers. post ( ) . number ( ) > & info. best_number ,
@@ -994,6 +977,17 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
994
977
leaf_state,
995
978
) ?;
996
979
980
+ operation. op . update_cache ( new_cache) ;
981
+ if let Some ( storage_update) = storage_update {
982
+ operation. op . update_db_storage ( storage_update) ?;
983
+ }
984
+ if let Some ( storage_changes) = storage_changes. clone ( ) {
985
+ operation. op . update_storage ( storage_changes. 0 , storage_changes. 1 ) ?;
986
+ }
987
+ if let Some ( Some ( changes_update) ) = changes_update {
988
+ operation. op . update_changes_trie ( changes_update) ?;
989
+ }
990
+
997
991
operation. op . insert_aux ( aux) ?;
998
992
999
993
if make_notifications {
@@ -1020,7 +1014,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
1020
1014
import_headers : & PrePostHeader < Block :: Header > ,
1021
1015
origin : BlockOrigin ,
1022
1016
hash : Block :: Hash ,
1023
- body : & [ Block :: Extrinsic ] ,
1017
+ body : Option < Vec < Block :: Extrinsic > > ,
1024
1018
) -> error:: Result < (
1025
1019
Option < StorageUpdate < B , Block > > ,
1026
1020
Option < Option < ChangesUpdate < Block > > > ,
@@ -1058,7 +1052,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
1058
1052
1059
1053
let encoded_block = <Block as BlockT >:: encode_from (
1060
1054
import_headers. pre ( ) ,
1061
- body,
1055
+ & body. unwrap_or_default ( )
1062
1056
) ;
1063
1057
1064
1058
let ( _, storage_update, changes_update) = self . executor
@@ -1529,7 +1523,7 @@ impl<'a, B, E, Block, RA> consensus::BlockImport<Block> for &'a Client<B, E, Blo
1529
1523
& mut self ,
1530
1524
block : BlockCheckParams < Block > ,
1531
1525
) -> Result < ImportResult , Self :: Error > {
1532
- let BlockCheckParams { hash, number, parent_hash, header_only } = block;
1526
+ let BlockCheckParams { hash, number, parent_hash } = block;
1533
1527
1534
1528
if let Some ( h) = self . fork_blocks . as_ref ( ) . and_then ( |x| x. get ( & number) ) {
1535
1529
if & hash != h {
@@ -1547,9 +1541,7 @@ impl<'a, B, E, Block, RA> consensus::BlockImport<Block> for &'a Client<B, E, Blo
1547
1541
. map_err ( |e| ConsensusError :: ClientImport ( e. to_string ( ) ) ) ?
1548
1542
{
1549
1543
BlockStatus :: InChainWithState | BlockStatus :: Queued => { } ,
1550
- BlockStatus :: Unknown => return Ok ( ImportResult :: UnknownParent ) ,
1551
- BlockStatus :: InChainPruned if header_only => { } ,
1552
- BlockStatus :: InChainPruned => return Ok ( ImportResult :: MissingState ) ,
1544
+ BlockStatus :: Unknown | BlockStatus :: InChainPruned => return Ok ( ImportResult :: UnknownParent ) ,
1553
1545
BlockStatus :: KnownBad => return Ok ( ImportResult :: KnownBad ) ,
1554
1546
}
1555
1547
@@ -1561,6 +1553,7 @@ impl<'a, B, E, Block, RA> consensus::BlockImport<Block> for &'a Client<B, E, Blo
1561
1553
BlockStatus :: KnownBad => return Ok ( ImportResult :: KnownBad ) ,
1562
1554
}
1563
1555
1556
+
1564
1557
Ok ( ImportResult :: imported ( false ) )
1565
1558
}
1566
1559
}
0 commit comments