Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

fix: add yParity field to type 1 and 2 txs to match geth #4514

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/ethereum/ethereum/tests/database.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ describe("database", () => {
accessList: [],
v: "0x0",
r: "0x48507a6e4e1e7bdbcdb0a5021195d13d7c2a1b89f06555049bca5cc246b6f7d4",
s: "0x487a3f23364c97c469f8ee948a9de2bdc80a4502046625793f664bb7be4c0cd9"
s: "0x487a3f23364c97c469f8ee948a9de2bdc80a4502046625793f664bb7be4c0cd9",
yParity: "0x0"
}
],
uncles: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class EIP1559FeeMarketTransaction extends RuntimeTransaction {
public accessListJSON: AccessList;
public accessListDataFee: bigint;
public type: Quantity = Quantity.from("0x2");
public yParity: Quantity = Quantity.from("0x0");

public constructor(
data: EIP1559FeeMarketRawTransaction | EIP1559FeeMarketRpcTransaction,
Expand All @@ -54,7 +55,7 @@ export class EIP1559FeeMarketTransaction extends RuntimeTransaction {
this.accessList = accessListData.accessList;
this.accessListJSON = accessListData.AccessListJSON;
this.accessListDataFee = accessListData.dataFeeEIP2930;
this.v = Quantity.from(data[9]);
this.yParity = this.v = Quantity.from(data[9]);
this.r = Quantity.from(data[10]);
this.s = Quantity.from(data[11]);
this.raw = data;
Expand Down Expand Up @@ -93,6 +94,8 @@ export class EIP1559FeeMarketTransaction extends RuntimeTransaction {
this.accessListJSON = accessListData.AccessListJSON;
this.accessListDataFee = accessListData.dataFeeEIP2930;
this.validateAndSetSignature(data);

this.yParity = this.v;
}
}

Expand Down Expand Up @@ -120,7 +123,8 @@ export class EIP1559FeeMarketTransaction extends RuntimeTransaction {
accessList: this.accessListJSON,
v: this.v,
r: this.r,
s: this.s
s: this.s,
yParity: this.yParity
};
}

Expand Down Expand Up @@ -193,7 +197,7 @@ export class EIP1559FeeMarketTransaction extends RuntimeTransaction {

const msgHash = keccak(digestWithPrefix(2, [data.output], dataLength));
const sig = ecsign(msgHash, privateKey);
this.v = Quantity.from(sig.v);
this.yParity = this.v = Quantity.from(sig.v);
this.r = Quantity.from(sig.r);
this.s = Quantity.from(sig.s);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class EIP2930AccessListTransaction extends RuntimeTransaction {
public accessListDataFee: bigint;
public gasPrice: Quantity;
public type: Quantity = Quantity.from("0x1");
public yParity: Quantity = Quantity.from("0x0");

public constructor(
data: EIP2930AccessListRawTransaction | EIP2930AccessListRpcTransaction,
Expand All @@ -50,7 +51,7 @@ export class EIP2930AccessListTransaction extends RuntimeTransaction {
this.accessList = accessListData.accessList;
this.accessListJSON = accessListData.AccessListJSON;
this.accessListDataFee = accessListData.dataFeeEIP2930;
this.v = Quantity.from(data[8]);
this.yParity = this.v = Quantity.from(data[8]);
this.r = Quantity.from(data[9]);
this.s = Quantity.from(data[10]);
this.raw = data;
Expand Down Expand Up @@ -94,6 +95,7 @@ export class EIP2930AccessListTransaction extends RuntimeTransaction {
this.accessListJSON = accessListData.AccessListJSON;
this.accessListDataFee = accessListData.dataFeeEIP2930;
this.validateAndSetSignature(data);
this.yParity = this.v;
}
}

Expand All @@ -119,7 +121,8 @@ export class EIP2930AccessListTransaction extends RuntimeTransaction {
accessList: this.accessListJSON,
v: this.v,
r: this.r,
s: this.s
s: this.s,
yParity: this.v
};
}
public static fromTxData(
Expand Down Expand Up @@ -179,7 +182,7 @@ export class EIP2930AccessListTransaction extends RuntimeTransaction {

const msgHash = keccak(digestWithPrefix(1, [data.output], dataLength));
const sig = ecsign(msgHash, privateKey);
this.v = Quantity.from(sig.v);
this.yParity = this.v = Quantity.from(sig.v);
this.r = Quantity.from(sig.r);
this.s = Quantity.from(sig.s);

Expand Down
2 changes: 2 additions & 0 deletions packages/ethereum/transaction/src/transaction-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export type EIP2930AccessListTransactionJSON = {
v: Quantity;
r: Quantity;
s: Quantity;
yParity: Quantity;
};

export type EIP1559FeeMarketTransactionJSON = {
Expand All @@ -74,4 +75,5 @@ export type EIP1559FeeMarketTransactionJSON = {
v: Quantity;
r: Quantity;
s: Quantity;
yParity: Quantity;
};
1 change: 0 additions & 1 deletion packages/ethereum/transaction/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
LegacyRawTransaction,
LegacyTransaction,
TransactionFactory,
TransactionType,
TypedDatabaseTransaction,
Transaction,
encodeWithPrefix,
Expand Down