Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually impl PartialEq for Reverts #1813

Open
Rjected opened this issue Sep 30, 2024 · 2 comments · May be fixed by #1827
Open

Manually impl PartialEq for Reverts #1813

Rjected opened this issue Sep 30, 2024 · 2 comments · May be fixed by #1827
Labels
feature New feature or lib ability good first issue Good for newcomers

Comments

@Rjected
Copy link
Collaborator

Rjected commented Sep 30, 2024

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.

@0xurb
Copy link

0xurb commented Oct 3, 2024

@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
    }

@frankudoags
Copy link
Contributor

can I take this? @Rjected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or lib ability good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants