-
Notifications
You must be signed in to change notification settings - Fork 246
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
Remove signature.v parity before calculating tx hash #893
Conversation
can you provide a minimal repro of this so we can be sure we understand the observed behavior? |
Sure! My minimal repro is very close to unit tests, except I used LocalWallet to get a signature for tx. You can observe the incorrect behavior by reverting my changes and running tests. Revert: diff --git a/crates/consensus/src/transaction/eip1559.rs b/crates/consensus/src/transaction/eip1559.rs
index d195edb9..729d811b 100644
--- a/crates/consensus/src/transaction/eip1559.rs
+++ b/crates/consensus/src/transaction/eip1559.rs
@@ -308,13 +308,13 @@ impl SignableTransaction<Signature> for TxEip1559 {
// Drop any v chain id value to ensure the signature format is correct at the time of
// combination for an EIP-1559 transaction. V should indicate the y-parity of the
// signature.
- let signature = signature.with_parity_bool();
+ // let signature = signature.with_parity_bool();
let mut buf = Vec::with_capacity(self.encoded_len_with_signature(&signature, false));
self.encode_with_signature(&signature, &mut buf, false);
let hash = keccak256(&buf);
- Signed::new_unchecked(self, signature, hash)
+ Signed::new_unchecked(self, signature.with_parity_bool(), hash)
}
} Failed test:
|
thank you! I'll be looking at this and #897 this morning |
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.
per #897 (comment) can you add the following to the legacy tx into_signed
fn into_signed(self, signature: Signature) -> Signed<Self> {
debug_assert_eq!(signature.v().chain_id(), self.chain_id);
this prevents most issues while we move towards a larger refactor
Done |
I did but CI failed with:
So I am reverting that assert. |
This reverts commit a3fa3f8.
Hi! Is there anything else I can do in this PR? |
Hello! Is there any progress? @prestwich |
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.
ty!
* Remove signature.v parity before calculating tx hash * Fix tx_hash parity for eip4844 * Fix review notes * Add signature chainid guard for a legacy tx * Revert "Add signature chainid guard for a legacy tx" This reverts commit a3fa3f8.
Motivation
I noticed that TxEnvelope::encode/decode didn't produce the same TxEnvelope. The difference was the hash only.
I fixed the issue for TxEip1559, TxEip2930, TxEip4844, TxEip4844WithSidecar and TxEip4844Variant.
Context
Related to: #150
Fixes #897