fix(hooks): sort reverts in BundleState before comparison (#11358)

This commit is contained in:
Dan Cline
2024-09-30 18:27:27 -04:00
committed by GitHub
parent 68f0b0a08f
commit c2cabcae71

View File

@ -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()),