@@ -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+ calculate_partial_block_hash,
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,18 @@ 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 : calculate_partial_block_hash ( components) . map_err ( |e| {
834+ error ! ( "Failed to compute partial block hash: {}" , e) ;
835+ BatcherError :: InternalError
836+ } ) ?,
837+ } ,
838+ ) ) ;
839+ }
827840
828841 // Commit the proposal to the storage.
829842 self . storage_writer
@@ -833,8 +846,6 @@ impl Batcher {
833846 BatcherError :: InternalError
834847 } ) ?;
835848 info ! ( "Successfully committed proposal for block {} to storage." , height) ;
836- self . prev_proposal_commitment =
837- Some ( ( height, ProposalCommitment { state_diff_commitment } ) ) ;
838849
839850 // Notify the L1 provider of the new block.
840851 let rejected_l1_handler_tx_hashes = rejected_tx_hashes
@@ -1131,25 +1142,28 @@ impl Batcher {
11311142 Ok ( Some ( commitment) )
11321143 }
11331144 None => {
1134- // Parent proposal commitment is not cached. Compute it from the stored state diff.
1135- let mut state_diff = self
1145+ // Parent proposal commitment is not cached. Read partial block hash
1146+ // components from storage and compute the partial block hash.
1147+ let ( _, components) = self
11361148 . storage_reader
1137- . get_state_diff ( prev_height)
1149+ . get_parent_hash_and_partial_block_hash_components ( prev_height)
11381150 . map_err ( |err| {
11391151 error ! (
1140- "Failed to read state diff for previous height {prev_height}: {}" ,
1152+ "Failed to read partial block hash components for previous height \
1153+ {prev_height}: {}",
11411154 err
11421155 ) ;
11431156 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 ( ) ;
1157+ } ) ?;
1158+ let components = components. expect (
1159+ "Missing partial block hash components for previous height." ,
1160+ ) ;
11501161
11511162 Ok ( Some ( ProposalCommitment {
1152- state_diff_commitment : calculate_state_diff_hash ( & state_diff) ,
1163+ partial_block_hash : calculate_partial_block_hash ( & components) . map_err ( |e| {
1164+ error ! ( "Failed to compute partial block hash: {}" , e) ;
1165+ BatcherError :: InternalError
1166+ } ) ?,
11531167 } ) )
11541168 }
11551169 }
0 commit comments