diff --git a/crates/engine/invalid-block-hooks/src/witness.rs b/crates/engine/invalid-block-hooks/src/witness.rs index 841427bc3f..37d5bb0829 100644 --- a/crates/engine/invalid-block-hooks/src/witness.rs +++ b/crates/engine/invalid-block-hooks/src/witness.rs @@ -118,7 +118,7 @@ where db.merge_transitions(BundleRetention::Reverts); // Take the bundle state - let bundle_state = db.take_bundle(); + let mut bundle_state = db.take_bundle(); // Initialize a map of preimages. let mut state_preimages = HashMap::default(); @@ -198,6 +198,21 @@ where } // The bundle state after re-execution should match the original one. + // + // NOTE: This should not be needed if `Reverts` had a comparison method that sorted first, + // or otherwise did not care about order. + // + // See: https://github.com/bluealloy/revm/issues/1813 + let mut output = output.clone(); + for reverts in output.state.reverts.iter_mut() { + reverts.sort_by(|left, right| left.0.cmp(&right.0)); + } + + // We also have to sort the `bundle_state` reverts + for reverts in bundle_state.reverts.iter_mut() { + reverts.sort_by(|left, right| left.0.cmp(&right.0)); + } + if bundle_state != output.state { let original_path = self.save_file( format!("{}_{}.bundle_state.original.json", block.number, block.hash()),