@@ -681,16 +681,29 @@ impl Batcher {
681681 StorageCommitmentBlockHash :: ParentHash ( block_header_without_hash. parent_hash )
682682 } ;
683683
684+ let optional_state_diff_commitment = match & storage_commitment_block_hash {
685+ StorageCommitmentBlockHash :: ParentHash ( _) => None ,
686+ StorageCommitmentBlockHash :: Partial ( PartialBlockHashComponents {
687+ ref header_commitments,
688+ ..
689+ } ) => Some ( header_commitments. state_diff_commitment ) ,
690+ } ;
691+
684692 self . commit_proposal_and_block (
685693 height,
686- state_diff,
694+ state_diff. clone ( ) ,
687695 address_to_nonce,
688696 l1_transaction_hashes. iter ( ) . copied ( ) . collect ( ) ,
689697 Default :: default ( ) ,
690698 storage_commitment_block_hash,
691699 )
692700 . await ?;
693701
702+ self . commitment_manager
703+ . add_commitment_task ( height, state_diff, optional_state_diff_commitment)
704+ . await
705+ . expect ( "The commitment offset unexpectedly doesn't match the given block height." ) ;
706+
694707 // Write ready commitments to storage.
695708 self . write_commitment_results_to_storage ( ) . await ?;
696709
@@ -732,7 +745,9 @@ impl Batcher {
732745 )
733746 . expect ( "Number of reverted transactions should fit in u64" ) ;
734747 let partial_block_hash_components =
735- block_execution_artifacts. partial_block_hash_components ( ) . await ;
748+ block_execution_artifacts. partial_block_hash_components ( ) ;
749+ let state_diff_commitment =
750+ partial_block_hash_components. header_commitments . state_diff_commitment ;
736751 let block_header_commitments = partial_block_hash_components. header_commitments . clone ( ) ;
737752 let parent_proposal_commitment = self . get_parent_proposal_commitment ( height) ?;
738753 self . commit_proposal_and_block (
@@ -745,6 +760,15 @@ impl Batcher {
745760 )
746761 . await ?;
747762
763+ self . commitment_manager
764+ . add_commitment_task (
765+ height,
766+ state_diff. clone ( ) , // TODO(Nimrod): Remove the clone here.
767+ Some ( state_diff_commitment) ,
768+ )
769+ . await
770+ . expect ( "The commitment offset unexpectedly doesn't match the given block height." ) ;
771+
748772 // Write ready commitments to storage.
749773 self . write_commitment_results_to_storage ( ) . await ?;
750774
@@ -784,8 +808,6 @@ impl Batcher {
784808 } )
785809 }
786810
787- // The `partial_block_hash_components` is optional as it doesn't exist for old blocks coming
788- // from sync.
789811 async fn commit_proposal_and_block (
790812 & mut self ,
791813 height : BlockNumber ,
0 commit comments