@@ -63,8 +63,10 @@ use indexmap::{IndexMap, IndexSet};
6363#[ cfg( test) ]
6464use mockall:: automock;
6565use starknet_api:: block:: { BlockHash , BlockNumber } ;
66- use starknet_api:: block_hash:: block_hash_calculator:: PartialBlockHashComponents ;
67- use starknet_api:: block_hash:: state_diff_hash:: calculate_state_diff_hash;
66+ use starknet_api:: block_hash:: block_hash_calculator:: {
67+ PartialBlockHash ,
68+ PartialBlockHashComponents ,
69+ } ;
6870use starknet_api:: consensus_transaction:: InternalConsensusTransaction ;
6971use starknet_api:: core:: { ContractAddress , GlobalRoot , Nonce } ;
7072use starknet_api:: state:: { StateNumber , ThinStateDiff } ;
@@ -823,7 +825,21 @@ impl Batcher {
823825 ) ;
824826 trace ! ( "Rejected transactions: {:#?}, State diff: {:#?}." , rejected_tx_hashes, state_diff) ;
825827
826- let state_diff_commitment = calculate_state_diff_hash ( & state_diff) ;
828+ if let StorageCommitmentBlockHash :: Partial ( ref components) = & storage_commitment_block_hash
829+ {
830+ self . prev_proposal_commitment = Some ( (
831+ height,
832+ ProposalCommitment {
833+ partial_block_hash : PartialBlockHash :: from_partial_block_hash_components (
834+ components,
835+ )
836+ . map_err ( |e| {
837+ error ! ( "Failed to compute partial block hash: {}" , e) ;
838+ BatcherError :: InternalError
839+ } ) ?,
840+ } ,
841+ ) ) ;
842+ }
827843
828844 // Commit the proposal to the storage.
829845 self . storage_writer
@@ -833,8 +849,6 @@ impl Batcher {
833849 BatcherError :: InternalError
834850 } ) ?;
835851 info ! ( "Successfully committed proposal for block {} to storage." , height) ;
836- self . prev_proposal_commitment =
837- Some ( ( height, ProposalCommitment { state_diff_commitment } ) ) ;
838852
839853 // Notify the L1 provider of the new block.
840854 let rejected_l1_handler_tx_hashes = rejected_tx_hashes
@@ -1131,25 +1145,30 @@ impl Batcher {
11311145 Ok ( Some ( commitment) )
11321146 }
11331147 None => {
1134- // Parent proposal commitment is not cached. Compute it from the stored state diff.
1135- let mut state_diff = self
1148+ // Parent proposal commitment is not cached. Read partial block hash
1149+ // components from storage and compute the partial block hash.
1150+ let ( _, components) = self
11361151 . storage_reader
1137- . get_state_diff ( prev_height)
1152+ . get_parent_hash_and_partial_block_hash_components ( prev_height)
11381153 . map_err ( |err| {
11391154 error ! (
1140- "Failed to read state diff for previous height {prev_height}: {}" ,
1155+ "Failed to read partial block hash components for previous height \
1156+ {prev_height}: {}",
11411157 err
11421158 ) ;
11431159 BatcherError :: InternalError
1144- } ) ?
1145- . expect ( "Missing state diff for previous height." ) ;
1146-
1147- // Enforcing no deprecated classes (since v0.14.0).
1148- // TODO(dafna): Remove once the state sync bug is fixed.
1149- state_diff. deprecated_declared_classes = Vec :: new ( ) ;
1160+ } ) ?;
1161+ let components =
1162+ components. expect ( "Missing partial block hash components for previous height." ) ;
11501163
11511164 Ok ( Some ( ProposalCommitment {
1152- state_diff_commitment : calculate_state_diff_hash ( & state_diff) ,
1165+ partial_block_hash : PartialBlockHash :: from_partial_block_hash_components (
1166+ & components,
1167+ )
1168+ . map_err ( |e| {
1169+ error ! ( "Failed to compute partial block hash: {}" , e) ;
1170+ BatcherError :: InternalError
1171+ } ) ?,
11531172 } ) )
11541173 }
11551174 }
0 commit comments