Skip to content

Commit

Permalink
Undo #6819 - make yParity and v match (#7139)
Browse files Browse the repository at this point in the history
Undo PR #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 <[email protected]>
  • Loading branch information
shemnon authored May 30, 2024
1 parent 8128866 commit e68c4e1
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
### Bug fixes
- Fix parsing `gasLimit` parameter when its value is > `Long.MAX_VALUE` [#7116](https://github.com/hyperledger/besu/pull/7116)
- Skip validation of withdrawals when importing BFT blocks since withdrawals don't apply to BFT chains [#7115](https://github.com/hyperledger/besu/pull/7115)
- Make `v` abd `yParity` match in type 1 and 2 transactions in JSON-RPC and GraphQL [#7139](https://github.com/hyperledger/besu/pull/7139)

### Download Links
https://github.com/hyperledger/besu/releases/tag/24.5.2
Expand Down
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
@@ -0,0 +1,29 @@
{
"request": "{block (number: 32) { difficulty extraData miner { address } mixHash nonce stateRoot totalDifficulty transactions { gasPrice type yParity v r s} }} ",
"response": {
"data": {
"block": {
"difficulty": "0x207c0",
"extraData": "0x",
"miner": {
"address": "0x8888f1f195afa192cfee860698584c030f4c9db1"
},
"mixHash": "0x4edd77bfff565659bb0ae09421918e4def65d938a900eb94230eb01f5ce80c99",
"nonce": "0xdb063000b00e8026",
"stateRoot": "0xf65f3dd13f72f5fa5607a5224691419969b4f4bae7a00a6cdb853f2ca9eeb1be",
"totalDifficulty": "0x427c00",
"transactions": [
{
"gasPrice": "0x1",
"type": "0x0",
"yParity": null,
"v": "0x1b",
"r": "0x705b002a7df60707d33812e0298411721be20ea5a2f533707295140d89263b79",
"s": "0x78024390784f24160739533b3ceea2698289a02afd9cc768581b4aa3d5f4b105"
}
]
}
}
},
"statusCode": 200
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"request": "{block (number : 33) { baseFeePerGas difficulty extraData miner { address } mixHash nonce stateRoot totalDifficulty withdrawalsRoot withdrawals { address amount index validator } }} ",
"request": "{block (number : 33) { baseFeePerGas difficulty extraData miner { address } mixHash nonce stateRoot totalDifficulty transactions { r s v yParity } withdrawalsRoot withdrawals { address amount index validator } }} ",
"response": {
"data": {
"block": {
Expand All @@ -13,6 +13,14 @@
"nonce": "0x0000000000000000",
"stateRoot": "0x0d3c456bb68669bad05da3a1a766daab236c9df1da8f74edf5ebe9383f00084c",
"totalDifficulty": "0x427c00",
"transactions": [
{
"r": "0x8abbfbd4c5f2a13a8d5ed394ac50bac7d678f83a23f645818492f76e8ee17ab3",
"s": "0x7bd38c6929235f775d68b45bd7dea7981264f9a265b6bea97b070e15be88389c",
"v": "0x0",
"yParity": "0x0"
}
],
"withdrawalsRoot": "0x37945ab58d2712a26df2a38d217e822694927e29b30d5993d7a53ccea618d1f3",
"withdrawals": [
{
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 e68c4e1

Please sign in to comment.