feat: integrate signature with boolean parity#1540
Merged
Conversation
3 tasks
b5e0a98 to
846c125
Compare
3 tasks
3 tasks
2e15710 to
e6177f7
Compare
e6177f7 to
fabd775
Compare
6e67c32 to
4ad8918
Compare
mattsse
approved these changes
Oct 31, 2024
mattsse
approved these changes
Nov 1, 2024
7a56d8a to
ede6173
Compare
ede6173 to
6408184
Compare
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
Integrates signature from alloy-rs/core#776
Depends on alloy-rs/eips#12 and alloy-rs/core#796, needs minor releases for core and eips
Solution
Changes in this PR:
signature.v()is now encoded and accounted in length separatelyu64and extracting chain_id when possible. Encoding manually encodes chain_id into boolean parity as per EIP-155 spec.sign_transaction_with_chain_idmacro no more adjusts the signature. as long as signer signed the correct payload with chain_id we are fine with parity being boolean, and legacy transaction encoding methods will figure out how to encode it into integersigned_legacy_serdemodule is added which should be used for serialization ofSigned<TxLegacy>to respect the specification requiring parity being serialized as EIP-155 compliantvkey.This is not perfect from our pov because we now have more boilerplate logic for parity encoding. However, this makes encoding API safer without any changes to it.
One limitation here is that
Signed<TxLegacy>on its own would be serialized incorrectly withyParitykey. We can't implement serialize directly on individualSigned<_>types because this would make it impossible to implement serde forSigned<_>with custom transaction. For now I've addedwith = "signed_legacy_serde"to envelope legacy variants which should ensure that enveloped transactions are always (de)serialized correctlyPR Checklist