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

Implement updated Deneb builder REST API #7665

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.TestSpecContext;
import tech.pegasys.teku.spec.TestSpecInvocationContextProvider.SpecContext;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBlindedBlockContainer;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.datastructures.builder.BuilderPayload;
import tech.pegasys.teku.spec.datastructures.builder.SignedBuilderBid;
import tech.pegasys.teku.spec.datastructures.builder.SignedValidatorRegistration;
Expand Down Expand Up @@ -99,7 +99,7 @@ class RestBuilderClientTest {
private RestBuilderClient restBuilderClient;

private String signedValidatorRegistrationsRequest;
private String signedBlindedBlockContainerRequest;
private String signedBlindedBeaconBlockRequest;

private String signedBuilderBidResponse;
private String unblindedBuilderPayloadResponse;
Expand All @@ -118,8 +118,8 @@ void setUp(final SpecContext specContext) throws IOException {

signedValidatorRegistrationsRequest = readResource("builder/signedValidatorRegistrations.json");
final String milestoneFolder = "builder/" + milestone.toString().toLowerCase(Locale.ROOT);
signedBlindedBlockContainerRequest =
readResource(milestoneFolder + "/signedBlindedBlockContainer.json");
signedBlindedBeaconBlockRequest =
readResource(milestoneFolder + "/signedBlindedBeaconBlock.json");
signedBuilderBidResponse = readResource(milestoneFolder + "/signedBuilderBid.json");
unblindedBuilderPayloadResponse =
readResource(milestoneFolder + "/unblindedBuilderPayload.json");
Expand Down Expand Up @@ -378,10 +378,9 @@ void getPayload_success() {
mockWebServer.enqueue(
new MockResponse().setResponseCode(200).setBody(unblindedBuilderPayloadResponse));

final SignedBlindedBlockContainer signedBlindedBlockContainer =
createSignedBlindedBlockContainer();
final SignedBeaconBlock signedBlindedBeaconBlock = createSignedBlindedBeaconBlock();

assertThat(restBuilderClient.getPayload(signedBlindedBlockContainer))
assertThat(restBuilderClient.getPayload(signedBlindedBeaconBlock))
.succeedsWithin(WAIT_FOR_CALL_COMPLETION)
.satisfies(
response -> {
Expand All @@ -390,7 +389,7 @@ void getPayload_success() {
verifyBuilderPayloadResponse(builderPayload);
});

verifyPostRequest("/eth/v1/builder/blinded_blocks", signedBlindedBlockContainerRequest);
verifyPostRequest("/eth/v1/builder/blinded_blocks", signedBlindedBeaconBlockRequest);
}

@TestTemplate
Expand All @@ -400,31 +399,30 @@ void getPayload_failures() {
"{\"code\":400,\"message\":\"Invalid block: missing signature\"}";
mockWebServer.enqueue(new MockResponse().setResponseCode(400).setBody(missingSignatureError));

final SignedBlindedBlockContainer signedBlindedBlockContainer =
createSignedBlindedBlockContainer();
final SignedBeaconBlock signedBlindedBeaconBlock = createSignedBlindedBeaconBlock();

assertThat(restBuilderClient.getPayload(signedBlindedBlockContainer))
assertThat(restBuilderClient.getPayload(signedBlindedBeaconBlock))
.succeedsWithin(WAIT_FOR_CALL_COMPLETION)
.satisfies(
response -> {
assertThat(response.isFailure()).isTrue();
assertThat(response.getErrorMessage()).isEqualTo(missingSignatureError);
});

verifyPostRequest("/eth/v1/builder/blinded_blocks", signedBlindedBlockContainerRequest);
verifyPostRequest("/eth/v1/builder/blinded_blocks", signedBlindedBeaconBlockRequest);

mockWebServer.enqueue(
new MockResponse().setResponseCode(500).setBody(INTERNAL_SERVER_ERROR_MESSAGE));

assertThat(restBuilderClient.getPayload(signedBlindedBlockContainer))
assertThat(restBuilderClient.getPayload(signedBlindedBeaconBlock))
.succeedsWithin(WAIT_FOR_CALL_COMPLETION)
.satisfies(
response -> {
assertThat(response.isFailure()).isTrue();
assertThat(response.getErrorMessage()).isEqualTo(INTERNAL_SERVER_ERROR_MESSAGE);
});

verifyPostRequest("/eth/v1/builder/blinded_blocks", signedBlindedBlockContainerRequest);
verifyPostRequest("/eth/v1/builder/blinded_blocks", signedBlindedBeaconBlockRequest);
}

@TestTemplate
Expand All @@ -437,10 +435,9 @@ void getPayload_wrongVersion(final SpecContext specContext) {
mockWebServer.enqueue(
new MockResponse().setResponseCode(200).setBody(unblindedBuilderPayloadResponse));

final SignedBlindedBlockContainer signedBlindedBlockContainer =
createSignedBlindedBlockContainer();
final SignedBeaconBlock signedBlindedBeaconBlock = createSignedBlindedBeaconBlock();

assertThat(restBuilderClient.getPayload(signedBlindedBlockContainer))
assertThat(restBuilderClient.getPayload(signedBlindedBeaconBlock))
.succeedsWithin(WAIT_FOR_CALL_COMPLETION)
.satisfies(
response -> {
Expand All @@ -449,7 +446,7 @@ void getPayload_wrongVersion(final SpecContext specContext) {
verifyBuilderPayloadResponse(builderPayload);
});

verifyPostRequest("/eth/v1/builder/blinded_blocks", signedBlindedBlockContainerRequest);
verifyPostRequest("/eth/v1/builder/blinded_blocks", signedBlindedBeaconBlockRequest);
}

private void verifyGetRequest(final String apiPath) {
Expand Down Expand Up @@ -517,13 +514,11 @@ private void verifySignedBuilderBidResponse(final SignedBuilderBid actual) {
}
}

private SignedBlindedBlockContainer createSignedBlindedBlockContainer() {
private SignedBeaconBlock createSignedBlindedBeaconBlock() {
try {
return JsonUtil.parse(
signedBlindedBlockContainerRequest,
schemaDefinitions.getSignedBlindedBlockContainerSchema().getJsonTypeDefinition())
.toBlinded()
.orElseThrow();
signedBlindedBeaconBlockRequest,
schemaDefinitions.getSignedBlindedBeaconBlockSchema().getJsonTypeDefinition());
} catch (final JsonProcessingException ex) {
throw new UncheckedIOException(ex);
}
Expand Down
Loading
Loading