diff --git a/ethereum/executionclient/src/integration-test/java/tech/pegasys/teku/ethereum/executionclient/rest/RestExecutionBuilderClientTest.java b/ethereum/executionclient/src/integration-test/java/tech/pegasys/teku/ethereum/executionclient/rest/RestExecutionBuilderClientTest.java new file mode 100644 index 00000000000..8595c2b5755 --- /dev/null +++ b/ethereum/executionclient/src/integration-test/java/tech/pegasys/teku/ethereum/executionclient/rest/RestExecutionBuilderClientTest.java @@ -0,0 +1,379 @@ +/* + * Copyright 2022 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package tech.pegasys.teku.ethereum.executionclient.rest; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.io.Resources; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import java.util.Optional; +import okhttp3.OkHttpClient; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import okio.Buffer; +import org.apache.tuweni.bytes.Bytes32; +import org.apache.tuweni.bytes.Bytes48; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestTemplate; +import tech.pegasys.teku.bls.BLSPublicKey; +import tech.pegasys.teku.ethereum.executionclient.schema.BuilderApiResponse; +import tech.pegasys.teku.infrastructure.json.JsonUtil; +import tech.pegasys.teku.infrastructure.json.types.DeserializableTypeDefinition; +import tech.pegasys.teku.infrastructure.unsigned.UInt64; +import tech.pegasys.teku.spec.Spec; +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.SignedBeaconBlock; +import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; +import tech.pegasys.teku.spec.datastructures.execution.SignedBuilderBidV1; +import tech.pegasys.teku.spec.datastructures.execution.SignedValidatorRegistrationV1; +import tech.pegasys.teku.spec.networks.Eth2Network; +import tech.pegasys.teku.spec.schemas.SchemaDefinitionsBellatrix; + +@TestSpecContext( + milestone = SpecMilestone.BELLATRIX, + network = {Eth2Network.MAINNET}) +class RestExecutionBuilderClientTest { + + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); + + private static final Duration WAIT_FOR_CALL_COMPLETION = Duration.ofSeconds(10); + + private static final String INTERNAL_SERVER_ERROR_MESSAGE = + "{\"code\":500,\"message\":\"Internal server error\"}"; + + private static final String SIGNED_VALIDATOR_REGISTRATION_REQUEST = + readResource("builder/signedValidatorRegistration.json"); + + private static final String SIGNED_BLINDED_BEACON_BLOCK_REQUEST = + readResource("builder/signedBlindedBeaconBlock.json"); + + private static final String EXECUTION_PAYLOAD_HEADER_RESPONSE = + readResource("builder/executionPayloadHeaderResponse.json"); + + private static final String UNBLINDED_EXECUTION_PAYLOAD_RESPONSE = + readResource("builder/unblindedExecutionPayloadResponse.json"); + + private static final UInt64 SLOT = UInt64.ONE; + + private static final Bytes32 PARENT_HASH = + Bytes32.fromHexString("0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2"); + + private static final BLSPublicKey PUB_KEY = + BLSPublicKey.fromBytesCompressed( + Bytes48.fromHexString( + "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a")); + + private final MockWebServer mockWebServer = new MockWebServer(); + private final OkHttpClient okHttpClient = new OkHttpClient.Builder().build(); + + private SchemaDefinitionsBellatrix schemaDefinitionsBellatrix; + + private RestExecutionBuilderClient restExecutionBuilderClient; + + @BeforeEach + void setUp(SpecContext specContext) throws IOException { + mockWebServer.start(); + Spec spec = specContext.getSpec(); + String endpoint = "http://localhost:" + mockWebServer.getPort(); + OkHttpRestClient okHttpRestClient = new OkHttpRestClient(okHttpClient, endpoint); + this.schemaDefinitionsBellatrix = + spec.forMilestone(specContext.getSpecMilestone()) + .getSchemaDefinitions() + .toVersionBellatrix() + .orElseThrow(); + this.restExecutionBuilderClient = new RestExecutionBuilderClient(okHttpRestClient, spec); + } + + @AfterEach + void afterEach() throws Exception { + mockWebServer.shutdown(); + } + + @TestTemplate + void getStatus_success() { + mockWebServer.enqueue(new MockResponse().setResponseCode(200)); + + assertThat(restExecutionBuilderClient.status()) + .succeedsWithin(WAIT_FOR_CALL_COMPLETION) + .satisfies( + response -> { + assertThat(response.isSuccess()).isTrue(); + assertThat(response.getPayload()).isNull(); + }); + + verifyGetRequest("/eth1/v1/builder/status"); + } + + @TestTemplate + void getStatus_failures() { + mockWebServer.enqueue( + new MockResponse().setResponseCode(500).setBody(INTERNAL_SERVER_ERROR_MESSAGE)); + + assertThat(restExecutionBuilderClient.status()) + .succeedsWithin(WAIT_FOR_CALL_COMPLETION) + .satisfies( + response -> { + assertThat(response.isFailure()).isTrue(); + assertThat(response.getErrorMessage()).isEqualTo(INTERNAL_SERVER_ERROR_MESSAGE); + }); + + verifyGetRequest("/eth1/v1/builder/status"); + } + + @TestTemplate + void registerValidator_success() { + + mockWebServer.enqueue(new MockResponse().setResponseCode(200)); + + SignedValidatorRegistrationV1 signedValidatorRegistration = createSignedValidatorRegistration(); + + assertThat(restExecutionBuilderClient.registerValidator(SLOT, signedValidatorRegistration)) + .succeedsWithin(WAIT_FOR_CALL_COMPLETION) + .satisfies( + response -> { + assertThat(response.isSuccess()).isTrue(); + assertThat(response.getPayload()).isNull(); + }); + + verifyPostRequest("/eth/v1/builder/validators", SIGNED_VALIDATOR_REGISTRATION_REQUEST); + } + + @TestTemplate + void registerValidator_failures() { + + String unknownValidatorError = "{\"code\":400,\"message\":\"unknown validator\"}"; + + mockWebServer.enqueue(new MockResponse().setResponseCode(400).setBody(unknownValidatorError)); + + SignedValidatorRegistrationV1 signedValidatorRegistration = createSignedValidatorRegistration(); + + assertThat(restExecutionBuilderClient.registerValidator(SLOT, signedValidatorRegistration)) + .succeedsWithin(WAIT_FOR_CALL_COMPLETION) + .satisfies( + response -> { + assertThat(response.isFailure()).isTrue(); + assertThat(response.getErrorMessage()).isEqualTo(unknownValidatorError); + }); + + verifyPostRequest("/eth/v1/builder/validators", SIGNED_VALIDATOR_REGISTRATION_REQUEST); + + mockWebServer.enqueue( + new MockResponse().setResponseCode(500).setBody(INTERNAL_SERVER_ERROR_MESSAGE)); + + assertThat(restExecutionBuilderClient.registerValidator(SLOT, signedValidatorRegistration)) + .succeedsWithin(WAIT_FOR_CALL_COMPLETION) + .satisfies( + response -> { + assertThat(response.isFailure()).isTrue(); + assertThat(response.getErrorMessage()).isEqualTo(INTERNAL_SERVER_ERROR_MESSAGE); + }); + + verifyPostRequest("/eth/v1/builder/validators", SIGNED_VALIDATOR_REGISTRATION_REQUEST); + } + + @TestTemplate + void getExecutionPayloadHeader_success() { + + mockWebServer.enqueue( + new MockResponse().setResponseCode(200).setBody(EXECUTION_PAYLOAD_HEADER_RESPONSE)); + + assertThat(restExecutionBuilderClient.getHeader(SLOT, PUB_KEY, PARENT_HASH)) + .succeedsWithin(WAIT_FOR_CALL_COMPLETION) + .satisfies( + response -> { + assertThat(response.isSuccess()).isTrue(); + SignedBuilderBidV1 responsePayload = response.getPayload(); + verifySignedBuilderBidV1Response(responsePayload); + }); + + verifyGetRequest("/eth/v1/builder/header/1/" + PARENT_HASH + "/" + PUB_KEY); + } + + @TestTemplate + void getExecutionPayloadHeader_failures() { + + String missingParentHashError = + "{\"code\":400,\"message\":\"Unknown hash: missing parent hash\"}"; + mockWebServer.enqueue(new MockResponse().setResponseCode(400).setBody(missingParentHashError)); + + assertThat(restExecutionBuilderClient.getHeader(SLOT, PUB_KEY, PARENT_HASH)) + .succeedsWithin(WAIT_FOR_CALL_COMPLETION) + .satisfies( + response -> { + assertThat(response.isFailure()).isTrue(); + assertThat(response.getErrorMessage()).isEqualTo(missingParentHashError); + }); + + verifyGetRequest("/eth/v1/builder/header/1/" + PARENT_HASH + "/" + PUB_KEY); + + mockWebServer.enqueue( + new MockResponse().setResponseCode(500).setBody(INTERNAL_SERVER_ERROR_MESSAGE)); + + assertThat(restExecutionBuilderClient.getHeader(SLOT, PUB_KEY, PARENT_HASH)) + .succeedsWithin(WAIT_FOR_CALL_COMPLETION) + .satisfies( + response -> { + assertThat(response.isFailure()).isTrue(); + assertThat(response.getErrorMessage()).isEqualTo(INTERNAL_SERVER_ERROR_MESSAGE); + }); + + verifyGetRequest("/eth/v1/builder/header/1/" + PARENT_HASH + "/" + PUB_KEY); + } + + @TestTemplate + void sendSignedBlindedBlock_success() { + + mockWebServer.enqueue( + new MockResponse().setResponseCode(200).setBody(UNBLINDED_EXECUTION_PAYLOAD_RESPONSE)); + + SignedBeaconBlock signedBlindedBeaconBlock = createSignedBlindedBeaconBlock(); + + assertThat(restExecutionBuilderClient.getPayload(signedBlindedBeaconBlock)) + .succeedsWithin(WAIT_FOR_CALL_COMPLETION) + .satisfies( + response -> { + assertThat(response.isSuccess()).isTrue(); + ExecutionPayload responsePayload = response.getPayload(); + verifyExecutionPayloadResponse(responsePayload); + }); + + verifyPostRequest("/eth/v1/builder/blinded_blocks", SIGNED_BLINDED_BEACON_BLOCK_REQUEST); + } + + @TestTemplate + void sendSignedBlindedBlock_failures() { + + String missingSignatureError = + "{\"code\":400,\"message\":\"Invalid block: missing signature\"}"; + mockWebServer.enqueue(new MockResponse().setResponseCode(400).setBody(missingSignatureError)); + + SignedBeaconBlock signedBlindedBeaconBlock = createSignedBlindedBeaconBlock(); + + assertThat(restExecutionBuilderClient.getPayload(signedBlindedBeaconBlock)) + .succeedsWithin(WAIT_FOR_CALL_COMPLETION) + .satisfies( + response -> { + assertThat(response.isFailure()).isTrue(); + assertThat(response.getErrorMessage()).isEqualTo(missingSignatureError); + }); + + verifyPostRequest("/eth/v1/builder/blinded_blocks", SIGNED_BLINDED_BEACON_BLOCK_REQUEST); + + mockWebServer.enqueue( + new MockResponse().setResponseCode(500).setBody(INTERNAL_SERVER_ERROR_MESSAGE)); + + assertThat(restExecutionBuilderClient.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", SIGNED_BLINDED_BEACON_BLOCK_REQUEST); + } + + private void verifyGetRequest(String apiPath) { + verifyRequest("GET", apiPath, Optional.empty()); + } + + private void verifyPostRequest(String apiPath, String requestBody) { + verifyRequest("POST", apiPath, Optional.of(requestBody)); + } + + private void verifyRequest( + String method, String apiPath, Optional expectedRequestBody) { + try { + RecordedRequest request = mockWebServer.takeRequest(); + assertThat(request.getMethod()).isEqualTo(method); + assertThat(request.getPath()).isEqualTo(apiPath); + Buffer actualRequestBody = request.getBody(); + if (expectedRequestBody.isEmpty()) { + assertThat(actualRequestBody.size()).isZero(); + } else { + assertThat(actualRequestBody.size()).isNotZero(); + assertThat(OBJECT_MAPPER.readTree(expectedRequestBody.get())) + .isEqualTo(OBJECT_MAPPER.readTree(actualRequestBody.readUtf8())); + } + } catch (InterruptedException | JsonProcessingException ex) { + Assertions.fail(ex); + } + } + + private SignedValidatorRegistrationV1 createSignedValidatorRegistration() { + try { + return JsonUtil.parse( + SIGNED_VALIDATOR_REGISTRATION_REQUEST, + schemaDefinitionsBellatrix + .getSignedValidatorRegistrationSchema() + .getJsonTypeDefinition()); + } catch (JsonProcessingException ex) { + throw new UncheckedIOException(ex); + } + } + + private void verifySignedBuilderBidV1Response(SignedBuilderBidV1 actual) { + DeserializableTypeDefinition> responseTypeDefinition = + BuilderApiResponse.createTypeDefinition( + schemaDefinitionsBellatrix.getSignedBuilderBidV1Schema().getJsonTypeDefinition()); + try { + SignedBuilderBidV1 expected = + JsonUtil.parse(EXECUTION_PAYLOAD_HEADER_RESPONSE, responseTypeDefinition).getData(); + assertThat(actual).isEqualTo(expected); + } catch (JsonProcessingException ex) { + Assertions.fail(ex); + } + } + + private SignedBeaconBlock createSignedBlindedBeaconBlock() { + try { + return JsonUtil.parse( + SIGNED_BLINDED_BEACON_BLOCK_REQUEST, + schemaDefinitionsBellatrix.getSignedBlindedBeaconBlockSchema().getJsonTypeDefinition()); + } catch (JsonProcessingException ex) { + throw new UncheckedIOException(ex); + } + } + + private void verifyExecutionPayloadResponse(ExecutionPayload actual) { + DeserializableTypeDefinition> responseTypeDefinition = + BuilderApiResponse.createTypeDefinition( + schemaDefinitionsBellatrix.getExecutionPayloadSchema().getJsonTypeDefinition()); + try { + ExecutionPayload expected = + JsonUtil.parse(UNBLINDED_EXECUTION_PAYLOAD_RESPONSE, responseTypeDefinition).getData(); + assertThat(actual).isEqualTo(expected); + } catch (JsonProcessingException ex) { + Assertions.fail(ex); + } + } + + private static String readResource(String resource) { + try { + return Resources.toString(Resources.getResource(resource), StandardCharsets.UTF_8); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } +} diff --git a/ethereum/executionclient/src/integration-test/java/tech/pegasys/teku/ethereum/executionclient/web3j/Web3JExecutionBuilderClientTest.java b/ethereum/executionclient/src/integration-test/java/tech/pegasys/teku/ethereum/executionclient/web3j/Web3JExecutionBuilderClientTest.java deleted file mode 100644 index 40800ed0b59..00000000000 --- a/ethereum/executionclient/src/integration-test/java/tech/pegasys/teku/ethereum/executionclient/web3j/Web3JExecutionBuilderClientTest.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright 2022 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.web3j; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.InstanceOfAssertFactories.INTEGER; -import static org.assertj.core.api.InstanceOfAssertFactories.STRING; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.io.Resources; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.time.Duration; -import java.util.Optional; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okhttp3.mockwebserver.RecordedRequest; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.bytes.Bytes48; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.TestTemplate; -import tech.pegasys.teku.bls.BLSPublicKey; -import tech.pegasys.teku.ethereum.executionclient.schema.BlindedBeaconBlockV1; -import tech.pegasys.teku.ethereum.executionclient.schema.BuilderBidV1; -import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadV1; -import tech.pegasys.teku.ethereum.executionclient.schema.Response; -import tech.pegasys.teku.ethereum.executionclient.schema.SignedMessage; -import tech.pegasys.teku.infrastructure.async.SafeFuture; -import tech.pegasys.teku.infrastructure.time.StubTimeProvider; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.spec.SpecMilestone; -import tech.pegasys.teku.spec.TestSpecContext; -import tech.pegasys.teku.spec.TestSpecInvocationContextProvider.SpecContext; -import tech.pegasys.teku.spec.util.DataStructureUtil; - -@TestSpecContext(milestone = SpecMilestone.BELLATRIX) -public class Web3JExecutionBuilderClientTest { - private static final Duration DEFAULT_TIMEOUT = Duration.ofMinutes(1); - private final MockWebServer mockWebServer = new MockWebServer(); - private final StubTimeProvider timeProvider = StubTimeProvider.withTimeInSeconds(0); - - ObjectMapper objectMapper; - DataStructureUtil dataStructureUtil; - - Web3JExecutionBuilderClient ebClient; - - @BeforeEach - void setUp(SpecContext specContext) throws IOException { - objectMapper = new ObjectMapper(); - dataStructureUtil = specContext.getDataStructureUtil(); - mockWebServer.start(); - Web3jClientBuilder web3JClientBuilder = new Web3jClientBuilder(); - Web3JClient web3JClient = - web3JClientBuilder - .endpoint("http://localhost:" + mockWebServer.getPort()) - .timeout(DEFAULT_TIMEOUT) - .jwtConfigOpt(Optional.empty()) - .timeProvider(timeProvider) - .build(); - ebClient = new Web3JExecutionBuilderClient(web3JClient); - } - - @AfterEach - public void afterEach() throws Exception { - mockWebServer.shutdown(); - } - - @TestTemplate - void getPayload_shouldRoundtripWithMockedWebServer() throws Exception { - final String jsonGetPayloadResponse = - Resources.toString( - Resources.getResource("builder_getPayloadResponse.json"), StandardCharsets.UTF_8); - - final String bodyResponse = - "{\"jsonrpc\": \"2.0\", \"id\": 0, \"result\":" + jsonGetPayloadResponse + "}"; - - final ExecutionPayloadV1 executionPayloadResponse = - objectMapper.readValue(jsonGetPayloadResponse, ExecutionPayloadV1.class); - - // double-check that what we are going to respond corresponds to the json data - final String serializedExecutionPayloadResponse = - objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(executionPayloadResponse); - assertThat(serializedExecutionPayloadResponse) - .isEqualToIgnoringNewLines(jsonGetPayloadResponse); - - mockWebServer.enqueue( - new MockResponse() - .setBody(bodyResponse) - .setResponseCode(200) - .addHeader("Content-Type", "application/json")); - - final String jsonGetPayloadRequest = - Resources.toString( - Resources.getResource("builder_getPayloadRequest.json"), StandardCharsets.UTF_8); - - final SignedMessage signedBlindedBeaconBlockRequest = - objectMapper.readValue(jsonGetPayloadRequest, new TypeReference<>() {}); - - SafeFuture> futureResponseProposeBlindedBlock = - ebClient.getPayload(signedBlindedBeaconBlockRequest); - - final RecordedRequest request = mockWebServer.takeRequest(); - - final JsonNode requestBodyJsonNode = - objectMapper.readTree(request.getBody().readString(StandardCharsets.UTF_8)); - - // check that sent blinded block match as per sent object as well as received object from the - // mock - final String serializedSignedBlindedBeaconBlockRequest = - objectMapper - .writerWithDefaultPrettyPrinter() - .writeValueAsString(signedBlindedBeaconBlockRequest); - assertThat(serializedSignedBlindedBeaconBlockRequest) - .isEqualToIgnoringNewLines(jsonGetPayloadRequest); - assertThat(serializedSignedBlindedBeaconBlockRequest) - .isEqualTo(requestBodyJsonNode.get("params").get(0).toPrettyString()); - - verifyJsonRpcMethodCall(requestBodyJsonNode, "builder_getPayloadV1"); - - assertThat(futureResponseProposeBlindedBlock.join()) - .matches( - executionPayloadV1Response1 -> - executionPayloadV1Response1.getPayload().equals(executionPayloadResponse)); - } - - @TestTemplate - void getHeader_shouldRoundtripWithMockedWebServer() throws Exception { - final String jsonSignedBuilderBidResponse = - Resources.toString( - Resources.getResource("builder_getHeaderResponse.json"), StandardCharsets.UTF_8); - - final String bodyResponse = - "{\"jsonrpc\": \"2.0\", \"id\": 0, \"result\":" + jsonSignedBuilderBidResponse + "}"; - - final SignedMessage signedBuilderBidV1 = - objectMapper.readValue(jsonSignedBuilderBidResponse, new TypeReference<>() {}); - - // double-check that what we are going to respond corresponds to the json data - final String serializedSignedBuilderBidResponse = - objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(signedBuilderBidV1); - assertThat(serializedSignedBuilderBidResponse) - .isEqualToIgnoringNewLines(jsonSignedBuilderBidResponse); - - mockWebServer.enqueue( - new MockResponse() - .setBody(bodyResponse) - .setResponseCode(200) - .addHeader("Content-Type", "application/json")); - - final UInt64 slotRequest = dataStructureUtil.randomUInt64(); - final BLSPublicKey pubKeyRequest = dataStructureUtil.randomPublicKey(); - final Bytes32 parentHashRequest = dataStructureUtil.randomBytes32(); - - SafeFuture>> futureResponseExecutionHeader = - ebClient.getHeader(slotRequest, pubKeyRequest, parentHashRequest); - - final RecordedRequest request = mockWebServer.takeRequest(); - - final JsonNode requestBodyJsonNode = - objectMapper.readTree(request.getBody().readString(StandardCharsets.UTF_8)); - - final String slot = requestBodyJsonNode.get("params").get(0).asText(); - final String pubKey = requestBodyJsonNode.get("params").get(1).asText(); - final String parentHash = requestBodyJsonNode.get("params").get(2).asText(); - - verifyJsonRpcMethodCall(requestBodyJsonNode, "builder_getHeaderV1"); - - assertThat(slotRequest).isEqualTo(UInt64.valueOf(slot)); - assertThat(pubKeyRequest) - .isEqualTo(BLSPublicKey.fromBytesCompressed(Bytes48.fromHexString(pubKey))); - assertThat(parentHashRequest).isEqualTo(Bytes32.fromHexString(parentHash)); - - assertThat(futureResponseExecutionHeader.join()) - .matches( - signedBuilderBidV1Response -> - signedBuilderBidV1Response.getPayload().equals(signedBuilderBidV1)); - } - - private void verifyJsonRpcMethodCall(final JsonNode requestBodyJsonNode, final String method) { - assertThat(requestBodyJsonNode.get("method").asText()).asInstanceOf(STRING).isEqualTo(method); - assertThat(requestBodyJsonNode.get("id").asInt()) - .asInstanceOf(INTEGER) - .isGreaterThanOrEqualTo(0); - assertThat(requestBodyJsonNode.get("jsonrpc").asText()).asInstanceOf(STRING).isEqualTo("2.0"); - } -} diff --git a/ethereum/executionclient/src/integration-test/resources/builder/executionPayloadHeaderResponse.json b/ethereum/executionclient/src/integration-test/resources/builder/executionPayloadHeaderResponse.json new file mode 100644 index 00000000000..b6bd1d8e189 --- /dev/null +++ b/ethereum/executionclient/src/integration-test/resources/builder/executionPayloadHeaderResponse.json @@ -0,0 +1,26 @@ +{ + "version": "bellatrix", + "data": { + "message": { + "header": { + "parent_hash": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "fee_recipient": "0xabcf8e0d4e9587369b2301d0790347320302cc09", + "state_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "receipts_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "logs_bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "prev_randao": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "block_number": "1", + "gas_limit": "1", + "gas_used": "1", + "timestamp": "1", + "extra_data": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "base_fee_per_gas": "1", + "block_hash": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "transactions_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2" + }, + "value": "1", + "pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a" + }, + "signature": "0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505" + } +} \ No newline at end of file diff --git a/ethereum/executionclient/src/integration-test/resources/builder/signedBlindedBeaconBlock.json b/ethereum/executionclient/src/integration-test/resources/builder/signedBlindedBeaconBlock.json new file mode 100644 index 00000000000..80678c8d73d --- /dev/null +++ b/ethereum/executionclient/src/integration-test/resources/builder/signedBlindedBeaconBlock.json @@ -0,0 +1,177 @@ +{ + "message": { + "slot": "1", + "proposer_index": "1", + "parent_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "state_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "body": { + "randao_reveal": "0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505", + "eth1_data": { + "deposit_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "deposit_count": "1", + "block_hash": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2" + }, + "graffiti": "0x00000000000000000000000000000000000000000000000000deadbeefc0ffee", + "proposer_slashings": [ + { + "signed_header_1": { + "message": { + "slot": "1", + "proposer_index": "1", + "parent_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "state_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "body_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2" + }, + "signature": "0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505" + }, + "signed_header_2": { + "message": { + "slot": "1", + "proposer_index": "1", + "parent_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "state_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "body_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2" + }, + "signature": "0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505" + } + } + ], + "attester_slashings": [ + { + "attestation_1": { + "attesting_indices": [ + "1" + ], + "data": { + "slot": "1", + "index": "1", + "beacon_block_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "source": { + "epoch": "1", + "root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2" + }, + "target": { + "epoch": "1", + "root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2" + } + }, + "signature": "0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505" + }, + "attestation_2": { + "attesting_indices": [ + "1" + ], + "data": { + "slot": "1", + "index": "1", + "beacon_block_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "source": { + "epoch": "1", + "root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2" + }, + "target": { + "epoch": "1", + "root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2" + } + }, + "signature": "0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505" + } + } + ], + "attestations": [ + { + "aggregation_bits": "0x01", + "data": { + "slot": "1", + "index": "1", + "beacon_block_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "source": { + "epoch": "1", + "root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2" + }, + "target": { + "epoch": "1", + "root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2" + } + }, + "signature": "0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505" + } + ], + "deposits": [ + { + "proof": [ + "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ], + "data": { + "pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a", + "withdrawal_credentials": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "amount": "1", + "signature": "0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505" + } + } + ], + "voluntary_exits": [ + { + "message": { + "epoch": "1", + "validator_index": "1" + }, + "signature": "0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505" + } + ], + "sync_aggregate": { + "sync_committee_bits": "0x145d5c188ceac5989ccd022005035da255b149a1f4bfe2a1d4ff074188777c7db6f13f4a2fb490a312df10b5bb11e2ba2ddd66c2b3ada8b4dbd4c456a9f17ac7", + "sync_committee_signature": "0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505" + }, + "execution_payload_header": { + "parent_hash": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "fee_recipient": "0xabcf8e0d4e9587369b2301d0790347320302cc09", + "state_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "receipts_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "logs_bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "prev_randao": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "block_number": "1", + "gas_limit": "1", + "gas_used": "1", + "timestamp": "1", + "extra_data": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "base_fee_per_gas": "1", + "block_hash": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "transactions_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2" + } + } + }, + "signature": "0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505" +} \ No newline at end of file diff --git a/ethereum/executionclient/src/integration-test/resources/builder/signedValidatorRegistration.json b/ethereum/executionclient/src/integration-test/resources/builder/signedValidatorRegistration.json new file mode 100644 index 00000000000..e1ec5e406f3 --- /dev/null +++ b/ethereum/executionclient/src/integration-test/resources/builder/signedValidatorRegistration.json @@ -0,0 +1,9 @@ +{ + "message": { + "fee_recipient": "0xabcf8e0d4e9587369b2301d0790347320302cc09", + "gas_limit": "1", + "timestamp": "1", + "pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a" + }, + "signature": "0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505" +} \ No newline at end of file diff --git a/ethereum/executionclient/src/integration-test/resources/builder/unblindedExecutionPayloadResponse.json b/ethereum/executionclient/src/integration-test/resources/builder/unblindedExecutionPayloadResponse.json new file mode 100644 index 00000000000..3d7d262c5f7 --- /dev/null +++ b/ethereum/executionclient/src/integration-test/resources/builder/unblindedExecutionPayloadResponse.json @@ -0,0 +1,21 @@ +{ + "version": "bellatrix", + "data": { + "parent_hash": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "fee_recipient": "0xabcf8e0d4e9587369b2301d0790347320302cc09", + "state_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "receipts_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "logs_bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "prev_randao": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "block_number": "1", + "gas_limit": "1", + "gas_used": "1", + "timestamp": "1", + "extra_data": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "base_fee_per_gas": "1", + "block_hash": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", + "transactions": [ + "0x02f878831469668303f51d843b9ac9f9843b9aca0082520894c93269b73096998db66be0441e836d873535cb9c8894a19041886f000080c001a031cc29234036afbf9a1fb9476b463367cb1f957ac0b919b69bbc798436e604aaa018c4e9c3914eb27aadd0b91e10b18655739fcf8c1fc398763a9f1beecb8ddc86" + ] + } +} \ No newline at end of file diff --git a/ethereum/executionclient/src/integration-test/resources/builder_getHeaderResponse.json b/ethereum/executionclient/src/integration-test/resources/builder_getHeaderResponse.json deleted file mode 100644 index 75eac30ee8a..00000000000 --- a/ethereum/executionclient/src/integration-test/resources/builder_getHeaderResponse.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "message" : { - "header" : { - "parentHash" : "0x235bc3400c2839fd856a524871200bd5e362db615fc4565e1870ed9a2a936464", - "feeRecipient" : "0x367cbd40ac7318427aadb97345a91fa2e965daf3", - "stateRoot" : "0xfd18cf40cc907a739be483f1ca0ee23ad65cdd3df23205eabc6d660a75d1f54e", - "receiptsRoot" : "0x103ac9406cdc59b89027eb1c9e97f607dd5fdccfa8fb2da4eaeea9d25032add9", - "logsBloom" : "0x6fdfab408c56b6105a76eff5c0435d09fc6ed7a938e7f946cf74fbbb9416428f619b26eab6d66297cbd9dbc84db437c8d36f9b30556f5f8062bbc80a0e3f35fb2f4921ae3f8361dacf697513c2f8aac786dccb24a7ca3eef9743ab9071ee3663dca121493e717c27ee277bf5d484a83c2da75b4bea86c1d15a2b29352abad715b00fa1c4b94733e496720ced4c31ce785ec3e407136f39dcb857d7d9ff590deeb512704b2f0a58ee953d5a85894a9e9ab9528d1fc87daf2064b515ee861e4dd23bb5714c0fb38a36a1da1698fbee3aae5de1b51de39f6e3d3309e338abb70e275410a1b83e9e9d43d051e6a4a9bdbe6d6fb282c4f2463428a0502a0e2e4b71fb", - "prevRandao" : "0x8200a6402ca295554fb9562193cc71d60272d63beeaf2201fdf53e846e77f919", - "blockNumber" : "0x40b79d4886f7bf4c", - "gasLimit" : "0x40b1be5bcbd70aec", - "gasUsed" : "0x3fd8861ec01cf90b", - "timestamp" : "0x3fd2a73204fc44aa", - "extraData" : "0x0c65de3f6bad3d", - "baseFeePerGas" : "0x6b0ac13f8a279ad3abec11bed1a49214f6e7af79b643595df6a38706b338e93b", - "blockHash" : "0x7e2bbb3f2a737918a12f79e9a52da7e1fceaae0b6c0c82172425cbce8d99a0c6", - "transactionsRoot" : "0x9e2bbb3f2a737918a12f79e9a52da7e1fceaae0b6c0c82172425cbce8d99a0c6" - }, - "value" : "0x1020333333220000", - "pubkey" : "0xb0861f72583516b17a3fdc33419d5c04c0a4444cc2478136b4935f3148797699e3ef4a4b2227b14876b3d49ff03b796d" - }, - "signature" : "0xddc1ca509e29c6452441069f26da6e073589b3bd1cace50e3427426af5bfdd566d077d4bdf618e249061b9770471e3d515779aa758b8ccb4b06226a8d5ebc99e19d4c3278e5006b837985bec4e0ce39df92c1f88d1afd0f98dbae360024a390d" -} \ No newline at end of file diff --git a/ethereum/executionclient/src/integration-test/resources/builder_getPayloadRequest.json b/ethereum/executionclient/src/integration-test/resources/builder_getPayloadRequest.json deleted file mode 100644 index b3246f86665..00000000000 --- a/ethereum/executionclient/src/integration-test/resources/builder_getPayloadRequest.json +++ /dev/null @@ -1,161 +0,0 @@ -{ - "message" : { - "slot" : "0x40c35b22fd39280c", - "proposerIndex" : "0x40bd7c36421873ac", - "parentRoot" : "0xfd18cf40cc907a739be483f1ca0ee23ad65cdd3df23205eabc6d660a75d1f54e", - "stateRoot" : "0x103ac9406cdc59b89027eb1c9e97f607dd5fdccfa8fb2da4eaeea9d25032add9", - "body" : { - "randaoReveal" : "0x983e008a34dda42f0c8f857f66aa82212aff48250f9ac54b30ae622d0835bdb7609c9cac67e7d19be24ffe5c77d581230e25c0e72fdf4066618bb0df7e09e66562de35b1f751004ad1ec65089c19a56a8b120983c301dbbf03df5ba674712ab4", - "eth1Data" : { - "depositRoot" : "0x8200a6402ca295554fb9562193cc71d60272d63beeaf2201fdf53e846e77f919", - "depositCount" : "0x40b79d4886f7bf4c", - "blockHash" : "0x5cbeb140ec0ad7cb653388caecba483cf66bd817821ed18ca1f3b7f3b9b58a04" - }, - "graffiti" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "proposerSlashings" : [ { - "signedHeader1" : { - "message" : { - "slot" : "0x3fd8861ec01cf90b", - "proposerIndex" : "0x3fd2a73204fc44aa", - "parentRoot" : "0xf943e43fcb615e36ec5aa6b9db6f1746d0d5b50d708f6400e39cf25495f39cfb", - "stateRoot" : "0x0c65de3f6bad3d7be19d0de5aff82b13d6d8b49f26588dba111e361d6f545486", - "bodyRoot" : "0x6b0ac13f8a279ad3abec11bed1a49214f6e7af79b643595df6a38706b338e93b" - }, - "signature" : "0x860cc33a81805835339f1598b95691556b6f4fc5ee6a25bb24d70c658dc69d3d2e5cd62a22e14e7d962a4095e0d93ea41240a49151f9bb2884bdd1cdefcff246969101fe377460d78d58ea47c2f270e9cc8ce4bc4e81e43314bda61076350d4d" - }, - "signedHeader2" : { - "message" : { - "slot" : "0x3fd8861ec01cf90b", - "proposerIndex" : "0x3fd2a73204fc44aa", - "parentRoot" : "0x45c8cc3f4a90db49c16643672a93697ae9e1b15549b207e99aa10076fe767a26", - "stateRoot" : "0x58e9c63feadbba8eb6a9aa92fd1b7e47efe4b0e7ff7a30a3c822443ed8d731b1", - "bodyRoot" : "0xb88ea93f0a5617e780f8ae6b1fc8e4480ff4abc18f66fc45ada895271cbcc666" - }, - "signature" : "0xb8f4f7eb7f1ff3eb3923e6bf36b3a0865c80f47fb8e5dbe8830751f66bd8a06a3a1e06b7b2dec66556b532721018ce940c982953c8c6176125c7dd2ba1e8cb944e10e4a14905f7135a477810872518cbac085dfc69c1759d64dab5e225a5f16c" - } - } ], - "attesterSlashings" : [ { - "attestation1" : { - "attestingIndices" : [ "0x3fb54c925d58beca", "0x3faf6da4a2380a6a", "0x3f921303fa94848a" ], - "data" : { - "slot" : "0x3f8c34173f73d02a", - "index" : "0x3f9dd0de70d5ed4a", - "beaconBlockRoot" : "0xf1f1973fea38b5b560c1e4ed9a6222b021fda877b2c07674362c6080acdeec06", - "source" : { - "epoch" : "0x201b3a76", - "root" : "0x00963040ab8a07b778f467851c7d0cdc7faec2a32d5e528c900d85297e084df0" - }, - "target" : { - "epoch" : "0x20211963", - "root" : "0xda533c406bf3482d8e6e992e756be34172a8c47fc1cc0018350bfe98c946deda" - } - }, - "signature" : "0x8bfc6e1a1c76bdafb4d491ce02a35effde6d7362eb32c03f119c47c12fb2b49e7656bbd4702ba02560fd7fe117f2c74e02142ce46176ebf269d5b34a48a65525e35db6cc446965e86e22e9d8adf5abe92315690b6de5f4591769487539fed52a" - }, - "attestation2" : { - "attestingIndices" : [ "0x3fb54c925d58beca", "0x3faf6da4a2380a6a", "0x3f921303fa94848a" ], - "data" : { - "slot" : "0x40191a4cca84b92b", - "index" : "0x402ab713fbe6d64b", - "beaconBlockRoot" : "0x27d82440eb21c640637a36dcc38e35768bb4c0c79aefa300ec0f0cba32cabb05", - "source" : { - "epoch" : "0x2003bec3", - "root" : "0x999e0140abe701de220ca2e0b9c3b044b1c6ba33e0a3985dfe16a16b510f0846" - }, - "target" : { - "epoch" : "0x20099db0", - "root" : "0x735c0d406b5043543786d38912b287aaa4c0bc0f731247e9a3141adb9c4d9930" - } - }, - "signature" : "0xb2213ef588828a7c18cdc781d0ed2516fd3e11de625f191aae7ae4be8b1ad2cc217728c65a500aedea276d345f09fd3212b009568a6549f5f40ead6d7ec4d0f3f329c00a1b4bca59068ee0555c94aec91bebc18365ca0b2d6692557b4b0c4267" - } - } ], - "attestations" : [ { - "aggregationBits" : "0x46e4e5ccf2f1f586175a551fbef71fe367c10ae7f627b52680c69658efc3b9da2f03cedf49e4513374e10642a1ed264963dc671c03d571d45f02ec63fba7c7cb5897c09c76e4c5236f21c008302634d96493aae59b7960506c097817d713613d4b3e735f49272d0db6c25864be1413035ae25485ce5cb268bd0ec7a76871cc5cc0b3a892d31613f8f58fbcc1c4848be416ec389ac6b0c1e25ee635a1da4e2aeb872b99856e51958cbf99b64db166c7de9cc849fc9ca7e56dda4a7b586db617c6c55fcd252d40b15b9fbdd843a50d56cbd65f7ecffef1b632b74275254a3ee3487a305314041fa888fb642ab9d17e38e5eb338144f383c4ef9cd53141a6c9153001", - "data" : { - "slot" : "0x3ffbbfac22e1334b", - "index" : "0x3ff5e0bf67c07eeb", - "beaconBlockRoot" : "0x82a81c3f096d065c7e3f5d7df79bd182a53c9471a737cfb9f7c4e9ed95d0f767", - "source" : { - "epoch" : "0x1f8b64ca", - "root" : "0x5c66283fc9d547d293b98e264f8aa8e89836964d3ba67d459cc2625de10e8952" - }, - "target" : { - "epoch" : "0x1f9143b7", - "root" : "0xcf2c053f899b836f534bfa2a45bf23b7be4890b9815a72a2aec9f70eff53d592" - } - }, - "signature" : "0x90b1100958899f808951acd4cc1d72be010f4b43fdf69587719b141b72d8410d144cac042cec8515ea74c9cbe5150c7e10b02be9ddd07421143b08f67c911f57c4a1544bc7f6a984df017e189f72aff167227b4238b50340311483aa9c843d43" - }, { - "aggregationBits" : "0x16ffdcef1985b63b0b86daf194945f6e5c79ff31d7f9e08dee15b8fc65e74f6026349b4d5581aed81b7b945f0311e8318ae875d01c887e25386494a4151a7674dc0d279e3a2e2cb766fab0b30149410e81047bf6716e4627426e31ffa8ee22ca74c2a8db72cc801a5e912011916389fe12b8a5aee2441475ce7eb8efed2750b3d42fa1c1160c759ef11a6c999dd4bbc975a5b74a5f235cb575ef86c17418c6573d2699ff130df86057d200f042949e6997925f96fd595654ade0dec66e5b0834fdfd10f4860899ee48b80944cc981f4558aad23743e7b51e9ba22d445a5dc3601569e23e0c2c50ee21f954b0d903c7f8455cc4c66334ffec5d2095a4177766bc01", - "data" : { - "slot" : "0x3f0b0bbb2aa44fe9", - "index" : "0x3eedb11a8300ca09", - "beaconBlockRoot" : "0x2ed2e73ea915e0c71d9afe03676b8ab8dd578b9311463e45934f49f843386a48", - "source" : { - "epoch" : "0x1f7cb77a", - "root" : "0x0890f33e697e213e331430adc059611ed0518d6fa4b4ecd0384dc2678e76fb32" - }, - "target" : { - "epoch" : "0x1f6b1ab3", - "root" : "0x7a56d03e29445ddbf2a59bb1b68edcecf66387dbea68e12d4a545719acbb4773" - } - }, - "signature" : "0x8b88a54eb155233ec6d52f2e549cacd5d9bc79e05bf0915d9278a94c9a3c75e0d75167129d10e728550df65875ecef551085599499b226b88d238a71dfdd199be5de9fde058fbaf60cf7765b0e614d3bfa76c1c47281283d7bb2ff9a30247fc5" - }, { - "aggregationBits" : "0x703ed6e365b5bf731c1f0eb420574e1c82eec772e63229764db7d26d22edd399ebcb9efabf0ffa4739ccd17c80383fbabe45ac79e3bc7343b3d58f63c2e2f60081accefcaf44c38b4166828de77250e91c3277d8659a794cc12fa329122c631c97ca0c49886e0fd2fd661d945dd464b0ef56e83e286cf1a06feaa1ee634f5ff320b2a107ead7e4831d52e9c165b43807060efe5b45a5ed8876bd2b00959c83f37ac0f1d7ecfa7db13dca97b2dc84df4e7346f45d464d7fc8e2b9fa74af320b9d50be3887bb9a4e07a46ee9a32c8d713f85768f525671e924a66020227fbf2fb6de5bcfc9596c1153fe20674dbfd85cdd63a3e73af76327fa8e537ea3019c583601", - "data" : { - "slot" : "0x3f7a97510e11b30a", - "index" : "0x3f74b86452f0feaa", - "beaconBlockRoot" : "0x2a55863fca1b5384408a1a7015fd5f173406a62dd51af1a2c0af2ad93b0113a7", - "source" : { - "epoch" : "0x1fc03b1e", - "root" : "0x9d1b633f8ae18e21ff1b86740b32dbe55a18a0991bcfe5ffd2b6bf8a59465fe7" - }, - "target" : { - "epoch" : "0x1fae9e58", - "root" : "0x77d96e3f4a4ad0971596b71d6420b24b4d12a275af3d948b77b438faa484f0d1" - } - }, - "signature" : "0x8c2c3b368bc00b3853e6df352e816dd910016db953ac77cc1565e3c22f1c0b24c59f24ea9e8ca406aa95b23368d163e80baa6de3f8f7ac19ee78c976d2ae5a21c86fa1762cc959bc734379055cb7aa1de36eae00541936b8c2ee908c770d41ff" - } ], - "deposits" : [ { - "proof" : [ "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12", "0xe99f4b3f0a100c35d42723225a552d1a73249ce1f5f188e889bbcdabc2c93c12" ], - "data" : { - "pubkey" : "0x8394a37cbc9eeea84b75c9f76a70ff76ace5592592024093f471cb0bcc656d1b8ff2f483bce58db6162f8e7c961c5b41", - "withdrawalCredentials" : "0xc35d573fca784dabeaa154cbb2430480661e9ebd886037742eb9461b0e08cefc", - "amount" : "0x773594000", - "signature" : "0xa12ef7e492b6761e5e3db657c6dbfc9221d4407013c7bded7b2c08cc01bc410f9a56a6954002755a97a4e67f60868b751443d66a10e7773ce4d841b90e0ea1972cd25fbb79cd0d452ccf4cd8474f7632d06f70c8b9cdee109e0210ff0618d517" - } - } ], - "voluntaryExits" : [ { - "message" : { - "epoch" : "0x3f34243648893e89", - "validatorIndex" : "0x3f517ed5f02cc46a" - }, - "signature" : "0x8077d47ad0fe431af45ca6ed24efda0fa9c84364ee8af5f9e83f53b3e5934961197cb31b062dcc3d5dc793ec6de565960924b65d0535f3833ecc51567572959e2849e470be8b6a1f21e2c735552595e9765e66a599d645d33fa3746d409fa122" - } ], - "syncAggregate" : { - "syncCommitteeBits" : "0x01000000", - "syncCommitteeSignature" : "0xaacffaf60c8253477ecad70de8589f2ef7670d0b0dc446d4baac3b465a901d3e64bb6d2c3d8bdb58aed45ac30466261416d152d5ae242204201bf6decfddde697ae0c5d44cf31ca3d43aa18f2799461fc1ee14dbf905b1e31f242fd31c083c5a" - }, - "executionPayloadHeader" : { - "parentHash" : "0xf8eb5a3ea82ccf3c1be1ac153e3f77f273a07343291711b9de6b9dbebc4c9b49", - "feeRecipient" : "0xbf886c3ec849316e3b187793c3a4398b6097768d", - "stateRoot" : "0xd2a9663e689510b3305bdebe972d4e58669a751fbc85bf448269162e078b2c34", - "receiptsRoot" : "0x324f493e880f6d0bfaa9e297b9d9b45986a970f94c718be767ef67174b6fc1e9", - "logsBloom" : "0x4570433e285b4c50f0ec49c38d62c9268cac6f8b023ab4a19570abdf25d078748f9069c96e9d6a2801cf607000a52447e46e1bef4e056ee30d4bd3517aaf7bf65ba04dd28c3a4a14b8dc72a300f051722a6814fa3931d90a82d23285d4c1127b6c67bbc4f8682ddbf9b31eb3114c26dccc5330109d6f17799339c2d7ed7e4e3a7de5d515106aaec7be6d78be3e21806d6d30c39b77c75dcf354b63033fb200b3b9dc023d948278f0956c0ee99323da0162f2a84b6a95749d2fa1d4e089af416d412ccd992683f7e41f7b496ca04f9f463806e3643d1c07f39d2a65f84e97b7dfaafac740d1e03f30923a4270fcf651ad2ca3737859a524e86e02229a55abd1a7", - "prevRandao" : "0x0c0d553e4878ae811024144112c88bbf79a372d5dfdf39730cede08696ad52d4", - "blockNumber" : "0x3e4f2e1ec68dc3e8", - "gasLimit" : "0x3e31d37e1eea3e08", - "gasUsed" : "0x3e2bf49163c989a8", - "timestamp" : "0x3e3d9157952ba6c8", - "extraData" : "0xcb571a3e876c67", - "baseFeePerGas" : "0xde78143e27b846779904841e2aa96d8fbec4671bb57ffa72037ac721f8d633ca", - "blockHash" : "0xa415263e48d5a8a8ba3b4e9caf0e3028abbb6a65922580447af6fcc869b40d2a", - "transactionsRoot" : "0xb736203ee72088edaf7eb5c7839744f5b1be69f748eea8fea77740914415c5b4" - } - } - }, - "signature" : "0x896e97042e9255565a03a997df50fd179a215e566b6f3e6d26079573ddeb571771e55709c1fe02456d74b8fa921045c00cdf09653914c9feb018edbcab2efe7114f4820fe12a98920e54058ea3dee06f00bb2f9ea8bfad95c0056fbd55fac8a4" -} \ No newline at end of file diff --git a/ethereum/executionclient/src/integration-test/resources/builder_getPayloadResponse.json b/ethereum/executionclient/src/integration-test/resources/builder_getPayloadResponse.json deleted file mode 100644 index 61c6e967845..00000000000 --- a/ethereum/executionclient/src/integration-test/resources/builder_getPayloadResponse.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "parentHash" : "0x235bc3400c2839fd856a524871200bd5e362db615fc4565e1870ed9a2a936464", - "feeRecipient" : "0x367cbd40ac7318427aadb97345a91fa2e965daf3", - "stateRoot" : "0xfd18cf40cc907a739be483f1ca0ee23ad65cdd3df23205eabc6d660a75d1f54e", - "receiptsRoot" : "0x103ac9406cdc59b89027eb1c9e97f607dd5fdccfa8fb2da4eaeea9d25032add9", - "logsBloom" : "0x6fdfab408c56b6105a76eff5c0435d09fc6ed7a938e7f946cf74fbbb9416428f619b26eab6d66297cbd9dbc84db437c8d36f9b30556f5f8062bbc80a0e3f35fb2f4921ae3f8361dacf697513c2f8aac786dccb24a7ca3eef9743ab9071ee3663dca121493e717c27ee277bf5d484a83c2da75b4bea86c1d15a2b29352abad715b00fa1c4b94733e496720ced4c31ce785ec3e407136f39dcb857d7d9ff590deeb512704b2f0a58ee953d5a85894a9e9ab9528d1fc87daf2064b515ee861e4dd23bb5714c0fb38a36a1da1698fbee3aae5de1b51de39f6e3d3309e338abb70e275410a1b83e9e9d43d051e6a4a9bdbe6d6fb282c4f2463428a0502a0e2e4b71fb", - "prevRandao" : "0x8200a6402ca295554fb9562193cc71d60272d63beeaf2201fdf53e846e77f919", - "blockNumber" : "0x40b79d4886f7bf4c", - "gasLimit" : "0x40b1be5bcbd70aec", - "gasUsed" : "0x3fd8861ec01cf90b", - "timestamp" : "0x3fd2a73204fc44aa", - "extraData" : "0x0c65de3f6bad3d", - "baseFeePerGas" : "0x6b0ac13f8a279ad3abec11bed1a49214f6e7af79b643595df6a38706b338e93b", - "blockHash" : "0x7e2bbb3f2a737918a12f79e9a52da7e1fceaae0b6c0c82172425cbce8d99a0c6", - "transactions" : [ "0xb88ea93f0a5617" ] -} \ No newline at end of file diff --git a/ethereum/executionclient/src/integration-test/resources/getPayloadHeaderResponse.json b/ethereum/executionclient/src/integration-test/resources/getPayloadHeaderResponse.json deleted file mode 100644 index e0b65fb002e..00000000000 --- a/ethereum/executionclient/src/integration-test/resources/getPayloadHeaderResponse.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "parentHash": "0x235bc3400c2839fd856a524871200bd5e362db615fc4565e1870ed9a2a936464", - "feeRecipient": "0x367cbd40ac7318427aadb97345a91fa2e965daf3", - "stateRoot": "0xfd18cf40cc907a739be483f1ca0ee23ad65cdd3df23205eabc6d660a75d1f54e", - "receiptsRoot": "0x103ac9406cdc59b89027eb1c9e97f607dd5fdccfa8fb2da4eaeea9d25032add9", - "logsBloom": "0x6fdfab408c56b6105a76eff5c0435d09fc6ed7a938e7f946cf74fbbb9416428f619b26eab6d66297cbd9dbc84db437c8d36f9b30556f5f8062bbc80a0e3f35fb2f4921ae3f8361dacf697513c2f8aac786dccb24a7ca3eef9743ab9071ee3663dca121493e717c27ee277bf5d484a83c2da75b4bea86c1d15a2b29352abad715b00fa1c4b94733e496720ced4c31ce785ec3e407136f39dcb857d7d9ff590deeb512704b2f0a58ee953d5a85894a9e9ab9528d1fc87daf2064b515ee861e4dd23bb5714c0fb38a36a1da1698fbee3aae5de1b51de39f6e3d3309e338abb70e275410a1b83e9e9d43d051e6a4a9bdbe6d6fb282c4f2463428a0502a0e2e4b71fb", - "prevRandao": "0x8200a6402ca295554fb9562193cc71d60272d63beeaf2201fdf53e846e77f919", - "blockNumber": "0x40b79d4886f7bf4c", - "gasLimit": "0x40b1be5bcbd70aec", - "gasUsed": "0x3fd8861ec01cf90b", - "timestamp": "0x3fd2a73204fc44aa", - "extraData": "0x0c65de3f6bad3d", - "baseFeePerGas": "0x6b0ac13f8a279ad3abec11bed1a49214f6e7af79b643595df6a38706b338e93b", - "blockHash": "0x7e2bbb3f2a737918a12f79e9a52da7e1fceaae0b6c0c82172425cbce8d99a0c6", - "transactionsRoot": "0x9e2bbb3f2a737918a12f79e9a52da7e1fceaae0b6c0c82172425cbce8d99a0c6" -} \ No newline at end of file diff --git a/ethereum/executionclient/src/integration-test/resources/proposeBlindedBlockResponse.json b/ethereum/executionclient/src/integration-test/resources/proposeBlindedBlockResponse.json deleted file mode 100644 index ade0fa3fbf1..00000000000 --- a/ethereum/executionclient/src/integration-test/resources/proposeBlindedBlockResponse.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "parentHash": "0x235bc3400c2839fd856a524871200bd5e362db615fc4565e1870ed9a2a936464", - "feeRecipient": "0x367cbd40ac7318427aadb97345a91fa2e965daf3", - "stateRoot": "0xfd18cf40cc907a739be483f1ca0ee23ad65cdd3df23205eabc6d660a75d1f54e", - "receiptsRoot": "0x103ac9406cdc59b89027eb1c9e97f607dd5fdccfa8fb2da4eaeea9d25032add9", - "logsBloom": "0x6fdfab408c56b6105a76eff5c0435d09fc6ed7a938e7f946cf74fbbb9416428f619b26eab6d66297cbd9dbc84db437c8d36f9b30556f5f8062bbc80a0e3f35fb2f4921ae3f8361dacf697513c2f8aac786dccb24a7ca3eef9743ab9071ee3663dca121493e717c27ee277bf5d484a83c2da75b4bea86c1d15a2b29352abad715b00fa1c4b94733e496720ced4c31ce785ec3e407136f39dcb857d7d9ff590deeb512704b2f0a58ee953d5a85894a9e9ab9528d1fc87daf2064b515ee861e4dd23bb5714c0fb38a36a1da1698fbee3aae5de1b51de39f6e3d3309e338abb70e275410a1b83e9e9d43d051e6a4a9bdbe6d6fb282c4f2463428a0502a0e2e4b71fb", - "prevRandao": "0x8200a6402ca295554fb9562193cc71d60272d63beeaf2201fdf53e846e77f919", - "blockNumber": "0x40b79d4886f7bf4c", - "gasLimit": "0x40b1be5bcbd70aec", - "gasUsed": "0x3fd8861ec01cf90b", - "timestamp": "0x3fd2a73204fc44aa", - "extraData": "0x0c65de3f6bad3d", - "baseFeePerGas": "0x6b0ac13f8a279ad3abec11bed1a49214f6e7af79b643595df6a38706b338e93b", - "blockHash": "0x7e2bbb3f2a737918a12f79e9a52da7e1fceaae0b6c0c82172425cbce8d99a0c6", - "transactions": [ - "0xb88ea93f0a5617" - ] -} \ No newline at end of file diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/BuilderApiMethod.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/BuilderApiMethod.java index d9a5c3fe7fe..a551edc029a 100644 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/BuilderApiMethod.java +++ b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/BuilderApiMethod.java @@ -17,7 +17,6 @@ import static java.nio.charset.StandardCharsets.UTF_8; import java.util.Map; -import tech.pegasys.teku.ethereum.executionclient.rest.RestExecutionBuilderClient; public enum BuilderApiMethod { REGISTER_VALIDATOR("eth/v1/builder/validators"), @@ -35,8 +34,6 @@ public String getPath() { return path; } - /** Will be used when {@link RestExecutionBuilderClient} is implemented * */ - @SuppressWarnings("UnusedMethod") public String resolvePath(final Map urlParams) { String result = path; for (final Map.Entry param : urlParams.entrySet()) { diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/ExecutionBuilderClient.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/ExecutionBuilderClient.java index fbeb8af48a8..867c17aafe1 100644 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/ExecutionBuilderClient.java +++ b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/ExecutionBuilderClient.java @@ -15,25 +15,23 @@ import org.apache.tuweni.bytes.Bytes32; import tech.pegasys.teku.bls.BLSPublicKey; -import tech.pegasys.teku.ethereum.executionclient.schema.BlindedBeaconBlockV1; -import tech.pegasys.teku.ethereum.executionclient.schema.BuilderBidV1; -import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadV1; import tech.pegasys.teku.ethereum.executionclient.schema.Response; -import tech.pegasys.teku.ethereum.executionclient.schema.SignedMessage; -import tech.pegasys.teku.ethereum.executionclient.schema.ValidatorRegistrationV1; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.unsigned.UInt64; +import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; +import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; +import tech.pegasys.teku.spec.datastructures.execution.SignedBuilderBidV1; +import tech.pegasys.teku.spec.datastructures.execution.SignedValidatorRegistrationV1; public interface ExecutionBuilderClient { SafeFuture> status(); SafeFuture> registerValidator( - SignedMessage signedValidatorRegistrationV1); + UInt64 slot, SignedValidatorRegistrationV1 signedValidatorRegistrationV1); - SafeFuture>> getHeader( + SafeFuture> getHeader( UInt64 slot, BLSPublicKey pubKey, Bytes32 parentHash); - SafeFuture> getPayload( - SignedMessage signedBlindedBeaconBlock); + SafeFuture> getPayload(SignedBeaconBlock signedBlindedBeaconBlock); } diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/ThrottlingExecutionBuilderClient.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/ThrottlingExecutionBuilderClient.java index fc21462c38c..3a2cc31f818 100644 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/ThrottlingExecutionBuilderClient.java +++ b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/ThrottlingExecutionBuilderClient.java @@ -16,16 +16,15 @@ import org.apache.tuweni.bytes.Bytes32; import org.hyperledger.besu.plugin.services.MetricsSystem; import tech.pegasys.teku.bls.BLSPublicKey; -import tech.pegasys.teku.ethereum.executionclient.schema.BlindedBeaconBlockV1; -import tech.pegasys.teku.ethereum.executionclient.schema.BuilderBidV1; -import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadV1; import tech.pegasys.teku.ethereum.executionclient.schema.Response; -import tech.pegasys.teku.ethereum.executionclient.schema.SignedMessage; -import tech.pegasys.teku.ethereum.executionclient.schema.ValidatorRegistrationV1; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.async.ThrottlingTaskQueue; import tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory; import tech.pegasys.teku.infrastructure.unsigned.UInt64; +import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; +import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; +import tech.pegasys.teku.spec.datastructures.execution.SignedBuilderBidV1; +import tech.pegasys.teku.spec.datastructures.execution.SignedValidatorRegistrationV1; public class ThrottlingExecutionBuilderClient implements ExecutionBuilderClient { private final ExecutionBuilderClient delegate; @@ -51,19 +50,20 @@ public SafeFuture> status() { @Override public SafeFuture> registerValidator( - final SignedMessage signedValidatorRegistrationV1) { - return taskQueue.queueTask(() -> delegate.registerValidator(signedValidatorRegistrationV1)); + UInt64 slot, final SignedValidatorRegistrationV1 signedValidatorRegistrationV1) { + return taskQueue.queueTask( + () -> delegate.registerValidator(slot, signedValidatorRegistrationV1)); } @Override - public SafeFuture>> getHeader( + public SafeFuture> getHeader( final UInt64 slot, final BLSPublicKey pubKey, final Bytes32 parentHash) { return taskQueue.queueTask(() -> delegate.getHeader(slot, pubKey, parentHash)); } @Override - public SafeFuture> getPayload( - final SignedMessage signedBlindedBeaconBlock) { + public SafeFuture> getPayload( + SignedBeaconBlock signedBlindedBeaconBlock) { return taskQueue.queueTask(() -> delegate.getPayload(signedBlindedBeaconBlock)); } } diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/rest/OkHttpRestClient.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/rest/OkHttpRestClient.java index d9c8346c49f..428ec10c7e6 100644 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/rest/OkHttpRestClient.java +++ b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/rest/OkHttpRestClient.java @@ -186,7 +186,7 @@ private void handleFailure( final okhttp3.Response response, final SafeFuture> futureResponse) { try { final String errorMessage = getErrorMessageForFailedResponse(response); - futureResponse.complete(new Response<>(errorMessage)); + futureResponse.complete(Response.withErrorMessage(errorMessage)); } catch (Throwable ex) { futureResponse.completeExceptionally(ex); } diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/rest/RestExecutionBuilderClient.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/rest/RestExecutionBuilderClient.java index 5e54791d0b5..6f6f82bfbb8 100644 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/rest/RestExecutionBuilderClient.java +++ b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/rest/RestExecutionBuilderClient.java @@ -13,27 +13,50 @@ package tech.pegasys.teku.ethereum.executionclient.rest; +import static tech.pegasys.teku.spec.config.Constants.EL_BUILDER_GET_HEADER_TIMEOUT; +import static tech.pegasys.teku.spec.config.Constants.EL_BUILDER_GET_PAYLOAD_TIMEOUT; +import static tech.pegasys.teku.spec.config.Constants.EL_BUILDER_REGISTER_VALIDATOR_TIMEOUT; import static tech.pegasys.teku.spec.config.Constants.EL_BUILDER_STATUS_TIMEOUT; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.apache.tuweni.bytes.Bytes32; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.ethereum.executionclient.BuilderApiMethod; import tech.pegasys.teku.ethereum.executionclient.ExecutionBuilderClient; -import tech.pegasys.teku.ethereum.executionclient.schema.BlindedBeaconBlockV1; -import tech.pegasys.teku.ethereum.executionclient.schema.BuilderBidV1; -import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadV1; +import tech.pegasys.teku.ethereum.executionclient.schema.BuilderApiResponse; import tech.pegasys.teku.ethereum.executionclient.schema.Response; -import tech.pegasys.teku.ethereum.executionclient.schema.SignedMessage; -import tech.pegasys.teku.ethereum.executionclient.schema.ValidatorRegistrationV1; import tech.pegasys.teku.infrastructure.async.SafeFuture; +import tech.pegasys.teku.infrastructure.json.types.DeserializableTypeDefinition; import tech.pegasys.teku.infrastructure.unsigned.UInt64; +import tech.pegasys.teku.spec.Spec; +import tech.pegasys.teku.spec.SpecMilestone; +import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; +import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; +import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadSchema; +import tech.pegasys.teku.spec.datastructures.execution.SignedBuilderBidV1; +import tech.pegasys.teku.spec.datastructures.execution.SignedBuilderBidV1Schema; +import tech.pegasys.teku.spec.datastructures.execution.SignedValidatorRegistrationV1; +import tech.pegasys.teku.spec.schemas.SchemaDefinitionCache; +import tech.pegasys.teku.spec.schemas.SchemaDefinitionsBellatrix; public class RestExecutionBuilderClient implements ExecutionBuilderClient { + private final Map< + SpecMilestone, DeserializableTypeDefinition>> + cachedBuilderApiExecutionPayloadResponseType = new ConcurrentHashMap<>(); + + private final Map< + SpecMilestone, DeserializableTypeDefinition>> + cachedBuilderApiSignedBuilderBidV1ResponseType = new ConcurrentHashMap<>(); + private final RestClient restClient; + private final SchemaDefinitionCache schemaDefinitionCache; - public RestExecutionBuilderClient(final RestClient restClient) { + public RestExecutionBuilderClient(final RestClient restClient, final Spec spec) { this.restClient = restClient; + this.schemaDefinitionCache = new SchemaDefinitionCache(spec); } @Override @@ -45,19 +68,103 @@ public SafeFuture> status() { @Override public SafeFuture> registerValidator( - final SignedMessage signedValidatorRegistrationV1) { - throw new UnsupportedOperationException(); + final UInt64 slot, final SignedValidatorRegistrationV1 signedValidatorRegistrationV1) { + + final SpecMilestone milestone = schemaDefinitionCache.milestoneAtSlot(slot); + final SchemaDefinitionsBellatrix schemaDefinitionsBellatrix = + getSchemaDefinitionsBellatrix(milestone); + + final DeserializableTypeDefinition requestType = + schemaDefinitionsBellatrix.getSignedValidatorRegistrationSchema().getJsonTypeDefinition(); + return restClient + .postAsync( + BuilderApiMethod.REGISTER_VALIDATOR.getPath(), + signedValidatorRegistrationV1, + requestType) + .orTimeout(EL_BUILDER_REGISTER_VALIDATOR_TIMEOUT); } @Override - public SafeFuture>> getHeader( + public SafeFuture> getHeader( final UInt64 slot, final BLSPublicKey pubKey, final Bytes32 parentHash) { - throw new UnsupportedOperationException(); + + final Map urlParams = new HashMap<>(); + urlParams.put("slot", slot.toString()); + urlParams.put("parent_hash", parentHash.toHexString()); + urlParams.put("pubkey", pubKey.toBytesCompressed().toHexString()); + + final SpecMilestone milestone = schemaDefinitionCache.milestoneAtSlot(slot); + + final DeserializableTypeDefinition> + responseTypeDefinition = + cachedBuilderApiSignedBuilderBidV1ResponseType.computeIfAbsent( + milestone, + __ -> { + final SchemaDefinitionsBellatrix schemaDefinitionsBellatrix = + getSchemaDefinitionsBellatrix(milestone); + final SignedBuilderBidV1Schema signedBuilderBidV1Schema = + schemaDefinitionsBellatrix.getSignedBuilderBidV1Schema(); + return BuilderApiResponse.createTypeDefinition( + signedBuilderBidV1Schema.getJsonTypeDefinition()); + }); + + return restClient + .getAsync( + BuilderApiMethod.GET_EXECUTION_PAYLOAD_HEADER.resolvePath(urlParams), + responseTypeDefinition) + .thenApply(this::getBuilderApiResponseData) + .orTimeout(EL_BUILDER_GET_HEADER_TIMEOUT); } @Override - public SafeFuture> getPayload( - final SignedMessage signedBlindedBeaconBlock) { - throw new UnsupportedOperationException(); + public SafeFuture> getPayload( + final SignedBeaconBlock signedBlindedBeaconBlock) { + + final UInt64 blockSlot = signedBlindedBeaconBlock.getSlot(); + final SpecMilestone milestone = schemaDefinitionCache.milestoneAtSlot(blockSlot); + + final SchemaDefinitionsBellatrix schemaDefinitionsBellatrix = + getSchemaDefinitionsBellatrix(milestone); + + final DeserializableTypeDefinition requestTypeDefinition = + schemaDefinitionsBellatrix.getSignedBlindedBeaconBlockSchema().getJsonTypeDefinition(); + + final DeserializableTypeDefinition> + responseTypeDefinition = + cachedBuilderApiExecutionPayloadResponseType.computeIfAbsent( + milestone, + __ -> { + final ExecutionPayloadSchema executionPayloadSchema = + schemaDefinitionsBellatrix.getExecutionPayloadSchema(); + return BuilderApiResponse.createTypeDefinition( + executionPayloadSchema.getJsonTypeDefinition()); + }); + + return restClient + .postAsync( + BuilderApiMethod.SEND_SIGNED_BLINDED_BLOCK.getPath(), + signedBlindedBeaconBlock, + requestTypeDefinition, + responseTypeDefinition) + .thenApply(this::getBuilderApiResponseData) + .orTimeout(EL_BUILDER_GET_PAYLOAD_TIMEOUT); + } + + private SchemaDefinitionsBellatrix getSchemaDefinitionsBellatrix(SpecMilestone specMilestone) { + return schemaDefinitionCache + .getSchemaDefinition(specMilestone) + .toVersionBellatrix() + .orElseThrow( + () -> + new IllegalArgumentException( + specMilestone + + " is not a supported milestone for the builder rest api. Milestones >= Bellatrix are supported.")); + } + + private Response getBuilderApiResponseData(Response> response) { + if (response.isFailure()) { + return Response.withErrorMessage(response.getErrorMessage()); + } + return new Response<>(response.getPayload().getData()); } } diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/AttestationDataV1.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/AttestationDataV1.java deleted file mode 100644 index 67627933310..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/AttestationDataV1.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2020 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import java.util.Objects; -import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes32Deserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BytesSerializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexSerializer; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; - -@SuppressWarnings("JavaCase") -public class AttestationDataV1 { - @JsonSerialize(using = UInt64AsHexSerializer.class) - @JsonDeserialize(using = UInt64AsHexDeserializer.class) - public final UInt64 slot; - - @JsonSerialize(using = UInt64AsHexSerializer.class) - @JsonDeserialize(using = UInt64AsHexDeserializer.class) - public final UInt64 index; - - @JsonSerialize(using = BytesSerializer.class) - @JsonDeserialize(using = Bytes32Deserializer.class) - public final Bytes32 beaconBlockRoot; - - public final CheckpointV1 source; - public final CheckpointV1 target; - - @JsonCreator - public AttestationDataV1( - @JsonProperty("slot") final UInt64 slot, - @JsonProperty("index") final UInt64 index, - @JsonProperty("beaconBlockRoot") final Bytes32 beaconBlockRoot, - @JsonProperty("source") final CheckpointV1 source, - @JsonProperty("target") final CheckpointV1 target) { - this.slot = slot; - this.index = index; - this.beaconBlockRoot = beaconBlockRoot; - this.source = source; - this.target = target; - } - - public AttestationDataV1(tech.pegasys.teku.spec.datastructures.operations.AttestationData data) { - this.slot = data.getSlot(); - this.index = data.getIndex(); - this.beaconBlockRoot = data.getBeaconBlockRoot(); - this.source = new CheckpointV1(data.getSource()); - this.target = new CheckpointV1(data.getTarget()); - } - - public tech.pegasys.teku.spec.datastructures.operations.AttestationData - asInternalAttestationData() { - tech.pegasys.teku.spec.datastructures.state.Checkpoint src = source.asInternalCheckpoint(); - tech.pegasys.teku.spec.datastructures.state.Checkpoint tgt = target.asInternalCheckpoint(); - - return new tech.pegasys.teku.spec.datastructures.operations.AttestationData( - slot, index, beaconBlockRoot, src, tgt); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof AttestationDataV1)) { - return false; - } - AttestationDataV1 that = (AttestationDataV1) o; - return Objects.equals(slot, that.slot) - && Objects.equals(index, that.index) - && Objects.equals(beaconBlockRoot, that.beaconBlockRoot) - && Objects.equals(source, that.source) - && Objects.equals(target, that.target); - } - - @Override - public int hashCode() { - return Objects.hash(slot, index, beaconBlockRoot, source, target); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/AttestationV1.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/AttestationV1.java deleted file mode 100644 index 831a1d43a7a..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/AttestationV1.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2020 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import java.util.Objects; -import org.apache.tuweni.bytes.Bytes; -import tech.pegasys.teku.ethereum.executionclient.serialization.BLSSignatureDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BLSSignatureSerializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BytesDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BytesSerializer; -import tech.pegasys.teku.spec.Spec; -import tech.pegasys.teku.spec.SpecVersion; -import tech.pegasys.teku.spec.datastructures.operations.Attestation.AttestationSchema; - -public class AttestationV1 { - @JsonSerialize(using = BytesSerializer.class) - @JsonDeserialize(using = BytesDeserializer.class) - public final Bytes aggregationBits; - - public final AttestationDataV1 data; - - @JsonSerialize(using = BLSSignatureSerializer.class) - @JsonDeserialize(using = BLSSignatureDeserializer.class) - public final BLSSignature signature; - - public AttestationV1(tech.pegasys.teku.spec.datastructures.operations.Attestation attestation) { - this.aggregationBits = attestation.getAggregationBits().sszSerialize(); - this.data = new AttestationDataV1(attestation.getData()); - this.signature = new BLSSignature(attestation.getAggregateSignature()); - } - - @JsonCreator - public AttestationV1( - @JsonProperty("aggregationBits") final Bytes aggregationBits, - @JsonProperty("data") final AttestationDataV1 data, - @JsonProperty("signature") final BLSSignature signature) { - this.aggregationBits = aggregationBits; - this.data = data; - this.signature = signature; - } - - public tech.pegasys.teku.spec.datastructures.operations.Attestation asInternalAttestation( - final Spec spec) { - return asInternalAttestation(spec.atSlot(data.slot)); - } - - public tech.pegasys.teku.spec.datastructures.operations.Attestation asInternalAttestation( - final SpecVersion specVersion) { - final AttestationSchema attestationSchema = - specVersion.getSchemaDefinitions().getAttestationSchema(); - return attestationSchema.create( - attestationSchema.getAggregationBitsSchema().sszDeserialize(aggregationBits), - data.asInternalAttestationData(), - signature.asInternalBLSSignature()); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof AttestationV1)) { - return false; - } - AttestationV1 that = (AttestationV1) o; - return Objects.equals(aggregationBits, that.aggregationBits) - && Objects.equals(data, that.data) - && Objects.equals(signature, that.signature); - } - - @Override - public int hashCode() { - return Objects.hash(aggregationBits, data, signature); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/AttesterSlashingV1.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/AttesterSlashingV1.java deleted file mode 100644 index f99a0f27ca2..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/AttesterSlashingV1.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2020 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Objects; -import tech.pegasys.teku.spec.SpecVersion; -import tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing.AttesterSlashingSchema; - -public class AttesterSlashingV1 { - public final IndexedAttestationV1 attestation1; - public final IndexedAttestationV1 attestation2; - - @JsonCreator - public AttesterSlashingV1( - @JsonProperty("attestation1") final IndexedAttestationV1 attestation1, - @JsonProperty("attestation2") final IndexedAttestationV1 attestation2) { - this.attestation1 = attestation1; - this.attestation2 = attestation2; - } - - public AttesterSlashingV1( - tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing attesterSlashing) { - attestation1 = new IndexedAttestationV1(attesterSlashing.getAttestation1()); - attestation2 = new IndexedAttestationV1(attesterSlashing.getAttestation2()); - } - - public tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing - asInternalAttesterSlashing(final SpecVersion spec) { - final AttesterSlashingSchema attesterSlashingSchema = - spec.getSchemaDefinitions().getAttesterSlashingSchema(); - return attesterSlashingSchema.create( - attestation1.asInternalIndexedAttestation(spec), - attestation2.asInternalIndexedAttestation(spec)); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof AttesterSlashingV1)) { - return false; - } - AttesterSlashingV1 that = (AttesterSlashingV1) o; - return Objects.equals(attestation1, that.attestation1) - && Objects.equals(attestation2, that.attestation2); - } - - @Override - public int hashCode() { - return Objects.hash(attestation1, attestation2); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BLSPubKey.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BLSPubKey.java deleted file mode 100644 index ae13d72acab..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BLSPubKey.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2020 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import static com.google.common.base.Preconditions.checkArgument; - -import java.util.Objects; -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes48; -import tech.pegasys.teku.bls.BLSPublicKey; - -@SuppressWarnings("JavaCase") -public class BLSPubKey { - /** The number of bytes in this value - i.e. 48 */ - private static final int SIZE = 48; - - private final Bytes bytes; - - public BLSPubKey(Bytes bytes) { - checkArgument( - bytes.size() == SIZE, - "Bytes%s should be %s bytes, but was %s bytes.", - SIZE, - SIZE, - bytes.size()); - this.bytes = bytes; - } - - public BLSPubKey(BLSPublicKey publicKey) { - this(publicKey.toSSZBytes()); - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final BLSPubKey BLSSignature = (BLSPubKey) o; - return bytes.equals(BLSSignature.bytes); - } - - @Override - public int hashCode() { - return Objects.hash(bytes); - } - - @Override - public String toString() { - return bytes.toString(); - } - - public static BLSPubKey fromHexString(String value) { - try { - return new BLSPubKey(BLSPublicKey.fromBytesCompressedValidate(Bytes48.fromHexString(value))); - } catch (IllegalArgumentException e) { - throw new IllegalArgumentException( - "Public key " + value + " is invalid: " + e.getMessage(), e); - } - } - - public String toHexString() { - return bytes.toHexString(); - } - - public Bytes toBytes() { - return bytes; - } - - public static BLSPubKey empty() { - return new BLSPubKey(Bytes.wrap(new byte[SIZE])); - } - - public BLSPublicKey asBLSPublicKey() { - return BLSPublicKey.fromSSZBytes(bytes); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BLSSignature.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BLSSignature.java deleted file mode 100644 index b7426b294ae..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BLSSignature.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2020 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import static com.google.common.base.Preconditions.checkArgument; - -import java.util.Objects; -import org.apache.tuweni.bytes.Bytes; -import tech.pegasys.teku.bls.BLSConstants; - -public class BLSSignature { - /** The number of bytes in this value - i.e. 96 */ - private static final int SIZE = BLSConstants.BLS_SIGNATURE_SIZE; - - private final Bytes bytes; - - public BLSSignature(Bytes bytes) { - checkArgument( - bytes.size() == SIZE, - "Bytes%s should be %s bytes, but was %s bytes.", - SIZE, - SIZE, - bytes.size()); - this.bytes = bytes; - } - - public BLSSignature(tech.pegasys.teku.bls.BLSSignature signature) { - this(signature.toBytesCompressed()); - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final BLSSignature blsSignature = (BLSSignature) o; - return bytes.equals(blsSignature.bytes); - } - - @Override - public int hashCode() { - return Objects.hash(bytes); - } - - @Override - public String toString() { - return bytes.toString(); - } - - public static BLSSignature fromHexString(String value) { - return new BLSSignature(Bytes.fromHexString(value)); - } - - public String toHexString() { - return bytes.toHexString(); - } - - public static BLSSignature empty() { - return new BLSSignature(tech.pegasys.teku.bls.BLSSignature.empty()); - } - - public final Bytes getBytes() { - return bytes; - } - - public tech.pegasys.teku.bls.BLSSignature asInternalBLSSignature() { - return tech.pegasys.teku.bls.BLSSignature.fromBytesCompressed(bytes); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BeaconBlockHeaderV1.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BeaconBlockHeaderV1.java deleted file mode 100644 index 640f53ed1f1..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BeaconBlockHeaderV1.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2020 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.google.common.base.MoreObjects; -import java.util.Objects; -import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes32Deserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BytesSerializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexSerializer; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; - -@SuppressWarnings("JavaCase") -public class BeaconBlockHeaderV1 { - @JsonSerialize(using = UInt64AsHexSerializer.class) - @JsonDeserialize(using = UInt64AsHexDeserializer.class) - public final UInt64 slot; - - @JsonSerialize(using = UInt64AsHexSerializer.class) - @JsonDeserialize(using = UInt64AsHexDeserializer.class) - public final UInt64 proposerIndex; - - @JsonSerialize(using = BytesSerializer.class) - @JsonDeserialize(using = Bytes32Deserializer.class) - public final Bytes32 parentRoot; - - @JsonSerialize(using = BytesSerializer.class) - @JsonDeserialize(using = Bytes32Deserializer.class) - public final Bytes32 stateRoot; - - @JsonSerialize(using = BytesSerializer.class) - @JsonDeserialize(using = Bytes32Deserializer.class) - public final Bytes32 bodyRoot; - - @JsonCreator - public BeaconBlockHeaderV1( - @JsonProperty("slot") final UInt64 slot, - @JsonProperty("proposerIndex") final UInt64 proposerIndex, - @JsonProperty("parentRoot") final Bytes32 parentRoot, - @JsonProperty("stateRoot") final Bytes32 stateRoot, - @JsonProperty("bodyRoot") final Bytes32 bodyRoot) { - this.slot = slot; - this.proposerIndex = proposerIndex; - this.parentRoot = parentRoot; - this.stateRoot = stateRoot; - this.bodyRoot = bodyRoot; - } - - public BeaconBlockHeaderV1( - final tech.pegasys.teku.spec.datastructures.blocks.BeaconBlockHeader header) { - this.slot = header.getSlot(); - this.proposerIndex = header.getProposerIndex(); - this.parentRoot = header.getParentRoot(); - this.stateRoot = header.getStateRoot(); - this.bodyRoot = header.getBodyRoot(); - } - - public tech.pegasys.teku.spec.datastructures.blocks.BeaconBlockHeader - asInternalBeaconBlockHeader() { - return new tech.pegasys.teku.spec.datastructures.blocks.BeaconBlockHeader( - slot, proposerIndex, parentRoot, stateRoot, bodyRoot); - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final BeaconBlockHeaderV1 that = (BeaconBlockHeaderV1) o; - return Objects.equals(slot, that.slot) - && Objects.equals(proposerIndex, that.proposerIndex) - && Objects.equals(parentRoot, that.parentRoot) - && Objects.equals(stateRoot, that.stateRoot) - && Objects.equals(bodyRoot, that.bodyRoot); - } - - @Override - public int hashCode() { - return Objects.hash(slot, proposerIndex, parentRoot, stateRoot, bodyRoot); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("slot", slot) - .add("proposerIndex", proposerIndex) - .add("parentRoot", parentRoot) - .add("stateRoot", stateRoot) - .add("bodyRoot", bodyRoot) - .toString(); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BlindedBeaconBlockBodyV1.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BlindedBeaconBlockBodyV1.java deleted file mode 100644 index 635c7332a69..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BlindedBeaconBlockBodyV1.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright 2022 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.google.common.base.MoreObjects; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; -import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.ethereum.executionclient.serialization.BLSSignatureDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BLSSignatureSerializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes32Deserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BytesSerializer; -import tech.pegasys.teku.spec.SpecVersion; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBodySchema; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair.SyncAggregateSchema; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.bellatrix.BlindedBeaconBlockBodySchemaBellatrix; -import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeaderSchema; -import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit; - -public class BlindedBeaconBlockBodyV1 { - @JsonSerialize(using = BLSSignatureSerializer.class) - @JsonDeserialize(using = BLSSignatureDeserializer.class) - public final BLSSignature randaoReveal; - - public final Eth1DataV1 eth1Data; - - @JsonSerialize(using = BytesSerializer.class) - @JsonDeserialize(using = Bytes32Deserializer.class) - public final Bytes32 graffiti; - - public final List proposerSlashings; - public final List attesterSlashings; - public final List attestations; - public final List deposits; - public final List> voluntaryExits; - public final SyncAggregateV1 syncAggregate; - public final ExecutionPayloadHeaderV1 executionPayloadHeader; - - @JsonCreator - public BlindedBeaconBlockBodyV1( - @JsonProperty("randaoReveal") final BLSSignature randaoReveal, - @JsonProperty("eth1Data") final Eth1DataV1 eth1Data, - @JsonProperty("graffiti") final Bytes32 graffiti, - @JsonProperty("proposerSlashings") final List proposerSlashings, - @JsonProperty("attesterSlashings") final List attesterSlashings, - @JsonProperty("attestations") final List attestations, - @JsonProperty("deposits") final List deposits, - @JsonProperty("voluntaryExits") final List> voluntaryExits, - @JsonProperty("syncAggregate") final SyncAggregateV1 syncAggregate, - @JsonProperty("executionPayloadHeader") - final ExecutionPayloadHeaderV1 executionPayloadHeader) { - this.randaoReveal = randaoReveal; - this.eth1Data = eth1Data; - this.graffiti = graffiti; - this.proposerSlashings = proposerSlashings; - this.attesterSlashings = attesterSlashings; - this.attestations = attestations; - this.deposits = deposits; - this.voluntaryExits = voluntaryExits; - this.syncAggregate = syncAggregate; - this.executionPayloadHeader = executionPayloadHeader; - } - - public BlindedBeaconBlockBodySchemaBellatrix getBeaconBlockBodySchema(final SpecVersion spec) { - return (BlindedBeaconBlockBodySchemaBellatrix) - spec.getSchemaDefinitions().getBlindedBeaconBlockBodySchema(); - } - - public BlindedBeaconBlockBodyV1( - tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody body) { - this.randaoReveal = new BLSSignature(body.getRandaoReveal().toSSZBytes()); - this.eth1Data = new Eth1DataV1(body.getEth1Data()); - this.graffiti = body.getGraffiti(); - this.proposerSlashings = - body.getProposerSlashings().stream() - .map(ProposerSlashingV1::new) - .collect(Collectors.toList()); - this.attesterSlashings = - body.getAttesterSlashings().stream() - .map(AttesterSlashingV1::new) - .collect(Collectors.toList()); - this.attestations = - body.getAttestations().stream().map(AttestationV1::new).collect(Collectors.toList()); - this.deposits = body.getDeposits().stream().map(DepositV1::new).collect(Collectors.toList()); - this.voluntaryExits = - body.getVoluntaryExits().stream() - .map( - signedVoluntaryExit -> - new SignedMessage<>( - new VoluntaryExitV1(signedVoluntaryExit.getMessage()), - signedVoluntaryExit.getSignature())) - .collect(Collectors.toList()); - this.syncAggregate = new SyncAggregateV1(body.getOptionalSyncAggregate().orElseThrow()); - this.executionPayloadHeader = - ExecutionPayloadHeaderV1.fromInternalExecutionPayloadHeader( - body.getOptionalExecutionPayloadHeader().orElseThrow()); - } - - public tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody - asInternalBeaconBlockBody(final SpecVersion spec) { - - final ExecutionPayloadHeaderSchema executionPayloadHeaderSchema = - getBeaconBlockBodySchema(spec).getExecutionPayloadHeaderSchema(); - final SyncAggregateSchema syncAggregateSchema = - getBeaconBlockBodySchema(spec).getSyncAggregateSchema(); - final BeaconBlockBodySchema schema = getBeaconBlockBodySchema(spec); - - return schema.createBlockBody( - builder -> - builder - .randaoReveal(randaoReveal.asInternalBLSSignature()) - .eth1Data( - new tech.pegasys.teku.spec.datastructures.blocks.Eth1Data( - eth1Data.depositRoot, eth1Data.depositCount, eth1Data.blockHash)) - .graffiti(graffiti) - .attestations( - attestations.stream() - .map(attestation -> attestation.asInternalAttestation(spec)) - .collect(schema.getAttestationsSchema().collector())) - .proposerSlashings( - proposerSlashings.stream() - .map(ProposerSlashingV1::asInternalProposerSlashing) - .collect(schema.getProposerSlashingsSchema().collector())) - .attesterSlashings( - attesterSlashings.stream() - .map(slashing -> slashing.asInternalAttesterSlashing(spec)) - .collect(schema.getAttesterSlashingsSchema().collector())) - .deposits( - deposits.stream() - .map(DepositV1::asInternalDeposit) - .collect(schema.getDepositsSchema().collector())) - .voluntaryExits( - voluntaryExits.stream() - .map( - voluntaryExit -> - new SignedVoluntaryExit( - voluntaryExit.getMessage().asInternalVoluntaryExit(), - voluntaryExit.getSignature().asInternalBLSSignature())) - .collect(schema.getVoluntaryExitsSchema().collector())) - .syncAggregate( - () -> - syncAggregateSchema.create( - syncAggregateSchema - .getSyncCommitteeBitsSchema() - .fromBytes(syncAggregate.syncCommitteeBits) - .getAllSetBits(), - syncAggregate.syncCommitteeSignature.asInternalBLSSignature())) - .executionPayloadHeader( - () -> - executionPayloadHeaderSchema.create( - executionPayloadHeader.parentHash, - executionPayloadHeader.feeRecipient, - executionPayloadHeader.stateRoot, - executionPayloadHeader.receiptsRoot, - executionPayloadHeader.logsBloom, - executionPayloadHeader.prevRandao, - executionPayloadHeader.blockNumber, - executionPayloadHeader.gasLimit, - executionPayloadHeader.gasUsed, - executionPayloadHeader.timestamp, - executionPayloadHeader.extraData, - executionPayloadHeader.baseFeePerGas, - executionPayloadHeader.blockHash, - executionPayloadHeader.transactionsRoot))); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof BlindedBeaconBlockBodyV1)) { - return false; - } - BlindedBeaconBlockBodyV1 that = (BlindedBeaconBlockBodyV1) o; - return Objects.equals(randaoReveal, that.randaoReveal) - && Objects.equals(eth1Data, that.eth1Data) - && Objects.equals(graffiti, that.graffiti) - && Objects.equals(proposerSlashings, that.proposerSlashings) - && Objects.equals(attesterSlashings, that.attesterSlashings) - && Objects.equals(attestations, that.attestations) - && Objects.equals(deposits, that.deposits) - && Objects.equals(voluntaryExits, that.voluntaryExits) - && Objects.equals(syncAggregate, that.syncAggregate) - && Objects.equals(executionPayloadHeader, that.executionPayloadHeader); - } - - @Override - public int hashCode() { - return Objects.hash( - randaoReveal, - eth1Data, - graffiti, - proposerSlashings, - attesterSlashings, - attestations, - deposits, - voluntaryExits, - syncAggregate, - executionPayloadHeader); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("randaoReveal", randaoReveal) - .add("eth1Data", eth1Data) - .add("graffiti", graffiti) - .add("proposerSlashings", proposerSlashings) - .add("attesterSlashings", attesterSlashings) - .add("attestations", attestations) - .add("deposits", deposits) - .add("voluntaryExits", voluntaryExits) - .add("syncAggregate", syncAggregate) - .add("executionPayloadHeader", executionPayloadHeader) - .toString(); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BlindedBeaconBlockV1.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BlindedBeaconBlockV1.java deleted file mode 100644 index 9d30dd30a27..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BlindedBeaconBlockV1.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2022 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.google.common.base.MoreObjects; -import java.util.Objects; -import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes32Deserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BytesSerializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexSerializer; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.spec.Spec; -import tech.pegasys.teku.spec.SpecVersion; -import tech.pegasys.teku.spec.datastructures.blocks.BeaconBlockSchema; - -public class BlindedBeaconBlockV1 { - @JsonSerialize(using = UInt64AsHexSerializer.class) - @JsonDeserialize(using = UInt64AsHexDeserializer.class) - public final UInt64 slot; - - @JsonSerialize(using = UInt64AsHexSerializer.class) - @JsonDeserialize(using = UInt64AsHexDeserializer.class) - public final UInt64 proposerIndex; - - @JsonSerialize(using = BytesSerializer.class) - @JsonDeserialize(using = Bytes32Deserializer.class) - public final Bytes32 parentRoot; - - @JsonSerialize(using = BytesSerializer.class) - @JsonDeserialize(using = Bytes32Deserializer.class) - public final Bytes32 stateRoot; - - protected final BlindedBeaconBlockBodyV1 body; - - public BlindedBeaconBlockBodyV1 getBody() { - return body; - } - - @JsonCreator - public BlindedBeaconBlockV1( - @JsonProperty("slot") final UInt64 slot, - @JsonProperty("proposerIndex") final UInt64 proposerIndex, - @JsonProperty("parentRoot") final Bytes32 parentRoot, - @JsonProperty("stateRoot") final Bytes32 stateRoot, - @JsonProperty("body") final BlindedBeaconBlockBodyV1 body) { - this.slot = slot; - this.proposerIndex = proposerIndex; - this.parentRoot = parentRoot; - this.stateRoot = stateRoot; - this.body = body; - } - - public BeaconBlockSchema getBeaconBlockSchema(final SpecVersion spec) { - return spec.getSchemaDefinitions().getBeaconBlockSchema(); - } - - public BlindedBeaconBlockV1(tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock message) { - this.slot = message.getSlot(); - this.proposerIndex = message.getProposerIndex(); - this.parentRoot = message.getParentRoot(); - this.stateRoot = message.getStateRoot(); - this.body = - new BlindedBeaconBlockBodyV1(message.getBody().toBlindedVersionBellatrix().orElseThrow()); - } - - public tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock asInternalBeaconBlock( - final Spec spec) { - final SpecVersion specVersion = spec.atSlot(slot); - return getBeaconBlockSchema(spec.atSlot(slot)) - .create( - slot, - proposerIndex, - parentRoot, - stateRoot, - body.asInternalBeaconBlockBody(specVersion)); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof BlindedBeaconBlockV1)) { - return false; - } - BlindedBeaconBlockV1 that = (BlindedBeaconBlockV1) o; - return Objects.equals(slot, that.slot) - && Objects.equals(proposerIndex, that.proposerIndex) - && Objects.equals(parentRoot, that.parentRoot) - && Objects.equals(stateRoot, that.stateRoot) - && Objects.equals(body, that.body); - } - - @Override - public int hashCode() { - return Objects.hash(slot, proposerIndex, parentRoot, stateRoot, body); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("slot", slot) - .add("proposerIndex", proposerIndex) - .add("parentRoot", parentRoot) - .add("stateRoot", stateRoot) - .add("body", body) - .toString(); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BuilderApiResponse.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BuilderApiResponse.java new file mode 100644 index 00000000000..fc267982ef7 --- /dev/null +++ b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BuilderApiResponse.java @@ -0,0 +1,106 @@ +/* + * Copyright 2022 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package tech.pegasys.teku.ethereum.executionclient.schema; + +import com.google.common.base.MoreObjects; +import java.util.Objects; +import tech.pegasys.teku.infrastructure.json.types.CoreTypes; +import tech.pegasys.teku.infrastructure.json.types.DeserializableObjectTypeDefinitionBuilder; +import tech.pegasys.teku.infrastructure.json.types.DeserializableTypeDefinition; + +public class BuilderApiResponse { + + private final String version; + private final T data; + + public BuilderApiResponse(final String version, final T data) { + this.version = version; + this.data = data; + } + + public String getVersion() { + return version; + } + + public T getData() { + return data; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final BuilderApiResponse that = (BuilderApiResponse) o; + return Objects.equals(version, that.version) && Objects.equals(data, that.data); + } + + @Override + public int hashCode() { + return Objects.hash(version, data); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this).add("version", version).add("data", data).toString(); + } + + public static class Builder { + private String version; + private T data; + + private Builder() {} + + public static Builder builder() { + return new Builder<>(); + } + + public Builder version(final String version) { + this.version = version; + return this; + } + + public Builder data(final T data) { + this.data = data; + return this; + } + + public BuilderApiResponse build() { + return new BuilderApiResponse<>(version, data); + } + } + + public static DeserializableTypeDefinition> createTypeDefinition( + final DeserializableTypeDefinition dataTypeDefinition) { + final DeserializableObjectTypeDefinitionBuilder, Builder> + typeDefinitionBuilder = DeserializableTypeDefinition.object(); + return typeDefinitionBuilder + .initializer(BuilderApiResponse.Builder::builder) + .withField( + "version", + CoreTypes.STRING_TYPE, + BuilderApiResponse::getVersion, + BuilderApiResponse.Builder::version) + .withField( + "data", + dataTypeDefinition, + BuilderApiResponse::getData, + BuilderApiResponse.Builder::data) + .finisher(BuilderApiResponse.Builder::build) + .build(); + } +} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BuilderBidV1.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BuilderBidV1.java deleted file mode 100644 index 714a9653ff9..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/BuilderBidV1.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2022 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.google.common.base.MoreObjects; -import java.util.Objects; -import org.apache.tuweni.units.bigints.UInt256; -import tech.pegasys.teku.ethereum.executionclient.serialization.BLSPubKeyDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BLSPubKeySerializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt256AsHexDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt256AsHexSerializer; - -public class BuilderBidV1 { - @JsonProperty("header") - private final ExecutionPayloadHeaderV1 header; - - @JsonSerialize(using = UInt256AsHexSerializer.class) - @JsonDeserialize(using = UInt256AsHexDeserializer.class) - private final UInt256 value; - - @JsonSerialize(using = BLSPubKeySerializer.class) - @JsonDeserialize(using = BLSPubKeyDeserializer.class) - private final BLSPubKey pubkey; - - @JsonCreator - public BuilderBidV1( - @JsonProperty("header") ExecutionPayloadHeaderV1 header, - @JsonProperty("value") UInt256 value, - @JsonProperty("pubkey") BLSPubKey pubkey) { - checkNotNull(header, "header cannot be null"); - checkNotNull(value, "value cannot be null"); - checkNotNull(pubkey, "pubkey cannot be null"); - - this.header = header; - this.value = value; - this.pubkey = pubkey; - } - - public ExecutionPayloadHeaderV1 getHeader() { - return header; - } - - public UInt256 getValue() { - return value; - } - - public BLSPubKey getPubkey() { - return pubkey; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final BuilderBidV1 that = (BuilderBidV1) o; - return Objects.equals(header, that.header) - && Objects.equals(value, that.value) - && Objects.equals(pubkey, that.pubkey); - } - - @Override - public int hashCode() { - return Objects.hash(header, value, pubkey); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("header", header) - .add("value", value) - .add("pubkey", pubkey) - .toString(); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/CheckpointV1.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/CheckpointV1.java deleted file mode 100644 index c6ecf860afc..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/CheckpointV1.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2020 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; -import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes32Deserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BytesSerializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexSerializer; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; - -public class CheckpointV1 { - @JsonSerialize(using = UInt64AsHexSerializer.class) - @JsonDeserialize(using = UInt64AsHexDeserializer.class) - public final UInt64 epoch; - - @JsonSerialize(using = BytesSerializer.class) - @JsonDeserialize(using = Bytes32Deserializer.class) - public final Bytes32 root; - - public CheckpointV1(tech.pegasys.teku.spec.datastructures.state.Checkpoint checkpoint) { - this.epoch = checkpoint.getEpoch(); - this.root = checkpoint.getRoot(); - } - - @JsonCreator - public CheckpointV1( - @JsonProperty("epoch") final UInt64 epoch, @JsonProperty("root") final Bytes32 root) { - this.epoch = epoch; - this.root = root; - } - - public tech.pegasys.teku.spec.datastructures.state.Checkpoint asInternalCheckpoint() { - return new tech.pegasys.teku.spec.datastructures.state.Checkpoint(epoch, root); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof CheckpointV1)) { - return false; - } - CheckpointV1 that = (CheckpointV1) o; - return Objects.equal(epoch, that.epoch) && Objects.equal(root, that.root); - } - - @Override - public int hashCode() { - return Objects.hashCode(epoch, root); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this).add("epoch", epoch).add("root", root).toString(); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/DepositDataV1.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/DepositDataV1.java deleted file mode 100644 index af2e3854cc8..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/DepositDataV1.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2020 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import java.util.Objects; -import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.bls.BLSPublicKey; -import tech.pegasys.teku.ethereum.executionclient.serialization.BLSPubKeyDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BLSPubKeySerializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BLSSignatureDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BLSSignatureSerializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes32Deserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BytesSerializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexSerializer; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; - -public class DepositDataV1 { - @JsonSerialize(using = BLSPubKeySerializer.class) - @JsonDeserialize(using = BLSPubKeyDeserializer.class) - public final BLSPubKey pubkey; - - @JsonSerialize(using = BytesSerializer.class) - @JsonDeserialize(using = Bytes32Deserializer.class) - public final Bytes32 withdrawalCredentials; - - @JsonSerialize(using = UInt64AsHexSerializer.class) - @JsonDeserialize(using = UInt64AsHexDeserializer.class) - public final UInt64 amount; - - @JsonSerialize(using = BLSSignatureSerializer.class) - @JsonDeserialize(using = BLSSignatureDeserializer.class) - public final BLSSignature signature; - - public DepositDataV1(tech.pegasys.teku.spec.datastructures.operations.DepositData depositData) { - this.pubkey = new BLSPubKey(depositData.getPubkey().toSSZBytes()); - this.withdrawalCredentials = depositData.getWithdrawalCredentials(); - this.amount = depositData.getAmount(); - this.signature = new BLSSignature(depositData.getSignature()); - } - - @JsonCreator - public DepositDataV1( - @JsonProperty("pubkey") final BLSPubKey pubkey, - @JsonProperty("withdrawalCredentials") final Bytes32 withdrawalCredentials, - @JsonProperty("amount") final UInt64 amount, - @JsonProperty("signature") final BLSSignature signature) { - this.pubkey = pubkey; - this.withdrawalCredentials = withdrawalCredentials; - this.amount = amount; - this.signature = signature; - } - - public tech.pegasys.teku.spec.datastructures.operations.DepositData asInternalDepositData() { - return new tech.pegasys.teku.spec.datastructures.operations.DepositData( - BLSPublicKey.fromSSZBytes(pubkey.toBytes()), - withdrawalCredentials, - amount, - signature.asInternalBLSSignature()); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof DepositDataV1)) { - return false; - } - DepositDataV1 that = (DepositDataV1) o; - return Objects.equals(pubkey, that.pubkey) - && Objects.equals(withdrawalCredentials, that.withdrawalCredentials) - && Objects.equals(amount, that.amount) - && Objects.equals(signature, that.signature); - } - - @Override - public int hashCode() { - return Objects.hash(pubkey, withdrawalCredentials, amount, signature); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/DepositV1.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/DepositV1.java deleted file mode 100644 index 17b88fc0bda..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/DepositV1.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2020 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; -import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes32Deserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BytesSerializer; - -public class DepositV1 { - @JsonSerialize(contentUsing = BytesSerializer.class) - @JsonDeserialize(contentUsing = Bytes32Deserializer.class) - public final List proof; - - public final DepositDataV1 data; - - public DepositV1(tech.pegasys.teku.spec.datastructures.operations.Deposit deposit) { - this.proof = deposit.getProof().streamUnboxed().collect(Collectors.toList()); - this.data = new DepositDataV1(deposit.getData()); - } - - @JsonCreator - public DepositV1( - @JsonProperty("proof") final List proof, - @JsonProperty("data") final DepositDataV1 data) { - this.proof = proof; - this.data = data; - } - - public tech.pegasys.teku.spec.datastructures.operations.Deposit asInternalDeposit() { - return new tech.pegasys.teku.spec.datastructures.operations.Deposit( - tech.pegasys.teku.spec.datastructures.operations.Deposit.SSZ_SCHEMA - .getProofSchema() - .of(proof), - data.asInternalDepositData()); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof DepositV1)) { - return false; - } - DepositV1 deposit = (DepositV1) o; - return Objects.equals(proof, deposit.proof) && Objects.equals(data, deposit.data); - } - - @Override - public int hashCode() { - return Objects.hash(proof, data); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/Eth1DataV1.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/Eth1DataV1.java deleted file mode 100644 index 562c74311fb..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/Eth1DataV1.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2020 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import java.util.Objects; -import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes32Deserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BytesSerializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexSerializer; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; - -@SuppressWarnings("JavaCase") -public class Eth1DataV1 { - @JsonSerialize(using = BytesSerializer.class) - @JsonDeserialize(using = Bytes32Deserializer.class) - public final Bytes32 depositRoot; - - @JsonSerialize(using = UInt64AsHexSerializer.class) - @JsonDeserialize(using = UInt64AsHexDeserializer.class) - public final UInt64 depositCount; - - @JsonSerialize(using = BytesSerializer.class) - @JsonDeserialize(using = Bytes32Deserializer.class) - public final Bytes32 blockHash; - - public Eth1DataV1(final tech.pegasys.teku.spec.datastructures.blocks.Eth1Data eth1Data) { - depositCount = eth1Data.getDepositCount(); - depositRoot = eth1Data.getDepositRoot(); - blockHash = eth1Data.getBlockHash(); - } - - @JsonCreator - public Eth1DataV1( - @JsonProperty("depositRoot") final Bytes32 depositRoot, - @JsonProperty("depositCount") final UInt64 depositCount, - @JsonProperty("blockHash") final Bytes32 blockHash) { - this.depositRoot = depositRoot; - this.depositCount = depositCount; - this.blockHash = blockHash; - } - - public tech.pegasys.teku.spec.datastructures.blocks.Eth1Data asInternalEth1Data() { - return new tech.pegasys.teku.spec.datastructures.blocks.Eth1Data( - depositRoot, depositCount, blockHash); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof Eth1DataV1)) { - return false; - } - Eth1DataV1 eth1Data = (Eth1DataV1) o; - return Objects.equals(depositRoot, eth1Data.depositRoot) - && Objects.equals(depositCount, eth1Data.depositCount) - && Objects.equals(blockHash, eth1Data.blockHash); - } - - @Override - public int hashCode() { - return Objects.hash(depositRoot, depositCount, blockHash); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/ExecutionPayloadHeaderV1.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/ExecutionPayloadHeaderV1.java deleted file mode 100644 index 2989e676e0b..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/ExecutionPayloadHeaderV1.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright 2022 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.google.common.base.MoreObjects; -import java.util.Objects; -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt256; -import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes32Deserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BytesSerializer; -import tech.pegasys.teku.infrastructure.bytes.Bytes20; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; -import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeaderSchema; - -public class ExecutionPayloadHeaderV1 extends ExecutionPayloadCommon { - @JsonSerialize(using = BytesSerializer.class) - @JsonDeserialize(using = Bytes32Deserializer.class) - public final Bytes32 transactionsRoot; - - @JsonCreator - public ExecutionPayloadHeaderV1( - @JsonProperty("parentHash") Bytes32 parentHash, - @JsonProperty("feeRecipient") Bytes20 feeRecipient, - @JsonProperty("stateRoot") Bytes32 stateRoot, - @JsonProperty("receiptsRoot") Bytes32 receiptsRoot, - @JsonProperty("logsBloom") Bytes logsBloom, - @JsonProperty("prevRandao") Bytes32 prevRandao, - @JsonProperty("blockNumber") UInt64 blockNumber, - @JsonProperty("gasLimit") UInt64 gasLimit, - @JsonProperty("gasUsed") UInt64 gasUsed, - @JsonProperty("timestamp") UInt64 timestamp, - @JsonProperty("extraData") Bytes extraData, - @JsonProperty("baseFeePerGas") UInt256 baseFeePerGas, - @JsonProperty("blockHash") Bytes32 blockHash, - @JsonProperty("transactionsRoot") Bytes32 transactionsRoot) { - super( - parentHash, - feeRecipient, - stateRoot, - receiptsRoot, - logsBloom, - prevRandao, - blockNumber, - gasLimit, - gasUsed, - timestamp, - extraData, - baseFeePerGas, - blockHash); - checkNotNull(transactionsRoot, "transactionsRoot"); - this.transactionsRoot = transactionsRoot; - } - - public ExecutionPayloadHeader asInternalExecutionPayloadHeader( - ExecutionPayloadHeaderSchema executionPayloadHeaderSchema) { - return executionPayloadHeaderSchema.create( - parentHash, - feeRecipient, - stateRoot, - receiptsRoot, - logsBloom, - prevRandao, - blockNumber, - gasLimit, - gasUsed, - timestamp, - extraData, - baseFeePerGas, - blockHash, - transactionsRoot); - } - - public static ExecutionPayloadHeaderV1 fromInternalExecutionPayloadHeader( - ExecutionPayloadHeader executionPayloadHeader) { - return new ExecutionPayloadHeaderV1( - executionPayloadHeader.getParentHash(), - executionPayloadHeader.getFeeRecipient(), - executionPayloadHeader.getStateRoot(), - executionPayloadHeader.getReceiptsRoot(), - executionPayloadHeader.getLogsBloom(), - executionPayloadHeader.getPrevRandao(), - executionPayloadHeader.getBlockNumber(), - executionPayloadHeader.getGasLimit(), - executionPayloadHeader.getGasUsed(), - executionPayloadHeader.getTimestamp(), - executionPayloadHeader.getExtraData(), - executionPayloadHeader.getBaseFeePerGas(), - executionPayloadHeader.getBlockHash(), - executionPayloadHeader.getTransactionsRoot()); - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - if (!super.equals(o)) { - return false; - } - final ExecutionPayloadHeaderV1 that = (ExecutionPayloadHeaderV1) o; - return Objects.equals(parentHash, that.parentHash) - && Objects.equals(feeRecipient, that.feeRecipient) - && Objects.equals(stateRoot, that.stateRoot) - && Objects.equals(receiptsRoot, that.receiptsRoot) - && Objects.equals(logsBloom, that.logsBloom) - && Objects.equals(prevRandao, that.prevRandao) - && Objects.equals(blockNumber, that.blockNumber) - && Objects.equals(gasLimit, that.gasLimit) - && Objects.equals(gasUsed, that.gasUsed) - && Objects.equals(timestamp, that.timestamp) - && Objects.equals(extraData, that.extraData) - && Objects.equals(baseFeePerGas, that.baseFeePerGas) - && Objects.equals(blockHash, that.blockHash) - && Objects.equals(transactionsRoot, that.transactionsRoot); - } - - @Override - public int hashCode() { - return Objects.hash( - super.hashCode(), - parentHash, - feeRecipient, - stateRoot, - receiptsRoot, - logsBloom, - prevRandao, - blockNumber, - gasLimit, - gasUsed, - timestamp, - extraData, - baseFeePerGas, - blockHash, - transactionsRoot); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("parentHash", parentHash) - .add("feeRecipient", feeRecipient) - .add("stateRoot", stateRoot) - .add("receiptsRoot", receiptsRoot) - .add("logsBloom", logsBloom) - .add("prevRandao", prevRandao) - .add("blockNumber", blockNumber) - .add("gasLimit", gasLimit) - .add("gasUsed", gasUsed) - .add("timestamp", timestamp) - .add("extraData", extraData) - .add("baseFeePerGas", baseFeePerGas) - .add("blockHash", blockHash) - .add("transactionsRoot", transactionsRoot) - .toString(); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/GenericBuilderStatus.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/GenericBuilderStatus.java deleted file mode 100644 index dd72f24e148..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/GenericBuilderStatus.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2022 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -public enum GenericBuilderStatus { - OK -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/IndexedAttestationV1.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/IndexedAttestationV1.java deleted file mode 100644 index 61bf53e1efa..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/IndexedAttestationV1.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2020 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; -import tech.pegasys.teku.ethereum.executionclient.serialization.BLSSignatureDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BLSSignatureSerializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexSerializer; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.spec.Spec; -import tech.pegasys.teku.spec.SpecVersion; -import tech.pegasys.teku.spec.datastructures.operations.IndexedAttestation.IndexedAttestationSchema; - -@SuppressWarnings("JavaCase") -public class IndexedAttestationV1 { - @JsonSerialize(contentUsing = UInt64AsHexSerializer.class) - @JsonDeserialize(contentUsing = UInt64AsHexDeserializer.class) - public final List attestingIndices; - - public final AttestationDataV1 data; - - @JsonSerialize(using = BLSSignatureSerializer.class) - @JsonDeserialize(using = BLSSignatureDeserializer.class) - public final BLSSignature signature; - - public IndexedAttestationV1( - tech.pegasys.teku.spec.datastructures.operations.IndexedAttestation indexedAttestation) { - this.attestingIndices = - indexedAttestation.getAttestingIndices().streamUnboxed().collect(Collectors.toList()); - this.data = new AttestationDataV1(indexedAttestation.getData()); - this.signature = new BLSSignature(indexedAttestation.getSignature()); - } - - @JsonCreator - public IndexedAttestationV1( - @JsonProperty("attestingIndices") final List attestingIndices, - @JsonProperty("data") final AttestationDataV1 data, - @JsonProperty("signature") final BLSSignature signature) { - this.attestingIndices = attestingIndices; - this.data = data; - this.signature = signature; - } - - public tech.pegasys.teku.spec.datastructures.operations.IndexedAttestation - asInternalIndexedAttestation(final Spec spec) { - return asInternalIndexedAttestation(spec.atSlot(data.slot)); - } - - public tech.pegasys.teku.spec.datastructures.operations.IndexedAttestation - asInternalIndexedAttestation(final SpecVersion spec) { - final IndexedAttestationSchema indexedAttestationSchema = - spec.getSchemaDefinitions().getIndexedAttestationSchema(); - return indexedAttestationSchema.create( - indexedAttestationSchema.getAttestingIndicesSchema().of(attestingIndices), - data.asInternalAttestationData(), - signature.asInternalBLSSignature()); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof IndexedAttestationV1)) { - return false; - } - IndexedAttestationV1 that = (IndexedAttestationV1) o; - return Objects.equals(attestingIndices, that.attestingIndices) - && Objects.equals(data, that.data) - && Objects.equals(signature, that.signature); - } - - @Override - public int hashCode() { - return Objects.hash(attestingIndices, data, signature); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/ProposerSlashingV1.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/ProposerSlashingV1.java deleted file mode 100644 index bad44c8ed88..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/ProposerSlashingV1.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2020 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Objects; -import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlockHeader; - -public class ProposerSlashingV1 { - public final SignedMessage signedHeader1; - public final SignedMessage signedHeader2; - - @JsonCreator - public ProposerSlashingV1( - @JsonProperty("signedHeader1") final SignedMessage header1, - @JsonProperty("signedHeader2") final SignedMessage header2) { - this.signedHeader1 = header1; - this.signedHeader2 = header2; - } - - public ProposerSlashingV1( - tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing proposerSlashing) { - signedHeader1 = - new SignedMessage( - new BeaconBlockHeaderV1(proposerSlashing.getHeader1().getMessage()), - proposerSlashing.getHeader1().getSignature()); - signedHeader2 = - new SignedMessage( - new BeaconBlockHeaderV1(proposerSlashing.getHeader2().getMessage()), - proposerSlashing.getHeader2().getSignature()); - } - - public tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing - asInternalProposerSlashing() { - return new tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing( - new SignedBeaconBlockHeader( - signedHeader1.getMessage().asInternalBeaconBlockHeader(), - signedHeader1.getSignature().asInternalBLSSignature()), - new SignedBeaconBlockHeader( - signedHeader2.getMessage().asInternalBeaconBlockHeader(), - signedHeader2.getSignature().asInternalBLSSignature())); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof ProposerSlashingV1)) { - return false; - } - ProposerSlashingV1 that = (ProposerSlashingV1) o; - return Objects.equals(signedHeader1, that.signedHeader1) - && Objects.equals(signedHeader2, that.signedHeader2); - } - - @Override - public int hashCode() { - return Objects.hash(signedHeader1, signedHeader2); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/Response.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/Response.java index 69042236e13..3c4c636e532 100644 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/Response.java +++ b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/Response.java @@ -13,6 +13,7 @@ package tech.pegasys.teku.ethereum.executionclient.schema; +import com.google.common.base.MoreObjects; import java.util.Objects; public class Response { @@ -20,16 +21,12 @@ public class Response { private final T payload; private final String errorMessage; - private Response(T payload, String errorMessage) { + public Response(final T payload, final String errorMessage) { this.payload = payload; this.errorMessage = errorMessage; } - public Response(String errorMessage) { - this(null, errorMessage); - } - - public Response(T payload) { + public Response(final T payload) { this.payload = payload; this.errorMessage = null; } @@ -38,6 +35,10 @@ public static Response withNullPayload() { return new Response<>(null, null); } + public static Response withErrorMessage(final String errorMessage) { + return new Response<>(null, errorMessage); + } + public T getPayload() { return payload; } @@ -71,4 +72,12 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash(payload, errorMessage); } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("payload", payload) + .add("errorMessage", errorMessage) + .toString(); + } } diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/SignedMessage.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/SignedMessage.java deleted file mode 100644 index 1480f3b3025..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/SignedMessage.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2022 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.google.common.base.MoreObjects; -import java.util.Objects; -import tech.pegasys.teku.ethereum.executionclient.serialization.BLSSignatureDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BLSSignatureSerializer; - -public class SignedMessage { - private final T message; - - @JsonSerialize(using = BLSSignatureSerializer.class) - @JsonDeserialize(using = BLSSignatureDeserializer.class) - private final BLSSignature signature; - - @JsonCreator - public SignedMessage( - @JsonProperty("message") T message, @JsonProperty("signature") BLSSignature signature) { - checkNotNull(message, "message cannot be null"); - checkNotNull(signature, "signature cannot be null"); - this.message = message; - this.signature = signature; - } - - public SignedMessage(T message, tech.pegasys.teku.bls.BLSSignature signature) { - checkNotNull(message, "message cannot be null"); - checkNotNull(signature, "signature cannot be null"); - this.message = message; - this.signature = new BLSSignature(signature); - } - - public T getMessage() { - return message; - } - - public BLSSignature getSignature() { - return signature; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final SignedMessage that = (SignedMessage) o; - return Objects.equals(message, that.message) && Objects.equals(signature, that.signature); - } - - @Override - public int hashCode() { - return Objects.hash(message, signature); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("message", message) - .add("signature", signature) - .toString(); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/SyncAggregateV1.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/SyncAggregateV1.java deleted file mode 100644 index 4c100a0c6e7..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/SyncAggregateV1.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2021 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import java.util.Objects; -import org.apache.tuweni.bytes.Bytes; -import tech.pegasys.teku.ethereum.executionclient.serialization.BLSSignatureDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BLSSignatureSerializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BytesDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BytesSerializer; - -public class SyncAggregateV1 { - @JsonSerialize(using = BytesSerializer.class) - @JsonDeserialize(using = BytesDeserializer.class) - public Bytes syncCommitteeBits; - - @JsonSerialize(using = BLSSignatureSerializer.class) - @JsonDeserialize(using = BLSSignatureDeserializer.class) - public final BLSSignature syncCommitteeSignature; - - @JsonCreator - public SyncAggregateV1( - @JsonProperty("syncCommitteeBits") final Bytes syncCommitteeBits, - @JsonProperty("syncCommitteeSignature") final BLSSignature syncCommitteeSignature) { - this.syncCommitteeBits = syncCommitteeBits; - this.syncCommitteeSignature = syncCommitteeSignature; - } - - public SyncAggregateV1( - final tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair.SyncAggregate - aggregate) { - this.syncCommitteeSignature = - new BLSSignature(aggregate.getSyncCommitteeSignature().getSignature()); - this.syncCommitteeBits = aggregate.getSyncCommitteeBits().sszSerialize(); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof SyncAggregateV1)) { - return false; - } - SyncAggregateV1 that = (SyncAggregateV1) o; - return Objects.equals(syncCommitteeBits, that.syncCommitteeBits) - && Objects.equals(syncCommitteeSignature, that.syncCommitteeSignature); - } - - @Override - public int hashCode() { - return Objects.hash(syncCommitteeBits, syncCommitteeSignature); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/ValidatorRegistrationV1.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/ValidatorRegistrationV1.java deleted file mode 100644 index 381a7667a2e..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/ValidatorRegistrationV1.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2022 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.google.common.base.MoreObjects; -import java.util.Objects; -import tech.pegasys.teku.ethereum.executionclient.serialization.BLSPubKeyDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BLSPubKeySerializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes20Deserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes20Serializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexSerializer; -import tech.pegasys.teku.infrastructure.bytes.Bytes20; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; - -public class ValidatorRegistrationV1 { - @JsonSerialize(using = Bytes20Serializer.class) - @JsonDeserialize(using = Bytes20Deserializer.class) - private final Bytes20 feeRecipient; - - @JsonSerialize(using = UInt64AsHexSerializer.class) - @JsonDeserialize(using = UInt64AsHexDeserializer.class) - private final UInt64 gasTarget; - - @JsonSerialize(using = UInt64AsHexSerializer.class) - @JsonDeserialize(using = UInt64AsHexDeserializer.class) - private final UInt64 timestamp; - - @JsonSerialize(using = BLSPubKeySerializer.class) - @JsonDeserialize(using = BLSPubKeyDeserializer.class) - private final BLSPubKey pubkey; - - @JsonCreator - public ValidatorRegistrationV1( - @JsonProperty("feeRecipient") Bytes20 feeRecipient, - @JsonProperty("gasTarget") UInt64 gasTarget, - @JsonProperty("timestamp") UInt64 timestamp, - @JsonProperty("pubkey") BLSPubKey pubkey) { - checkNotNull(feeRecipient, "feeRecipient cannot be null"); - checkNotNull(gasTarget, "gasTarget cannot be null"); - checkNotNull(timestamp, "timestamp cannot be null"); - checkNotNull(pubkey, "pubkey cannot be null"); - - this.feeRecipient = feeRecipient; - this.gasTarget = gasTarget; - this.timestamp = timestamp; - this.pubkey = pubkey; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final ValidatorRegistrationV1 that = (ValidatorRegistrationV1) o; - return Objects.equals(feeRecipient, that.feeRecipient) - && Objects.equals(gasTarget, that.gasTarget) - && Objects.equals(timestamp, that.timestamp) - && Objects.equals(pubkey, that.pubkey); - } - - @Override - public int hashCode() { - return Objects.hash(feeRecipient, gasTarget, timestamp, pubkey); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("feeRecipient", feeRecipient) - .add("gasTarget", gasTarget) - .add("timestamp", timestamp) - .add("pubkey", pubkey) - .toString(); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/VoluntaryExitV1.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/VoluntaryExitV1.java deleted file mode 100644 index 572a37c12d9..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/VoluntaryExitV1.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2020 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import java.util.Objects; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexSerializer; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; - -public class VoluntaryExitV1 { - @JsonSerialize(using = UInt64AsHexSerializer.class) - @JsonDeserialize(using = UInt64AsHexDeserializer.class) - public final UInt64 epoch; - - @JsonSerialize(using = UInt64AsHexSerializer.class) - @JsonDeserialize(using = UInt64AsHexDeserializer.class) - public final UInt64 validatorIndex; - - public VoluntaryExitV1( - tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit voluntaryExit) { - this.epoch = voluntaryExit.getEpoch(); - this.validatorIndex = voluntaryExit.getValidatorIndex(); - } - - @JsonCreator - public VoluntaryExitV1( - @JsonProperty("epoch") final UInt64 epoch, - @JsonProperty("validatorIndex") final UInt64 validatorIndex) { - this.epoch = epoch; - this.validatorIndex = validatorIndex; - } - - public tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit asInternalVoluntaryExit() { - return new tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit( - epoch, validatorIndex); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof VoluntaryExitV1)) { - return false; - } - VoluntaryExitV1 that = (VoluntaryExitV1) o; - return Objects.equals(epoch, that.epoch) && Objects.equals(validatorIndex, that.validatorIndex); - } - - @Override - public int hashCode() { - return Objects.hash(epoch, validatorIndex); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/serialization/BLSPubKeyDeserializer.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/serialization/BLSPubKeyDeserializer.java deleted file mode 100644 index b5a9a7a987c..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/serialization/BLSPubKeyDeserializer.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2020 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.serialization; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import java.io.IOException; -import tech.pegasys.teku.ethereum.executionclient.schema.BLSPubKey; - -public class BLSPubKeyDeserializer extends JsonDeserializer { - @Override - public BLSPubKey deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - return BLSPubKey.fromHexString(p.getValueAsString()); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/serialization/BLSPubKeySerializer.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/serialization/BLSPubKeySerializer.java deleted file mode 100644 index d9f927c864e..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/serialization/BLSPubKeySerializer.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2020 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.serialization; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; -import java.io.IOException; -import tech.pegasys.teku.ethereum.executionclient.schema.BLSPubKey; - -public class BLSPubKeySerializer extends JsonSerializer { - @Override - public void serialize(BLSPubKey value, JsonGenerator gen, SerializerProvider serializers) - throws IOException { - gen.writeString(value.toHexString().toLowerCase()); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/serialization/BLSSignatureDeserializer.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/serialization/BLSSignatureDeserializer.java deleted file mode 100644 index 8517fc6371f..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/serialization/BLSSignatureDeserializer.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2020 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.serialization; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import java.io.IOException; -import tech.pegasys.teku.ethereum.executionclient.schema.BLSSignature; - -public class BLSSignatureDeserializer extends JsonDeserializer { - @Override - public BLSSignature deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - return BLSSignature.fromHexString(p.getValueAsString()); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/serialization/BLSSignatureSerializer.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/serialization/BLSSignatureSerializer.java deleted file mode 100644 index 12586e5955f..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/serialization/BLSSignatureSerializer.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2020 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.ethereum.executionclient.serialization; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; -import java.io.IOException; -import tech.pegasys.teku.ethereum.executionclient.schema.BLSSignature; - -public class BLSSignatureSerializer extends JsonSerializer { - @Override - public void serialize(BLSSignature value, JsonGenerator gen, SerializerProvider serializers) - throws IOException { - gen.writeString(value.toHexString().toLowerCase()); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/web3j/Web3JClient.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/web3j/Web3JClient.java index 9cadce38aa5..665281c7475 100644 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/web3j/Web3JClient.java +++ b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/web3j/Web3JClient.java @@ -68,7 +68,7 @@ public SafeFuture> doRequest( (response, exception) -> { if (exception != null) { handleError(exception); - return new Response<>( + return Response.withErrorMessage( exception.getMessage() != null ? exception.getMessage() : exception.getClass().getSimpleName()); @@ -76,7 +76,7 @@ public SafeFuture> doRequest( final String errorMessage = response.getError().getCode() + ": " + response.getError().getMessage(); handleError(new IOException(errorMessage)); - return new Response<>(errorMessage); + return Response.withErrorMessage(errorMessage); } else { handleSuccess(); return new Response<>(response.getResult()); diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/web3j/Web3JExecutionBuilderClient.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/web3j/Web3JExecutionBuilderClient.java index ebe189e8632..3ee4678a6c5 100644 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/web3j/Web3JExecutionBuilderClient.java +++ b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/web3j/Web3JExecutionBuilderClient.java @@ -13,29 +13,19 @@ package tech.pegasys.teku.ethereum.executionclient.web3j; -import static tech.pegasys.teku.spec.config.Constants.EL_BUILDER_GET_HEADER_TIMEOUT; -import static tech.pegasys.teku.spec.config.Constants.EL_BUILDER_GET_PAYLOAD_TIMEOUT; -import static tech.pegasys.teku.spec.config.Constants.EL_BUILDER_REGISTER_VALIDATOR_TIMEOUT; -import static tech.pegasys.teku.spec.config.Constants.EL_BUILDER_STATUS_TIMEOUT; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; import org.apache.tuweni.bytes.Bytes32; -import org.web3j.protocol.core.Request; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.ethereum.executionclient.ExecutionBuilderClient; -import tech.pegasys.teku.ethereum.executionclient.schema.BlindedBeaconBlockV1; -import tech.pegasys.teku.ethereum.executionclient.schema.BuilderBidV1; -import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadV1; -import tech.pegasys.teku.ethereum.executionclient.schema.GenericBuilderStatus; import tech.pegasys.teku.ethereum.executionclient.schema.Response; -import tech.pegasys.teku.ethereum.executionclient.schema.SignedMessage; -import tech.pegasys.teku.ethereum.executionclient.schema.ValidatorRegistrationV1; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.unsigned.UInt64; +import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; +import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; +import tech.pegasys.teku.spec.datastructures.execution.SignedBuilderBidV1; +import tech.pegasys.teku.spec.datastructures.execution.SignedValidatorRegistrationV1; public class Web3JExecutionBuilderClient implements ExecutionBuilderClient { + @SuppressWarnings("unused") // will be removed in upcoming PRs private final Web3JClient web3JClient; public Web3JExecutionBuilderClient(final Web3JClient web3JClient) { @@ -44,79 +34,24 @@ public Web3JExecutionBuilderClient(final Web3JClient web3JClient) { @Override public SafeFuture> status() { - Request web3jRequest = - new Request<>( - "builder_status", - List.of(), - web3JClient.getWeb3jService(), - GenericBuilderStatusWeb3jResponse.class); - return web3JClient - .doRequest(web3jRequest, EL_BUILDER_STATUS_TIMEOUT) - .thenApply(statusResponse -> new Response<>(statusResponse.getErrorMessage())); + return SafeFuture.failedFuture(new UnsupportedOperationException("Deprecated")); } @Override public SafeFuture> registerValidator( - final SignedMessage signedValidatorRegistrationV1) { - Request web3jRequest = - new Request<>( - "builder_registerValidatorV1", - Collections.singletonList(signedValidatorRegistrationV1), - web3JClient.getWeb3jService(), - GenericBuilderStatusWeb3jResponse.class); - return web3JClient - .doRequest(web3jRequest, EL_BUILDER_REGISTER_VALIDATOR_TIMEOUT) - .thenApply(statusResponse -> new Response<>(statusResponse.getErrorMessage())); + UInt64 slot, final SignedValidatorRegistrationV1 signedValidatorRegistrationV1) { + return SafeFuture.failedFuture(new UnsupportedOperationException("Deprecated")); } @Override - public SafeFuture>> getHeader( + public SafeFuture> getHeader( final UInt64 slot, final BLSPublicKey pubKey, final Bytes32 parentHash) { - Request web3jRequest = - new Request<>( - "builder_getHeaderV1", - List.of(slot.toString(), pubKey.toString(), parentHash.toHexString()), - web3JClient.getWeb3jService(), - ExecutionPayloadHeaderV1Web3jResponse.class); - return web3JClient.doRequest(web3jRequest, EL_BUILDER_GET_HEADER_TIMEOUT); + return SafeFuture.failedFuture(new UnsupportedOperationException("Deprecated")); } @Override - public SafeFuture> getPayload( - SignedMessage signedBlindedBeaconBlock) { - Request web3jRequest = - new Request<>( - "builder_getPayloadV1", - Collections.singletonList(signedBlindedBeaconBlock), - web3JClient.getWeb3jService(), - ExecutionPayloadV1Web3jResponse.class); - return web3JClient.doRequest(web3jRequest, EL_BUILDER_GET_PAYLOAD_TIMEOUT); - } - - protected Web3JClient getWeb3JClient() { - return web3JClient; - } - - static class ExecutionPayloadV1Web3jResponse - extends org.web3j.protocol.core.Response {} - - static class ExecutionPayloadHeaderV1Web3jResponse - extends org.web3j.protocol.core.Response> {} - - static class GenericBuilderStatusWeb3jResponse - extends org.web3j.protocol.core.Response {} - - /** - * Returns a list that supports null items. - * - * @param items the items to put in a list - * @return the list - */ - protected List list(final Object... items) { - final List list = new ArrayList<>(); - for (Object item : items) { - list.add(item); - } - return list; + public SafeFuture> getPayload( + SignedBeaconBlock signedBlindedBeaconBlock) { + return SafeFuture.failedFuture(new UnsupportedOperationException("Deprecated")); } } diff --git a/ethereum/executionclient/src/test/java/tech/pegasys/teku/ethereum/executionclient/SchemaSerializationTests.java b/ethereum/executionclient/src/test/java/tech/pegasys/teku/ethereum/executionclient/SchemaSerializationTests.java index 49f46e46ef0..42ad6d8efd6 100644 --- a/ethereum/executionclient/src/test/java/tech/pegasys/teku/ethereum/executionclient/SchemaSerializationTests.java +++ b/ethereum/executionclient/src/test/java/tech/pegasys/teku/ethereum/executionclient/SchemaSerializationTests.java @@ -34,7 +34,6 @@ import org.apache.tuweni.units.bigints.UInt256; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestTemplate; -import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadHeaderV1; import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadV1; import tech.pegasys.teku.ethereum.executionclient.schema.ForkChoiceStateV1; import tech.pegasys.teku.ethereum.executionclient.schema.ForkChoiceUpdatedResult; @@ -57,7 +56,6 @@ import tech.pegasys.teku.spec.TestSpecContext; import tech.pegasys.teku.spec.TestSpecInvocationContextProvider.SpecContext; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; -import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; import tech.pegasys.teku.spec.executionlayer.ExecutionPayloadStatus; import tech.pegasys.teku.spec.executionlayer.PayloadStatus; import tech.pegasys.teku.spec.executionlayer.TransitionConfiguration; @@ -224,26 +222,6 @@ void shouldSerializeDeserializeExecutionPayloadV1() throws IOException { .isEqualTo(internalExecutionPayload); } - @TestTemplate - void shouldSerializeDeserializeExecutionPayloadHeaderV1() throws IOException { - ExecutionPayloadHeader internalExecutionPayloadHeader = - dataStructureUtil.randomExecutionPayloadHeader(); - ExecutionPayloadHeaderV1 executionPayloadHeaderV1Orig = - ExecutionPayloadHeaderV1.fromInternalExecutionPayloadHeader(internalExecutionPayloadHeader); - - String executionPayloadHeaderV1OrigSerialized = - objectMapper.writeValueAsString(executionPayloadHeaderV1Orig); - ExecutionPayloadHeaderV1 executionPayloadHeaderV1New = - objectMapper.readValue( - executionPayloadHeaderV1OrigSerialized, ExecutionPayloadHeaderV1.class); - - assertThat(executionPayloadHeaderV1Orig).isEqualTo(executionPayloadHeaderV1New); - assertThat( - executionPayloadHeaderV1Orig.asInternalExecutionPayloadHeader( - internalExecutionPayloadHeader.getSchema())) - .isEqualTo(internalExecutionPayloadHeader); - } - @TestTemplate void shouldDeserializePayloadStatusWithNulls() throws IOException { PayloadStatusV1 payloadStatusV1Expected = diff --git a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionLayerManagerImpl.java b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionLayerManagerImpl.java index 05de79bd296..da5693d96a0 100644 --- a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionLayerManagerImpl.java +++ b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionLayerManagerImpl.java @@ -33,15 +33,12 @@ import tech.pegasys.teku.ethereum.executionclient.ExecutionEngineClient; import tech.pegasys.teku.ethereum.executionclient.ThrottlingExecutionBuilderClient; import tech.pegasys.teku.ethereum.executionclient.ThrottlingExecutionEngineClient; -import tech.pegasys.teku.ethereum.executionclient.schema.BlindedBeaconBlockV1; -import tech.pegasys.teku.ethereum.executionclient.schema.BuilderBidV1; import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadV1; import tech.pegasys.teku.ethereum.executionclient.schema.ForkChoiceStateV1; import tech.pegasys.teku.ethereum.executionclient.schema.ForkChoiceUpdatedResult; import tech.pegasys.teku.ethereum.executionclient.schema.PayloadAttributesV1; import tech.pegasys.teku.ethereum.executionclient.schema.PayloadStatusV1; import tech.pegasys.teku.ethereum.executionclient.schema.Response; -import tech.pegasys.teku.ethereum.executionclient.schema.SignedMessage; import tech.pegasys.teku.ethereum.executionclient.schema.TransitionConfigurationV1; import tech.pegasys.teku.ethereum.executionclient.web3j.Web3JClient; import tech.pegasys.teku.ethereum.executionclient.web3j.Web3JExecutionBuilderClient; @@ -53,11 +50,12 @@ import tech.pegasys.teku.spec.Spec; import tech.pegasys.teku.spec.SpecMilestone; import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; +import tech.pegasys.teku.spec.datastructures.execution.BuilderBidV1; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadContext; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; -import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeaderSchema; import tech.pegasys.teku.spec.datastructures.execution.PowBlock; +import tech.pegasys.teku.spec.datastructures.execution.SignedBuilderBidV1; import tech.pegasys.teku.spec.executionlayer.ForkChoiceState; import tech.pegasys.teku.spec.executionlayer.PayloadBuildingAttributes; import tech.pegasys.teku.spec.executionlayer.PayloadStatus; @@ -289,8 +287,8 @@ public SafeFuture builderGetHeader( .getHeader( slot, registeredValidatorPublicKey.get(), executionPayloadContext.getParentHash()) .thenApply(ExecutionLayerManagerImpl::unwrapResponseOrThrow) - .thenApply( - builderBidV1SignedMessage -> getHeaderFromBuilderBid(builderBidV1SignedMessage, slot)) + .thenApply(SignedBuilderBidV1::getMessage) + .thenApply(BuilderBidV1::getExecutionPayloadHeader) .thenPeek( executionPayloadHeader -> { // store that we haven't fallen back for this slot @@ -363,37 +361,14 @@ private SafeFuture doFallbackToLocal( .createFromExecutionPayload(executionPayload)); } - private ExecutionPayloadHeader getHeaderFromBuilderBid( - SignedMessage signedBuilderBid, UInt64 slot) { - ExecutionPayloadHeaderSchema executionPayloadHeaderSchema = - SchemaDefinitionsBellatrix.required(spec.atSlot(slot).getSchemaDefinitions()) - .getExecutionPayloadHeaderSchema(); - // TODO: validate signature - - return signedBuilderBid - .getMessage() - .getHeader() - .asInternalExecutionPayloadHeader(executionPayloadHeaderSchema); - } - private SafeFuture getPayloadFromBuilder( final SignedBeaconBlock signedBlindedBeaconBlock) { LOG.trace("calling builderGetPayload(signedBlindedBeaconBlock={})", signedBlindedBeaconBlock); return executionBuilderClient .orElseThrow() - .getPayload( - new SignedMessage<>( - new BlindedBeaconBlockV1(signedBlindedBeaconBlock.getMessage()), - signedBlindedBeaconBlock.getSignature())) + .getPayload(signedBlindedBeaconBlock) .thenApply(ExecutionLayerManagerImpl::unwrapResponseOrThrow) - .thenCombine( - SafeFuture.of( - () -> - SchemaDefinitionsBellatrix.required( - spec.atSlot(signedBlindedBeaconBlock.getSlot()).getSchemaDefinitions()) - .getExecutionPayloadSchema()), - ExecutionPayloadV1::asInternalExecutionPayload) .thenPeek( executionPayload -> LOG.trace( diff --git a/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionLayerManagerImplTest.java b/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionLayerManagerImplTest.java index 31febee386c..9a9fa5ca8dd 100644 --- a/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionLayerManagerImplTest.java +++ b/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionLayerManagerImplTest.java @@ -27,13 +27,8 @@ import org.mockito.Mockito; import tech.pegasys.teku.ethereum.executionclient.ExecutionBuilderClient; import tech.pegasys.teku.ethereum.executionclient.ExecutionEngineClient; -import tech.pegasys.teku.ethereum.executionclient.schema.BLSPubKey; -import tech.pegasys.teku.ethereum.executionclient.schema.BlindedBeaconBlockV1; -import tech.pegasys.teku.ethereum.executionclient.schema.BuilderBidV1; -import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadHeaderV1; import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadV1; import tech.pegasys.teku.ethereum.executionclient.schema.Response; -import tech.pegasys.teku.ethereum.executionclient.schema.SignedMessage; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.logging.EventLogger; import tech.pegasys.teku.infrastructure.unsigned.UInt64; @@ -43,6 +38,7 @@ import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadContext; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; +import tech.pegasys.teku.spec.datastructures.execution.SignedBuilderBidV1; import tech.pegasys.teku.spec.util.DataStructureUtil; class ExecutionLayerManagerImplTest { @@ -87,7 +83,7 @@ public void builderShouldBeAvailableWhenBuilderIsOperatingNormally() { @Test public void builderShouldNotBeAvailableWhenBuilderIsNotOperatingNormally() { SafeFuture> builderClientResponse = - SafeFuture.completedFuture(new Response<>("oops")); + SafeFuture.completedFuture(Response.withErrorMessage("oops")); updateBuilderStatus(builderClientResponse); @@ -119,7 +115,7 @@ public void builderAvailabilityIsUpdatedOnSlotEventAndLoggedAdequately() { verifyNoInteractions(eventLogger); // Given builder status is not ok - updateBuilderStatus(SafeFuture.completedFuture(new Response<>("oops"))); + updateBuilderStatus(SafeFuture.completedFuture(Response.withErrorMessage("oops"))); // Then assertThat(executionLayerManager.isBuilderAvailable()).isFalse(); @@ -161,20 +157,15 @@ public void builderGetHeaderGetPayload_shouldReturnHeaderAndPayloadViaBuilder() final SignedBeaconBlock signedBlindedBeaconBlock = dataStructureUtil.randomSignedBlindedBeaconBlock(slot); - final SignedMessage signedBlindedBeaconBlockRequest = - new SignedMessage<>( - new BlindedBeaconBlockV1(signedBlindedBeaconBlock.getMessage()), - signedBlindedBeaconBlock.getSignature()); - final ExecutionPayload payload = - prepareBuilderGetPayloadResponse(signedBlindedBeaconBlockRequest); + final ExecutionPayload payload = prepareBuilderGetPayloadResponse(signedBlindedBeaconBlock); // we expect result from the builder assertThat(executionLayerManager.builderGetPayload(signedBlindedBeaconBlock)) .isCompletedWithValue(payload); // we expect both builder and local engine have been called - verify(executionBuilderClient).getPayload(signedBlindedBeaconBlockRequest); + verify(executionBuilderClient).getPayload(signedBlindedBeaconBlock); verifyNoMoreInteractions(executionEngineClient); } @@ -327,20 +318,15 @@ void onSlot_shouldCleanUpFallbackCache() { final UInt64 slot = UInt64.ONE; final SignedBeaconBlock signedBlindedBeaconBlock = dataStructureUtil.randomSignedBlindedBeaconBlock(slot); - final SignedMessage signedBlindedBeaconBlockRequest = - new SignedMessage<>( - new BlindedBeaconBlockV1(signedBlindedBeaconBlock.getMessage()), - signedBlindedBeaconBlock.getSignature()); - final ExecutionPayload payload = - prepareBuilderGetPayloadResponse(signedBlindedBeaconBlockRequest); + final ExecutionPayload payload = prepareBuilderGetPayloadResponse(signedBlindedBeaconBlock); // we expect result from the builder assertThat(executionLayerManager.builderGetPayload(signedBlindedBeaconBlock)) .isCompletedWithValue(payload); // we expect both builder and local engine have been called - verify(executionBuilderClient).getPayload(signedBlindedBeaconBlockRequest); + verify(executionBuilderClient).getPayload(signedBlindedBeaconBlock); verifyNoMoreInteractions(executionEngineClient); } @@ -348,20 +334,7 @@ private ExecutionPayloadHeader prepareBuilderGetHeaderResponse( final ExecutionPayloadContext executionPayloadContext) { final UInt64 slot = executionPayloadContext.getForkChoiceState().getHeadBlockSlot(); - final ExecutionPayloadHeader header = dataStructureUtil.randomExecutionPayloadHeader(); - - final Response> response = - new Response<>( - new SignedMessage<>( - new BuilderBidV1( - ExecutionPayloadHeaderV1.fromInternalExecutionPayloadHeader(header), - dataStructureUtil.randomUInt256(), - new BLSPubKey( - executionPayloadContext - .getPayloadBuildingAttributes() - .getValidatorRegistrationPublicKey() - .orElseThrow())), - dataStructureUtil.randomSignature())); + SignedBuilderBidV1 signedBuilderBidV1 = dataStructureUtil.randomSignedBuilderBidV1(); when(executionBuilderClient.getHeader( slot, @@ -370,20 +343,18 @@ private ExecutionPayloadHeader prepareBuilderGetHeaderResponse( .getValidatorRegistrationPublicKey() .orElseThrow(), executionPayloadContext.getParentHash())) - .thenReturn(SafeFuture.completedFuture(response)); + .thenReturn(SafeFuture.completedFuture(new Response<>(signedBuilderBidV1))); - return header; + return signedBuilderBidV1.getMessage().getExecutionPayloadHeader(); } private ExecutionPayload prepareBuilderGetPayloadResponse( - final SignedMessage signedBlindedBeaconBlock) { + final SignedBeaconBlock signedBlindedBeaconBlock) { final ExecutionPayload payload = dataStructureUtil.randomExecutionPayload(); when(executionBuilderClient.getPayload(signedBlindedBeaconBlock)) - .thenReturn( - SafeFuture.completedFuture( - new Response<>(ExecutionPayloadV1.fromInternalExecutionPayload(payload)))); + .thenReturn(SafeFuture.completedFuture(new Response<>(payload))); return payload; } @@ -438,7 +409,7 @@ private void setBuilderOffline() { } private void setBuilderOffline(UInt64 slot) { - updateBuilderStatus(SafeFuture.completedFuture(new Response<>("oops")), slot); + updateBuilderStatus(SafeFuture.completedFuture(Response.withErrorMessage("oops")), slot); reset(executionBuilderClient); assertThat(executionLayerManager.isBuilderAvailable()).isFalse(); } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/SignedBuilderBidV1.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/SignedBuilderBidV1.java index dac9dfa9ee5..19080e5ab0b 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/SignedBuilderBidV1.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/SignedBuilderBidV1.java @@ -16,7 +16,6 @@ import tech.pegasys.teku.bls.BLSSignature; import tech.pegasys.teku.infrastructure.ssz.containers.Container2; import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; -import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlockSchema; import tech.pegasys.teku.spec.datastructures.type.SszSignature; public class SignedBuilderBidV1 extends Container2 { @@ -33,8 +32,8 @@ public class SignedBuilderBidV1 extends Container2 schema) { return schema.toVersionBellatrix().map(__ -> randomExecutionPayload()).orElse(null); diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ProposersDataManager.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ProposersDataManager.java index 2696bc6b144..674a5314031 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ProposersDataManager.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ProposersDataManager.java @@ -256,7 +256,7 @@ public Map getData() { .getValue() .getSignedValidatorRegistration() .getMessage() - .getGasTarget()) + .getGasLimit()) .put( "timestamp", registeredValidatorInfoEntry