diff --git a/CHANGELOG.md b/CHANGELOG.md index 617fd606b67..b32a9574905 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,10 +12,11 @@ * `--skip-pow-validation-enabled` is now an error with `block import --format JSON`. This is because the JSON format doesn't include the nonce so the proof of work must be calculated. [\#1815](https://github.com/hyperledger/besu/pull/1815) * Added a new CLI option `--Xlauncher` to start a mainnet launcher. It will help to configure Besu easily. * Return the revert reason from `eth_call` JSON-RPC api calls when the contract causes a revert. [\#1829](https://github.com/hyperledger/besu/pull/1829) +* Added `chainId`, `publicKey`, and `raw` to JSON-RPC api calls returning detailed transaction results. [\#1835](https://github.com/hyperledger/besu/pull/1835) ### Bug Fixes -* Ethereum classic heights will no longer be reported in mainnet metrics. Issue [\#1751]((https://github.com/hyperledger/besu/pull/1751) Fix [\#1820](https://github.com/hyperledger/besu/pull/1820) -* Don't enforce balance checks in `eth_call` unless explicitly requested. Issue [\#502]((https://github.com/hyperledger/besu/pull/502) Fix [\#1834](https://github.com/hyperledger/besu/pull/1834) +* Ethereum classic heights will no longer be reported in mainnet metrics. Issue [\#1751](https://github.com/hyperledger/besu/pull/1751) Fix [\#1820](https://github.com/hyperledger/besu/pull/1820) +* Don't enforce balance checks in `eth_call` unless explicitly requested. Issue [\#502](https://github.com/hyperledger/besu/pull/502) Fix [\#1834](https://github.com/hyperledger/besu/pull/1834) ### Early Access Features @@ -2203,7 +2204,7 @@ The [documentation](https://docs.pantheon.pegasys.tech/en/latest/) has been upda | `--datadir` | [`--data-path`](https://besu.hyperledger.org/en/latest/Reference/CLI/CLI-Syntax/#data-path) | Renamed | | `--dev-mode` | [`--network=dev`](https://besu.hyperledger.org/en/latest/Reference/CLI/CLI-Syntax/#network) | Replaced by `--network` option | | `--genesis` | [`--genesis-file`](https://besu.hyperledger.org/en/latest/Reference/CLI/CLI-Syntax/#genesis-file) | Renamed | -| `--goerli` | [`--network=goerli`]((https://besu.hyperledger.org/en/latest/Reference/CLI/CLI-Syntax/#network) | Replaced by `--network` option | +| `--goerli` | [`--network=goerli`](https://besu.hyperledger.org/en/latest/Reference/CLI/CLI-Syntax/#network) | Replaced by `--network` option | | `--metrics-listen=` | [`--metrics-host=`](https://besu.hyperledger.org/en/latest/Reference/CLI/CLI-Syntax/#metrics-host) and [`--metrics-port=`](https://besu.hyperledger.org/en/latest/Reference/CLI/CLI-Syntax/#metrics-port) | Split into host and port options | | `--miner-extraData` | [`--miner-extra-data`](https://besu.hyperledger.org/en/latest/Reference/CLI/CLI-Syntax/#miner-extra-data) | Renamed | | `--miner-minTransactionGasPriceWei` | [`--min-gas-price`](https://besu.hyperledger.org/en/latest/Reference/CLI/CLI-Syntax/#min-gas-price) | Renamed | @@ -2211,8 +2212,8 @@ The [documentation](https://docs.pantheon.pegasys.tech/en/latest/) has been upda | `--node-private-key` | [`--node-private-key-file`](https://besu.hyperledger.org/en/latest/Reference/CLI/CLI-Syntax/#node-private-key-file) | Renamed | | `--ottoman` | N/A | Removed | | `--p2p-listen=` | [`--p2p-host=`](https://besu.hyperledger.org/en/latest/Reference/CLI/CLI-Syntax/#p2p-hostt) and [`--p2p-port=`](https://besu.hyperledger.org/en/latest/Reference/CLI/CLI-Syntax/#p2p-port) | Split into host and port options | -| `--rinkeby` | [`--network=rinkeby`]((https://besu.hyperledger.org/en/latest/Reference/CLI/CLI-Syntax/#network) | Replaced by `--network` option | -| `--ropsten` | [`--network=ropsten`]((https://besu.hyperledger.org/en/latest/Reference/CLI/CLI-Syntax/#network) | Replaced by `--network` option | +| `--rinkeby` | [`--network=rinkeby`](https://besu.hyperledger.org/en/latest/Reference/CLI/CLI-Syntax/#network) | Replaced by `--network` option | +| `--ropsten` | [`--network=ropsten`](https://besu.hyperledger.org/en/latest/Reference/CLI/CLI-Syntax/#network) | Replaced by `--network` option | | `--rpc-enabled` | [` --rpc-http-enabled`](https://besu.hyperledger.org/en/latest/Reference/CLI/CLI-Syntax/#rpc-http-enabled)| Renamed| | `--rpc-listen=` | [`--rpc-http-host=`](https://besu.hyperledger.org/en/latest/Reference/CLI/CLI-Syntax/#rpc-http-host) and [`--rpc-http-port=`](https://besu.hyperledger.org/en/latest/Reference/CLI/CLI-Syntax/#rpc-http-port) | Split into host and port options | | `--rpc-api` | [`--rpc-http-api`](https://besu.hyperledger.org/en/latest/Reference/CLI/CLI-Syntax/#rpc-http-api)| Renamed | diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseKey.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseKey.java index 278c6f1a5d7..eda1ff46c0a 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseKey.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseKey.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc; public enum JsonRpcResponseKey { + CHAIN_ID, COINBASE, DIFFICULTY, EXTRA_DATA, @@ -26,6 +27,8 @@ public enum JsonRpcResponseKey { NUMBER, OMMERS_HASH, PARENT_HASH, + PUBLIC_KEY, + RAW, RECEIPTS_ROOT, SIZE, STATE_ROOT, diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseUtils.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseUtils.java index 6257bcdfcca..620e36aa063 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseUtils.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseUtils.java @@ -32,6 +32,8 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcResponseKey.TIMESTAMP; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcResponseKey.TOTAL_DIFFICULTY; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcResponseKey.TRANSACTION_ROOT; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -51,6 +53,7 @@ import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Wei; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; +import org.hyperledger.besu.ethereum.rlp.RLPOutput; import java.math.BigInteger; import java.util.ArrayList; @@ -145,12 +148,15 @@ public List transactions(final TransactionResult... transacti public TransactionResult transaction( final String blockHash, final String blockNumber, + final String chainId, final String fromAddress, final String gas, final String gasPrice, final String hash, final String input, final String nonce, + final String publicKey, + final String raw, final String toAddress, final String transactionIndex, final String value, @@ -170,6 +176,15 @@ public TransactionResult transaction( when(transaction.getPayload()).thenReturn(bytes(input)); when(transaction.getValue()).thenReturn(wei(value)); when(transaction.getGasLimit()).thenReturn(unsignedLong(gas)); + when(transaction.getChainId()).thenReturn(Optional.ofNullable(bigInteger(chainId))); + when(transaction.getPublicKey()).thenReturn(Optional.ofNullable(publicKey)); + doAnswer( + answer -> { + answer.getArgument(0, RLPOutput.class).writeRLPBytes(Bytes.fromHexString(raw)); + return null; + }) + .when(transaction) + .writeTo(any()); return new TransactionCompleteResult( new TransactionWithMetadata( @@ -198,7 +213,7 @@ private String removeHexPrefix(final String prefixedHex) { } private BigInteger bigInteger(final String hex) { - return new BigInteger(removeHexPrefix(hex), HEX_RADIX); + return hex == null ? null : new BigInteger(removeHexPrefix(hex), HEX_RADIX); } private Wei wei(final String hex) { diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/EthGetBlockByHashIntegrationTest.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/EthGetBlockByHashIntegrationTest.java index 4a867a620e8..38cb0cb80c8 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/EthGetBlockByHashIntegrationTest.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/EthGetBlockByHashIntegrationTest.java @@ -112,17 +112,26 @@ public void returnFullTransactionIfBlockFound() { expectedResult.put(JsonRpcResponseKey.GAS_LIMIT, "0x2fefd8"); expectedResult.put(JsonRpcResponseKey.GAS_USED, "0x78674"); expectedResult.put(JsonRpcResponseKey.TIMESTAMP, "0x561bc2e0"); + expectedResult.put( + JsonRpcResponseKey.PUBLIC_KEY, + "0x3a514176466fa815ed481ffad09110a2d344f6c9b78c1d14afc351c3a51be33d8072e77939dc03ba44790779b7a1025baf3003f6732430e20cd9b76d953391b3"); + expectedResult.put( + JsonRpcResponseKey.RAW, + "0xf907638001832fefd8800ab907155b5b610705806100106000396000f3006000357c010000000000000000000000000000000000000000000000000000000090048063102accc11461012c57806312a7b9141461013a5780631774e6461461014c5780631e26fd331461015d5780631f9030371461016e578063343a875d1461018057806338cc4831146101955780634e7ad367146101bd57806357cb2fc4146101cb57806365538c73146101e057806368895979146101ee57806376bc21d9146102005780639a19a9531461020e5780639dc2c8f51461021f578063a53b1c1e1461022d578063a67808571461023e578063b61c05031461024c578063c2b12a731461025a578063d2282dc51461026b578063e30081a01461027c578063e8beef5b1461028d578063f38b06001461029b578063f5b53e17146102a9578063fd408767146102bb57005b6101346104d6565b60006000f35b61014261039b565b8060005260206000f35b610157600435610326565b60006000f35b6101686004356102c9565b60006000f35b610176610442565b8060005260206000f35b6101886103d3565b8060ff1660005260206000f35b61019d610413565b8073ffffffffffffffffffffffffffffffffffffffff1660005260206000f35b6101c56104c5565b60006000f35b6101d36103b7565b8060000b60005260206000f35b6101e8610454565b60006000f35b6101f6610401565b8060005260206000f35b61020861051f565b60006000f35b6102196004356102e5565b60006000f35b610227610693565b60006000f35b610238600435610342565b60006000f35b610246610484565b60006000f35b610254610493565b60006000f35b61026560043561038d565b60006000f35b610276600435610350565b60006000f35b61028760043561035e565b60006000f35b6102956105b4565b60006000f35b6102a3610547565b60006000f35b6102b16103ef565b8060005260206000f35b6102c3610600565b60006000f35b80600060006101000a81548160ff021916908302179055505b50565b80600060016101000a81548160ff02191690837f01000000000000000000000000000000000000000000000000000000000000009081020402179055505b50565b80600060026101000a81548160ff021916908302179055505b50565b806001600050819055505b50565b806002600050819055505b50565b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b50565b806004600050819055505b50565b6000600060009054906101000a900460ff1690506103b4565b90565b6000600060019054906101000a900460000b90506103d0565b90565b6000600060029054906101000a900460ff1690506103ec565b90565b600060016000505490506103fe565b90565b60006002600050549050610410565b90565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905061043f565b90565b60006004600050549050610451565b90565b7f65c9ac8011e286e89d02a269890f41d67ca2cc597b2c76c7c69321ff492be5806000602a81526020016000a15b565b6000602a81526020016000a05b565b60017f81933b308056e7e85668661dcd102b1f22795b4431f9cf4625794f381c271c6b6000602a81526020016000a25b565b60016000602a81526020016000a15b565b3373ffffffffffffffffffffffffffffffffffffffff1660017f0e216b62efbb97e751a2ce09f607048751720397ecfb9eef1e48a6644948985b6000602a81526020016000a35b565b3373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a25b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017f317b31292193c2a4f561cc40a95ea0d97a2733f14af6d6d59522473e1f3ae65f6000602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a35b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017fd5f0a30e4be0c6be577a71eceb7464245a796a7e6a55c0d971837b250de05f4e60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff16600160007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a35b561ca0e439aa8812c1c0a751b0931ea20c5a30cd54fe15cae883c59fd8107e04557679a058d025af99b538b778a47da8115c43d5cee564c3cc8d58eb972aaf80ea2c406e"); final List transactions = responseUtils.transactions( responseUtils.transaction( "0x10aaf14a53caf27552325374429d3558398a36d3682ede6603c2c6511896e9f9", "0x1", + null, "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "0x2fefd8", "0x1", "0x812742182a79a8e67733edc58cfa3767aa2d7ad06439d156ddbbb33e3403b4ed", "0x5b5b610705806100106000396000f3006000357c010000000000000000000000000000000000000000000000000000000090048063102accc11461012c57806312a7b9141461013a5780631774e6461461014c5780631e26fd331461015d5780631f9030371461016e578063343a875d1461018057806338cc4831146101955780634e7ad367146101bd57806357cb2fc4146101cb57806365538c73146101e057806368895979146101ee57806376bc21d9146102005780639a19a9531461020e5780639dc2c8f51461021f578063a53b1c1e1461022d578063a67808571461023e578063b61c05031461024c578063c2b12a731461025a578063d2282dc51461026b578063e30081a01461027c578063e8beef5b1461028d578063f38b06001461029b578063f5b53e17146102a9578063fd408767146102bb57005b6101346104d6565b60006000f35b61014261039b565b8060005260206000f35b610157600435610326565b60006000f35b6101686004356102c9565b60006000f35b610176610442565b8060005260206000f35b6101886103d3565b8060ff1660005260206000f35b61019d610413565b8073ffffffffffffffffffffffffffffffffffffffff1660005260206000f35b6101c56104c5565b60006000f35b6101d36103b7565b8060000b60005260206000f35b6101e8610454565b60006000f35b6101f6610401565b8060005260206000f35b61020861051f565b60006000f35b6102196004356102e5565b60006000f35b610227610693565b60006000f35b610238600435610342565b60006000f35b610246610484565b60006000f35b610254610493565b60006000f35b61026560043561038d565b60006000f35b610276600435610350565b60006000f35b61028760043561035e565b60006000f35b6102956105b4565b60006000f35b6102a3610547565b60006000f35b6102b16103ef565b8060005260206000f35b6102c3610600565b60006000f35b80600060006101000a81548160ff021916908302179055505b50565b80600060016101000a81548160ff02191690837f01000000000000000000000000000000000000000000000000000000000000009081020402179055505b50565b80600060026101000a81548160ff021916908302179055505b50565b806001600050819055505b50565b806002600050819055505b50565b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b50565b806004600050819055505b50565b6000600060009054906101000a900460ff1690506103b4565b90565b6000600060019054906101000a900460000b90506103d0565b90565b6000600060029054906101000a900460ff1690506103ec565b90565b600060016000505490506103fe565b90565b60006002600050549050610410565b90565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905061043f565b90565b60006004600050549050610451565b90565b7f65c9ac8011e286e89d02a269890f41d67ca2cc597b2c76c7c69321ff492be5806000602a81526020016000a15b565b6000602a81526020016000a05b565b60017f81933b308056e7e85668661dcd102b1f22795b4431f9cf4625794f381c271c6b6000602a81526020016000a25b565b60016000602a81526020016000a15b565b3373ffffffffffffffffffffffffffffffffffffffff1660017f0e216b62efbb97e751a2ce09f607048751720397ecfb9eef1e48a6644948985b6000602a81526020016000a35b565b3373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a25b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017f317b31292193c2a4f561cc40a95ea0d97a2733f14af6d6d59522473e1f3ae65f6000602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a35b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017fd5f0a30e4be0c6be577a71eceb7464245a796a7e6a55c0d971837b250de05f4e60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff16600160007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a35b56", "0x0", + "0x3a514176466fa815ed481ffad09110a2d344f6c9b78c1d14afc351c3a51be33d8072e77939dc03ba44790779b7a1025baf3003f6732430e20cd9b76d953391b3", + "0xf907638001832fefd8800ab907155b5b610705806100106000396000f3006000357c010000000000000000000000000000000000000000000000000000000090048063102accc11461012c57806312a7b9141461013a5780631774e6461461014c5780631e26fd331461015d5780631f9030371461016e578063343a875d1461018057806338cc4831146101955780634e7ad367146101bd57806357cb2fc4146101cb57806365538c73146101e057806368895979146101ee57806376bc21d9146102005780639a19a9531461020e5780639dc2c8f51461021f578063a53b1c1e1461022d578063a67808571461023e578063b61c05031461024c578063c2b12a731461025a578063d2282dc51461026b578063e30081a01461027c578063e8beef5b1461028d578063f38b06001461029b578063f5b53e17146102a9578063fd408767146102bb57005b6101346104d6565b60006000f35b61014261039b565b8060005260206000f35b610157600435610326565b60006000f35b6101686004356102c9565b60006000f35b610176610442565b8060005260206000f35b6101886103d3565b8060ff1660005260206000f35b61019d610413565b8073ffffffffffffffffffffffffffffffffffffffff1660005260206000f35b6101c56104c5565b60006000f35b6101d36103b7565b8060000b60005260206000f35b6101e8610454565b60006000f35b6101f6610401565b8060005260206000f35b61020861051f565b60006000f35b6102196004356102e5565b60006000f35b610227610693565b60006000f35b610238600435610342565b60006000f35b610246610484565b60006000f35b610254610493565b60006000f35b61026560043561038d565b60006000f35b610276600435610350565b60006000f35b61028760043561035e565b60006000f35b6102956105b4565b60006000f35b6102a3610547565b60006000f35b6102b16103ef565b8060005260206000f35b6102c3610600565b60006000f35b80600060006101000a81548160ff021916908302179055505b50565b80600060016101000a81548160ff02191690837f01000000000000000000000000000000000000000000000000000000000000009081020402179055505b50565b80600060026101000a81548160ff021916908302179055505b50565b806001600050819055505b50565b806002600050819055505b50565b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b50565b806004600050819055505b50565b6000600060009054906101000a900460ff1690506103b4565b90565b6000600060019054906101000a900460000b90506103d0565b90565b6000600060029054906101000a900460ff1690506103ec565b90565b600060016000505490506103fe565b90565b60006002600050549050610410565b90565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905061043f565b90565b60006004600050549050610451565b90565b7f65c9ac8011e286e89d02a269890f41d67ca2cc597b2c76c7c69321ff492be5806000602a81526020016000a15b565b6000602a81526020016000a05b565b60017f81933b308056e7e85668661dcd102b1f22795b4431f9cf4625794f381c271c6b6000602a81526020016000a25b565b60016000602a81526020016000a15b565b3373ffffffffffffffffffffffffffffffffffffffff1660017f0e216b62efbb97e751a2ce09f607048751720397ecfb9eef1e48a6644948985b6000602a81526020016000a35b565b3373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a25b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017f317b31292193c2a4f561cc40a95ea0d97a2733f14af6d6d59522473e1f3ae65f6000602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a35b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017fd5f0a30e4be0c6be577a71eceb7464245a796a7e6a55c0d971837b250de05f4e60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff16600160007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a35b561ca0e439aa8812c1c0a751b0931ea20c5a30cd54fe15cae883c59fd8107e04557679a058d025af99b538b778a47da8115c43d5cee564c3cc8d58eb972aaf80ea2c406e", null, "0x0", "0xa", @@ -137,7 +146,7 @@ public void returnFullTransactionIfBlockFound() { requestWithParams( "0x10aaf14a53caf27552325374429d3558398a36d3682ede6603c2c6511896e9f9", true)); - assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); + assertThat(actual).usingRecursiveComparison().isEqualTo(expected); } @Test diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/EthGetBlockByNumberIntegrationTest.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/EthGetBlockByNumberIntegrationTest.java index 82a1778ce88..6fbb74c5b1c 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/EthGetBlockByNumberIntegrationTest.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/EthGetBlockByNumberIntegrationTest.java @@ -112,7 +112,7 @@ public void earliestBlockHashes() { final JsonRpcResponse actual = ethGetBlockNumber().response(request); - assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); + assertThat(actual).usingRecursiveComparison().isEqualTo(expected); } @Test @@ -154,7 +154,7 @@ public void earliestBlockTransactions() { final JsonRpcResponse actual = ethGetBlockNumber().response(request); - assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); + assertThat(actual).usingRecursiveComparison().isEqualTo(expected); } private JsonRpcResponse expectedLatestBlockHashes() { @@ -203,7 +203,7 @@ public void latestBlockHashes() { final JsonRpcResponse actual = ethGetBlockNumber().response(request); - assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); + assertThat(actual).usingRecursiveComparison().isEqualTo(expected); } private JsonRpcResponse expectedLatestBlockTransactions() { @@ -244,12 +244,15 @@ private JsonRpcResponse expectedLatestBlockTransactions() { responseUtils.transaction( "0x71d59849ddd98543bdfbe8548f5eed559b07b8aaf196369f39134500eab68e53", "0x20", + null, "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "0x4cb2f", "0x1", "0xcef53f2311d7c80e9086d661e69ac11a5f3d081e28e02a9ba9b66749407ac310", "0x9dc2c8f5", "0x1f", + "0x3a514176466fa815ed481ffad09110a2d344f6c9b78c1d14afc351c3a51be33d8072e77939dc03ba44790779b7a1025baf3003f6732430e20cd9b76d953391b3", + "0xf8641f018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a849dc2c8f51ba0705b002a7df60707d33812e0298411721be20ea5a2f533707295140d89263b79a078024390784f24160739533b3ceea2698289a02afd9cc768581b4aa3d5f4b105", "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", "0x0", "0xa", @@ -266,7 +269,7 @@ public void latestBlockTransactions() { final JsonRpcResponse actual = ethGetBlockNumber().response(request); - assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); + assertThat(actual).usingRecursiveComparison().isEqualTo(expected); } @Test @@ -276,7 +279,7 @@ public void pendingBlockHashes() { final JsonRpcResponse actual = ethGetBlockNumber().response(request); - assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); + assertThat(actual).usingRecursiveComparison().isEqualTo(expected); } @Test @@ -286,7 +289,7 @@ public void pendingBlockTransactions() { final JsonRpcResponse actual = ethGetBlockNumber().response(request); - assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); + assertThat(actual).usingRecursiveComparison().isEqualTo(expected); } @Test @@ -331,7 +334,7 @@ public void blockSixHashes() { final JsonRpcResponse actual = ethGetBlockNumber().response(request); - assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); + assertThat(actual).usingRecursiveComparison().isEqualTo(expected); } @Test @@ -373,12 +376,15 @@ public void blockSixTransactions() { responseUtils.transaction( "0x609427ccfeae6d2a930927c9a29a0a3077cac7e4b5826159586b10e25770eef9", "0x5", + null, "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "0x4cb2f", "0x1", "0xec7e53d1b99ef586b3e43c1c7068311f6861d51ac3d6fbf257ac0b54ba3f2032", "0xf5b53e17", "0x4", + "0x3a514176466fa815ed481ffad09110a2d344f6c9b78c1d14afc351c3a51be33d8072e77939dc03ba44790779b7a1025baf3003f6732430e20cd9b76d953391b3", + "0xf86404018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a84f5b53e171ca01c07bd41fc821f95b9f543b080c520654727f9cf829800f789c3b03b8de8b326a0259c8aceea2d462192d95f9d6b7cb9e0bf2a6d549c3a4111194fdd22105728f5", "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", "0x0", "0xa", @@ -390,7 +396,7 @@ public void blockSixTransactions() { final JsonRpcResponse actual = ethGetBlockNumber().response(request); - assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); + assertThat(actual).usingRecursiveComparison().isEqualTo(expected); } /** The Tag | Quantity is the first parameter, either a String or a number */ 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 fdf572f592b..59096fcdfdb 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 @@ -16,6 +16,7 @@ import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata; import org.hyperledger.besu.ethereum.core.Transaction; +import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -24,12 +25,15 @@ @JsonPropertyOrder({ "blockHash", "blockNumber", + "chainId", "from", "gas", "gasPrice", "hash", "input", "nonce", + "publicKey", + "raw", "to", "transactionIndex", "value", @@ -41,12 +45,15 @@ public class TransactionCompleteResult implements TransactionResult { private final String blockHash; private final String blockNumber; + private final String chainId; private final String from; private final String gas; private final String gasPrice; private final String hash; private final String input; private final String nonce; + private final String publicKey; + private final String raw; private final String to; private final String transactionIndex; private final String value; @@ -58,12 +65,17 @@ public TransactionCompleteResult(final TransactionWithMetadata tx) { final Transaction transaction = tx.getTransaction(); this.blockHash = tx.getBlockHash().get().toString(); this.blockNumber = Quantity.create(tx.getBlockNumber().get()); + this.chainId = transaction.getChainId().map(Quantity::create).orElse(null); this.from = transaction.getSender().toString(); this.gas = Quantity.create(transaction.getGasLimit()); this.gasPrice = Quantity.create(transaction.getGasPrice()); this.hash = transaction.getHash().toString(); this.input = transaction.getPayload().toString(); this.nonce = Quantity.create(transaction.getNonce()); + this.publicKey = transaction.getPublicKey().orElse(null); + final BytesValueRLPOutput out = new BytesValueRLPOutput(); + transaction.writeTo(out); + this.raw = out.encoded().toString(); this.to = transaction.getTo().map(Bytes::toHexString).orElse(null); this.transactionIndex = Quantity.create(tx.getTransactionIndex().get()); this.value = Quantity.create(transaction.getValue()); @@ -82,6 +94,11 @@ public String getBlockNumber() { return blockNumber; } + @JsonGetter(value = "chainId") + public String getChainId() { + return chainId; + } + @JsonGetter(value = "from") public String getFrom() { return from; @@ -112,6 +129,16 @@ public String getNonce() { return nonce; } + @JsonGetter(value = "publicKey") + public String getPublicKey() { + return publicKey; + } + + @JsonGetter(value = "raw") + public String getRaw() { + return raw; + } + @JsonGetter(value = "to") public String getTo() { return to; 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 5fe2fa8f23b..e02b6d7ce79 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 @@ -16,6 +16,7 @@ import org.hyperledger.besu.ethereum.core.Address; import org.hyperledger.besu.ethereum.core.Transaction; +import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -38,12 +39,15 @@ }) public class TransactionPendingResult implements TransactionResult { + private final String chainId; private final String from; private final String gas; private final String gasPrice; private final String hash; private final String input; private final String nonce; + private final String publicKey; + private final String raw; private final String to; private final String value; private final String v; @@ -51,12 +55,17 @@ public class TransactionPendingResult implements TransactionResult { private final String s; public TransactionPendingResult(final Transaction transaction) { + this.chainId = transaction.getChainId().map(Quantity::create).orElse(null); this.from = transaction.getSender().toString(); this.gas = Quantity.create(transaction.getGasLimit()); this.gasPrice = Quantity.create(transaction.getGasPrice()); this.hash = transaction.getHash().toString(); this.input = transaction.getPayload().toString(); this.nonce = Quantity.create(transaction.getNonce()); + this.publicKey = transaction.getPublicKey().orElse(null); + final BytesValueRLPOutput out = new BytesValueRLPOutput(); + transaction.writeTo(out); + this.raw = out.encoded().toString(); this.to = transaction.getTo().map(Address::toHexString).orElse(null); this.value = Quantity.create(transaction.getValue()); this.v = Quantity.create(transaction.getV()); @@ -64,6 +73,11 @@ public TransactionPendingResult(final Transaction transaction) { this.s = Quantity.create(transaction.getS()); } + @JsonGetter(value = "chainId") + public String getChainId() { + return chainId; + } + @JsonGetter(value = "from") public String getFrom() { return from; @@ -94,6 +108,16 @@ public String getNonce() { return nonce; } + @JsonGetter(value = "publicKey") + public String getPublicKey() { + return publicKey; + } + + @JsonGetter(value = "raw") + public String getRaw() { + return raw; + } + @JsonGetter(value = "to") public String getTo() { return to; diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getBlockByNumber_complete.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getBlockByNumber_complete.json index 8f8da4ace03..4806720e433 100644 --- a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getBlockByNumber_complete.json +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getBlockByNumber_complete.json @@ -35,12 +35,15 @@ { "blockHash": "0x1878c6f27178250f3d55186a2887b076936599f307d96dabcf331b2ff0a38f0c", "blockNumber": "0x10", + "chainId": null, "from": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "gas": "0x4cb2f", "gasPrice": "0x1", "hash": "0x9f6a5eb65991ce483a9e1bfc57b44cd2c8ff4c26ca804240d593b4b63c3eafcd", "input": "0xc2b12a73aabbccffffffffffffffffffffffffffffffffffffffffffffffffffffffffee", "nonce": "0xf", + "publicKey": "0x3a514176466fa815ed481ffad09110a2d344f6c9b78c1d14afc351c3a51be33d8072e77939dc03ba44790779b7a1025baf3003f6732430e20cd9b76d953391b3", + "raw": "0xf8840f018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0aa4c2b12a73aabbccffffffffffffffffffffffffffffffffffffffffffffffffffffffffee1ba00394fa9c43a2469d48b98f4f7e8dfdf7bd3c7abd9eafe8c124b362594aafc5d6a00ecf369283eda15f4c4db09784b5226dfe48a0a80ff91e87d858f6adbb131cf9", "to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", "transactionIndex": "0x0", "value": "0xa", diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockHashAndIndex_00.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockHashAndIndex_00.json index a4edc86b628..396801c2137 100644 --- a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockHashAndIndex_00.json +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockHashAndIndex_00.json @@ -14,12 +14,15 @@ "result": { "blockHash": "0x10aaf14a53caf27552325374429d3558398a36d3682ede6603c2c6511896e9f9", "blockNumber": "0x1", + "chainId": null, "from": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "gas": "0x2fefd8", "gasPrice": "0x1", "hash": "0x812742182a79a8e67733edc58cfa3767aa2d7ad06439d156ddbbb33e3403b4ed", "input": "0x5b5b610705806100106000396000f3006000357c010000000000000000000000000000000000000000000000000000000090048063102accc11461012c57806312a7b9141461013a5780631774e6461461014c5780631e26fd331461015d5780631f9030371461016e578063343a875d1461018057806338cc4831146101955780634e7ad367146101bd57806357cb2fc4146101cb57806365538c73146101e057806368895979146101ee57806376bc21d9146102005780639a19a9531461020e5780639dc2c8f51461021f578063a53b1c1e1461022d578063a67808571461023e578063b61c05031461024c578063c2b12a731461025a578063d2282dc51461026b578063e30081a01461027c578063e8beef5b1461028d578063f38b06001461029b578063f5b53e17146102a9578063fd408767146102bb57005b6101346104d6565b60006000f35b61014261039b565b8060005260206000f35b610157600435610326565b60006000f35b6101686004356102c9565b60006000f35b610176610442565b8060005260206000f35b6101886103d3565b8060ff1660005260206000f35b61019d610413565b8073ffffffffffffffffffffffffffffffffffffffff1660005260206000f35b6101c56104c5565b60006000f35b6101d36103b7565b8060000b60005260206000f35b6101e8610454565b60006000f35b6101f6610401565b8060005260206000f35b61020861051f565b60006000f35b6102196004356102e5565b60006000f35b610227610693565b60006000f35b610238600435610342565b60006000f35b610246610484565b60006000f35b610254610493565b60006000f35b61026560043561038d565b60006000f35b610276600435610350565b60006000f35b61028760043561035e565b60006000f35b6102956105b4565b60006000f35b6102a3610547565b60006000f35b6102b16103ef565b8060005260206000f35b6102c3610600565b60006000f35b80600060006101000a81548160ff021916908302179055505b50565b80600060016101000a81548160ff02191690837f01000000000000000000000000000000000000000000000000000000000000009081020402179055505b50565b80600060026101000a81548160ff021916908302179055505b50565b806001600050819055505b50565b806002600050819055505b50565b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b50565b806004600050819055505b50565b6000600060009054906101000a900460ff1690506103b4565b90565b6000600060019054906101000a900460000b90506103d0565b90565b6000600060029054906101000a900460ff1690506103ec565b90565b600060016000505490506103fe565b90565b60006002600050549050610410565b90565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905061043f565b90565b60006004600050549050610451565b90565b7f65c9ac8011e286e89d02a269890f41d67ca2cc597b2c76c7c69321ff492be5806000602a81526020016000a15b565b6000602a81526020016000a05b565b60017f81933b308056e7e85668661dcd102b1f22795b4431f9cf4625794f381c271c6b6000602a81526020016000a25b565b60016000602a81526020016000a15b565b3373ffffffffffffffffffffffffffffffffffffffff1660017f0e216b62efbb97e751a2ce09f607048751720397ecfb9eef1e48a6644948985b6000602a81526020016000a35b565b3373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a25b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017f317b31292193c2a4f561cc40a95ea0d97a2733f14af6d6d59522473e1f3ae65f6000602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a35b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017fd5f0a30e4be0c6be577a71eceb7464245a796a7e6a55c0d971837b250de05f4e60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff16600160007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a35b56", "nonce": "0x0", + "publicKey": "0x3a514176466fa815ed481ffad09110a2d344f6c9b78c1d14afc351c3a51be33d8072e77939dc03ba44790779b7a1025baf3003f6732430e20cd9b76d953391b3", + "raw": "0xf907638001832fefd8800ab907155b5b610705806100106000396000f3006000357c010000000000000000000000000000000000000000000000000000000090048063102accc11461012c57806312a7b9141461013a5780631774e6461461014c5780631e26fd331461015d5780631f9030371461016e578063343a875d1461018057806338cc4831146101955780634e7ad367146101bd57806357cb2fc4146101cb57806365538c73146101e057806368895979146101ee57806376bc21d9146102005780639a19a9531461020e5780639dc2c8f51461021f578063a53b1c1e1461022d578063a67808571461023e578063b61c05031461024c578063c2b12a731461025a578063d2282dc51461026b578063e30081a01461027c578063e8beef5b1461028d578063f38b06001461029b578063f5b53e17146102a9578063fd408767146102bb57005b6101346104d6565b60006000f35b61014261039b565b8060005260206000f35b610157600435610326565b60006000f35b6101686004356102c9565b60006000f35b610176610442565b8060005260206000f35b6101886103d3565b8060ff1660005260206000f35b61019d610413565b8073ffffffffffffffffffffffffffffffffffffffff1660005260206000f35b6101c56104c5565b60006000f35b6101d36103b7565b8060000b60005260206000f35b6101e8610454565b60006000f35b6101f6610401565b8060005260206000f35b61020861051f565b60006000f35b6102196004356102e5565b60006000f35b610227610693565b60006000f35b610238600435610342565b60006000f35b610246610484565b60006000f35b610254610493565b60006000f35b61026560043561038d565b60006000f35b610276600435610350565b60006000f35b61028760043561035e565b60006000f35b6102956105b4565b60006000f35b6102a3610547565b60006000f35b6102b16103ef565b8060005260206000f35b6102c3610600565b60006000f35b80600060006101000a81548160ff021916908302179055505b50565b80600060016101000a81548160ff02191690837f01000000000000000000000000000000000000000000000000000000000000009081020402179055505b50565b80600060026101000a81548160ff021916908302179055505b50565b806001600050819055505b50565b806002600050819055505b50565b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b50565b806004600050819055505b50565b6000600060009054906101000a900460ff1690506103b4565b90565b6000600060019054906101000a900460000b90506103d0565b90565b6000600060029054906101000a900460ff1690506103ec565b90565b600060016000505490506103fe565b90565b60006002600050549050610410565b90565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905061043f565b90565b60006004600050549050610451565b90565b7f65c9ac8011e286e89d02a269890f41d67ca2cc597b2c76c7c69321ff492be5806000602a81526020016000a15b565b6000602a81526020016000a05b565b60017f81933b308056e7e85668661dcd102b1f22795b4431f9cf4625794f381c271c6b6000602a81526020016000a25b565b60016000602a81526020016000a15b565b3373ffffffffffffffffffffffffffffffffffffffff1660017f0e216b62efbb97e751a2ce09f607048751720397ecfb9eef1e48a6644948985b6000602a81526020016000a35b565b3373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a25b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017f317b31292193c2a4f561cc40a95ea0d97a2733f14af6d6d59522473e1f3ae65f6000602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a35b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017fd5f0a30e4be0c6be577a71eceb7464245a796a7e6a55c0d971837b250de05f4e60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff16600160007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a35b561ca0e439aa8812c1c0a751b0931ea20c5a30cd54fe15cae883c59fd8107e04557679a058d025af99b538b778a47da8115c43d5cee564c3cc8d58eb972aaf80ea2c406e", "to": null, "transactionIndex": "0x0", "value": "0xa", diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockHashAndIndex_01.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockHashAndIndex_01.json index 51cfefe27f2..d4df1bf64d1 100644 --- a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockHashAndIndex_01.json +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockHashAndIndex_01.json @@ -14,12 +14,15 @@ "result": { "blockHash": "0x0e29f455b8db7b15042efe9eabe0beb0ce2c7901919bba1107b1352191e09942", "blockNumber": "0x2", + "chainId": null, "from": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "gas": "0x4cb2f", "gasPrice": "0x1", "hash": "0xb1a62356d1433202cdef0ef9030f8abdfbb3aef549fab0867cf0eaee70b09d81", "input": "0x12a7b914", "nonce": "0x1", + "publicKey": "0x3a514176466fa815ed481ffad09110a2d344f6c9b78c1d14afc351c3a51be33d8072e77939dc03ba44790779b7a1025baf3003f6732430e20cd9b76d953391b3", + "raw": "0xf86401018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a8412a7b9141ba0ed2e0f715eccaab4362c19c1cf35ad8031ab1cabe71ada3fe8b269fe9d726712a06691074f289f826d23c92808ae363959eb958fb7a91fc721875ece4958114c65", "to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", "transactionIndex": "0x0", "value": "0xa", diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockHashAndIndex_02.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockHashAndIndex_02.json index e40ca03f955..aca3af8c9b3 100644 --- a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockHashAndIndex_02.json +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockHashAndIndex_02.json @@ -14,12 +14,15 @@ "result": { "blockHash": "0x71d59849ddd98543bdfbe8548f5eed559b07b8aaf196369f39134500eab68e53", "blockNumber": "0x20", + "chainId": null, "from": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "gas": "0x4cb2f", "gasPrice": "0x1", "hash": "0xcef53f2311d7c80e9086d661e69ac11a5f3d081e28e02a9ba9b66749407ac310", "input": "0x9dc2c8f5", "nonce": "0x1f", + "publicKey": "0x3a514176466fa815ed481ffad09110a2d344f6c9b78c1d14afc351c3a51be33d8072e77939dc03ba44790779b7a1025baf3003f6732430e20cd9b76d953391b3", + "raw": "0xf8641f018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a849dc2c8f51ba0705b002a7df60707d33812e0298411721be20ea5a2f533707295140d89263b79a078024390784f24160739533b3ceea2698289a02afd9cc768581b4aa3d5f4b105", "to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", "transactionIndex": "0x0", "value": "0xa", diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockNumberAndIndex_00.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockNumberAndIndex_00.json index 16e6bd9a16b..0204ee43f01 100644 --- a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockNumberAndIndex_00.json +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockNumberAndIndex_00.json @@ -14,12 +14,15 @@ "result": { "blockHash": "0x0e29f455b8db7b15042efe9eabe0beb0ce2c7901919bba1107b1352191e09942", "blockNumber": "0x2", + "chainId": null, "from": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "gas": "0x4cb2f", "gasPrice": "0x1", "hash": "0xb1a62356d1433202cdef0ef9030f8abdfbb3aef549fab0867cf0eaee70b09d81", "input": "0x12a7b914", "nonce": "0x1", + "publicKey": "0x3a514176466fa815ed481ffad09110a2d344f6c9b78c1d14afc351c3a51be33d8072e77939dc03ba44790779b7a1025baf3003f6732430e20cd9b76d953391b3", + "raw": "0xf86401018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a8412a7b9141ba0ed2e0f715eccaab4362c19c1cf35ad8031ab1cabe71ada3fe8b269fe9d726712a06691074f289f826d23c92808ae363959eb958fb7a91fc721875ece4958114c65", "to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", "transactionIndex": "0x0", "value": "0xa", diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockNumberAndIndex_01.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockNumberAndIndex_01.json index 1216deeb017..bb15bc7d2be 100644 --- a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockNumberAndIndex_01.json +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockNumberAndIndex_01.json @@ -14,12 +14,15 @@ "result": { "blockHash": "0x3d813a0ffc9cd04436e17e3e9c309f1e80df0407078e50355ce0d570b5424812", "blockNumber": "0x3", + "chainId": null, "from": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "gas": "0x4cb2f", "gasPrice": "0x1", "hash": "0x78e0c0452452a2465744eee11506c40de70f3da1296aa96f08bcf5d326822784", "input": "0x57cb2fc4", "nonce": "0x2", + "publicKey": "0x3a514176466fa815ed481ffad09110a2d344f6c9b78c1d14afc351c3a51be33d8072e77939dc03ba44790779b7a1025baf3003f6732430e20cd9b76d953391b3", + "raw": "0xf86402018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a8457cb2fc41ba09dc3bf93e023b46d5d6d3ff2e62b06e10ba3877b8df69a408d8f8ec2ad8ea040a046c830e900919e5e0e6e48d413ad3f1f7906c6f0fe51c5d38431f3fe64622143", "to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", "transactionIndex": "0x0", "value": "0xa", diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockNumberAndIndex_latest.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockNumberAndIndex_latest.json index ad8cfd98918..ad662aa8945 100644 --- a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockNumberAndIndex_latest.json +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockNumberAndIndex_latest.json @@ -14,12 +14,15 @@ "result": { "blockHash": "0x71d59849ddd98543bdfbe8548f5eed559b07b8aaf196369f39134500eab68e53", "blockNumber": "0x20", + "chainId": null, "from": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "gas": "0x4cb2f", "gasPrice": "0x1", "hash": "0xcef53f2311d7c80e9086d661e69ac11a5f3d081e28e02a9ba9b66749407ac310", "input": "0x9dc2c8f5", "nonce": "0x1f", + "publicKey": "0x3a514176466fa815ed481ffad09110a2d344f6c9b78c1d14afc351c3a51be33d8072e77939dc03ba44790779b7a1025baf3003f6732430e20cd9b76d953391b3", + "raw": "0xf8641f018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a849dc2c8f51ba0705b002a7df60707d33812e0298411721be20ea5a2f533707295140d89263b79a078024390784f24160739533b3ceea2698289a02afd9cc768581b4aa3d5f4b105", "to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", "transactionIndex": "0x0", "value": "0xa", diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockNumberAndIndex_pending.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockNumberAndIndex_pending.json index 03e3bad6672..6aa16c768de 100644 --- a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockNumberAndIndex_pending.json +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByBlockNumberAndIndex_pending.json @@ -14,12 +14,15 @@ "result": { "blockHash": "0x71d59849ddd98543bdfbe8548f5eed559b07b8aaf196369f39134500eab68e53", "blockNumber": "0x20", + "chainId": null, "from": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "gas": "0x4cb2f", "gasPrice": "0x1", "hash": "0xcef53f2311d7c80e9086d661e69ac11a5f3d081e28e02a9ba9b66749407ac310", "input": "0x9dc2c8f5", "nonce": "0x1f", + "publicKey": "0x3a514176466fa815ed481ffad09110a2d344f6c9b78c1d14afc351c3a51be33d8072e77939dc03ba44790779b7a1025baf3003f6732430e20cd9b76d953391b3", + "raw": "0xf8641f018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a849dc2c8f51ba0705b002a7df60707d33812e0298411721be20ea5a2f533707295140d89263b79a078024390784f24160739533b3ceea2698289a02afd9cc768581b4aa3d5f4b105", "to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", "transactionIndex": "0x0", "value": "0xa", diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByHash_addressReceiver.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByHash_addressReceiver.json index 6634cfe19cb..7008113936b 100644 --- a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByHash_addressReceiver.json +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByHash_addressReceiver.json @@ -13,12 +13,15 @@ "result": { "blockHash": "0xc8df1f061abb4d0c107b2b1a794ade8780b3120e681f723fe55a7be586d95ba6", "blockNumber": "0x1e", + "chainId": null, "from": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "gas": "0x4cb2f", "gasPrice": "0x1", "hash": "0x9cc6c7e602c56aa30c554bb691377f8703d778cec8845f4b88c0f72516b304f4", "input": "0xe8beef5b", "nonce": "0x1d", + "publicKey": "0x3a514176466fa815ed481ffad09110a2d344f6c9b78c1d14afc351c3a51be33d8072e77939dc03ba44790779b7a1025baf3003f6732430e20cd9b76d953391b3", + "raw": "0xf8641d018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a84e8beef5b1ca011232cac2f935ab8dd5d5972438fde90e05d0dd620860b42886e7d54dc5c4a0ca03dd467b5faa6e5a0f3c22a5396fefa5b03f07d8114d8434e0e1493736aad8d0e", "to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", "transactionIndex": "0x0", "value": "0xa", diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByHash_contractCreation.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByHash_contractCreation.json index 2cea6d0874a..47b1f6e968a 100644 --- a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByHash_contractCreation.json +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionByHash_contractCreation.json @@ -13,12 +13,15 @@ "result": { "blockHash": "0x10aaf14a53caf27552325374429d3558398a36d3682ede6603c2c6511896e9f9", "blockNumber": "0x1", + "chainId": null, "from": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "gas": "0x2fefd8", "gasPrice": "0x1", "hash": "0x812742182a79a8e67733edc58cfa3767aa2d7ad06439d156ddbbb33e3403b4ed", "input": "0x5b5b610705806100106000396000f3006000357c010000000000000000000000000000000000000000000000000000000090048063102accc11461012c57806312a7b9141461013a5780631774e6461461014c5780631e26fd331461015d5780631f9030371461016e578063343a875d1461018057806338cc4831146101955780634e7ad367146101bd57806357cb2fc4146101cb57806365538c73146101e057806368895979146101ee57806376bc21d9146102005780639a19a9531461020e5780639dc2c8f51461021f578063a53b1c1e1461022d578063a67808571461023e578063b61c05031461024c578063c2b12a731461025a578063d2282dc51461026b578063e30081a01461027c578063e8beef5b1461028d578063f38b06001461029b578063f5b53e17146102a9578063fd408767146102bb57005b6101346104d6565b60006000f35b61014261039b565b8060005260206000f35b610157600435610326565b60006000f35b6101686004356102c9565b60006000f35b610176610442565b8060005260206000f35b6101886103d3565b8060ff1660005260206000f35b61019d610413565b8073ffffffffffffffffffffffffffffffffffffffff1660005260206000f35b6101c56104c5565b60006000f35b6101d36103b7565b8060000b60005260206000f35b6101e8610454565b60006000f35b6101f6610401565b8060005260206000f35b61020861051f565b60006000f35b6102196004356102e5565b60006000f35b610227610693565b60006000f35b610238600435610342565b60006000f35b610246610484565b60006000f35b610254610493565b60006000f35b61026560043561038d565b60006000f35b610276600435610350565b60006000f35b61028760043561035e565b60006000f35b6102956105b4565b60006000f35b6102a3610547565b60006000f35b6102b16103ef565b8060005260206000f35b6102c3610600565b60006000f35b80600060006101000a81548160ff021916908302179055505b50565b80600060016101000a81548160ff02191690837f01000000000000000000000000000000000000000000000000000000000000009081020402179055505b50565b80600060026101000a81548160ff021916908302179055505b50565b806001600050819055505b50565b806002600050819055505b50565b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b50565b806004600050819055505b50565b6000600060009054906101000a900460ff1690506103b4565b90565b6000600060019054906101000a900460000b90506103d0565b90565b6000600060029054906101000a900460ff1690506103ec565b90565b600060016000505490506103fe565b90565b60006002600050549050610410565b90565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905061043f565b90565b60006004600050549050610451565b90565b7f65c9ac8011e286e89d02a269890f41d67ca2cc597b2c76c7c69321ff492be5806000602a81526020016000a15b565b6000602a81526020016000a05b565b60017f81933b308056e7e85668661dcd102b1f22795b4431f9cf4625794f381c271c6b6000602a81526020016000a25b565b60016000602a81526020016000a15b565b3373ffffffffffffffffffffffffffffffffffffffff1660017f0e216b62efbb97e751a2ce09f607048751720397ecfb9eef1e48a6644948985b6000602a81526020016000a35b565b3373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a25b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017f317b31292193c2a4f561cc40a95ea0d97a2733f14af6d6d59522473e1f3ae65f6000602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a35b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017fd5f0a30e4be0c6be577a71eceb7464245a796a7e6a55c0d971837b250de05f4e60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff16600160007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a35b56", "nonce": "0x0", + "publicKey": "0x3a514176466fa815ed481ffad09110a2d344f6c9b78c1d14afc351c3a51be33d8072e77939dc03ba44790779b7a1025baf3003f6732430e20cd9b76d953391b3", + "raw": "0xf907638001832fefd8800ab907155b5b610705806100106000396000f3006000357c010000000000000000000000000000000000000000000000000000000090048063102accc11461012c57806312a7b9141461013a5780631774e6461461014c5780631e26fd331461015d5780631f9030371461016e578063343a875d1461018057806338cc4831146101955780634e7ad367146101bd57806357cb2fc4146101cb57806365538c73146101e057806368895979146101ee57806376bc21d9146102005780639a19a9531461020e5780639dc2c8f51461021f578063a53b1c1e1461022d578063a67808571461023e578063b61c05031461024c578063c2b12a731461025a578063d2282dc51461026b578063e30081a01461027c578063e8beef5b1461028d578063f38b06001461029b578063f5b53e17146102a9578063fd408767146102bb57005b6101346104d6565b60006000f35b61014261039b565b8060005260206000f35b610157600435610326565b60006000f35b6101686004356102c9565b60006000f35b610176610442565b8060005260206000f35b6101886103d3565b8060ff1660005260206000f35b61019d610413565b8073ffffffffffffffffffffffffffffffffffffffff1660005260206000f35b6101c56104c5565b60006000f35b6101d36103b7565b8060000b60005260206000f35b6101e8610454565b60006000f35b6101f6610401565b8060005260206000f35b61020861051f565b60006000f35b6102196004356102e5565b60006000f35b610227610693565b60006000f35b610238600435610342565b60006000f35b610246610484565b60006000f35b610254610493565b60006000f35b61026560043561038d565b60006000f35b610276600435610350565b60006000f35b61028760043561035e565b60006000f35b6102956105b4565b60006000f35b6102a3610547565b60006000f35b6102b16103ef565b8060005260206000f35b6102c3610600565b60006000f35b80600060006101000a81548160ff021916908302179055505b50565b80600060016101000a81548160ff02191690837f01000000000000000000000000000000000000000000000000000000000000009081020402179055505b50565b80600060026101000a81548160ff021916908302179055505b50565b806001600050819055505b50565b806002600050819055505b50565b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b50565b806004600050819055505b50565b6000600060009054906101000a900460ff1690506103b4565b90565b6000600060019054906101000a900460000b90506103d0565b90565b6000600060029054906101000a900460ff1690506103ec565b90565b600060016000505490506103fe565b90565b60006002600050549050610410565b90565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905061043f565b90565b60006004600050549050610451565b90565b7f65c9ac8011e286e89d02a269890f41d67ca2cc597b2c76c7c69321ff492be5806000602a81526020016000a15b565b6000602a81526020016000a05b565b60017f81933b308056e7e85668661dcd102b1f22795b4431f9cf4625794f381c271c6b6000602a81526020016000a25b565b60016000602a81526020016000a15b565b3373ffffffffffffffffffffffffffffffffffffffff1660017f0e216b62efbb97e751a2ce09f607048751720397ecfb9eef1e48a6644948985b6000602a81526020016000a35b565b3373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a25b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017f317b31292193c2a4f561cc40a95ea0d97a2733f14af6d6d59522473e1f3ae65f6000602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a35b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017fd5f0a30e4be0c6be577a71eceb7464245a796a7e6a55c0d971837b250de05f4e60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff16600160007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a35b561ca0e439aa8812c1c0a751b0931ea20c5a30cd54fe15cae883c59fd8107e04557679a058d025af99b538b778a47da8115c43d5cee564c3cc8d58eb972aaf80ea2c406e", "to": null, "transactionIndex": "0x0", "value": "0xa", 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 81c70f1e433..008a0005f3c 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 @@ -19,6 +19,7 @@ import org.hyperledger.besu.config.experimental.ExperimentalEIPs; import org.hyperledger.besu.crypto.SECP256K1; +import org.hyperledger.besu.crypto.SECP256K1.PublicKey; import org.hyperledger.besu.ethereum.core.encoding.TransactionRLPDecoder; import org.hyperledger.besu.ethereum.core.encoding.TransactionRLPEncoder; import org.hyperledger.besu.ethereum.rlp.RLP; @@ -399,6 +400,16 @@ public Address getSender() { return sender; } + /** + * Returns the public key extracted from the signature. + * + * @return the public key + */ + public Optional getPublicKey() { + return SECP256K1.PublicKey.recoverFromSignature(getOrComputeSenderRecoveryHash(), signature) + .map(PublicKey::toString); + } + private Bytes32 getOrComputeSenderRecoveryHash() { if (hashNoSignature == null) { hashNoSignature =