@@ -31,7 +31,7 @@ use starknet_committer::db::serde_db_utils::{
3131use starknet_committer:: forest:: filled_forest:: FilledForest ;
3232use starknet_patricia_storage:: map_storage:: MapStorage ;
3333use starknet_patricia_storage:: storage_trait:: { DbValue , Storage } ;
34- use tracing:: error;
34+ use tracing:: { debug , error, info , warn } ;
3535
3636#[ cfg( test) ]
3737#[ path = "committer_test.rs" ]
@@ -66,6 +66,7 @@ impl<S: StorageConstructor, CB: CommitBlockTrait> Committer<S, CB> {
6666 pub async fn new ( config : CommitterConfig ) -> Self {
6767 let mut forest_storage = MockForestStorage { storage : S :: create_storage ( ) } ;
6868 let offset = Self :: load_offset_or_panic ( & mut forest_storage) . await ;
69+ info ! ( "Initializing committer with offset: {offset}" ) ;
6970 Self { forest_storage, config, offset, phantom : PhantomData }
7071 }
7172
@@ -75,6 +76,10 @@ impl<S: StorageConstructor, CB: CommitBlockTrait> Committer<S, CB> {
7576 & mut self ,
7677 CommitBlockRequest { state_diff, state_diff_commitment, height } : CommitBlockRequest ,
7778 ) -> CommitterResult < CommitBlockResponse > {
79+ info ! (
80+ "Received request to commit block number {height} with state diff \
81+ {state_diff_commitment:?}"
82+ ) ;
7883 if height > self . offset {
7984 // Request to commit a future height.
8085 // Returns an error, indicating the committer has a hole in the state diff series.
@@ -89,6 +94,11 @@ impl<S: StorageConstructor, CB: CommitBlockTrait> Committer<S, CB> {
8994 if height < self . offset {
9095 // Request to commit an old height.
9196 // Might be ok if the caller didn't get the results properly.
97+ warn ! (
98+ "Received request to commit an old block number {height}. The committer offset is \
99+ {0}.",
100+ self . offset
101+ ) ;
92102 let stored_state_diff_commitment = self . load_state_diff_commitment ( height) . await ?;
93103 // Verify the input state diff matches the stored one by comparing the commitments.
94104 if state_diff_commitment != stored_state_diff_commitment {
@@ -104,6 +114,7 @@ impl<S: StorageConstructor, CB: CommitBlockTrait> Committer<S, CB> {
104114 }
105115
106116 // Happy flow. Commits the state diff and returns the computed global root.
117+ debug ! ( "Committing block number {height} with state diff {state_diff_commitment:?}" ) ;
107118 let ( filled_forest, global_root) = self . commit_state_diff ( state_diff) . await ?;
108119 let next_offset = height. unchecked_next ( ) ;
109120 let metadata = HashMap :: from ( [
@@ -120,6 +131,10 @@ impl<S: StorageConstructor, CB: CommitBlockTrait> Committer<S, CB> {
120131 serialize_felt_no_packing ( state_diff_commitment. 0 . 0 ) ,
121132 ) ,
122133 ] ) ;
134+ info ! (
135+ "For block number {height}, writing filled forest to storage with metadata: \
136+ {metadata:?}"
137+ ) ;
123138 self . forest_storage
124139 . write_with_metadata ( & filled_forest, metadata)
125140 . await
@@ -133,19 +148,27 @@ impl<S: StorageConstructor, CB: CommitBlockTrait> Committer<S, CB> {
133148 & mut self ,
134149 RevertBlockRequest { reversed_state_diff, height } : RevertBlockRequest ,
135150 ) -> CommitterResult < RevertBlockResponse > {
151+ info ! ( "Received request to revert block number {height}" ) ;
136152 let Some ( last_committed_block) = self . offset . prev ( ) else {
137153 // No committed blocks. Nothing to revert.
154+ warn ! ( "Received request to revert block number {height}. No committed blocks." ) ;
138155 return Ok ( RevertBlockResponse :: Uncommitted ) ;
139156 } ;
140157
141158 if height > self . offset {
142159 // Request to revert a future height. Nothing to revert.
160+ warn ! (
161+ "Received request to revert a future block number {height}. The committer offset \
162+ is {0}.",
163+ self . offset
164+ ) ;
143165 return Ok ( RevertBlockResponse :: Uncommitted ) ;
144166 }
145167
146168 if height == self . offset {
147169 // Request to revert the next future height.
148170 // Nothing to revert, but we have the resulted state root.
171+ warn ! ( "Received request to revert the committer offset height block {height}." ) ;
149172 let db_state_root = self . load_global_root ( last_committed_block) . await ?;
150173 return Ok ( RevertBlockResponse :: AlreadyReverted ( db_state_root) ) ;
151174 }
@@ -158,6 +181,8 @@ impl<S: StorageConstructor, CB: CommitBlockTrait> Committer<S, CB> {
158181 last_committed_block,
159182 } ) ;
160183 }
184+
185+ debug ! ( "Reverting block number {height}" ) ;
161186 // Sanity.
162187 assert_eq ! ( height, last_committed_block) ;
163188 // Happy flow. Reverts the state diff and returns the computed global root.
@@ -187,6 +212,10 @@ impl<S: StorageConstructor, CB: CommitBlockTrait> Committer<S, CB> {
187212 ForestMetadataType :: CommitmentOffset ,
188213 DbValue ( DbBlockNumber ( last_committed_block) . serialize ( ) . to_vec ( ) ) ,
189214 ) ] ) ;
215+ info ! (
216+ "For block number {height}, writing filled forest and updating the commitment offset \
217+ to {last_committed_block}"
218+ ) ;
190219 self . forest_storage
191220 . write_with_metadata ( & filled_forest, metadata)
192221 . await
0 commit comments