Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude empty requests from requests hash #8036

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
770ee68
exclude empty requests from requests hash
daniellehrner Dec 16, 2024
6e9f120
Merge branch 'main' into feat/issue-7947/exclude_empty_requests_hash
daniellehrner Dec 17, 2024
d7c3a7f
Exclude empty requests and prepend request type byte in engine_getPay…
siladu Dec 18, 2024
a381b19
Merge branch 'main' into feat/issue-7947/exclude_empty_requests_hash
daniellehrner Dec 18, 2024
ffafb17
Merge branch 'feat/issue-7947/exclude_empty_requests_hash' of github.…
daniellehrner Dec 18, 2024
486812f
Merge branch 'main' into feat/issue-7947/exclude_empty_requests_hash
daniellehrner Dec 18, 2024
9d5b638
Merge branch 'main' into feat/issue-7947/exclude_empty_requests_hash
daniellehrner Jan 8, 2025
d8b62ff
fix test
daniellehrner Jan 8, 2025
857c369
fix prague tests: change request hash, reorder json elements
daniellehrner Jan 9, 2025
9c16f51
fix extracting of request for new payload
daniellehrner Jan 9, 2025
f19574b
Merge branch 'main' into feat/issue-7947/exclude_empty_requests_hash
daniellehrner Jan 9, 2025
1ec2403
Merge branch 'main' into feat/issue-7947/exclude_empty_requests_hash
daniellehrner Jan 13, 2025
61ea63a
fix test by fixing request object creation
daniellehrner Jan 13, 2025
ed3abc7
spotless
daniellehrner Jan 13, 2025
9f6c514
Merge branch 'main' into feat/issue-7947/exclude_empty_requests_hash
daniellehrner Jan 13, 2025
1b8a524
set request type to only one byte, fixed creation of request list in …
daniellehrner Jan 14, 2025
ed5d645
Merge branch 'main' into feat/issue-7947/exclude_empty_requests_hash
daniellehrner Jan 14, 2025
e25ebd2
fix expected json output to exclude empty requests
daniellehrner Jan 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Exclude empty requests and prepend request type byte in engine_getPay…
…loadV4

Fixes ethereum/execution-apis#599 change to EIP-7685

Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
  • Loading branch information
siladu committed Dec 18, 2024
commit d7c3a7fcc2069e755f40a4f5115adb3c542d1c4b
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ public EngineGetPayloadResultV4 payloadTransactionCompleteV4(final PayloadWrappe
rqs ->
rqs.stream()
.sorted(Comparator.comparing(Request::getType))
.map(r -> r.getData().toHexString())
.filter(r -> !r.getData().isEmpty())
.map(Request::getEncodedRequest)
.map(Bytes::toHexString)
.toList());

final BlobsBundleV1 blobsBundleV1 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ header, new BlockBody(List.of(blobTx), emptyList(), Optional.of(emptyList()))),
final List<String> requestsWithoutRequestId =
requests.stream()
.sorted(Comparator.comparing(Request::getType))
.map(r -> r.getData().toHexString())
.map(Request::getEncodedRequest)
.map(Bytes::toHexString)
.toList();
Optional.of(resp)
.map(JsonRpcSuccessResponse.class::cast)
Expand All @@ -172,6 +173,53 @@ header, new BlockBody(List.of(blobTx), emptyList(), Optional.of(emptyList()))),
verify(engineCallListener, times(1)).executionEngineCalled();
}

@Test
public void shouldExcludeEmptyRequestsInRequestsList() {

BlockHeader header =
new BlockHeaderTestFixture().timestamp(pragueHardfork.milestone() + 1).buildHeader();
PayloadIdentifier payloadIdentifier =
PayloadIdentifier.forPayloadParams(
Hash.ZERO,
pragueHardfork.milestone(),
Bytes32.random(),
Address.fromHexString("0x42"),
Optional.empty(),
Optional.empty());

BlockWithReceipts block =
new BlockWithReceipts(
new Block(header, new BlockBody(emptyList(), emptyList(), Optional.of(emptyList()))),
emptyList());
final List<Request> unorderedRequests =
List.of(
new Request(RequestType.CONSOLIDATION, Bytes.of(1)),
new Request(RequestType.DEPOSIT, Bytes.of(1)),
new Request(RequestType.WITHDRAWAL, Bytes.EMPTY));
PayloadWrapper payload =
new PayloadWrapper(payloadIdentifier, block, Optional.of(unorderedRequests));

when(mergeContext.retrievePayloadById(payloadIdentifier)).thenReturn(Optional.of(payload));

final var resp = resp(RpcMethod.ENGINE_GET_PAYLOAD_V4.getMethodName(), payloadIdentifier);
assertThat(resp).isInstanceOf(JsonRpcSuccessResponse.class);

final List<String> expectedRequests =
List.of(
Bytes.concatenate(Bytes.of(RequestType.DEPOSIT.getSerializedType()), Bytes.of(1))
.toHexString(),
Bytes.concatenate(Bytes.of(RequestType.CONSOLIDATION.getSerializedType()), Bytes.of(1))
.toHexString());
Optional.of(resp)
.map(JsonRpcSuccessResponse.class::cast)
.ifPresent(
r -> {
assertThat(r.getResult()).isInstanceOf(EngineGetPayloadResultV4.class);
final EngineGetPayloadResultV4 res = (EngineGetPayloadResultV4) r.getResult();
assertThat(res.getExecutionRequests()).isEqualTo(expectedRequests);
});
}

@Test
public void shouldReturnUnsupportedFork() {
final var resp = resp(RpcMethod.ENGINE_GET_PAYLOAD_V4.getMethodName(), mockPid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,13 @@ public RequestType getType() {
public Bytes getData() {
return data();
}

/**
* Gets the serialized form of the concatenated type and data.
*
* @return the serialized request as a byte.
*/
public Bytes getEncodedRequest() {
return Bytes.concatenate(Bytes.of(getType().getSerializedType()), getData());
}
}
Loading