Skip to content

feat: use longest common prefix for determining tx replay set #6353

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

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

hstove
Copy link
Contributor

@hstove hstove commented Aug 5, 2025

This PR adds the ability for the global state machine evaluator to use a longest common prefix algorithm to determine the global transaction replay set after a fork.

For example, if one replay set is [A,B,C] with 50% weight, and another is [A,B] with 30% weight, then we will use [A,B] as the global replay set.

There is code for ensuring we end up with a deterministic global replay set by doing a comparison of signer weight, and then length, and then via txid comparisons.

/// Find the longest common prefix of replay sets that has majority support.
/// This implements the longest common prefix (LCP) strategy where if one signer's replay set
/// is [A,B,C] and another is [A,B], we should use [A,B] as the replay set.
/// Order matters for transaction replay - [A,B] and [B,A] have no common prefix.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hahaha this looks like a leetcode question XD

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha I know, and it makes me feel fancy, but it's really much simpler than it sounds 😆

jferrant
jferrant previously approved these changes Aug 7, 2025
Copy link
Contributor

@jferrant jferrant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM: only some minor nits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tx Replay: when agreeing on transaction replay set, use the biggest subset of transactions
3 participants