Skip to content

Commit 4f6588a

Browse files
committed
Undo besu-eth#6819 - make yParity and v match
Undo PR besu-eth#6819 - for 2030 and 1559 transactions both v and yParity will be provided, and they will be the same number. Signed-off-by: Danno Ferrin <danno@numisight.com>
1 parent ac5d03f commit 4f6588a

File tree

8 files changed

+16
-13
lines changed

8 files changed

+16
-13
lines changed

ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/TransactionAdapter.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import org.hyperledger.besu.datatypes.Address;
1818
import org.hyperledger.besu.datatypes.Hash;
19+
import org.hyperledger.besu.datatypes.TransactionType;
1920
import org.hyperledger.besu.datatypes.VersionedHash;
2021
import org.hyperledger.besu.datatypes.Wei;
2122
import org.hyperledger.besu.ethereum.api.graphql.GraphQLContextType;
@@ -248,7 +249,13 @@ public BigInteger getS() {
248249
}
249250

250251
public Optional<BigInteger> getV() {
251-
return Optional.ofNullable(transactionWithMetadata.getTransaction().getV());
252+
BigInteger v = transactionWithMetadata.getTransaction().getV();
253+
return Optional.ofNullable(
254+
v == null
255+
&& (transactionWithMetadata.getTransaction().getType().getEthSerializedType()
256+
< TransactionType.BLOB.getEthSerializedType())
257+
? transactionWithMetadata.getTransaction().getYParity()
258+
: v);
252259
}
253260

254261
public Optional<BigInteger> getYParity() {

ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionCompleteResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public TransactionCompleteResult(final TransactionWithMetadata tx) {
126126
this.v =
127127
(transactionType == TransactionType.ACCESS_LIST
128128
|| transactionType == TransactionType.EIP1559)
129-
? Quantity.create(transaction.getV())
129+
? Quantity.create(transaction.getYParity())
130130
: null;
131131
}
132132
this.value = Quantity.create(transaction.getValue());

ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionPendingResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public TransactionPendingResult(final Transaction transaction) {
116116
this.v =
117117
(transactionType == TransactionType.ACCESS_LIST
118118
|| transactionType == TransactionType.EIP1559)
119-
? Quantity.create(transaction.getV())
119+
? Quantity.create(transaction.getYParity())
120120
: null;
121121
}
122122
this.value = Quantity.create(transaction.getValue());

ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/pending/PendingTransactionDetailResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public PendingTransactionDetailResult(final Transaction tx) {
7373
this.v =
7474
(transactionType == TransactionType.ACCESS_LIST
7575
|| transactionType == TransactionType.EIP1559)
76-
? Quantity.create(tx.getV())
76+
? Quantity.create(tx.getYParity())
7777
: null;
7878
}
7979
this.value = Quantity.create(tx.getValue());

ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getBlock_cancun.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"blobGasPrice": "0x1",
2525
"type": "0x3",
2626
"yParity": "0x0",
27-
"v": null,
27+
"v": "0x0",
2828
"r": "0x6ae0612cfda43a9b464b10b4881c6fc2e4c24533cf89bbe07934da65c3ae49ce",
2929
"s": "0x125387aeb222ec51130cf99cbdabf24bd4a881914faed69f254e4a3f4bc507fc"
3030
}

ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getTransaction_type2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"type": "0x2",
1818
"status": "0x1",
1919
"yParity": "0x0",
20-
"v": "0x25"
20+
"v": "0x0"
2121
}
2222
}
2323
},

ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getBlockByNumber_complete_shanghai.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"type": "0x2",
5959
"value": "0x0",
6060
"yParity": "0x0",
61-
"v" : "0x25",
61+
"v" : "0x0",
6262
"r": "0x8abbfbd4c5f2a13a8d5ed394ac50bac7d678f83a23f645818492f76e8ee17ab3",
6363
"s": "0x7bd38c6929235f775d68b45bd7dea7981264f9a265b6bea97b070e15be88389c"
6464
}

ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -495,14 +495,10 @@ public BigInteger getS() {
495495

496496
@Override
497497
public BigInteger getV() {
498-
if (transactionType != null
499-
&& transactionType != TransactionType.FRONTIER
500-
&& transactionType != TransactionType.ACCESS_LIST
501-
&& transactionType != TransactionType.EIP1559) {
502-
// Newer transaction type lacks V, so return null
498+
if (transactionType != null && transactionType != TransactionType.FRONTIER) {
499+
// EIP-2718 typed transaction, use yParity:
503500
return null;
504501
} else {
505-
// Mandatory for legacy, optional for EIP-2930 and EIP-1559 TXes, prohibited for all others.
506502
final BigInteger recId = BigInteger.valueOf(signature.getRecId());
507503
return chainId
508504
.map(bigInteger -> recId.add(REPLAY_PROTECTED_V_BASE).add(TWO.multiply(bigInteger)))

0 commit comments

Comments
 (0)