From ddc54a9f10a73772ed2b50e56c1305bf6e7c643c Mon Sep 17 00:00:00 2001 From: Danno Ferrin Date: Fri, 24 May 2024 06:36:46 -0600 Subject: [PATCH 1/4] Undo #6819 - make yParity and v match 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 --- .../graphql/internal/pojoadapter/TransactionAdapter.java | 9 ++++++++- .../internal/results/TransactionCompleteResult.java | 2 +- .../internal/results/TransactionPendingResult.java | 2 +- .../pending/PendingTransactionDetailResult.java | 2 +- .../besu/ethereum/api/graphql/eth_getBlock_cancun.json | 2 +- .../ethereum/api/graphql/eth_getTransaction_type2.json | 2 +- .../eth/eth_getBlockByNumber_complete_shanghai.json | 2 +- .../org/hyperledger/besu/ethereum/core/Transaction.java | 8 ++------ 8 files changed, 16 insertions(+), 13 deletions(-) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/TransactionAdapter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/TransactionAdapter.java index b0854e761c1..6e98afc90e5 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/TransactionAdapter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/TransactionAdapter.java @@ -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; @@ -248,7 +249,13 @@ public BigInteger getS() { } public Optional 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 getYParity() { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionCompleteResult.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionCompleteResult.java index 003ee07ce36..c8260d090c0 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionCompleteResult.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionCompleteResult.java @@ -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()); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionPendingResult.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionPendingResult.java index 62302808af3..2cbf5dd2255 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionPendingResult.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionPendingResult.java @@ -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()); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/pending/PendingTransactionDetailResult.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/pending/PendingTransactionDetailResult.java index acbcb85ff11..68f75ee4ecf 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/pending/PendingTransactionDetailResult.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/pending/PendingTransactionDetailResult.java @@ -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()); diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getBlock_cancun.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getBlock_cancun.json index 3f5dc4dc406..0d7aa6fd023 100644 --- a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getBlock_cancun.json +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getBlock_cancun.json @@ -24,7 +24,7 @@ "blobGasPrice": "0x1", "type": "0x3", "yParity": "0x0", - "v": null, + "v": "0x0", "r": "0x6ae0612cfda43a9b464b10b4881c6fc2e4c24533cf89bbe07934da65c3ae49ce", "s": "0x125387aeb222ec51130cf99cbdabf24bd4a881914faed69f254e4a3f4bc507fc" } diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getTransaction_type2.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getTransaction_type2.json index c2c00330ff0..d4c557f4bf1 100644 --- a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getTransaction_type2.json +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getTransaction_type2.json @@ -17,7 +17,7 @@ "type": "0x2", "status": "0x1", "yParity": "0x0", - "v": "0x25" + "v": "0x0" } } }, diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getBlockByNumber_complete_shanghai.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getBlockByNumber_complete_shanghai.json index 481dda711a9..fb77fccd598 100644 --- a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getBlockByNumber_complete_shanghai.json +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getBlockByNumber_complete_shanghai.json @@ -58,7 +58,7 @@ "type": "0x2", "value": "0x0", "yParity": "0x0", - "v" : "0x25", + "v" : "0x0", "r": "0x8abbfbd4c5f2a13a8d5ed394ac50bac7d678f83a23f645818492f76e8ee17ab3", "s": "0x7bd38c6929235f775d68b45bd7dea7981264f9a265b6bea97b070e15be88389c" } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java index a373a9b6fec..7ca349721f9 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java @@ -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))) From e51b4109cc822e562bbfcb202b4e90ff45133317 Mon Sep 17 00:00:00 2001 From: Danno Ferrin Date: Fri, 24 May 2024 06:49:11 -0600 Subject: [PATCH 2/4] fix blob test Signed-off-by: Danno Ferrin --- .../besu/ethereum/api/graphql/eth_getBlock_cancun.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getBlock_cancun.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getBlock_cancun.json index 0d7aa6fd023..3f5dc4dc406 100644 --- a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getBlock_cancun.json +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getBlock_cancun.json @@ -24,7 +24,7 @@ "blobGasPrice": "0x1", "type": "0x3", "yParity": "0x0", - "v": "0x0", + "v": null, "r": "0x6ae0612cfda43a9b464b10b4881c6fc2e4c24533cf89bbe07934da65c3ae49ce", "s": "0x125387aeb222ec51130cf99cbdabf24bd4a881914faed69f254e4a3f4bc507fc" } From c31157935c3113bab5f394a4263ffd7192a674b8 Mon Sep 17 00:00:00 2001 From: Danno Ferrin Date: Fri, 24 May 2024 07:16:12 -0600 Subject: [PATCH 3/4] enhance graphql tests to cover new fields Signed-off-by: Danno Ferrin --- .../api/graphql/eth_getBlock_frontier.json | 29 +++++++++++++++++++ .../api/graphql/eth_getBlock_shanghai.json | 10 ++++++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getBlock_frontier.json diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getBlock_frontier.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getBlock_frontier.json new file mode 100644 index 00000000000..335121ac896 --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getBlock_frontier.json @@ -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 +} \ No newline at end of file diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getBlock_shanghai.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getBlock_shanghai.json index 3e98251971b..add2edd6507 100644 --- a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getBlock_shanghai.json +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/graphql/eth_getBlock_shanghai.json @@ -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": { @@ -13,6 +13,14 @@ "nonce": "0x0000000000000000", "stateRoot": "0x0d3c456bb68669bad05da3a1a766daab236c9df1da8f74edf5ebe9383f00084c", "totalDifficulty": "0x427c00", + "transactions": [ + { + "r": "0x8abbfbd4c5f2a13a8d5ed394ac50bac7d678f83a23f645818492f76e8ee17ab3", + "s": "0x7bd38c6929235f775d68b45bd7dea7981264f9a265b6bea97b070e15be88389c", + "v": "0x0", + "yParity": "0x0" + } + ], "withdrawalsRoot": "0x37945ab58d2712a26df2a38d217e822694927e29b30d5993d7a53ccea618d1f3", "withdrawals": [ { From a244baf3ee567169509c8578cac537a7f515e9a5 Mon Sep 17 00:00:00 2001 From: Danno Ferrin Date: Fri, 24 May 2024 07:31:03 -0600 Subject: [PATCH 4/4] changelog Signed-off-by: Danno Ferrin --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fe0cbbc3c2..be2489c4cec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Fix parsing `gasLimit` parameter when its value is > `Long.MAX_VALUE` [#7116](https://github.com/hyperledger/besu/pull/7116) - Make `eth_gasPrice` aware of the base fee market [#7102](https://github.com/hyperledger/besu/pull/7102) - 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) ## 24.5.1