Skip to content
/ besu Public
forked from hyperledger/besu

Commit

Permalink
Transaction call object to accept both input and data field if equal (h…
Browse files Browse the repository at this point in the history
…yperledger#6702)

* relax JsonCallParameter constructor to allow for both input and data being set if equal

Signed-off-by: Friedemann Fürst <friedemann.fuerst@smartcontract.com>

* fix: format

Signed-off-by: Friedemann Fürst <friedemann.fuerst@smartcontract.com>

* add changelog entry

Signed-off-by: Friedemann Fürst <friedemann.fuerst@smartcontract.com>

---------

Signed-off-by: Friedemann Fürst <friedemann.fuerst@smartcontract.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Signed-off-by: amsmota <antonio.mota@citi.com>
  • Loading branch information
2 people authored and amsmota committed Apr 16, 2024
1 parent ba67c68 commit 0244579
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
"from": "a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"input": "0x12a7b914",
"data": "0x12a7b914"
"data": "0x12a7b915"
},
"0x19"
"latest"
]
},
"response": {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 0244579

Please sign in to comment.