diff --git a/acceptance-tests/src/acceptance-test/java/tech/pegasys/teku/test/acceptance/BlsToExecutionChangeAcceptanceTest.java b/acceptance-tests/src/acceptance-test/java/tech/pegasys/teku/test/acceptance/BlsToExecutionChangeAcceptanceTest.java index c8160aba60e..54845b74952 100644 --- a/acceptance-tests/src/acceptance-test/java/tech/pegasys/teku/test/acceptance/BlsToExecutionChangeAcceptanceTest.java +++ b/acceptance-tests/src/acceptance-test/java/tech/pegasys/teku/test/acceptance/BlsToExecutionChangeAcceptanceTest.java @@ -16,7 +16,7 @@ import java.io.IOException; import java.util.List; import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.response.v1.EventType; +import tech.pegasys.teku.api.response.EventType; import tech.pegasys.teku.bls.BLSKeyPair; import tech.pegasys.teku.ethereum.execution.types.Eth1Address; import tech.pegasys.teku.infrastructure.unsigned.UInt64; diff --git a/acceptance-tests/src/acceptance-test/java/tech/pegasys/teku/test/acceptance/SyncCommitteeGossipAcceptanceTest.java b/acceptance-tests/src/acceptance-test/java/tech/pegasys/teku/test/acceptance/SyncCommitteeGossipAcceptanceTest.java index de7c3fec795..f63048aa106 100644 --- a/acceptance-tests/src/acceptance-test/java/tech/pegasys/teku/test/acceptance/SyncCommitteeGossipAcceptanceTest.java +++ b/acceptance-tests/src/acceptance-test/java/tech/pegasys/teku/test/acceptance/SyncCommitteeGossipAcceptanceTest.java @@ -16,7 +16,7 @@ import java.io.IOException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.response.v1.EventType; +import tech.pegasys.teku.api.response.EventType; import tech.pegasys.teku.infrastructure.time.SystemTimeProvider; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.test.acceptance.dsl.AcceptanceTestBase; diff --git a/acceptance-tests/src/testFixtures/java/tech/pegasys/teku/test/acceptance/dsl/TekuBeaconNode.java b/acceptance-tests/src/testFixtures/java/tech/pegasys/teku/test/acceptance/dsl/TekuBeaconNode.java index 9599686b24c..a9119f9aba3 100644 --- a/acceptance-tests/src/testFixtures/java/tech/pegasys/teku/test/acceptance/dsl/TekuBeaconNode.java +++ b/acceptance-tests/src/testFixtures/java/tech/pegasys/teku/test/acceptance/dsl/TekuBeaconNode.java @@ -50,7 +50,7 @@ import org.testcontainers.containers.Network; import org.testcontainers.containers.wait.strategy.HttpWaitStrategy; import tech.pegasys.teku.api.migrated.ValidatorLivenessAtEpoch; -import tech.pegasys.teku.api.response.v1.EventType; +import tech.pegasys.teku.api.response.EventType; import tech.pegasys.teku.bls.BLS; import tech.pegasys.teku.bls.BLSKeyPair; import tech.pegasys.teku.bls.BLSSecretKey; diff --git a/acceptance-tests/src/testFixtures/java/tech/pegasys/teku/test/acceptance/dsl/TekuNode.java b/acceptance-tests/src/testFixtures/java/tech/pegasys/teku/test/acceptance/dsl/TekuNode.java index 766f4a4038b..f12c50f2e83 100644 --- a/acceptance-tests/src/testFixtures/java/tech/pegasys/teku/test/acceptance/dsl/TekuNode.java +++ b/acceptance-tests/src/testFixtures/java/tech/pegasys/teku/test/acceptance/dsl/TekuNode.java @@ -28,7 +28,7 @@ import org.testcontainers.containers.Network; import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy; import org.testcontainers.utility.MountableFile; -import tech.pegasys.teku.api.response.v1.EventType; +import tech.pegasys.teku.api.response.EventType; public abstract class TekuNode extends Node { public static final int VALIDATOR_API_PORT = 9052; diff --git a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerTest.java b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerTest.java index 53532eb70e8..9c54fd626c8 100644 --- a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerTest.java +++ b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerTest.java @@ -57,7 +57,7 @@ import tech.pegasys.teku.api.NetworkDataProvider; import tech.pegasys.teku.api.NodeDataProvider; import tech.pegasys.teku.api.migrated.ValidatorLivenessAtEpoch; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.beacon.sync.events.SyncState; import tech.pegasys.teku.beacon.sync.events.SyncStateProvider; import tech.pegasys.teku.bls.BLSPublicKey; diff --git a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/tekuv1/beacon/GetEth1DataCacheIntegrationTest.java b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/tekuv1/beacon/GetEth1DataCacheIntegrationTest.java index 2ee7a11f883..b6ff203fff1 100644 --- a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/tekuv1/beacon/GetEth1DataCacheIntegrationTest.java +++ b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/tekuv1/beacon/GetEth1DataCacheIntegrationTest.java @@ -26,11 +26,11 @@ import org.apache.tuweni.bytes.Bytes32; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.schema.Eth1Data; import tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest; import tech.pegasys.teku.beaconrestapi.handlers.tekuv1.beacon.GetEth1DataCache; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.SpecMilestone; +import tech.pegasys.teku.spec.datastructures.blocks.Eth1Data; import tech.pegasys.teku.spec.util.DataStructureUtil; public class GetEth1DataCacheIntegrationTest extends AbstractDataBackedRestAPIIntegrationTest { @@ -45,15 +45,11 @@ public void setup() { @Test public void shouldReturnAllEth1BlocksFromCache() throws IOException { - List eth1DataCacheList = - new ArrayList<>(); + final List eth1DataCacheList = new ArrayList<>(); for (int i = 0; i < 5; i++) { eth1DataCacheList.add(dataStructureUtil.randomEth1Data()); } - List eth1DataCacheBlocks = new ArrayList<>(); - eth1DataCacheList.stream() - .map(Eth1Data::new) - .forEach(eth1Block -> eth1DataCacheBlocks.add(eth1Block)); + final List eth1DataCacheBlocks = new ArrayList<>(eth1DataCacheList); when(eth1DataProvider.getEth1CachedBlocks()).thenReturn(eth1DataCacheList); final Response response = get(); assertThat(response.code()).isEqualTo(SC_OK); @@ -63,11 +59,11 @@ public void shouldReturnAllEth1BlocksFromCache() throws IOException { final JsonNode block = data.get(i); final Eth1Data eth1Data = eth1DataCacheBlocks.get(i); assertThat(Bytes32.fromHexString(block.get("deposit_root").asText())) - .isEqualTo(eth1Data.deposit_root); + .isEqualTo(eth1Data.getDepositRoot()); assertThat(UInt64.valueOf(block.get("deposit_count").asText())) - .isEqualTo(eth1Data.deposit_count); + .isEqualTo(eth1Data.getDepositCount()); assertThat(Bytes32.fromHexString(block.get("block_hash").asText())) - .isEqualTo(eth1Data.block_hash); + .isEqualTo(eth1Data.getBlockHash()); } } diff --git a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/beacon/GetBlindedBlockIntegrationTest.java b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/beacon/GetBlindedBlockIntegrationTest.java index f2b4c8657ef..21f1e5caccb 100644 --- a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/beacon/GetBlindedBlockIntegrationTest.java +++ b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/beacon/GetBlindedBlockIntegrationTest.java @@ -23,7 +23,6 @@ import okhttp3.Response; import org.apache.tuweni.bytes.Bytes; import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest; import tech.pegasys.teku.beaconrestapi.handlers.v1.beacon.GetBlindedBlock; import tech.pegasys.teku.ethereum.json.types.SharedApiTypes; @@ -46,7 +45,8 @@ public void shouldGetBlindedPhase0Block() throws IOException { assertThat(result.isBlinded()).isFalse(); assertThat(result).isEqualTo(created.get(0).getBlock()); assertThat(result.hashTreeRoot()).isEqualTo(created.get(0).getBlock().hashTreeRoot()); - assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.phase0.name()); + assertThat(response.header(HEADER_CONSENSUS_VERSION)) + .isEqualTo(SpecMilestone.PHASE0.lowerCaseName()); } @Test @@ -59,7 +59,8 @@ public void shouldGetBlindedBellatrixBlock() throws IOException { assertThat(result.isBlinded()).isTrue(); assertThat(result.hashTreeRoot()).isEqualTo(created.get(0).getBlock().hashTreeRoot()); - assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.bellatrix.name()); + assertThat(response.header(HEADER_CONSENSUS_VERSION)) + .isEqualTo(SpecMilestone.BELLATRIX.lowerCaseName()); } @Test @@ -75,7 +76,8 @@ public void shouldGetBellatrixBlockAsSsz() throws IOException { .sszDeserialize(Bytes.of(response.body().bytes())); assertThat(result.isBlinded()).isTrue(); assertThat(result.hashTreeRoot()).isEqualTo(created.get(0).getBlock().hashTreeRoot()); - assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.bellatrix.name()); + assertThat(response.header(HEADER_CONSENSUS_VERSION)) + .isEqualTo(SpecMilestone.BELLATRIX.lowerCaseName()); } public Response get(final String blockIdString, final String contentType) throws IOException { diff --git a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/beacon/GetFinalizedCheckpointStateIntegrationTest.java b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/beacon/GetFinalizedCheckpointStateIntegrationTest.java index facf1668faf..c6696114e62 100644 --- a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/beacon/GetFinalizedCheckpointStateIntegrationTest.java +++ b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/beacon/GetFinalizedCheckpointStateIntegrationTest.java @@ -23,7 +23,6 @@ import org.apache.tuweni.bytes.Bytes; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest; import tech.pegasys.teku.beaconrestapi.handlers.v1.beacon.GetFinalizedCheckpointState; import tech.pegasys.teku.infrastructure.http.ContentTypes; @@ -43,7 +42,8 @@ public void shouldGetBellatrixStateAsSsz() final Response response = getResponse(GetFinalizedCheckpointState.ROUTE, ContentTypes.OCTET_STREAM); assertThat(response.code()).isEqualTo(SC_OK); - assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.bellatrix.name()); + assertThat(response.header(HEADER_CONSENSUS_VERSION)) + .isEqualTo(SpecMilestone.BELLATRIX.lowerCaseName()); final Bytes actualResponse = Bytes.wrap(response.body().bytes()); assertThat(actualResponse) .isEqualTo(combinedChainDataClient.getBestState().get().get().sszSerialize()); diff --git a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/beacon/GetPendingDepositsIntegrationTest.java b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/beacon/GetPendingDepositsIntegrationTest.java index 198426e08cf..6eb6e3f102f 100644 --- a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/beacon/GetPendingDepositsIntegrationTest.java +++ b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/beacon/GetPendingDepositsIntegrationTest.java @@ -21,7 +21,6 @@ import java.util.List; import okhttp3.Response; import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest; import tech.pegasys.teku.beaconrestapi.handlers.v1.beacon.GetStatePendingDeposits; import tech.pegasys.teku.infrastructure.json.JsonTestUtil; @@ -50,7 +49,8 @@ public void shouldGetElectraDepositsJson() throws Exception { assertThat(node.get("data").get(1).get("slot").asInt()).isEqualTo(10); assertThat(node.get("data").get(1).get("pubkey").asText()) .isEqualTo(stateElectra.getPendingDeposits().get(1).getPublicKey().toHexString()); - assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.electra.name()); + assertThat(response.header(HEADER_CONSENSUS_VERSION)) + .isEqualTo(SpecMilestone.ELECTRA.lowerCaseName()); } public Response get(final String stateId) throws IOException { diff --git a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/beacon/GetStatePendingPartialWithdrawalsIntegrationTest.java b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/beacon/GetStatePendingPartialWithdrawalsIntegrationTest.java index 610d6ff9172..acd98b6fc61 100644 --- a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/beacon/GetStatePendingPartialWithdrawalsIntegrationTest.java +++ b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/beacon/GetStatePendingPartialWithdrawalsIntegrationTest.java @@ -20,7 +20,6 @@ import java.io.IOException; import okhttp3.Response; import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest; import tech.pegasys.teku.beaconrestapi.handlers.v1.beacon.GetStatePendingPartialWithdrawals; import tech.pegasys.teku.infrastructure.json.JsonTestUtil; @@ -40,7 +39,8 @@ public void shouldGetElectraDepositsJson() throws Exception { assertThat(node.get("execution_optimistic").asBoolean()).isFalse(); assertThat(node.get("finalized").asBoolean()).isFalse(); assertThat(node.get("data").size()).isEqualTo(0); - assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.electra.name()); + assertThat(response.header(HEADER_CONSENSUS_VERSION)) + .isEqualTo(SpecMilestone.ELECTRA.lowerCaseName()); } public Response get(final String stateId) throws IOException { diff --git a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/validator/PostRegisterValidatorTest.java b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/validator/PostRegisterValidatorTest.java index 300b1bca288..326be8973f8 100644 --- a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/validator/PostRegisterValidatorTest.java +++ b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/validator/PostRegisterValidatorTest.java @@ -34,7 +34,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest; import tech.pegasys.teku.beaconrestapi.handlers.v1.validator.PostRegisterValidator; import tech.pegasys.teku.bls.BLSPublicKey; diff --git a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v2/beacon/GetBlockV2IntegrationTest.java b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v2/beacon/GetBlockV2IntegrationTest.java index bc28cc7688b..70c25b5253f 100644 --- a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v2/beacon/GetBlockV2IntegrationTest.java +++ b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v2/beacon/GetBlockV2IntegrationTest.java @@ -28,7 +28,6 @@ import java.util.zip.GZIPInputStream; import okhttp3.Response; import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest; import tech.pegasys.teku.beaconrestapi.handlers.v2.beacon.GetBlock; import tech.pegasys.teku.infrastructure.http.ContentTypes; @@ -46,12 +45,13 @@ public void shouldGetBlock() throws IOException { final Response response = get("head"); final JsonNode body = OBJECT_MAPPER.readTree(response.body().string()); - assertThat(body.get("version").asText()).isEqualTo(Version.phase0.name()); + assertThat(body.get("version").asText()).isEqualTo(SpecMilestone.PHASE0.lowerCaseName()); assertThat(body.get("data").get("message").get("parent_root").asText()) .isEqualTo(created.get(0).getBlock().getMessage().getParentRoot().toHexString()); assertThat(body.get("data").get("message").get("state_root").asText()) .isEqualTo(created.get(0).getBlock().getMessage().getStateRoot().toHexString()); - assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.phase0.name()); + assertThat(response.header(HEADER_CONSENSUS_VERSION)) + .isEqualTo(SpecMilestone.PHASE0.lowerCaseName()); // this is the most practical way to compare the block to that created, but its secondary to // comparing state root and parent root. @@ -67,12 +67,13 @@ public void shouldGetAltairBlock() throws IOException { final Response response = get("head"); final JsonNode body = OBJECT_MAPPER.readTree(response.body().string()); - assertThat(body.get("version").asText()).isEqualTo(Version.altair.name()); + assertThat(body.get("version").asText()).isEqualTo(SpecMilestone.ALTAIR.lowerCaseName()); assertThat(body.get("data").get("message").get("parent_root").asText()) .isEqualTo(created.get(0).getBlock().getMessage().getParentRoot().toHexString()); assertThat(body.get("data").get("message").get("state_root").asText()) .isEqualTo(created.get(0).getBlock().getMessage().getStateRoot().toHexString()); - assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.altair.name()); + assertThat(response.header(HEADER_CONSENSUS_VERSION)) + .isEqualTo(SpecMilestone.ALTAIR.lowerCaseName()); // this is the most practical way to compare the block to that created, but its secondary to // comparing state root and parent root. @@ -97,7 +98,8 @@ public void shouldGetAltairBlockAsSsz() throws IOException { createBlocksAtSlots(10); final Response response = get("head", OCTET_STREAM); assertThat(response.code()).isEqualTo(SC_OK); - assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.altair.name()); + assertThat(response.header(HEADER_CONSENSUS_VERSION)) + .isEqualTo(SpecMilestone.ALTAIR.lowerCaseName()); } @Test @@ -106,7 +108,8 @@ public void shouldGetAltairBlockAsGzip() throws IOException { createBlocksAtSlots(10); final Response response = getGzip("head", ContentTypes.JSON); assertThat(response.code()).isEqualTo(SC_OK); - assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.altair.name()); + assertThat(response.header(HEADER_CONSENSUS_VERSION)) + .isEqualTo(SpecMilestone.ALTAIR.lowerCaseName()); assertThat(response.header(HEADER_CONTENT_ENCODING)).isEqualTo("gzip"); // Decompress response diff --git a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v2/debug/GetStateIntegrationTest.java b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v2/debug/GetStateIntegrationTest.java index 3afa02d5a15..36e746a1d72 100644 --- a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v2/debug/GetStateIntegrationTest.java +++ b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v2/debug/GetStateIntegrationTest.java @@ -23,7 +23,6 @@ import java.util.function.Function; import okhttp3.Response; import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest; import tech.pegasys.teku.beaconrestapi.handlers.v2.debug.GetState; import tech.pegasys.teku.infrastructure.http.ContentTypes; @@ -53,7 +52,8 @@ public void shouldGetPhase0StateAsJson() throws IOException { assertThat(stateResponse).isNotNull(); assertThat(stateResponse.getVersion()).isEqualTo(SpecMilestone.PHASE0); assertThat(stateResponse.getData()).isInstanceOf(BeaconStatePhase0.class); - assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.phase0.name()); + assertThat(response.header(HEADER_CONSENSUS_VERSION)) + .isEqualTo(SpecMilestone.PHASE0.lowerCaseName()); } @Test @@ -71,7 +71,8 @@ public void shouldGetAltairStateAsJson() throws IOException { assertThat(stateResponse).isNotNull(); assertThat(stateResponse.getVersion()).isEqualTo(SpecMilestone.ALTAIR); assertThat(stateResponse.getData()).isInstanceOf(BeaconStateAltair.class); - assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.altair.name()); + assertThat(response.header(HEADER_CONSENSUS_VERSION)) + .isEqualTo(SpecMilestone.ALTAIR.lowerCaseName()); } @Test @@ -79,7 +80,8 @@ public void shouldGetAltairStateAsSsz() throws IOException { startRestAPIAtGenesis(SpecMilestone.ALTAIR); final Response response = get("head", OCTET_STREAM); assertThat(response.code()).isEqualTo(SC_OK); - assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.altair.name()); + assertThat(response.header(HEADER_CONSENSUS_VERSION)) + .isEqualTo(SpecMilestone.ALTAIR.lowerCaseName()); } public Response get(final String stateIdIdString, final String contentType) throws IOException { diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/BeaconRestApiTypes.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/BeaconRestApiTypes.java index af65266c254..4f3cb736601 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/BeaconRestApiTypes.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/BeaconRestApiTypes.java @@ -66,7 +66,7 @@ import java.util.function.Function; import java.util.stream.Collectors; import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.api.response.v1.EventType; +import tech.pegasys.teku.api.response.EventType; import tech.pegasys.teku.bls.BLSSignature; import tech.pegasys.teku.ethereum.json.types.beacon.StatusParameter; import tech.pegasys.teku.infrastructure.http.RestApiConstants; diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/SingleQueryParameterUtils.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/SingleQueryParameterUtils.java deleted file mode 100644 index bfa0baffad6..00000000000 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/SingleQueryParameterUtils.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2025 - * - * 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.beaconrestapi; - -import static tech.pegasys.teku.infrastructure.restapi.endpoints.SingleQueryParameterUtils.validateQueryParameter; - -import java.util.List; -import java.util.Map; -import java.util.Optional; -import tech.pegasys.teku.api.exceptions.BadRequestException; -import tech.pegasys.teku.api.schema.BLSSignature; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; - -public class SingleQueryParameterUtils { - public static final String INVALID_BYTES96_DATA = - "Unable to read Bytes96 data from query parameter."; - - public static BLSSignature getParameterValueAsBLSSignature( - final Map> parameterMap, final String key) - throws IllegalArgumentException { - String stringValue = validateQueryParameter(parameterMap, key); - try { - return BLSSignature.fromHexString(stringValue); - } catch (IllegalArgumentException ex) { - throw new IllegalArgumentException(INVALID_BYTES96_DATA); - } - } - - public static Optional getParameterValueAsUInt64IfPresent( - final Map> parameterMap, final String key) { - try { - return parameterMap.containsKey(key) - ? Optional.of( - tech.pegasys.teku.infrastructure.restapi.endpoints.SingleQueryParameterUtils - .getParameterValueAsUInt64(parameterMap, key)) - : Optional.empty(); - } catch (IllegalArgumentException ex) { - throw new BadRequestException( - "Invalid value for " + key + ": " + String.join(",", parameterMap.get(key))); - } - } -} diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetBlindedBlock.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetBlindedBlock.java index 16ef43ba735..1dadb0fd9ac 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetBlindedBlock.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetBlindedBlock.java @@ -29,7 +29,6 @@ import java.util.Optional; import tech.pegasys.teku.api.ChainDataProvider; import tech.pegasys.teku.api.DataProvider; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.json.types.SerializableTypeDefinition; import tech.pegasys.teku.infrastructure.restapi.endpoints.AsyncApiResponse; @@ -87,7 +86,7 @@ public void handleRequest(final RestApiRequest request) throws JsonProcessingExc blockAndMetaData -> { request.header( HEADER_CONSENSUS_VERSION, - Version.fromMilestone(blockAndMetaData.getMilestone()).name()); + blockAndMetaData.getMilestone().lowerCaseName()); return AsyncApiResponse.respondOk(blockAndMetaData); }) .orElseGet(AsyncApiResponse::respondNotFound))); diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetBlobSidecars.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetBlobSidecars.java index 45754ed33fe..dc5055fe88e 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetBlobSidecars.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetBlobSidecars.java @@ -31,7 +31,6 @@ import java.util.Optional; import tech.pegasys.teku.api.ChainDataProvider; import tech.pegasys.teku.api.DataProvider; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.json.types.DeserializableTypeDefinition; import tech.pegasys.teku.infrastructure.json.types.SerializableTypeDefinition; @@ -100,7 +99,7 @@ public void handleRequest(final RestApiRequest request) throws JsonProcessingExc blobSidecarsAndMetaData -> { request.header( HEADER_CONSENSUS_VERSION, - Version.fromMilestone(blobSidecarsAndMetaData.getMilestone()).name()); + blobSidecarsAndMetaData.getMilestone().lowerCaseName()); return AsyncApiResponse.respondOk(blobSidecarsAndMetaData); }) .orElse(AsyncApiResponse.respondNotFound()))); diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetFinalizedCheckpointState.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetFinalizedCheckpointState.java index 946f4f94f52..22d17aac60a 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetFinalizedCheckpointState.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetFinalizedCheckpointState.java @@ -23,7 +23,6 @@ import java.util.Optional; import tech.pegasys.teku.api.ChainDataProvider; import tech.pegasys.teku.api.DataProvider; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.restapi.endpoints.AsyncApiResponse; import tech.pegasys.teku.infrastructure.restapi.endpoints.EndpointMetadata; @@ -77,7 +76,7 @@ public void handleRequest(final RestApiRequest request) throws JsonProcessingExc stateAndMetaData -> { request.header( HEADER_CONSENSUS_VERSION, - Version.fromMilestone(stateAndMetaData.getMilestone()).name()); + stateAndMetaData.getMilestone().lowerCaseName()); return AsyncApiResponse.respondOk(stateAndMetaData.getData()); }) .orElseGet(AsyncApiResponse::respondNotFound))); diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStatePendingConsolidations.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStatePendingConsolidations.java index b4dbac7ec00..a299b6c995e 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStatePendingConsolidations.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStatePendingConsolidations.java @@ -30,7 +30,6 @@ import java.util.Optional; import tech.pegasys.teku.api.ChainDataProvider; import tech.pegasys.teku.api.DataProvider; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.json.types.SerializableTypeDefinition; import tech.pegasys.teku.infrastructure.restapi.endpoints.AsyncApiResponse; @@ -92,7 +91,7 @@ public void handleRequest(final RestApiRequest request) throws JsonProcessingExc objectAndMetadata -> { request.header( HEADER_CONSENSUS_VERSION, - Version.fromMilestone(objectAndMetadata.getMilestone()).name()); + objectAndMetadata.getMilestone().lowerCaseName()); return AsyncApiResponse.respondOk(objectAndMetadata); }) .orElseGet(AsyncApiResponse::respondNotFound))); diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStatePendingDeposits.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStatePendingDeposits.java index ab4159cdfb4..2491052f3e1 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStatePendingDeposits.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStatePendingDeposits.java @@ -30,7 +30,6 @@ import java.util.Optional; import tech.pegasys.teku.api.ChainDataProvider; import tech.pegasys.teku.api.DataProvider; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.json.types.SerializableTypeDefinition; import tech.pegasys.teku.infrastructure.restapi.endpoints.AsyncApiResponse; @@ -90,7 +89,7 @@ public void handleRequest(final RestApiRequest request) throws JsonProcessingExc objectAndMetadata -> { request.header( HEADER_CONSENSUS_VERSION, - Version.fromMilestone(objectAndMetadata.getMilestone()).name()); + objectAndMetadata.getMilestone().lowerCaseName()); return AsyncApiResponse.respondOk(objectAndMetadata); }) .orElseGet(AsyncApiResponse::respondNotFound))); diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStatePendingPartialWithdrawals.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStatePendingPartialWithdrawals.java index 911ab916601..a8708ae252e 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStatePendingPartialWithdrawals.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStatePendingPartialWithdrawals.java @@ -30,7 +30,6 @@ import java.util.Optional; import tech.pegasys.teku.api.ChainDataProvider; import tech.pegasys.teku.api.DataProvider; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.json.types.SerializableTypeDefinition; import tech.pegasys.teku.infrastructure.restapi.endpoints.AsyncApiResponse; @@ -92,7 +91,7 @@ public void handleRequest(final RestApiRequest request) throws JsonProcessingExc objectAndMetadata -> { request.header( HEADER_CONSENSUS_VERSION, - Version.fromMilestone(objectAndMetadata.getMilestone()).name()); + objectAndMetadata.getMilestone().lowerCaseName()); return AsyncApiResponse.respondOk(objectAndMetadata); }) .orElseGet(AsyncApiResponse::respondNotFound))); diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStateValidators.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStateValidators.java index 8804784ceca..cba2511af24 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStateValidators.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStateValidators.java @@ -27,7 +27,7 @@ import java.util.Set; import tech.pegasys.teku.api.ChainDataProvider; import tech.pegasys.teku.api.DataProvider; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.ethereum.json.types.beacon.StateValidatorData; import tech.pegasys.teku.ethereum.json.types.beacon.StatusParameter; import tech.pegasys.teku.infrastructure.async.SafeFuture; diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/PostStateValidators.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/PostStateValidators.java index a73fa027208..5d9e8fcc0d1 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/PostStateValidators.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/PostStateValidators.java @@ -29,7 +29,7 @@ import java.util.Set; import tech.pegasys.teku.api.ChainDataProvider; import tech.pegasys.teku.api.DataProvider; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.ethereum.json.types.beacon.StateValidatorData; import tech.pegasys.teku.ethereum.json.types.beacon.StateValidatorRequestBodyType; import tech.pegasys.teku.ethereum.json.types.beacon.StatusParameter; diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/lightclient/GetLightClientBootstrap.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/lightclient/GetLightClientBootstrap.java index 8c1d178bdc4..94fd065b472 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/lightclient/GetLightClientBootstrap.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/lightclient/GetLightClientBootstrap.java @@ -26,7 +26,6 @@ import org.apache.tuweni.bytes.Bytes32; import tech.pegasys.teku.api.ChainDataProvider; import tech.pegasys.teku.api.DataProvider; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.json.types.SerializableTypeDefinition; import tech.pegasys.teku.infrastructure.restapi.endpoints.AsyncApiResponse; @@ -86,7 +85,7 @@ public void handleRequest(final RestApiRequest request) throws JsonProcessingExc bootstrapAndMetadata -> { request.header( HEADER_CONSENSUS_VERSION, - Version.fromMilestone(bootstrapAndMetadata.getMilestone()).name()); + bootstrapAndMetadata.getMilestone().lowerCaseName()); return AsyncApiResponse.respondOk(bootstrapAndMetadata); }) .orElseGet(AsyncApiResponse::respondNotFound))); diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/EventSubscriber.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/EventSubscriber.java index 119c475fe4d..ec60e88e141 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/EventSubscriber.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/EventSubscriber.java @@ -26,7 +26,7 @@ import java.util.concurrent.atomic.AtomicLong; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import tech.pegasys.teku.api.response.v1.EventType; +import tech.pegasys.teku.api.response.EventType; import tech.pegasys.teku.beaconrestapi.handlers.v1.events.EventSubscriptionManager.EventSource; import tech.pegasys.teku.infrastructure.async.AsyncRunner; import tech.pegasys.teku.infrastructure.time.TimeProvider; diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/EventSubscriptionManager.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/EventSubscriptionManager.java index 34e59a506ea..e898c703157 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/EventSubscriptionManager.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/EventSubscriptionManager.java @@ -30,7 +30,7 @@ import tech.pegasys.teku.api.ConfigProvider; import tech.pegasys.teku.api.NodeDataProvider; import tech.pegasys.teku.api.SyncDataProvider; -import tech.pegasys.teku.api.response.v1.EventType; +import tech.pegasys.teku.api.response.EventType; import tech.pegasys.teku.beacon.sync.events.SyncState; import tech.pegasys.teku.infrastructure.async.AsyncRunner; import tech.pegasys.teku.infrastructure.events.EventChannels; diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/QueuedEvent.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/QueuedEvent.java index db6c72662e9..fc0b8f89780 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/QueuedEvent.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/QueuedEvent.java @@ -15,7 +15,7 @@ import java.util.Objects; import org.apache.tuweni.bytes.Bytes; -import tech.pegasys.teku.api.response.v1.EventType; +import tech.pegasys.teku.api.response.EventType; public class QueuedEvent { private final EventType eventType; diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/GetAttestationsV2.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/GetAttestationsV2.java index cf48d532c32..16edeb75433 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/GetAttestationsV2.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/GetAttestationsV2.java @@ -32,7 +32,6 @@ import java.util.Optional; import tech.pegasys.teku.api.DataProvider; import tech.pegasys.teku.api.NodeDataProvider; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.beaconrestapi.handlers.v1.beacon.MilestoneDependentTypesUtil; import tech.pegasys.teku.infrastructure.json.types.SerializableTypeDefinition; import tech.pegasys.teku.infrastructure.restapi.endpoints.EndpointMetadata; @@ -88,8 +87,7 @@ public void handleRequest(final RestApiRequest request) throws JsonProcessingExc nodeDataProvider.getAttestationsAndMetaData(slot, committeeIndex); request.header( - HEADER_CONSENSUS_VERSION, - Version.fromMilestone(attestationsAndMetaData.getMilestone()).name()); + HEADER_CONSENSUS_VERSION, attestationsAndMetaData.getMilestone().lowerCaseName()); request.respondOk(attestationsAndMetaData); } diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/GetBlock.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/GetBlock.java index b4fdd948f0d..7bcb12e8535 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/GetBlock.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/GetBlock.java @@ -28,7 +28,6 @@ import java.util.Optional; import tech.pegasys.teku.api.ChainDataProvider; import tech.pegasys.teku.api.DataProvider; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.json.types.SerializableTypeDefinition; import tech.pegasys.teku.infrastructure.restapi.endpoints.AsyncApiResponse; @@ -83,7 +82,7 @@ public void handleRequest(final RestApiRequest request) throws JsonProcessingExc blockAndMetaData -> { request.header( HEADER_CONSENSUS_VERSION, - Version.fromMilestone(blockAndMetaData.getMilestone()).name()); + blockAndMetaData.getMilestone().lowerCaseName()); return AsyncApiResponse.respondOk(blockAndMetaData); }) .orElseGet(AsyncApiResponse::respondNotFound))); diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/GetBlockAttestationsV2.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/GetBlockAttestationsV2.java index 3f340a55254..17854c98ee8 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/GetBlockAttestationsV2.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/GetBlockAttestationsV2.java @@ -30,7 +30,6 @@ import java.util.function.Predicate; import tech.pegasys.teku.api.ChainDataProvider; import tech.pegasys.teku.api.DataProvider; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.beaconrestapi.BeaconRestApiTypes; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.json.types.SerializableOneOfTypeDefinition; @@ -88,7 +87,7 @@ public void handleRequest(final RestApiRequest request) throws JsonProcessingExc attestationsAndMetadata -> { request.header( HEADER_CONSENSUS_VERSION, - Version.fromMilestone(attestationsAndMetadata.getMilestone()).name()); + attestationsAndMetadata.getMilestone().lowerCaseName()); return AsyncApiResponse.respondOk(attestationsAndMetadata); }) .orElseGet(AsyncApiResponse::respondNotFound))); diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/debug/GetState.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/debug/GetState.java index 1e51b67ac18..7b124c2d840 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/debug/GetState.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/debug/GetState.java @@ -29,7 +29,6 @@ import java.util.Optional; import tech.pegasys.teku.api.ChainDataProvider; import tech.pegasys.teku.api.DataProvider; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.json.types.SerializableTypeDefinition; import tech.pegasys.teku.infrastructure.restapi.endpoints.AsyncApiResponse; @@ -87,7 +86,7 @@ public void handleRequest(final RestApiRequest request) throws JsonProcessingExc stateAndMetaData -> { request.header( HEADER_CONSENSUS_VERSION, - Version.fromMilestone(stateAndMetaData.getMilestone()).name()); + stateAndMetaData.getMilestone().lowerCaseName()); return AsyncApiResponse.respondOk(stateAndMetaData); }) .orElseGet(AsyncApiResponse::respondNotFound))); diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/validator/GetAggregateAttestationV2.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/validator/GetAggregateAttestationV2.java index 8177b6b4cfb..0a7cd3bc587 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/validator/GetAggregateAttestationV2.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/validator/GetAggregateAttestationV2.java @@ -28,7 +28,6 @@ import org.apache.tuweni.bytes.Bytes32; import tech.pegasys.teku.api.DataProvider; import tech.pegasys.teku.api.ValidatorDataProvider; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.beaconrestapi.BeaconRestApiTypes; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.http.HttpStatusCodes; @@ -101,7 +100,7 @@ public void handleRequest(final RestApiRequest request) throws JsonProcessingExc attestationAndMetaData -> { request.header( HEADER_CONSENSUS_VERSION, - Version.fromMilestone(attestationAndMetaData.getMilestone()).name()); + attestationAndMetaData.getMilestone().lowerCaseName()); return AsyncApiResponse.respondOk(attestationAndMetaData); }) .orElseGet(AsyncApiResponse::respondNotFound))); diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v3/validator/GetNewBlockV3.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v3/validator/GetNewBlockV3.java index 01fa2669747..4e6b8325b8c 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v3/validator/GetNewBlockV3.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v3/validator/GetNewBlockV3.java @@ -47,7 +47,6 @@ import org.apache.tuweni.bytes.Bytes32; import tech.pegasys.teku.api.DataProvider; import tech.pegasys.teku.api.ValidatorDataProvider; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.beaconrestapi.handlers.v1.beacon.MilestoneDependentTypesUtil; import tech.pegasys.teku.bls.BLSSignature; import tech.pegasys.teku.infrastructure.async.SafeFuture; @@ -131,8 +130,7 @@ public void handleRequest(final RestApiRequest request) throws JsonProcessingExc blockContainerAndMetaData -> { request.header( HEADER_CONSENSUS_VERSION, - Version.fromMilestone(blockContainerAndMetaData.specMilestone()) - .name()); + blockContainerAndMetaData.specMilestone().lowerCaseName()); request.header( HEADER_EXECUTION_PAYLOAD_BLINDED, Boolean.toString( diff --git a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/SingleQueryParameterUtilsTest.java b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/SingleQueryParameterUtilsTest.java deleted file mode 100644 index b81dd9632fa..00000000000 --- a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/SingleQueryParameterUtilsTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2025 - * - * 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.beaconrestapi; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static tech.pegasys.teku.beaconrestapi.SingleQueryParameterUtils.getParameterValueAsBLSSignature; - -import java.util.List; -import java.util.Map; -import java.util.Optional; -import org.apache.tuweni.bytes.Bytes; -import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.schema.BLSSignature; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; - -public class SingleQueryParameterUtilsTest { - - public static final String KEY = "any"; - public static final String VALUE = "1"; - public static final Map> INVALID_DATA = Map.of(KEY, List.of("1.5")); - - @Test - public void getParameterAsBLSSignature_shouldThrowIfCannotParse() { - assertThrows( - IllegalArgumentException.class, () -> getParameterValueAsBLSSignature(INVALID_DATA, KEY)); - } - - @Test - public void getParameterAsBLSSignature_shouldParseBytes96Data() { - BLSSignature signature = new BLSSignature(Bytes.random(96)); - Map> data = Map.of(KEY, List.of(signature.toHexString())); - BLSSignature result = getParameterValueAsBLSSignature(data, KEY); - assertEquals(signature, result); - } - - @Test - public void getParameterAsUInt64IfPresent_shouldReturnEmptyIfNotPresent() { - assertThat(SingleQueryParameterUtils.getParameterValueAsUInt64IfPresent(Map.of(), "t")) - .isEmpty(); - } - - @Test - public void getParameterAsUInt64IfPresent_shouldReturnData() { - final UInt64 value = UInt64.valueOf("123456"); - assertThat( - SingleQueryParameterUtils.getParameterValueAsUInt64IfPresent( - Map.of("t", List.of(value.toString())), "t")) - .isEqualTo(Optional.of(value)); - } -} diff --git a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetBlobSidecarsTest.java b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetBlobSidecarsTest.java index 6ccb5930f47..461f690a015 100644 --- a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetBlobSidecarsTest.java +++ b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetBlobSidecarsTest.java @@ -34,7 +34,6 @@ import java.util.concurrent.ExecutionException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerWithChainDataProviderTest; import tech.pegasys.teku.infrastructure.json.JsonTestUtil; import tech.pegasys.teku.spec.SpecMilestone; @@ -71,7 +70,7 @@ void shouldReturnBlobSidecars() assertThat(((BlobSidecarsAndMetaData) request.getResponseBody()).getData()) .isEqualTo(blobSidecars); assertThat(request.getResponseHeaders(ETH_CONSENSUS_VERSION_TYPE.getName())) - .isEqualTo(Version.fromMilestone(SpecMilestone.DENEB).name()); + .isEqualTo(SpecMilestone.DENEB.lowerCaseName()); } @Test diff --git a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStateValidatorTest.java b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStateValidatorTest.java index 4df36217d12..2ed358f6de7 100644 --- a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStateValidatorTest.java +++ b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStateValidatorTest.java @@ -33,7 +33,7 @@ import org.assertj.core.api.AssertionsForClassTypes; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerWithChainDataProviderTest; import tech.pegasys.teku.ethereum.json.types.beacon.StateValidatorData; import tech.pegasys.teku.infrastructure.http.HttpErrorResponse; diff --git a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStateValidatorsTest.java b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStateValidatorsTest.java index 0daa13ee037..d575699643d 100644 --- a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStateValidatorsTest.java +++ b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/GetStateValidatorsTest.java @@ -17,15 +17,15 @@ import static java.util.Collections.emptySet; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus.active_exiting; -import static tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus.active_ongoing; -import static tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus.active_slashed; -import static tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus.exited_slashed; -import static tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus.exited_unslashed; -import static tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus.pending_initialized; -import static tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus.pending_queued; -import static tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus.withdrawal_done; -import static tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus.withdrawal_possible; +import static tech.pegasys.teku.api.response.ValidatorStatus.active_exiting; +import static tech.pegasys.teku.api.response.ValidatorStatus.active_ongoing; +import static tech.pegasys.teku.api.response.ValidatorStatus.active_slashed; +import static tech.pegasys.teku.api.response.ValidatorStatus.exited_slashed; +import static tech.pegasys.teku.api.response.ValidatorStatus.exited_unslashed; +import static tech.pegasys.teku.api.response.ValidatorStatus.pending_initialized; +import static tech.pegasys.teku.api.response.ValidatorStatus.pending_queued; +import static tech.pegasys.teku.api.response.ValidatorStatus.withdrawal_done; +import static tech.pegasys.teku.api.response.ValidatorStatus.withdrawal_possible; import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_BAD_REQUEST; import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_INTERNAL_SERVER_ERROR; import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_NOT_FOUND; @@ -50,7 +50,7 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import tech.pegasys.teku.api.exceptions.BadRequestException; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerWithChainDataProviderTest; import tech.pegasys.teku.ethereum.json.types.beacon.StateValidatorData; import tech.pegasys.teku.ethereum.json.types.beacon.StatusParameter; diff --git a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/PostStateValidatorsTest.java b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/PostStateValidatorsTest.java index 6fb44313c12..9ef7ad92619 100644 --- a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/PostStateValidatorsTest.java +++ b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/beacon/PostStateValidatorsTest.java @@ -17,15 +17,15 @@ import static java.util.Collections.emptySet; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus.active_exiting; -import static tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus.active_ongoing; -import static tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus.active_slashed; -import static tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus.exited_slashed; -import static tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus.exited_unslashed; -import static tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus.pending_initialized; -import static tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus.pending_queued; -import static tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus.withdrawal_done; -import static tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus.withdrawal_possible; +import static tech.pegasys.teku.api.response.ValidatorStatus.active_exiting; +import static tech.pegasys.teku.api.response.ValidatorStatus.active_ongoing; +import static tech.pegasys.teku.api.response.ValidatorStatus.active_slashed; +import static tech.pegasys.teku.api.response.ValidatorStatus.exited_slashed; +import static tech.pegasys.teku.api.response.ValidatorStatus.exited_unslashed; +import static tech.pegasys.teku.api.response.ValidatorStatus.pending_initialized; +import static tech.pegasys.teku.api.response.ValidatorStatus.pending_queued; +import static tech.pegasys.teku.api.response.ValidatorStatus.withdrawal_done; +import static tech.pegasys.teku.api.response.ValidatorStatus.withdrawal_possible; import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_BAD_REQUEST; import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_INTERNAL_SERVER_ERROR; import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_NOT_FOUND; @@ -51,7 +51,7 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import tech.pegasys.teku.api.exceptions.BadRequestException; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerWithChainDataProviderTest; import tech.pegasys.teku.ethereum.json.types.beacon.StateValidatorData; import tech.pegasys.teku.ethereum.json.types.beacon.StateValidatorRequestBodyType; diff --git a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/EventSubscriberTest.java b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/EventSubscriberTest.java index 43d112b2ea7..16aea24d1e6 100644 --- a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/EventSubscriberTest.java +++ b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/EventSubscriberTest.java @@ -36,7 +36,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; -import tech.pegasys.teku.api.response.v1.EventType; +import tech.pegasys.teku.api.response.EventType; import tech.pegasys.teku.beaconrestapi.handlers.v1.events.EventSubscriptionManager.EventSource; import tech.pegasys.teku.infrastructure.async.StubAsyncRunner; import tech.pegasys.teku.infrastructure.time.StubTimeProvider; diff --git a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/EventSubscriptionManagerTest.java b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/EventSubscriptionManagerTest.java index 8d41dfab7c6..4ba60978b88 100644 --- a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/EventSubscriptionManagerTest.java +++ b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/EventSubscriptionManagerTest.java @@ -33,7 +33,6 @@ import tech.pegasys.teku.api.ConfigProvider; import tech.pegasys.teku.api.NodeDataProvider; import tech.pegasys.teku.api.SyncDataProvider; -import tech.pegasys.teku.api.schema.SignedBeaconBlock; import tech.pegasys.teku.beacon.sync.events.SyncState; import tech.pegasys.teku.beaconrestapi.handlers.v1.events.PayloadAttributesEvent.Data; import tech.pegasys.teku.beaconrestapi.handlers.v1.events.PayloadAttributesEvent.PayloadAttributes; @@ -50,6 +49,7 @@ import tech.pegasys.teku.spec.config.SpecConfig; import tech.pegasys.teku.spec.datastructures.attestation.ValidatableAttestation; import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar; +import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; import tech.pegasys.teku.spec.datastructures.operations.Attestation; import tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing; import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing; @@ -104,8 +104,7 @@ public class EventSubscriptionManagerTest { new FinalizedCheckpointEvent(data.randomBytes32(), data.randomBytes32(), epoch, false); private final SyncState sampleSyncState = SyncState.IN_SYNC; - private final SignedBeaconBlock sampleBlock = - SignedBeaconBlock.create(data.randomSignedBeaconBlock(0)); + private final SignedBeaconBlock sampleBlock = data.randomSignedBeaconBlock(0); private final BlobSidecar sampleBlobSidecar = data.randomBlobSidecar(); private final Attestation sampleAttestation = data.randomAttestation(0); private final SingleAttestation singleAttestation = data.randomSingleAttestation(); @@ -257,7 +256,7 @@ void shouldPropagateBlock() throws IOException { manager.registerClient(client1); triggerBlockEvent(); - checkEvent("block", new BlockEvent(sampleBlock.asInternalSignedBeaconBlock(spec), false)); + checkEvent("block", new BlockEvent(sampleBlock, false)); } @Test @@ -266,7 +265,7 @@ void shouldPropagateBlockGossip() throws IOException { manager.registerClient(client1); triggerBlockGossipEvent(); - checkEvent("block_gossip", new BlockGossipEvent(sampleBlock.asInternalSignedBeaconBlock(spec))); + checkEvent("block_gossip", new BlockGossipEvent(sampleBlock)); } @Test @@ -465,12 +464,12 @@ private void triggerProposerSlashingEvent() { } private void triggerBlockEvent() { - manager.onNewBlock(sampleBlock.asInternalSignedBeaconBlock(spec), false); + manager.onNewBlock(sampleBlock, false); asyncRunner.executeQueuedActions(); } private void triggerBlockGossipEvent() { - manager.onNewBlockGossip(sampleBlock.asInternalSignedBeaconBlock(spec)); + manager.onNewBlockGossip(sampleBlock); asyncRunner.executeQueuedActions(); } diff --git a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/GetAttestationsV2Test.java b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/GetAttestationsV2Test.java index e2e851217bb..96c577a7bbb 100644 --- a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/GetAttestationsV2Test.java +++ b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/GetAttestationsV2Test.java @@ -34,7 +34,6 @@ import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestTemplate; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerTest; import tech.pegasys.teku.infrastructure.json.JsonTestUtil; import tech.pegasys.teku.spec.SpecMilestone; @@ -72,7 +71,7 @@ public void shouldReturnAttestationsWhenFound() throws JsonProcessingException { assertThat(request.getResponseCode()).isEqualTo(SC_OK); assertThat(request.getResponseBody()).isEqualTo(attestationsAndMetaData); assertThat(request.getResponseHeaders(HEADER_CONSENSUS_VERSION)) - .isEqualTo(Version.fromMilestone(specMilestone).name()); + .isEqualTo(specMilestone.lowerCaseName()); } @TestTemplate @@ -87,7 +86,7 @@ public void shouldReturnEmptyListWhenNoAttestations() throws JsonProcessingExcep assertThat(request.getResponseCode()).isEqualTo(SC_OK); assertThat(request.getResponseBody()).isEqualTo(attestationsAndMetaData); assertThat(request.getResponseHeaders(HEADER_CONSENSUS_VERSION)) - .isEqualTo(Version.fromMilestone(specMilestone).name()); + .isEqualTo(specMilestone.lowerCaseName()); } @TestTemplate diff --git a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/GetBlockAttestationsV2Test.java b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/GetBlockAttestationsV2Test.java index 2ae84ded641..898ef9e6f1b 100644 --- a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/GetBlockAttestationsV2Test.java +++ b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/GetBlockAttestationsV2Test.java @@ -33,7 +33,6 @@ import java.util.Optional; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerTest; import tech.pegasys.teku.ethereum.json.types.SharedApiTypes; import tech.pegasys.teku.infrastructure.async.SafeFuture; @@ -95,7 +94,7 @@ public void shouldReturnBlockAttestationsInformationForPhase0() throws JsonProce assertThat(phase0responseData.getData().size()).isGreaterThan(0); assertThat(request.getResponseBody()).isEqualTo(optionalData.get()); assertThat(request.getResponseHeaders(HEADER_CONSENSUS_VERSION)) - .isEqualTo(Version.fromMilestone(phase0responseData.getMilestone()).name()); + .isEqualTo(phase0responseData.getMilestone().lowerCaseName()); } @Test @@ -111,7 +110,7 @@ public void shouldReturnBlockAttestationsInformationForElectra() throws JsonProc assertThat(electraResponseData.getData().size()).isGreaterThan(0); assertThat(request.getResponseBody()).isEqualTo(optionalData.get()); assertThat(request.getResponseHeaders(HEADER_CONSENSUS_VERSION)) - .isEqualTo(Version.fromMilestone(electraResponseData.getMilestone()).name()); + .isEqualTo(electraResponseData.getMilestone().lowerCaseName()); } @Test diff --git a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v2/validator/GetAggregateAttestationV2Test.java b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v2/validator/GetAggregateAttestationV2Test.java index eba88c8a8a5..8018966ea9f 100644 --- a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v2/validator/GetAggregateAttestationV2Test.java +++ b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v2/validator/GetAggregateAttestationV2Test.java @@ -31,7 +31,6 @@ import org.apache.tuweni.bytes.Bytes32; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerTest; import tech.pegasys.teku.ethereum.json.types.SharedApiTypes; import tech.pegasys.teku.infrastructure.async.SafeFuture; @@ -94,7 +93,7 @@ public void shouldReturnAggregateAttestationForPhase0() throws JsonProcessingExc assertThat(phase0responseData.getData().size()).isGreaterThan(0); assertThat(request.getResponseBody()).isEqualTo(optionalData.get()); assertThat(request.getResponseHeaders(HEADER_CONSENSUS_VERSION)) - .isEqualTo(Version.fromMilestone(phase0responseData.getMilestone()).name()); + .isEqualTo(phase0responseData.getMilestone().lowerCaseName()); } @Test @@ -109,7 +108,7 @@ public void shouldReturnAggregateAttestationForElectra() throws JsonProcessingEx assertThat(electraResponseData.getData().size()).isGreaterThan(0); assertThat(request.getResponseBody()).isEqualTo(optionalData.get()); assertThat(request.getResponseHeaders(HEADER_CONSENSUS_VERSION)) - .isEqualTo(Version.fromMilestone(electraResponseData.getMilestone()).name()); + .isEqualTo(electraResponseData.getMilestone().lowerCaseName()); } @Test diff --git a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v3/validator/GetNewBlockV3Test.java b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v3/validator/GetNewBlockV3Test.java index dc457ead4a0..eb2c0419d21 100644 --- a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v3/validator/GetNewBlockV3Test.java +++ b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v3/validator/GetNewBlockV3Test.java @@ -36,7 +36,6 @@ import java.util.Optional; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestTemplate; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerTest; import tech.pegasys.teku.bls.BLSSignature; import tech.pegasys.teku.bls.BLSTestUtil; @@ -82,7 +81,7 @@ void shouldHandleBlindedBeaconBlocks() throws Exception { assertThat(request.getResponseCode()).isEqualTo(HttpStatusCodes.SC_OK); assertThat(request.getResponseBody()).isEqualTo(blockContainerAndMetaData); assertThat(request.getResponseHeaders(HEADER_CONSENSUS_VERSION)) - .isEqualTo(Version.fromMilestone(blockContainerAndMetaData.specMilestone()).name()); + .isEqualTo(blockContainerAndMetaData.specMilestone().lowerCaseName()); assertThat(request.getResponseHeaders(HEADER_EXECUTION_PAYLOAD_BLINDED)) .isEqualTo(Boolean.toString(true)); assertThat(request.getResponseHeaders(HEADER_EXECUTION_PAYLOAD_VALUE)) @@ -105,7 +104,7 @@ void shouldHandleUnBlindedBeaconBlocks() throws Exception { assertThat(request.getResponseCode()).isEqualTo(HttpStatusCodes.SC_OK); assertThat(request.getResponseBody()).isEqualTo(blockContainerAndMetaData); assertThat(request.getResponseHeaders(HEADER_CONSENSUS_VERSION)) - .isEqualTo(Version.fromMilestone(blockContainerAndMetaData.specMilestone()).name()); + .isEqualTo(blockContainerAndMetaData.specMilestone().lowerCaseName()); assertThat(request.getResponseHeaders(HEADER_EXECUTION_PAYLOAD_BLINDED)) .isEqualTo(Boolean.toString(false)); assertThat(request.getResponseHeaders(HEADER_EXECUTION_PAYLOAD_VALUE)) @@ -129,7 +128,7 @@ void shouldHandleUnBlindedBlockContentsPostDeneb() throws Exception { assertThat(request.getResponseCode()).isEqualTo(HttpStatusCodes.SC_OK); assertThat(request.getResponseBody()).isEqualTo(blockContainerAndMetaData); assertThat(request.getResponseHeaders(HEADER_CONSENSUS_VERSION)) - .isEqualTo(Version.fromMilestone(blockContainerAndMetaData.specMilestone()).name()); + .isEqualTo(blockContainerAndMetaData.specMilestone().lowerCaseName()); assertThat(request.getResponseHeaders(HEADER_EXECUTION_PAYLOAD_BLINDED)).isEqualTo("false"); assertThat(request.getResponseHeaders(HEADER_EXECUTION_PAYLOAD_VALUE)) .isEqualTo(blockContainerAndMetaData.executionPayloadValue().toDecimalString()); diff --git a/data/dataexchange/src/main/java/tech/pegasys/teku/data/SlashingProtectionExporter.java b/data/dataexchange/src/main/java/tech/pegasys/teku/data/SlashingProtectionExporter.java index d55a8d4c7a4..ee71f7af50f 100644 --- a/data/dataexchange/src/main/java/tech/pegasys/teku/data/SlashingProtectionExporter.java +++ b/data/dataexchange/src/main/java/tech/pegasys/teku/data/SlashingProtectionExporter.java @@ -31,7 +31,7 @@ import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.bytes.Bytes48; -import tech.pegasys.teku.api.schema.PublicKeyException; +import tech.pegasys.teku.api.exceptions.PublicKeyException; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.data.slashinginterchange.Metadata; import tech.pegasys.teku.data.slashinginterchange.SigningHistory; diff --git a/data/dataexchange/src/main/java/tech/pegasys/teku/data/SlashingProtectionRepairer.java b/data/dataexchange/src/main/java/tech/pegasys/teku/data/SlashingProtectionRepairer.java index 80ed1a0ec08..b56c0a4f27f 100644 --- a/data/dataexchange/src/main/java/tech/pegasys/teku/data/SlashingProtectionRepairer.java +++ b/data/dataexchange/src/main/java/tech/pegasys/teku/data/SlashingProtectionRepairer.java @@ -24,7 +24,7 @@ import java.util.Optional; import java.util.Set; import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.api.schema.PublicKeyException; +import tech.pegasys.teku.api.exceptions.PublicKeyException; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.data.slashinginterchange.SigningHistory; import tech.pegasys.teku.ethereum.signingrecord.ValidatorSigningRecord; diff --git a/data/provider/src/main/java/tech/pegasys/teku/api/ChainDataProvider.java b/data/provider/src/main/java/tech/pegasys/teku/api/ChainDataProvider.java index a1b7a1cb91c..b71aeb33673 100644 --- a/data/provider/src/main/java/tech/pegasys/teku/api/ChainDataProvider.java +++ b/data/provider/src/main/java/tech/pegasys/teku/api/ChainDataProvider.java @@ -44,8 +44,8 @@ import tech.pegasys.teku.api.migrated.StateSyncCommitteesData; import tech.pegasys.teku.api.migrated.StateValidatorBalanceData; import tech.pegasys.teku.api.migrated.SyncCommitteeRewardData; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.api.response.v1.beacon.GenesisData; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; import tech.pegasys.teku.api.rewards.EpochAttestationRewardsCalculator; import tech.pegasys.teku.api.stateselector.StateSelectorFactory; import tech.pegasys.teku.bls.BLSPublicKey; diff --git a/data/provider/src/main/java/tech/pegasys/teku/api/ConfigProvider.java b/data/provider/src/main/java/tech/pegasys/teku/api/ConfigProvider.java index cb517e3b81f..85209fe4a61 100644 --- a/data/provider/src/main/java/tech/pegasys/teku/api/ConfigProvider.java +++ b/data/provider/src/main/java/tech/pegasys/teku/api/ConfigProvider.java @@ -16,11 +16,10 @@ import java.util.List; import java.util.Map; import org.apache.tuweni.units.bigints.UInt256; -import tech.pegasys.teku.api.response.v1.config.GetForkScheduleResponse; -import tech.pegasys.teku.api.schema.Fork; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.Spec; import tech.pegasys.teku.spec.config.SpecConfig; +import tech.pegasys.teku.spec.datastructures.state.Fork; public class ConfigProvider { final Spec spec; @@ -49,12 +48,7 @@ public static String formatValue(final Object v) { return v.toString(); } - public GetForkScheduleResponse getForkSchedule() { - final List forkList = spec.getForkSchedule().getForks().stream().map(Fork::new).toList(); - return new GetForkScheduleResponse(forkList); - } - - public List getStateForkSchedule() { + public List getStateForkSchedule() { return spec.getForkSchedule().getFullForkList(); } diff --git a/data/provider/src/main/java/tech/pegasys/teku/api/SchemaObjectProvider.java b/data/provider/src/main/java/tech/pegasys/teku/api/SchemaObjectProvider.java deleted file mode 100644 index 414e186caaa..00000000000 --- a/data/provider/src/main/java/tech/pegasys/teku/api/SchemaObjectProvider.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2025 - * - * 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.api; - -import tech.pegasys.teku.api.schema.BeaconBlock; -import tech.pegasys.teku.api.schema.BeaconBlockBody; -import tech.pegasys.teku.api.schema.altair.BeaconBlockAltair; -import tech.pegasys.teku.api.schema.altair.BeaconBlockBodyAltair; -import tech.pegasys.teku.api.schema.bellatrix.BeaconBlockBellatrix; -import tech.pegasys.teku.api.schema.bellatrix.BeaconBlockBodyBellatrix; -import tech.pegasys.teku.api.schema.bellatrix.BlindedBeaconBlockBodyBellatrix; -import tech.pegasys.teku.api.schema.bellatrix.BlindedBlockBellatrix; -import tech.pegasys.teku.api.schema.capella.BeaconBlockBodyCapella; -import tech.pegasys.teku.api.schema.capella.BeaconBlockCapella; -import tech.pegasys.teku.api.schema.capella.BlindedBeaconBlockBodyCapella; -import tech.pegasys.teku.api.schema.capella.BlindedBlockCapella; -import tech.pegasys.teku.api.schema.deneb.BeaconBlockBodyDeneb; -import tech.pegasys.teku.api.schema.deneb.BeaconBlockDeneb; -import tech.pegasys.teku.api.schema.deneb.BlindedBeaconBlockBodyDeneb; -import tech.pegasys.teku.api.schema.deneb.BlindedBlockDeneb; -import tech.pegasys.teku.api.schema.electra.BeaconBlockBodyElectra; -import tech.pegasys.teku.api.schema.electra.BeaconBlockElectra; -import tech.pegasys.teku.api.schema.electra.BlindedBeaconBlockBodyElectra; -import tech.pegasys.teku.api.schema.electra.BlindedBlockElectra; -import tech.pegasys.teku.api.schema.phase0.BeaconBlockPhase0; -import tech.pegasys.teku.spec.Spec; -import tech.pegasys.teku.spec.SpecMilestone; - -/** - * Takes objects from Internal layers and converts to an appropriate schema object. - * - *

Handles slot sensitive conversions like conversion of blocks to phase0 or altair blocks - */ -public class SchemaObjectProvider { - final Spec spec; - - public SchemaObjectProvider(final Spec spec) { - this.spec = spec; - } - - public BeaconBlock getBeaconBlock( - final tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock block) { - return getBeaconBlock(block, spec.atSlot(block.getSlot()).getMilestone()); - } - - public BeaconBlock getBlindedBlock( - final tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock block) { - return getBlindedBlock(block, spec.atSlot(block.getSlot()).getMilestone()); - } - - public BeaconBlock getBlindedBlock( - final tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock block, - final SpecMilestone milestone) { - return switch (milestone) { - case PHASE0 -> - new BeaconBlockPhase0( - block.getSlot(), - block.getProposerIndex(), - block.getParentRoot(), - block.getStateRoot(), - new BeaconBlockBody(block.getBody())); - case ALTAIR -> - new BeaconBlockAltair( - block.getSlot(), - block.getProposerIndex(), - block.getParentRoot(), - block.getStateRoot(), - getBeaconBlockBodyAltair(block.getBody())); - case BELLATRIX -> - new BlindedBlockBellatrix( - block.getSlot(), - block.getProposerIndex(), - block.getParentRoot(), - block.getStateRoot(), - getBlindedBlockBodyBellatrix(block.getBody())); - case CAPELLA -> - new BlindedBlockCapella( - block.getSlot(), - block.getProposerIndex(), - block.getParentRoot(), - block.getStateRoot(), - getBlindedBlockBodyCapella(block.getBody())); - case DENEB -> - new BlindedBlockDeneb( - block.getSlot(), - block.getProposerIndex(), - block.getParentRoot(), - block.getStateRoot(), - getBlindedBlockBodyDeneb(block.getBody())); - case ELECTRA, FULU -> - new BlindedBlockElectra( - block.getSlot(), - block.getProposerIndex(), - block.getParentRoot(), - block.getStateRoot(), - getBlindedBlockBodyElectra(block.getBody())); - }; - } - - public BeaconBlock getBeaconBlock( - final tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock block, - final SpecMilestone milestone) { - return switch (milestone) { - case PHASE0 -> - new BeaconBlockPhase0( - block.getSlot(), - block.getProposerIndex(), - block.getParentRoot(), - block.getStateRoot(), - new BeaconBlockBody(block.getBody())); - case ALTAIR -> - new BeaconBlockAltair( - block.getSlot(), - block.getProposerIndex(), - block.getParentRoot(), - block.getStateRoot(), - getBeaconBlockBodyAltair(block.getBody())); - case BELLATRIX -> - new BeaconBlockBellatrix( - block.getSlot(), - block.getProposerIndex(), - block.getParentRoot(), - block.getStateRoot(), - getBeaconBlockBodyBellatrix(block.getBody())); - case CAPELLA -> - new BeaconBlockCapella( - block.getSlot(), - block.getProposerIndex(), - block.getParentRoot(), - block.getStateRoot(), - getBeaconBlockBodyCapella(block.getBody())); - case DENEB -> - new BeaconBlockDeneb( - block.getSlot(), - block.getProposerIndex(), - block.getParentRoot(), - block.getStateRoot(), - getBeaconBlockBodyDeneb(block.getBody())); - case ELECTRA, FULU -> - new BeaconBlockElectra( - block.getSlot(), - block.getProposerIndex(), - block.getParentRoot(), - block.getStateRoot(), - getBeaconBlockBodyElectra(block.getBody())); - }; - } - - private BeaconBlockBodyAltair getBeaconBlockBodyAltair( - final tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody body) { - return new BeaconBlockBodyAltair( - tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair.BeaconBlockBodyAltair - .required(body)); - } - - private BeaconBlockBodyBellatrix getBeaconBlockBodyBellatrix( - final tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody body) { - return new BeaconBlockBodyBellatrix( - tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.bellatrix - .BeaconBlockBodyBellatrix.required(body)); - } - - private BeaconBlockBodyCapella getBeaconBlockBodyCapella( - final tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody body) { - return new BeaconBlockBodyCapella( - tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.capella - .BeaconBlockBodyCapella.required(body)); - } - - private BeaconBlockBodyDeneb getBeaconBlockBodyDeneb( - final tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody body) { - return new BeaconBlockBodyDeneb( - tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.BeaconBlockBodyDeneb - .required(body)); - } - - private BeaconBlockBodyElectra getBeaconBlockBodyElectra( - final tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody body) { - return new BeaconBlockBodyElectra( - tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.electra - .BeaconBlockBodyElectra.required(body)); - } - - private BlindedBeaconBlockBodyBellatrix getBlindedBlockBodyBellatrix( - final tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody body) { - return new BlindedBeaconBlockBodyBellatrix( - tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.bellatrix - .BlindedBeaconBlockBodyBellatrix.required(body)); - } - - private BlindedBeaconBlockBodyCapella getBlindedBlockBodyCapella( - final tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody body) { - return new BlindedBeaconBlockBodyCapella( - tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.capella - .BlindedBeaconBlockBodyCapella.required(body)); - } - - private BlindedBeaconBlockBodyDeneb getBlindedBlockBodyDeneb( - final tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody body) { - return new BlindedBeaconBlockBodyDeneb( - tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb - .BlindedBeaconBlockBodyDeneb.required(body)); - } - - private BlindedBeaconBlockBodyElectra getBlindedBlockBodyElectra( - final tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody body) { - return new BlindedBeaconBlockBodyElectra( - tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.electra - .BlindedBeaconBlockBodyElectra.required(body)); - } -} diff --git a/data/provider/src/main/java/tech/pegasys/teku/api/ValidatorDataProvider.java b/data/provider/src/main/java/tech/pegasys/teku/api/ValidatorDataProvider.java index 492db3399f3..eca9db8ffd2 100644 --- a/data/provider/src/main/java/tech/pegasys/teku/api/ValidatorDataProvider.java +++ b/data/provider/src/main/java/tech/pegasys/teku/api/ValidatorDataProvider.java @@ -20,8 +20,6 @@ import java.util.Optional; import org.apache.tuweni.bytes.Bytes32; import tech.pegasys.teku.api.exceptions.BadRequestException; -import tech.pegasys.teku.api.schema.SignedBeaconBlock; -import tech.pegasys.teku.api.schema.ValidatorBlockResult; import tech.pegasys.teku.bls.BLSSignature; import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuties; import tech.pegasys.teku.ethereum.json.types.validator.ProposerDuties; @@ -44,7 +42,6 @@ import tech.pegasys.teku.spec.datastructures.operations.versions.altair.SyncCommitteeMessage; import tech.pegasys.teku.spec.datastructures.validator.BeaconPreparableProposer; import tech.pegasys.teku.spec.datastructures.validator.BroadcastValidationLevel; -import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult.FailureReason; import tech.pegasys.teku.spec.schemas.SchemaDefinitionsAltair; import tech.pegasys.teku.storage.client.ChainDataUnavailableException; import tech.pegasys.teku.storage.client.CombinedChainDataClient; @@ -63,9 +60,6 @@ public class ValidatorDataProvider { private final ValidatorApiChannel validatorApiChannel; private final CombinedChainDataClient combinedChainDataClient; - private static final int SC_INTERNAL_ERROR = 500; - private static final int SC_ACCEPTED = 202; - private static final int SC_OK = 200; private final Spec spec; public ValidatorDataProvider( @@ -136,14 +130,6 @@ public SafeFuture> submitAttestations( return validatorApiChannel.sendSignedAttestations(attestations); } - public SafeFuture submitSignedBlock( - final SignedBeaconBlock signedBeaconBlock, - final BroadcastValidationLevel broadcastValidationLevel) { - return submitSignedBlock( - signedBeaconBlock.asInternalSignedBeaconBlock(spec), broadcastValidationLevel) - .thenApply(ValidatorDataProvider::generateSubmitSignedBlockResponse); - } - public SafeFuture submitSignedBlock( final SignedBlockContainer signedBlockContainer, final BroadcastValidationLevel broadcastValidationLevel) { @@ -274,21 +260,6 @@ public boolean isPhase0Slot(final UInt64 slot) { return spec.atSlot(slot).getMilestone() == SpecMilestone.PHASE0; } - private static ValidatorBlockResult generateSubmitSignedBlockResponse( - final SendSignedBlockResult result) { - int responseCode; - Optional hashRoot = result.getBlockRoot(); - if (result.getRejectionReason().isEmpty()) { - responseCode = SC_OK; - } else if (result.getRejectionReason().get().equals(FailureReason.INTERNAL_ERROR.name())) { - responseCode = SC_INTERNAL_ERROR; - } else { - responseCode = SC_ACCEPTED; - } - - return new ValidatorBlockResult(responseCode, result.getRejectionReason(), hashRoot); - } - private ObjectAndMetaData lookUpMetadata(final Attestation attestation) { return new ObjectAndMetaData<>( attestation, diff --git a/data/provider/src/test/java/tech/pegasys/teku/api/ChainDataProviderTest.java b/data/provider/src/test/java/tech/pegasys/teku/api/ChainDataProviderTest.java index 5816854c65b..613c5d4ad7d 100644 --- a/data/provider/src/test/java/tech/pegasys/teku/api/ChainDataProviderTest.java +++ b/data/provider/src/test/java/tech/pegasys/teku/api/ChainDataProviderTest.java @@ -55,8 +55,8 @@ import tech.pegasys.teku.api.migrated.BlockRewardData; import tech.pegasys.teku.api.migrated.StateSyncCommitteesData; import tech.pegasys.teku.api.migrated.SyncCommitteeRewardData; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.api.response.v1.beacon.GenesisData; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.async.SafeFutureAssert; import tech.pegasys.teku.infrastructure.bytes.Bytes20; diff --git a/data/provider/src/test/java/tech/pegasys/teku/api/ChainDataProviderTestPhase0.java b/data/provider/src/test/java/tech/pegasys/teku/api/ChainDataProviderTestPhase0.java index f31706d856f..ad0cb98e358 100644 --- a/data/provider/src/test/java/tech/pegasys/teku/api/ChainDataProviderTestPhase0.java +++ b/data/provider/src/test/java/tech/pegasys/teku/api/ChainDataProviderTestPhase0.java @@ -47,8 +47,8 @@ import tech.pegasys.teku.api.migrated.BlockHeadersResponse; import tech.pegasys.teku.api.migrated.StateSyncCommitteesData; import tech.pegasys.teku.api.migrated.SyncCommitteeRewardData; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.api.response.v1.beacon.GenesisData; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.bytes.Bytes4; import tech.pegasys.teku.infrastructure.unsigned.UInt64; diff --git a/data/provider/src/test/java/tech/pegasys/teku/api/ValidatorDataProviderTest.java b/data/provider/src/test/java/tech/pegasys/teku/api/ValidatorDataProviderTest.java index 0457d913e41..e0d4a1f8ae2 100644 --- a/data/provider/src/test/java/tech/pegasys/teku/api/ValidatorDataProviderTest.java +++ b/data/provider/src/test/java/tech/pegasys/teku/api/ValidatorDataProviderTest.java @@ -17,7 +17,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.assertj.core.api.Assertions.fail; import static org.assertj.core.api.Assumptions.assumeThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyCollection; @@ -31,26 +30,21 @@ import static tech.pegasys.teku.infrastructure.ssz.SszDataAssert.assertThatSszData; import static tech.pegasys.teku.infrastructure.unsigned.UInt64.ONE; import static tech.pegasys.teku.infrastructure.unsigned.UInt64.ZERO; -import static tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult.FailureReason; import it.unimi.dsi.fastutil.ints.IntList; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.IntStream; -import java.util.stream.Stream; import org.apache.tuweni.bytes.Bytes32; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestTemplate; import org.mockito.ArgumentCaptor; import tech.pegasys.teku.api.exceptions.BadRequestException; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; -import tech.pegasys.teku.api.schema.ValidatorBlockResult; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.bls.BLSSignature; import tech.pegasys.teku.bls.BLSTestUtil; @@ -65,16 +59,13 @@ 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.builder.SignedValidatorRegistration; import tech.pegasys.teku.spec.datastructures.metadata.BlockContainerAndMetaData; import tech.pegasys.teku.spec.datastructures.operations.Attestation; import tech.pegasys.teku.spec.datastructures.operations.AttestationData; -import tech.pegasys.teku.spec.datastructures.validator.BroadcastValidationLevel; import tech.pegasys.teku.spec.util.DataStructureUtil; import tech.pegasys.teku.storage.client.ChainDataUnavailableException; import tech.pegasys.teku.storage.client.CombinedChainDataClient; -import tech.pegasys.teku.validator.api.SendSignedBlockResult; import tech.pegasys.teku.validator.api.SubmitDataError; import tech.pegasys.teku.validator.api.ValidatorApiChannel; @@ -280,78 +271,6 @@ void submitAttestation_shouldSubmitAnInternalAttestationStructure() { assertThatSszData(args.getValue().get(0)).isEqualByAllMeansTo(attestation); } - @TestTemplate - public void submitSignedBlock_shouldReturn200ForSuccess() - throws ExecutionException, InterruptedException { - final SignedBeaconBlock internalSignedBeaconBlock = - dataStructureUtil.randomSignedBeaconBlock(1); - final tech.pegasys.teku.api.schema.SignedBeaconBlock signedBeaconBlock = - tech.pegasys.teku.api.schema.SignedBeaconBlock.create(internalSignedBeaconBlock); - - final SafeFuture successImportResult = - completedFuture(SendSignedBlockResult.success(internalSignedBeaconBlock.getRoot())); - - when(validatorApiChannel.sendSignedBlock(any(), any())).thenReturn(successImportResult); - - final SafeFuture validatorBlockResultSafeFuture = - provider.submitSignedBlock(signedBeaconBlock, BroadcastValidationLevel.NOT_REQUIRED); - - assertThat(validatorBlockResultSafeFuture.get().getResponseCode()).isEqualTo(200); - } - - @TestTemplate - public void submitSignedBlock_shouldReturn202ForInvalidBlock() { - final SignedBeaconBlock internalSignedBeaconBlock = - dataStructureUtil.randomSignedBeaconBlock(1); - final tech.pegasys.teku.api.schema.SignedBeaconBlock signedBeaconBlock = - tech.pegasys.teku.api.schema.SignedBeaconBlock.create(internalSignedBeaconBlock); - final AtomicInteger failReasonCount = new AtomicInteger(); - - Stream.of(FailureReason.values()) - .filter(failureReason -> !failureReason.equals(FailureReason.INTERNAL_ERROR)) - .forEach( - failureReason -> { - failReasonCount.getAndIncrement(); - - final SafeFuture failImportResult = - completedFuture(SendSignedBlockResult.notImported(failureReason.name())); - - when(validatorApiChannel.sendSignedBlock(any(), any())).thenReturn(failImportResult); - - final SafeFuture validatorBlockResultSafeFuture = - provider.submitSignedBlock( - signedBeaconBlock, BroadcastValidationLevel.NOT_REQUIRED); - - try { - assertThat(validatorBlockResultSafeFuture.get().getResponseCode()).isEqualTo(202); - } catch (final Exception e) { - fail("Exception while executing test."); - } - }); - - // Assert that the check has run over each FailureReason except the 500. - assertThat(failReasonCount.get()).isEqualTo(FailureReason.values().length - 1); - } - - @TestTemplate - public void submitSignedBlock_shouldReturn500ForInternalError() - throws ExecutionException, InterruptedException { - final SignedBeaconBlock internalSignedBeaconBlock = - dataStructureUtil.randomSignedBeaconBlock(1); - final tech.pegasys.teku.api.schema.SignedBeaconBlock signedBeaconBlock = - tech.pegasys.teku.api.schema.SignedBeaconBlock.create(internalSignedBeaconBlock); - - final SafeFuture failImportResult = - completedFuture(SendSignedBlockResult.rejected(FailureReason.INTERNAL_ERROR.name())); - - when(validatorApiChannel.sendSignedBlock(any(), any())).thenReturn(failImportResult); - - final SafeFuture validatorBlockResultSafeFuture = - provider.submitSignedBlock(signedBeaconBlock, BroadcastValidationLevel.NOT_REQUIRED); - - assertThat(validatorBlockResultSafeFuture.get().getResponseCode()).isEqualTo(500); - } - @TestTemplate public void getAttesterDuties_shouldHandleEmptyIndicesList() { final Bytes32 previousTargetRoot = dataStructureUtil.randomBytes32(); diff --git a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/PublicKeyException.java b/data/serializer/src/main/java/tech/pegasys/teku/api/exceptions/PublicKeyException.java similarity index 95% rename from data/serializer/src/main/java/tech/pegasys/teku/api/schema/PublicKeyException.java rename to data/serializer/src/main/java/tech/pegasys/teku/api/exceptions/PublicKeyException.java index 4a847782d62..97c9665e6e0 100644 --- a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/PublicKeyException.java +++ b/data/serializer/src/main/java/tech/pegasys/teku/api/exceptions/PublicKeyException.java @@ -11,7 +11,7 @@ * specific language governing permissions and limitations under the License. */ -package tech.pegasys.teku.api.schema; +package tech.pegasys.teku.api.exceptions; public class PublicKeyException extends RuntimeException { diff --git a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/ValidatorBlockResult.java b/data/serializer/src/main/java/tech/pegasys/teku/api/provider/ValidatorBlockResult.java similarity index 87% rename from data/serializer/src/main/java/tech/pegasys/teku/api/schema/ValidatorBlockResult.java rename to data/serializer/src/main/java/tech/pegasys/teku/api/provider/ValidatorBlockResult.java index 685a8e05258..e2df9524563 100644 --- a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/ValidatorBlockResult.java +++ b/data/serializer/src/main/java/tech/pegasys/teku/api/provider/ValidatorBlockResult.java @@ -11,9 +11,7 @@ * specific language governing permissions and limitations under the License. */ -package tech.pegasys.teku.api.schema; - -import static tech.pegasys.teku.api.schema.SchemaConstants.DESCRIPTION_BYTES32; +package tech.pegasys.teku.api.provider; import io.swagger.v3.oas.annotations.media.Schema; import java.util.Optional; @@ -26,7 +24,7 @@ public class ValidatorBlockResult { @Schema(type = "string") private final Optional failureReason; - @Schema(type = "string", format = "byte", description = DESCRIPTION_BYTES32) + @Schema(type = "string", format = "byte", description = "Bytes32 hexadecimal") private final Optional hash_tree_root; public ValidatorBlockResult( diff --git a/data/serializer/src/main/java/tech/pegasys/teku/api/response/v1/EventType.java b/data/serializer/src/main/java/tech/pegasys/teku/api/response/EventType.java similarity index 96% rename from data/serializer/src/main/java/tech/pegasys/teku/api/response/v1/EventType.java rename to data/serializer/src/main/java/tech/pegasys/teku/api/response/EventType.java index 202787baf33..383ee7cf4ac 100644 --- a/data/serializer/src/main/java/tech/pegasys/teku/api/response/v1/EventType.java +++ b/data/serializer/src/main/java/tech/pegasys/teku/api/response/EventType.java @@ -11,7 +11,7 @@ * specific language governing permissions and limitations under the License. */ -package tech.pegasys.teku.api.response.v1; +package tech.pegasys.teku.api.response; import java.util.List; diff --git a/data/serializer/src/main/java/tech/pegasys/teku/api/response/v1/beacon/ValidatorStatus.java b/data/serializer/src/main/java/tech/pegasys/teku/api/response/ValidatorStatus.java similarity index 96% rename from data/serializer/src/main/java/tech/pegasys/teku/api/response/v1/beacon/ValidatorStatus.java rename to data/serializer/src/main/java/tech/pegasys/teku/api/response/ValidatorStatus.java index a8ff281362c..5da922e6576 100644 --- a/data/serializer/src/main/java/tech/pegasys/teku/api/response/v1/beacon/ValidatorStatus.java +++ b/data/serializer/src/main/java/tech/pegasys/teku/api/response/ValidatorStatus.java @@ -11,7 +11,7 @@ * specific language governing permissions and limitations under the License. */ -package tech.pegasys.teku.api.response.v1.beacon; +package tech.pegasys.teku.api.response; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/data/serializer/src/main/java/tech/pegasys/teku/api/response/v1/beacon/ValidatorResponse.java b/data/serializer/src/main/java/tech/pegasys/teku/api/response/v1/beacon/ValidatorResponse.java index 847a0cb132d..2b508be4760 100644 --- a/data/serializer/src/main/java/tech/pegasys/teku/api/response/v1/beacon/ValidatorResponse.java +++ b/data/serializer/src/main/java/tech/pegasys/teku/api/response/v1/beacon/ValidatorResponse.java @@ -22,6 +22,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import java.util.Objects; import java.util.Optional; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.api.schema.Validator; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.infrastructure.unsigned.UInt64; diff --git a/data/serializer/src/main/java/tech/pegasys/teku/api/response/v1/debug/ChainHead.java b/data/serializer/src/main/java/tech/pegasys/teku/api/response/v1/debug/ChainHead.java deleted file mode 100644 index 4d4dbf402fe..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/api/response/v1/debug/ChainHead.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2025 - * - * 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.api.response.v1.debug; - -import static tech.pegasys.teku.api.schema.SchemaConstants.DESCRIPTION_BYTES32; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import java.util.Objects; -import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; - -public class ChainHead { - @Schema(type = "string", format = "uint64") - public final UInt64 slot; - - @Schema(type = "string", format = "byte", description = DESCRIPTION_BYTES32) - public final Bytes32 root; - - @JsonCreator - public ChainHead( - @JsonProperty("slot") final UInt64 slot, @JsonProperty("root") final Bytes32 root) { - this.slot = slot; - this.root = root; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final ChainHead chainHead = (ChainHead) o; - return Objects.equals(slot, chainHead.slot) && Objects.equals(root, chainHead.root); - } - - @Override - public int hashCode() { - return Objects.hash(slot, root); - } -} diff --git a/data/serializer/src/main/java/tech/pegasys/teku/api/response/v1/debug/GetChainHeadsResponse.java b/data/serializer/src/main/java/tech/pegasys/teku/api/response/v1/debug/GetChainHeadsResponse.java deleted file mode 100644 index 11e2eea670f..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/api/response/v1/debug/GetChainHeadsResponse.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2025 - * - * 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.api.response.v1.debug; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -public class GetChainHeadsResponse { - public final List data; - - @JsonCreator - public GetChainHeadsResponse(@JsonProperty("data") final List data) { - this.data = data; - } -} diff --git a/data/serializer/src/main/java/tech/pegasys/teku/api/response/v1/debug/GetStateResponse.java b/data/serializer/src/main/java/tech/pegasys/teku/api/response/v1/debug/GetStateResponse.java deleted file mode 100644 index 7e8fc86da57..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/api/response/v1/debug/GetStateResponse.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2025 - * - * 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.api.response.v1.debug; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import tech.pegasys.teku.api.schema.BeaconState; -import tech.pegasys.teku.api.schema.Version; -import tech.pegasys.teku.api.schema.phase0.BeaconStatePhase0; - -public class GetStateResponse { - - public final BeaconStatePhase0 data; - - @JsonCreator - public GetStateResponse(@JsonProperty("data") final BeaconStatePhase0 data) { - this.data = data; - } - - public GetStateResponse(final Version version, final BeaconState data) { - if (!version.equals(Version.phase0)) { - throw new IllegalArgumentException( - String.format("Beacon state at slot %s is not a phase0 state", data.slot)); - } - this.data = (BeaconStatePhase0) data; - } -} diff --git a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/BLSPubKey.java b/data/serializer/src/main/java/tech/pegasys/teku/api/schema/BLSPubKey.java index c3f053154d3..87b379beee3 100644 --- a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/BLSPubKey.java +++ b/data/serializer/src/main/java/tech/pegasys/teku/api/schema/BLSPubKey.java @@ -18,6 +18,7 @@ import java.util.Objects; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes48; +import tech.pegasys.teku.api.exceptions.PublicKeyException; import tech.pegasys.teku.bls.BLSPublicKey; @SuppressWarnings("JavaCase") diff --git a/data/serializer/src/test/java/tech/pegasys/teku/api/response/v1/EventTypeTest.java b/data/serializer/src/test/java/tech/pegasys/teku/api/response/v1/EventTypeTest.java index 25d82f0af9f..29aa4a6d9d9 100644 --- a/data/serializer/src/test/java/tech/pegasys/teku/api/response/v1/EventTypeTest.java +++ b/data/serializer/src/test/java/tech/pegasys/teku/api/response/v1/EventTypeTest.java @@ -18,6 +18,7 @@ import java.util.List; import org.junit.jupiter.api.Test; +import tech.pegasys.teku.api.response.EventType; public class EventTypeTest { @Test diff --git a/data/serializer/src/test/java/tech/pegasys/teku/api/response/v1/beacon/ValidatorResponseTest.java b/data/serializer/src/test/java/tech/pegasys/teku/api/response/v1/beacon/ValidatorResponseTest.java index e0937e63832..541bad62315 100644 --- a/data/serializer/src/test/java/tech/pegasys/teku/api/response/v1/beacon/ValidatorResponseTest.java +++ b/data/serializer/src/test/java/tech/pegasys/teku/api/response/v1/beacon/ValidatorResponseTest.java @@ -21,6 +21,7 @@ import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.bytes.Bytes48; import org.junit.jupiter.api.Test; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.Spec; import tech.pegasys.teku.spec.TestSpecFactory; diff --git a/data/serializer/src/test/java/tech/pegasys/teku/api/schema/BLSPubKeyTest.java b/data/serializer/src/test/java/tech/pegasys/teku/api/schema/BLSPubKeyTest.java deleted file mode 100644 index 872d6cd0eb7..00000000000 --- a/data/serializer/src/test/java/tech/pegasys/teku/api/schema/BLSPubKeyTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2025 - * - * 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.api.schema; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.jupiter.api.Test; -import tech.pegasys.teku.bls.BLSPublicKey; -import tech.pegasys.teku.spec.TestSpecFactory; -import tech.pegasys.teku.spec.util.DataStructureUtil; - -public class BLSPubKeyTest { - private final DataStructureUtil dataStructureUtil = - new DataStructureUtil(TestSpecFactory.createDefault()); - private final BLSPublicKey blsPublicKey = dataStructureUtil.randomPublicKey(); - - @Test - public void shouldConvertToInternalObject() { - final BLSPubKey blsPubKey = new BLSPubKey(blsPublicKey); - assertThat(blsPubKey.asBLSPublicKey()).isEqualTo(blsPublicKey); - } -} diff --git a/data/serializer/src/test/java/tech/pegasys/teku/api/schema/BeaconStateTest.java b/data/serializer/src/test/java/tech/pegasys/teku/api/schema/BeaconStateTest.java deleted file mode 100644 index aa4206c5902..00000000000 --- a/data/serializer/src/test/java/tech/pegasys/teku/api/schema/BeaconStateTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2025 - * - * 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.api.schema; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.jupiter.api.TestTemplate; -import tech.pegasys.teku.api.schema.altair.BeaconStateAltair; -import tech.pegasys.teku.api.schema.bellatrix.BeaconStateBellatrix; -import tech.pegasys.teku.api.schema.capella.BeaconStateCapella; -import tech.pegasys.teku.api.schema.deneb.BeaconStateDeneb; -import tech.pegasys.teku.api.schema.electra.BeaconStateElectra; -import tech.pegasys.teku.api.schema.phase0.BeaconStatePhase0; -import tech.pegasys.teku.spec.Spec; -import tech.pegasys.teku.spec.TestSpecContext; -import tech.pegasys.teku.spec.TestSpecInvocationContextProvider.SpecContext; - -@TestSpecContext(allMilestones = true) -public class BeaconStateTest { - - @TestTemplate - public void shouldConvertToInternalObject(final SpecContext ctx) { - final tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState beaconStateInternal = - ctx.getDataStructureUtil().randomBeaconState(); - final Spec spec = ctx.getSpec(); - final BeaconState beaconState = - switch (spec.getGenesisSpec().getMilestone()) { - case PHASE0 -> new BeaconStatePhase0(beaconStateInternal); - case ALTAIR -> new BeaconStateAltair(beaconStateInternal); - case BELLATRIX -> new BeaconStateBellatrix(beaconStateInternal); - case CAPELLA -> new BeaconStateCapella(beaconStateInternal); - case DENEB -> new BeaconStateDeneb(beaconStateInternal); - case ELECTRA, FULU -> new BeaconStateElectra(beaconStateInternal); - }; - - assertThat(beaconState.asInternalBeaconState(spec)).isEqualTo(beaconStateInternal); - } -} diff --git a/data/serializer/src/test/java/tech/pegasys/teku/api/schema/altair/BeaconBlockBodyAltairTest.java b/data/serializer/src/test/java/tech/pegasys/teku/api/schema/altair/BeaconBlockBodyAltairTest.java deleted file mode 100644 index 3589e7d5675..00000000000 --- a/data/serializer/src/test/java/tech/pegasys/teku/api/schema/altair/BeaconBlockBodyAltairTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2025 - * - * 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.api.schema.altair; - -import static org.assertj.core.api.Assertions.assertThat; -import static tech.pegasys.teku.infrastructure.unsigned.UInt64.ONE; - -import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.SchemaObjectProvider; -import tech.pegasys.teku.api.schema.BeaconBlock; -import tech.pegasys.teku.spec.Spec; -import tech.pegasys.teku.spec.TestSpecFactory; -import tech.pegasys.teku.spec.util.DataStructureUtil; - -public class BeaconBlockBodyAltairTest { - private final Spec spec = TestSpecFactory.createMinimalAltair(); - private final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec); - private final SchemaObjectProvider schemaObjectProvider = new SchemaObjectProvider(spec); - - @Test - void asInternalBeaconBlockBody_ShouldConvertAltairBlock() { - final tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock internalBlock = - dataStructureUtil.randomBeaconBlock(ONE); - final BeaconBlock block = schemaObjectProvider.getBeaconBlock(internalBlock); - - assertThat(block).isInstanceOf(BeaconBlockAltair.class); - assertThat(block.asInternalBeaconBlock(spec)).isEqualTo(internalBlock); - } -} diff --git a/data/serializer/src/test/java/tech/pegasys/teku/api/schema/bellatrix/BeaconBlockBodyBellatrixTest.java b/data/serializer/src/test/java/tech/pegasys/teku/api/schema/bellatrix/BeaconBlockBodyBellatrixTest.java deleted file mode 100644 index d6726906c26..00000000000 --- a/data/serializer/src/test/java/tech/pegasys/teku/api/schema/bellatrix/BeaconBlockBodyBellatrixTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2025 - * - * 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.api.schema.bellatrix; - -import static org.assertj.core.api.Assertions.assertThat; -import static tech.pegasys.teku.infrastructure.unsigned.UInt64.ONE; - -import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.SchemaObjectProvider; -import tech.pegasys.teku.api.schema.BeaconBlock; -import tech.pegasys.teku.spec.Spec; -import tech.pegasys.teku.spec.TestSpecFactory; -import tech.pegasys.teku.spec.util.DataStructureUtil; - -public class BeaconBlockBodyBellatrixTest { - private final Spec spec = TestSpecFactory.createMinimalBellatrix(); - private final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec); - private final SchemaObjectProvider schemaObjectProvider = new SchemaObjectProvider(spec); - - @Test - void asInternalBeaconBlockBody_ShouldConvertBellatrixBlock() { - final tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock internalBlock = - dataStructureUtil.randomBeaconBlock(ONE); - final BeaconBlock block = schemaObjectProvider.getBeaconBlock(internalBlock); - - assertThat(block).isInstanceOf(BeaconBlockBellatrix.class); - assertThat(block.asInternalBeaconBlock(spec)).isEqualTo(internalBlock); - } -} diff --git a/data/serializer/src/test/java/tech/pegasys/teku/api/schema/bellatrix/BlindedBeaconBlockBellatrixTest.java b/data/serializer/src/test/java/tech/pegasys/teku/api/schema/bellatrix/BlindedBeaconBlockBellatrixTest.java deleted file mode 100644 index 2897dc87087..00000000000 --- a/data/serializer/src/test/java/tech/pegasys/teku/api/schema/bellatrix/BlindedBeaconBlockBellatrixTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2025 - * - * 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.api.schema.bellatrix; - -import static org.assertj.core.api.Assertions.assertThat; -import static tech.pegasys.teku.infrastructure.unsigned.UInt64.ONE; - -import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.SchemaObjectProvider; -import tech.pegasys.teku.api.schema.BeaconBlock; -import tech.pegasys.teku.spec.Spec; -import tech.pegasys.teku.spec.TestSpecFactory; -import tech.pegasys.teku.spec.util.DataStructureUtil; - -public class BlindedBeaconBlockBellatrixTest { - private final Spec spec = TestSpecFactory.createMinimalBellatrix(); - private final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec); - private final SchemaObjectProvider schemaObjectProvider = new SchemaObjectProvider(spec); - - @Test - void asInternalBeaconBlockBody_ShouldConvertBellatrixBlindedBlock() { - final tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock internalBlock = - dataStructureUtil.randomBlindedBeaconBlock(ONE); - final BeaconBlock block = schemaObjectProvider.getBlindedBlock(internalBlock); - assertThat(block).isInstanceOf(BlindedBlockBellatrix.class); - - final BlindedBlockBellatrix bellatrixBlock = (BlindedBlockBellatrix) block; - assertThat(bellatrixBlock.asInternalBeaconBlock(spec)).isEqualTo(internalBlock); - } -} diff --git a/ethereum/json-types/src/main/java/tech/pegasys/teku/ethereum/json/types/EthereumTypes.java b/ethereum/json-types/src/main/java/tech/pegasys/teku/ethereum/json/types/EthereumTypes.java index dbcb61af7bf..061c052beaa 100644 --- a/ethereum/json-types/src/main/java/tech/pegasys/teku/ethereum/json/types/EthereumTypes.java +++ b/ethereum/json-types/src/main/java/tech/pegasys/teku/ethereum/json/types/EthereumTypes.java @@ -27,7 +27,6 @@ import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.units.bigints.UInt256; import org.jetbrains.annotations.NotNull; -import tech.pegasys.teku.api.schema.Version; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.bls.BLSSignature; import tech.pegasys.teku.infrastructure.http.RestApiConstants; @@ -166,7 +165,7 @@ private static Map getSszHeaders( final Function milestoneSelector, final T value) { return Map.of( HEADER_CONSENSUS_VERSION, - Version.fromMilestone(milestoneSelector.apply(value)).name(), + milestoneSelector.apply(value).lowerCaseName(), RestApiConstants.HEADER_CONTENT_DISPOSITION, getSszFilename(value)); } diff --git a/ethereum/json-types/src/main/java/tech/pegasys/teku/ethereum/json/types/beacon/StateValidatorData.java b/ethereum/json-types/src/main/java/tech/pegasys/teku/ethereum/json/types/beacon/StateValidatorData.java index 7bfe53eeca0..2fabd12cdcd 100644 --- a/ethereum/json-types/src/main/java/tech/pegasys/teku/ethereum/json/types/beacon/StateValidatorData.java +++ b/ethereum/json-types/src/main/java/tech/pegasys/teku/ethereum/json/types/beacon/StateValidatorData.java @@ -15,8 +15,8 @@ import java.util.Objects; import java.util.Optional; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.api.response.v1.beacon.ValidatorResponse; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.datastructures.state.Validator; diff --git a/ethereum/json-types/src/main/java/tech/pegasys/teku/ethereum/json/types/beacon/StateValidatorDataBuilder.java b/ethereum/json-types/src/main/java/tech/pegasys/teku/ethereum/json/types/beacon/StateValidatorDataBuilder.java index db5fa358a5c..96e9df883a9 100644 --- a/ethereum/json-types/src/main/java/tech/pegasys/teku/ethereum/json/types/beacon/StateValidatorDataBuilder.java +++ b/ethereum/json-types/src/main/java/tech/pegasys/teku/ethereum/json/types/beacon/StateValidatorDataBuilder.java @@ -20,7 +20,7 @@ import static tech.pegasys.teku.infrastructure.json.types.DeserializableTypeDefinition.listOf; import java.util.List; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.infrastructure.json.types.DeserializableTypeDefinition; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.datastructures.metadata.ObjectAndMetaData; diff --git a/ethereum/json-types/src/main/java/tech/pegasys/teku/ethereum/json/types/beacon/StatusParameter.java b/ethereum/json-types/src/main/java/tech/pegasys/teku/ethereum/json/types/beacon/StatusParameter.java index 6b0aa88aca9..d1a34cce778 100644 --- a/ethereum/json-types/src/main/java/tech/pegasys/teku/ethereum/json/types/beacon/StatusParameter.java +++ b/ethereum/json-types/src/main/java/tech/pegasys/teku/ethereum/json/types/beacon/StatusParameter.java @@ -18,7 +18,7 @@ import java.util.Locale; import java.util.Set; import java.util.stream.Collectors; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; public enum StatusParameter { PENDING_INITIALIZED("pending_initialized"), diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/SpecMilestone.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/SpecMilestone.java index fd799579961..6398b2a4cc9 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/SpecMilestone.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/SpecMilestone.java @@ -161,4 +161,8 @@ public static SpecMilestone forName(final String milestoneName) { checkNotNull(milestoneName, "Milestone name can't be null"); return SpecMilestone.valueOf(milestoneName.toUpperCase(Locale.ROOT)); } + + public String lowerCaseName() { + return this.name().toLowerCase(Locale.ROOT); + } } diff --git a/teku/src/test/java/tech/pegasys/teku/cli/options/P2POptionsTest.java b/teku/src/test/java/tech/pegasys/teku/cli/options/P2POptionsTest.java index 9652d99cb60..d57f1bb5430 100644 --- a/teku/src/test/java/tech/pegasys/teku/cli/options/P2POptionsTest.java +++ b/teku/src/test/java/tech/pegasys/teku/cli/options/P2POptionsTest.java @@ -36,6 +36,8 @@ import java.util.List; import java.util.stream.Stream; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -91,6 +93,7 @@ public void shouldReadFromConfigurationFile() { } @Test + @DisabledOnOs(OS.WINDOWS) public void shouldReadUrlFromConfigurationFile(@TempDir final Path tempDir) throws Exception { final Path peersFile = tempDir.resolve("peers.txt"); final Path configPath = tempDir.resolve("config.yaml"); diff --git a/validator/api/src/main/java/tech/pegasys/teku/validator/api/ValidatorTimingChannel.java b/validator/api/src/main/java/tech/pegasys/teku/validator/api/ValidatorTimingChannel.java index 4cfce40d667..8d3d8cd5a36 100644 --- a/validator/api/src/main/java/tech/pegasys/teku/validator/api/ValidatorTimingChannel.java +++ b/validator/api/src/main/java/tech/pegasys/teku/validator/api/ValidatorTimingChannel.java @@ -15,7 +15,7 @@ import java.util.Map; import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.infrastructure.events.VoidReturningChannelInterface; import tech.pegasys.teku.infrastructure.unsigned.UInt64; diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/AttestationDutyScheduler.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/AttestationDutyScheduler.java index fb53cf1b84d..2239c529da1 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/AttestationDutyScheduler.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/AttestationDutyScheduler.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes32; import org.hyperledger.besu.plugin.services.MetricsSystem; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory; import tech.pegasys.teku.infrastructure.unsigned.UInt64; diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/BeaconProposerPreparer.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/BeaconProposerPreparer.java index b8d9bbf9e2a..21bb80ae072 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/BeaconProposerPreparer.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/BeaconProposerPreparer.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.Spec; diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/BlockDutyScheduler.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/BlockDutyScheduler.java index ca7865c3766..c3dd7fde29f 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/BlockDutyScheduler.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/BlockDutyScheduler.java @@ -18,7 +18,7 @@ import java.util.Map; import org.apache.tuweni.bytes.Bytes32; import org.hyperledger.besu.plugin.services.MetricsSystem; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory; import tech.pegasys.teku.infrastructure.unsigned.UInt64; diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/OwnedKeyManager.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/OwnedKeyManager.java index 04833d20fdc..41be3eba5ed 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/OwnedKeyManager.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/OwnedKeyManager.java @@ -24,6 +24,7 @@ import java.util.stream.Collectors; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.bls.keystore.KeyStoreLoader; import tech.pegasys.teku.bls.keystore.KeyStoreValidationException; @@ -94,7 +95,7 @@ public Optional getValidatorByPublicKey(final BLSPublicKey publicKey) * protection information * *

- NOT_ACTIVE indicates the key is not owned, but we had slashing data, should not be - * confused with {@link tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus} + * confused with {@link ValidatorStatus} * *

- DELETED indicates the key was found, and we have stopped using it and removed it. * diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/OwnedValidatorStatusProvider.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/OwnedValidatorStatusProvider.java index 47008eefd63..191621171f5 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/OwnedValidatorStatusProvider.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/OwnedValidatorStatusProvider.java @@ -30,7 +30,7 @@ import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes32; import org.hyperledger.besu.plugin.services.MetricsSystem; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.ethereum.json.types.beacon.StateValidatorData; import tech.pegasys.teku.infrastructure.async.AsyncRunner; diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/SyncCommitteeScheduler.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/SyncCommitteeScheduler.java index dde574a4c22..015ba866b09 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/SyncCommitteeScheduler.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/SyncCommitteeScheduler.java @@ -20,7 +20,7 @@ import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes32; import org.hyperledger.besu.plugin.services.MetricsSystem; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.Spec; diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorRegistrator.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorRegistrator.java index 819b685d00e..04a4cea43a2 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorRegistrator.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorRegistrator.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.infrastructure.async.AsyncRunner; import tech.pegasys.teku.infrastructure.async.SafeFuture; diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorStatusLogger.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorStatusLogger.java index bd72de17cf9..b6722a7ef0a 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorStatusLogger.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorStatusLogger.java @@ -20,7 +20,7 @@ import java.util.Optional; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.validator.client.loader.OwnedValidators; diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorStatusSubscriber.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorStatusSubscriber.java index 5df424a01dc..2da0a42215d 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorStatusSubscriber.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorStatusSubscriber.java @@ -14,7 +14,7 @@ package tech.pegasys.teku.validator.client; import java.util.Map; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; public interface ValidatorStatusSubscriber { diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorTimingActions.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorTimingActions.java index b60136491e9..e6e40f3107f 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorTimingActions.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorTimingActions.java @@ -21,7 +21,7 @@ import java.util.stream.Collectors; import org.apache.tuweni.bytes.Bytes32; import org.hyperledger.besu.plugin.services.MetricsSystem; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.infrastructure.metrics.SettableGauge; import tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory; diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/synccommittee/ChainHeadTracker.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/synccommittee/ChainHeadTracker.java index 67f6b7926bf..88e82aae65d 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/synccommittee/ChainHeadTracker.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/synccommittee/ChainHeadTracker.java @@ -16,7 +16,7 @@ import java.util.Map; import java.util.Optional; import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing; diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/loader/SlashingProtectionLogger.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/loader/SlashingProtectionLogger.java index 4876d9c9b53..46f148a6042 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/loader/SlashingProtectionLogger.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/loader/SlashingProtectionLogger.java @@ -29,7 +29,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.ethereum.signingrecord.ValidatorSigningRecord; import tech.pegasys.teku.infrastructure.async.AsyncRunner; diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/restapi/apis/schema/DeletionStatus.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/restapi/apis/schema/DeletionStatus.java index e02aa969736..6413f9f7dc7 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/restapi/apis/schema/DeletionStatus.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/restapi/apis/schema/DeletionStatus.java @@ -13,11 +13,13 @@ package tech.pegasys.teku.validator.client.restapi.apis.schema; +import tech.pegasys.teku.api.response.ValidatorStatus; + public enum DeletionStatus { DELETED("deleted"), /** - * Should not be confused with {@link tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus}. - * Means the key was managed but not managed anymore + * Should not be confused with {@link ValidatorStatus}. Means the key was managed but not managed + * anymore */ NOT_ACTIVE("not_active"), NOT_FOUND("not_found"), diff --git a/validator/client/src/test/java/tech/pegasys/teku/validator/client/OwnedValidatorStatusProviderTest.java b/validator/client/src/test/java/tech/pegasys/teku/validator/client/OwnedValidatorStatusProviderTest.java index 2095bdf3f8b..9e3022eada8 100644 --- a/validator/client/src/test/java/tech/pegasys/teku/validator/client/OwnedValidatorStatusProviderTest.java +++ b/validator/client/src/test/java/tech/pegasys/teku/validator/client/OwnedValidatorStatusProviderTest.java @@ -27,7 +27,7 @@ import java.util.stream.Stream; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.ethereum.json.types.beacon.StateValidatorData; import tech.pegasys.teku.infrastructure.async.AsyncRunner; diff --git a/validator/client/src/test/java/tech/pegasys/teku/validator/client/ValidatorRegistratorTest.java b/validator/client/src/test/java/tech/pegasys/teku/validator/client/ValidatorRegistratorTest.java index e3806b2fd0e..fa5367e2663 100644 --- a/validator/client/src/test/java/tech/pegasys/teku/validator/client/ValidatorRegistratorTest.java +++ b/validator/client/src/test/java/tech/pegasys/teku/validator/client/ValidatorRegistratorTest.java @@ -37,7 +37,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestTemplate; import org.mockito.ArgumentCaptor; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.ethereum.execution.types.Eth1Address; import tech.pegasys.teku.infrastructure.async.SafeFuture; diff --git a/validator/client/src/test/java/tech/pegasys/teku/validator/client/ValidatorStatusProviderTest.java b/validator/client/src/test/java/tech/pegasys/teku/validator/client/ValidatorStatusProviderTest.java index ceecfe8d45d..a6b1eeab7e8 100644 --- a/validator/client/src/test/java/tech/pegasys/teku/validator/client/ValidatorStatusProviderTest.java +++ b/validator/client/src/test/java/tech/pegasys/teku/validator/client/ValidatorStatusProviderTest.java @@ -36,7 +36,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.bls.BLSTestUtil; import tech.pegasys.teku.ethereum.json.types.beacon.StateValidatorData; diff --git a/validator/client/src/test/java/tech/pegasys/teku/validator/client/ValidatorTimingActionsTest.java b/validator/client/src/test/java/tech/pegasys/teku/validator/client/ValidatorTimingActionsTest.java index d2ea74a6002..ac919b687eb 100644 --- a/validator/client/src/test/java/tech/pegasys/teku/validator/client/ValidatorTimingActionsTest.java +++ b/validator/client/src/test/java/tech/pegasys/teku/validator/client/ValidatorTimingActionsTest.java @@ -27,7 +27,7 @@ import java.util.Set; import org.hyperledger.besu.plugin.services.MetricsSystem; import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.infrastructure.logging.StatusLogger; import tech.pegasys.teku.infrastructure.unsigned.UInt64; diff --git a/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/apiclient/SchemaObjectsTestFixture.java b/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/apiclient/SchemaObjectsTestFixture.java deleted file mode 100644 index 86cf379cd3a..00000000000 --- a/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/apiclient/SchemaObjectsTestFixture.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2025 - * - * 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.validator.remote.apiclient; - -import static tech.pegasys.teku.spec.config.SpecConfig.FAR_FUTURE_EPOCH; - -import tech.pegasys.teku.api.response.v1.beacon.GenesisData; -import tech.pegasys.teku.api.response.v1.beacon.GetGenesisResponse; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorResponse; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; -import tech.pegasys.teku.api.schema.Attestation; -import tech.pegasys.teku.api.schema.BLSPubKey; -import tech.pegasys.teku.api.schema.SignedAggregateAndProof; -import tech.pegasys.teku.api.schema.SignedVoluntaryExit; -import tech.pegasys.teku.api.schema.SubnetSubscription; -import tech.pegasys.teku.api.schema.Validator; -import tech.pegasys.teku.api.schema.altair.SyncCommitteeContribution; -import tech.pegasys.teku.bls.BLSPublicKey; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.spec.Spec; -import tech.pegasys.teku.spec.TestSpecFactory; -import tech.pegasys.teku.spec.util.DataStructureUtil; - -public class SchemaObjectsTestFixture { - - private final DataStructureUtil dataStructureUtil; - - public SchemaObjectsTestFixture(final Spec spec) { - this.dataStructureUtil = new DataStructureUtil(spec); - } - - public SchemaObjectsTestFixture() { - this(TestSpecFactory.createMinimalPhase0()); - } - - public GetGenesisResponse getGenesisResponse() { - return new GetGenesisResponse( - new GenesisData( - dataStructureUtil.randomUInt64(), - dataStructureUtil.randomBytes32(), - dataStructureUtil.randomBytes4())); - } - - public SignedVoluntaryExit signedVoluntaryExit() { - return new SignedVoluntaryExit(dataStructureUtil.randomSignedVoluntaryExit()); - } - - public ValidatorResponse validatorResponse() { - return validatorResponse(dataStructureUtil.randomLong(), dataStructureUtil.randomPublicKey()); - } - - public ValidatorResponse validatorResponse(final long index, final BLSPublicKey publicKey) { - return new ValidatorResponse( - UInt64.valueOf(index), - dataStructureUtil.randomUInt64(), - ValidatorStatus.active_ongoing, - new Validator( - new BLSPubKey(publicKey), - dataStructureUtil.randomBytes32(), - dataStructureUtil.randomUInt64(), - false, - UInt64.ZERO, - UInt64.ZERO, - FAR_FUTURE_EPOCH, - FAR_FUTURE_EPOCH)); - } - - public SyncCommitteeContribution syncCommitteeContribution(final UInt64 slot) { - final Spec altairSpec = TestSpecFactory.createMainnetAltair(); - final DataStructureUtil altairData = new DataStructureUtil(altairSpec); - return new SyncCommitteeContribution(altairData.randomSyncCommitteeContribution(slot)); - } - - public Attestation attestation() { - return new Attestation(dataStructureUtil.randomAttestation()); - } - - public SubnetSubscription subnetSubscription() { - return new SubnetSubscription(1, UInt64.ONE); - } - - public SignedAggregateAndProof signedAggregateAndProof() { - return new SignedAggregateAndProof(dataStructureUtil.randomSignedAggregateAndProof()); - } -} diff --git a/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java b/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java index f2ffa97fe99..fbd21b13a9c 100644 --- a/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java +++ b/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java @@ -61,7 +61,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestTemplate; import tech.pegasys.teku.api.exceptions.RemoteServiceNotAvailableException; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSSignature; import tech.pegasys.teku.ethereum.json.types.beacon.StateValidatorData; import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuties; diff --git a/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/handlers/GetStateValidatorsRequestTest.java b/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/handlers/GetStateValidatorsRequestTest.java index 15088135ad5..d5e544d3565 100644 --- a/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/handlers/GetStateValidatorsRequestTest.java +++ b/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/handlers/GetStateValidatorsRequestTest.java @@ -36,7 +36,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestTemplate; import tech.pegasys.teku.api.exceptions.RemoteServiceNotAvailableException; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.ethereum.json.types.beacon.StateValidatorData; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.TestSpecContext; diff --git a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/BeaconNodeReadinessManager.java b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/BeaconNodeReadinessManager.java index b1099d82eda..647941fd7ab 100644 --- a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/BeaconNodeReadinessManager.java +++ b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/BeaconNodeReadinessManager.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.ethereum.json.types.node.PeerCount; import tech.pegasys.teku.infrastructure.async.SafeFuture; diff --git a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/eventsource/EventSourceBeaconChainEventAdapter.java b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/eventsource/EventSourceBeaconChainEventAdapter.java index da34c803791..c05848ae775 100644 --- a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/eventsource/EventSourceBeaconChainEventAdapter.java +++ b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/eventsource/EventSourceBeaconChainEventAdapter.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.hyperledger.besu.plugin.services.MetricsSystem; -import tech.pegasys.teku.api.response.v1.EventType; +import tech.pegasys.teku.api.response.EventType; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.logging.ValidatorLogger; import tech.pegasys.teku.spec.Spec; diff --git a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/eventsource/EventSourceHandler.java b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/eventsource/EventSourceHandler.java index 36585ae92a3..1907ee36a58 100644 --- a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/eventsource/EventSourceHandler.java +++ b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/eventsource/EventSourceHandler.java @@ -25,7 +25,7 @@ import org.hyperledger.besu.plugin.services.MetricsSystem; import org.hyperledger.besu.plugin.services.metrics.Counter; import org.hyperledger.besu.plugin.services.metrics.LabelledMetric; -import tech.pegasys.teku.api.response.v1.EventType; +import tech.pegasys.teku.api.response.EventType; import tech.pegasys.teku.infrastructure.json.JsonUtil; import tech.pegasys.teku.infrastructure.json.types.DeserializableTypeDefinition; import tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory; diff --git a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/FailoverValidatorApiHandlerTest.java b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/FailoverValidatorApiHandlerTest.java index 26c5cfe7536..c749bf718fe 100644 --- a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/FailoverValidatorApiHandlerTest.java +++ b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/FailoverValidatorApiHandlerTest.java @@ -45,7 +45,7 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import tech.pegasys.teku.api.migrated.ValidatorLivenessAtEpoch; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.bls.BLSSignature; import tech.pegasys.teku.ethereum.json.types.beacon.StateValidatorData; diff --git a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/RemoteValidatorApiHandlerTest.java b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/RemoteValidatorApiHandlerTest.java index 5d0f1865194..eed0df5963f 100644 --- a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/RemoteValidatorApiHandlerTest.java +++ b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/RemoteValidatorApiHandlerTest.java @@ -48,7 +48,7 @@ import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import tech.pegasys.teku.api.migrated.ValidatorLivenessAtEpoch; -import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus; +import tech.pegasys.teku.api.response.ValidatorStatus; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.bls.BLSSignature; import tech.pegasys.teku.ethereum.json.types.beacon.StateValidatorData; diff --git a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/eventsource/EventSourceBeaconChainEventAdapterTest.java b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/eventsource/EventSourceBeaconChainEventAdapterTest.java index 5f5ca028a75..03689b3ebb6 100644 --- a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/eventsource/EventSourceBeaconChainEventAdapterTest.java +++ b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/eventsource/EventSourceBeaconChainEventAdapterTest.java @@ -33,7 +33,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import tech.pegasys.teku.api.response.v1.EventType; +import tech.pegasys.teku.api.response.EventType; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.logging.ValidatorLogger; import tech.pegasys.teku.spec.Spec; diff --git a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/eventsource/EventSourceHandlerTest.java b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/eventsource/EventSourceHandlerTest.java index 112e5d32890..8f40ee12064 100644 --- a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/eventsource/EventSourceHandlerTest.java +++ b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/eventsource/EventSourceHandlerTest.java @@ -23,7 +23,7 @@ import com.launchdarkly.eventsource.MessageEvent; import org.apache.tuweni.bytes.Bytes32; import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.response.v1.EventType; +import tech.pegasys.teku.api.response.EventType; import tech.pegasys.teku.infrastructure.json.JsonUtil; import tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem; import tech.pegasys.teku.infrastructure.unsigned.UInt64;