-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
anvil/eth: Use the raw v
signature value instead of bool
#7918
base: master
Are you sure you want to change the base?
Conversation
fn v_parity_to_u64(v: Parity) -> u64 { | ||
match v { | ||
Parity::Eip155(v) => v, | ||
Parity::NonEip155(b) => (b as u64) + 27, | ||
Parity::Parity(b) => b as u64, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prestwich is this something we should add as function instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
impl From<Parity> for u64
would be clean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be in alloy
then, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, in this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the method to_u64()
already existed ; I completely missed it 🙈 Updated the PR!
Instead of converting the boolean corresponding to the y parity byte to a u64/U256, use the raw `v` value for the `v` field when available.
967ae98
to
2091dd9
Compare
I added a 2nd commit that fixes invalid (from geth's PoV) dummy signatures. The issue was that it was using By using |
d913d6e
to
c751351
Compare
OK and one last commit, to actually use the provided signature when creating a transaction. This resolves an issue where the computed transaction hash in This is a bit tangential to the initial issue, so I could if needed open another PR for it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
I think the failing tests are related |
|
The correct `v` value must be used when using a dummy signature, depending on the transaction type (the Legacy transactions being the ones needing a special case).
This fixes wrong hash being computed for transactions.
57c0cf9
to
a66a0cf
Compare
OK, I found the issue! So TIL, for all transactions that are not legacy, the To see the issue, cf. the signature change in the failing test. The previous signature wasn't actually valid. This can be checked here, for example: https://toolkit.abdk.consulting/ethereum#rlp,transaction (the v value was set to |
Fixes #7898
Motivation
Cf. the linked issue. The
v
value (which should be deprecated for some tx types) was wrongly set as the y parity byte converted into a uint.Solution
Instead of converting the boolean corresponding to the y parity byte to a u64/U256, use the raw
v
value for thev
field when available.