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

fix(mevboost, relay): ordering logic for multiproofs #166

Merged
merged 4 commits into from
Jul 26, 2024

Conversation

thedevbirb
Copy link
Contributor

@thedevbirb thedevbirb commented Jul 26, 2024

After some internal discussion we figured out that our MEV-Boost and relay fork don't need to sort the unindexed constraints like builder does, see #162 for context, but it is sufficient that the InclusionProof struct satisfies the following property:

The TransactionHashes field must be following the same order of GeneralizedIndexes

An example is the following: if on a block $B$ I have two preconfirmed transactions $T_1$ and $T_2$ at index $i_1$, $i_2$ respectively and $g_1$, $g_2$ are their generalized indexes, then the proof data must be:

TransactionHashes: [Hash(T_1), Hash(T_2)],
GeneralizedIndexes: [g_1, g_2]

or, equivalently

TransactionHashes: [Hash(T_2), Hash(T_1)],
GeneralizedIndexes: [g_2, g_1]

@thedevbirb thedevbirb requested a review from mempirate July 26, 2024 12:47
@@ -50,17 +61,14 @@ func verifyInclusionProof(log *logrus.Entry, transactionsRoot phase0.Root, proof
}

leaves[i] = txHashTreeRoot[:]
indexes[i] = int(proof.GeneralizedIndexes[i])
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be careful with converting from uin64 to int64 here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is safe because max i64 is 9,223,372,036,854,775,807 and all generalized indexes for transactions are capped at 2^22 -1 = 4,194,303 by consensus specs

Copy link
Contributor Author

@thedevbirb thedevbirb Jul 26, 2024

Choose a reason for hiding this comment

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

For the multiproof verification it is required that indexes is a []int. Given that generalized indexes will reasonably be small numbers (in the order of $2^{21}$ in our use case), we should not worry too much about it

Copy link
Contributor

@mempirate mempirate left a comment

Choose a reason for hiding this comment

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

LGTM, let's test this and then merge

@merklefruit merklefruit merged commit 0d1f0be into unstable Jul 26, 2024
2 checks passed
@thedevbirb thedevbirb deleted the fix/devnet/multiproof-ordering-logic branch July 26, 2024 14:34
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.

3 participants