fix(l1): check ENR key/value pairs are ordered and unique - #7227
Open
zexoverz wants to merge 1 commit into
Open
Conversation
…licated EIP-778 requires the pairs to be sorted by key and unique. `encode_pairs` already emits them that way but decoding accepted any order, so a record with a duplicate key kept whichever copy came last and one with unordered keys re-encoded into a different byte string than the one that was signed. Closes lambdaclass#3493 Claude-Session: https://claude.ai/code/session_01CWCwisL95EQwmp51L72uQ7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
EIP-778 requires the key/value pairs to be sorted by key and unique, and nothing checked it on decode.
Description
Rejecting rather than sorting or deduplicating on the way in, since the signature covers the encoded bytes. A record we normalised would re-encode into something other than what was signed, so it could not be verified or relayed anyway, and a peer sending one is violating the spec either way. The check lives in
try_from_raw_pairsso it also covers the raw pairs built by callers, not only what arrives over the wire.Closes #3493
Checklist
STORE_SCHEMA_VERSION(crates/storage/lib.rs) if the PR includes breaking changes to theStorerequiring a re-sync.