Skip to content

Commit

Permalink
fix(consensus): ensure into_signed forces correct format for eip155…
Browse files Browse the repository at this point in the history
…9/2930 txs (#150)
  • Loading branch information
Evalir authored Jan 24, 2024
1 parent 269d902 commit d68e110
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions crates/consensus/src/transaction/eip1559.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,17 @@ impl Decodable for TxEip1559 {

impl Transaction for TxEip1559 {
type Signature = Signature;
// type Receipt = ReceiptWithBloom;

fn into_signed(self, signature: Signature) -> Signed<Self> {
let mut buf = vec![];
buf.put_u8(TxType::Eip1559 as u8);
self.encode_signed(&signature, &mut buf);
let hash = keccak256(&buf);

Signed::new_unchecked(self, signature, hash)
// 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.
Signed::new_unchecked(self, signature.with_parity_bool(), hash)
}

fn encode_signed(&self, signature: &Signature, out: &mut dyn BufMut) {
Expand Down
5 changes: 4 additions & 1 deletion crates/consensus/src/transaction/eip2930.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ impl Transaction for TxEip2930 {
self.encode_signed(&signature, &mut buf);
let hash = keccak256(&buf);

Signed::new_unchecked(self, signature, hash)
// Drop any v chain id value to ensure the signature format is correct at the time of
// combination for an EIP-2930 transaction. V should indicate the y-parity of the
// signature.
Signed::new_unchecked(self, signature.with_parity_bool(), hash)
}

fn encode_signed(&self, signature: &Signature, out: &mut dyn BufMut) {
Expand Down

0 comments on commit d68e110

Please sign in to comment.