revm icon indicating copy to clipboard operation
revm copied to clipboard

Manually impl `PartialEq` for `Reverts`

Open Rjected opened this issue 1 year ago • 2 comments

In reth's invalid block hooks, we first compare the invalid block's BundleState to a re-executed version, then use serde_json to serialize BundleState and save it as JSON. Because the reverts are unsorted, this leads to equivalent BundleStates being seen as not equal. Instead, there should be a comparison API for Reverts that returns true if the reverts have the same contents, regardless of ordering.

Rjected avatar Sep 30 '24 20:09 Rjected

@Rjected like this?

    /// Compares two `Reverts` for equality, sorting the internal `Vec`s in place.
    pub fn unordered_eq(&mut self, other: &mut Self) -> bool {
        // Sort inner vectors by Address in place
        self.sort();
        other.sort();

        // Compare sorted structures for equality
        self.0 == other.0
    }

0xurb avatar Oct 03 '24 20:10 0xurb

can I take this? @Rjected

frankudoags avatar Oct 14 '24 12:10 frankudoags