Skip to content

Commit

Permalink
Undo hyperledger#6819 - make yParity and v match
Browse files Browse the repository at this point in the history
Undo PR hyperledger#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>
  • Loading branch information
shemnon committed May 24, 2024
1 parent a31ffc9 commit ddc54a9
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.datatypes.VersionedHash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLContextType;
Expand Down Expand Up @@ -248,7 +249,13 @@ public BigInteger getS() {
}

public Optional<BigInteger> getV() {
return Optional.ofNullable(transactionWithMetadata.getTransaction().getV());
BigInteger v = transactionWithMetadata.getTransaction().getV();
return Optional.ofNullable(
v == null
&& (transactionWithMetadata.getTransaction().getType().getEthSerializedType()
< TransactionType.BLOB.getEthSerializedType())
? transactionWithMetadata.getTransaction().getYParity()
: v);
}

public Optional<BigInteger> getYParity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public TransactionCompleteResult(final TransactionWithMetadata tx) {
this.v =
(transactionType == TransactionType.ACCESS_LIST
|| transactionType == TransactionType.EIP1559)
? Quantity.create(transaction.getV())
? Quantity.create(transaction.getYParity())
: null;
}
this.value = Quantity.create(transaction.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public TransactionPendingResult(final Transaction transaction) {
this.v =
(transactionType == TransactionType.ACCESS_LIST
|| transactionType == TransactionType.EIP1559)
? Quantity.create(transaction.getV())
? Quantity.create(transaction.getYParity())
: null;
}
this.value = Quantity.create(transaction.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public PendingTransactionDetailResult(final Transaction tx) {
this.v =
(transactionType == TransactionType.ACCESS_LIST
|| transactionType == TransactionType.EIP1559)
? Quantity.create(tx.getV())
? Quantity.create(tx.getYParity())
: null;
}
this.value = Quantity.create(tx.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"blobGasPrice": "0x1",
"type": "0x3",
"yParity": "0x0",
"v": null,
"v": "0x0",
"r": "0x6ae0612cfda43a9b464b10b4881c6fc2e4c24533cf89bbe07934da65c3ae49ce",
"s": "0x125387aeb222ec51130cf99cbdabf24bd4a881914faed69f254e4a3f4bc507fc"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"type": "0x2",
"status": "0x1",
"yParity": "0x0",
"v": "0x25"
"v": "0x0"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"type": "0x2",
"value": "0x0",
"yParity": "0x0",
"v" : "0x25",
"v" : "0x0",
"r": "0x8abbfbd4c5f2a13a8d5ed394ac50bac7d678f83a23f645818492f76e8ee17ab3",
"s": "0x7bd38c6929235f775d68b45bd7dea7981264f9a265b6bea97b070e15be88389c"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,14 +495,10 @@ public BigInteger getS() {

@Override
public BigInteger getV() {
if (transactionType != null
&& transactionType != TransactionType.FRONTIER
&& transactionType != TransactionType.ACCESS_LIST
&& transactionType != TransactionType.EIP1559) {
// Newer transaction type lacks V, so return null
if (transactionType != null && transactionType != TransactionType.FRONTIER) {
// EIP-2718 typed transaction, use yParity:
return null;
} else {
// Mandatory for legacy, optional for EIP-2930 and EIP-1559 TXes, prohibited for all others.
final BigInteger recId = BigInteger.valueOf(signature.getRecId());
return chainId
.map(bigInteger -> recId.add(REPLAY_PROTECTED_V_BASE).add(TWO.multiply(bigInteger)))
Expand Down

0 comments on commit ddc54a9

Please sign in to comment.