File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed
crates/blockifier_reexecution/src/state_reader Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -133,7 +133,9 @@ pub trait ConsecutiveReexecutionStateReaders<S: StateReader + Send + Sync + 'sta
133133
134134 fn get_next_block_state_diff ( & self ) -> ReexecutionResult < CommitmentStateDiff > ;
135135
136- fn reexecute_and_verify_correctness ( self ) -> Option < CachedState < S > > {
136+ /// Reexecutes a block and returns the block state along with the expected and actual state
137+ /// diffs. Does not verify that the state diffs match.
138+ fn reexecute_block ( self ) -> ( Option < CachedState < S > > , CommitmentStateDiff , CommitmentStateDiff ) {
137139 let expected_state_diff = self . get_next_block_state_diff ( ) . unwrap ( ) ;
138140
139141 let all_txs_in_next_block = self . get_next_block_txs ( ) . unwrap ( ) ;
@@ -153,8 +155,14 @@ pub trait ConsecutiveReexecutionStateReaders<S: StateReader + Send + Sync + 'sta
153155 . expect ( "Couldn't finalize block" )
154156 . state_diff ;
155157
158+ ( transaction_executor. block_state , expected_state_diff, actual_state_diff)
159+ }
160+
161+ fn reexecute_and_verify_correctness ( self ) -> Option < CachedState < S > > {
162+ let ( block_state, expected_state_diff, actual_state_diff) = self . reexecute_block ( ) ;
163+
156164 assert_eq_state_diff ! ( expected_state_diff, actual_state_diff) ;
157165
158- transaction_executor . block_state
166+ block_state
159167 }
160168}
Original file line number Diff line number Diff line change @@ -276,8 +276,21 @@ pub fn write_block_reexecution_data_to_file(
276276
277277 let old_block_hash = consecutive_state_readers. get_old_block_hash ( ) . unwrap ( ) ;
278278
279- // Run the reexecution test and get the state maps and contract class mapping.
280- let block_state = consecutive_state_readers. reexecute_and_verify_correctness ( ) . unwrap ( ) ;
279+ // Run the reexecution and get the state maps and contract class mapping.
280+ let ( block_state, expected_state_diff, actual_state_diff) =
281+ consecutive_state_readers. reexecute_block ( ) ;
282+
283+ // Warn if state diffs don't match, but continue writing the file.
284+ let expected_comparable = ComparableStateDiff :: from ( expected_state_diff) ;
285+ let actual_comparable = ComparableStateDiff :: from ( actual_state_diff) ;
286+ if expected_comparable != actual_comparable {
287+ println ! (
288+ "WARNING: State diff mismatch for block {block_number}. Expected and actual state \
289+ diffs do not match."
290+ ) ;
291+ }
292+
293+ let block_state = block_state. unwrap ( ) ;
281294 let serializable_data_prev_block = SerializableDataPrevBlock {
282295 state_maps : block_state. get_initial_reads ( ) . unwrap ( ) . into ( ) ,
283296 contract_class_mapping : block_state
You can’t perform that action at this time.
0 commit comments