From 718d4fd33e0aabdbb8dbb4468cf4ea7068b5e23b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedemann=20F=C3=BCrst?= <59653747+friedemannf@users.noreply.github.com> Date: Tue, 12 Mar 2024 03:17:06 +0100 Subject: [PATCH] Transaction call object to accept both input and data field if equal (#6702) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * relax JsonCallParameter constructor to allow for both input and data being set if equal Signed-off-by: Friedemann Fürst * fix: format Signed-off-by: Friedemann Fürst * add changelog entry Signed-off-by: Friedemann Fürst --------- Signed-off-by: Friedemann Fürst Co-authored-by: Sally MacFarlane Signed-off-by: MASDXI --- CHANGELOG.md | 1 + .../fork/frontier/EthCallIntegrationTest.java | 27 +++++++++++++++++++ .../parameters/JsonCallParameter.java | 2 +- ...dWithDifferentInputAndDataAttributes.json} | 4 +-- .../eth_call_withInputAndDataAttribute.json | 22 +++++++++++++++ 5 files changed, 53 insertions(+), 3 deletions(-) rename ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/{eth_call_invalidWithInputAndDataAttribute.json => eth_call_invalidWithDifferentInputAndDataAttributes.json} (90%) create mode 100644 ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_call_withInputAndDataAttribute.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 762d5856135..0799f409f91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - Add blob transaction support to `eth_call` [#6661](https://github.com/hyperledger/besu/pull/6661) - Add blobs to `eth_feeHistory` [#6679](https://github.com/hyperledger/besu/pull/6679) - Refactor and extend `TransactionPoolValidatorService` [#6636](https://github.com/hyperledger/besu/pull/6636) +- Transaction call object to accept both `input` and `data` field simultaneously if they are set to equal values [#6702](https://github.com/hyperledger/besu/pull/6702) ### Bug fixes diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthCallIntegrationTest.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthCallIntegrationTest.java index 5fa1c70ae16..14aa15c5c8f 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthCallIntegrationTest.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthCallIntegrationTest.java @@ -408,6 +408,33 @@ public void shouldReturnEmptyHashResultForCallWithOnlyToField() { assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse); } + @Test + public void shouldReturnSuccessWithInputAndDataFieldSetToSameValue() { + final JsonCallParameter callParameter = + new JsonCallParameter( + Address.fromHexString("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b"), + Address.fromHexString("0x6295ee1b4f6dd65047762f924ecd367c17eabf8f"), + null, + null, + null, + null, + null, + Bytes.fromHexString("0x12a7b914"), + Bytes.fromHexString("0x12a7b914"), + null, + null, + null, + null); + final JsonRpcRequestContext request = requestWithParams(callParameter, "latest"); + final JsonRpcResponse expectedResponse = + new JsonRpcSuccessResponse( + null, "0x0000000000000000000000000000000000000000000000000000000000000001"); + + final JsonRpcResponse response = method.response(request); + + assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse); + } + private JsonRpcRequestContext requestWithParams(final Object... params) { return new JsonRpcRequestContext(new JsonRpcRequest("2.0", "eth_call", params)); } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/JsonCallParameter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/JsonCallParameter.java index dae98e6896a..b71083a4c38 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/JsonCallParameter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/JsonCallParameter.java @@ -71,7 +71,7 @@ public JsonCallParameter( Optional.ofNullable(maxFeePerBlobGas), Optional.ofNullable(blobVersionedHashes)); - if (input != null && data != null) { + if (input != null && data != null && !input.equals(data)) { throw new IllegalArgumentException("Only one of 'input' or 'data' should be provided"); } diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_call_invalidWithInputAndDataAttribute.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_call_invalidWithDifferentInputAndDataAttributes.json similarity index 90% rename from ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_call_invalidWithInputAndDataAttribute.json rename to ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_call_invalidWithDifferentInputAndDataAttributes.json index eda5c99c0bc..309e96df249 100644 --- a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_call_invalidWithInputAndDataAttribute.json +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_call_invalidWithDifferentInputAndDataAttributes.json @@ -8,9 +8,9 @@ "to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", "from": "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", "input": "0x12a7b914", - "data": "0x12a7b914" + "data": "0x12a7b915" }, - "0x19" + "latest" ] }, "response": { diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_call_withInputAndDataAttribute.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_call_withInputAndDataAttribute.json new file mode 100644 index 00000000000..929dbe2ad4f --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_call_withInputAndDataAttribute.json @@ -0,0 +1,22 @@ +{ + "request": { + "id": 3, + "jsonrpc": "2.0", + "method": "eth_call", + "params": [ + { + "to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", + "from": "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "input": "0x12a7b914", + "data": "0x12a7b914" + }, + "0x19" + ] + }, + "response": { + "jsonrpc": "2.0", + "id": 3, + "result": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + "statusCode": 200 +} \ No newline at end of file