From 039cbf3bf5b5e422936c7b0ac8f8c289e7f57e57 Mon Sep 17 00:00:00 2001 From: Paul Harris Date: Wed, 9 Oct 2024 14:12:55 +1000 Subject: [PATCH 1/2] Cleanup JsonProvider and unused serializers Signed-off-by: Paul Harris --- .../teku/api/SchemaObjectProvider.java | 38 -- .../pegasys/teku/api/ConfigProviderTest.java | 42 -- .../pegasys/teku/api/schema/package-info.java | 5 + .../teku/provider/BLSPubKeyDeserializer.java | 29 -- .../teku/provider/BLSPubKeySerializer.java | 30 -- .../provider/BLSSignatureDeserializer.java | 28 -- .../teku/provider/BLSSignatureSerializer.java | 30 -- ...etNewBlindedBlockResponseDeserializer.java | 60 --- .../GetNewBlockResponseV1Deserializer.java | 40 -- .../GetNewBlockResponseV2Deserializer.java | 59 --- .../GetStateResponseV2Deserializer.java | 56 --- .../pegasys/teku/provider/JsonProvider.java | 135 ------ .../provider/KZGCommitmentDeserializer.java | 29 -- .../provider/KZGCommitmentSerializer.java | 30 -- .../teku/provider/KZGProofDeserializer.java | 29 -- .../teku/provider/KZGProofSerializer.java | 30 -- .../teku/provider/SszBitvectorSerializer.java | 30 -- .../provider/JsonProviderPropertyTest.java | 428 ------------------ .../teku/provider/JsonProviderTest.java | 183 -------- .../config/WeakSubjectivityConfigTest.java | 2 +- 20 files changed, 6 insertions(+), 1307 deletions(-) delete mode 100644 data/provider/src/test/java/tech/pegasys/teku/api/ConfigProviderTest.java create mode 100644 data/serializer/src/main/java/tech/pegasys/teku/api/schema/package-info.java delete mode 100644 data/serializer/src/main/java/tech/pegasys/teku/provider/BLSPubKeyDeserializer.java delete mode 100644 data/serializer/src/main/java/tech/pegasys/teku/provider/BLSPubKeySerializer.java delete mode 100644 data/serializer/src/main/java/tech/pegasys/teku/provider/BLSSignatureDeserializer.java delete mode 100644 data/serializer/src/main/java/tech/pegasys/teku/provider/BLSSignatureSerializer.java delete mode 100644 data/serializer/src/main/java/tech/pegasys/teku/provider/GetNewBlindedBlockResponseDeserializer.java delete mode 100644 data/serializer/src/main/java/tech/pegasys/teku/provider/GetNewBlockResponseV1Deserializer.java delete mode 100644 data/serializer/src/main/java/tech/pegasys/teku/provider/GetNewBlockResponseV2Deserializer.java delete mode 100644 data/serializer/src/main/java/tech/pegasys/teku/provider/GetStateResponseV2Deserializer.java delete mode 100644 data/serializer/src/main/java/tech/pegasys/teku/provider/JsonProvider.java delete mode 100644 data/serializer/src/main/java/tech/pegasys/teku/provider/KZGCommitmentDeserializer.java delete mode 100644 data/serializer/src/main/java/tech/pegasys/teku/provider/KZGCommitmentSerializer.java delete mode 100644 data/serializer/src/main/java/tech/pegasys/teku/provider/KZGProofDeserializer.java delete mode 100644 data/serializer/src/main/java/tech/pegasys/teku/provider/KZGProofSerializer.java delete mode 100644 data/serializer/src/main/java/tech/pegasys/teku/provider/SszBitvectorSerializer.java delete mode 100644 data/serializer/src/property-test/java/tech/pegasys/teku/provider/JsonProviderPropertyTest.java delete mode 100644 data/serializer/src/test/java/tech/pegasys/teku/provider/JsonProviderTest.java 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 index d78fadf6b52..2c829b40b96 100644 --- a/data/provider/src/main/java/tech/pegasys/teku/api/SchemaObjectProvider.java +++ b/data/provider/src/main/java/tech/pegasys/teku/api/SchemaObjectProvider.java @@ -13,37 +13,27 @@ package tech.pegasys.teku.api; -import tech.pegasys.teku.api.schema.BLSSignature; import tech.pegasys.teku.api.schema.BeaconBlock; import tech.pegasys.teku.api.schema.BeaconBlockBody; -import tech.pegasys.teku.api.schema.BeaconState; -import tech.pegasys.teku.api.schema.SignedBeaconBlock; import tech.pegasys.teku.api.schema.altair.BeaconBlockAltair; import tech.pegasys.teku.api.schema.altair.BeaconBlockBodyAltair; -import tech.pegasys.teku.api.schema.altair.BeaconStateAltair; import tech.pegasys.teku.api.schema.bellatrix.BeaconBlockBellatrix; import tech.pegasys.teku.api.schema.bellatrix.BeaconBlockBodyBellatrix; -import tech.pegasys.teku.api.schema.bellatrix.BeaconStateBellatrix; 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.BeaconStateCapella; 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.BeaconStateDeneb; 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.BeaconStateElectra; 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.api.schema.phase0.BeaconStatePhase0; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.Spec; import tech.pegasys.teku.spec.SpecMilestone; @@ -59,21 +49,6 @@ public SchemaObjectProvider(final Spec spec) { this.spec = spec; } - public SignedBeaconBlock getSignedBeaconBlock( - final tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock internalBlock) { - - return new SignedBeaconBlock( - getBeaconBlock(internalBlock.getMessage()), new BLSSignature(internalBlock.getSignature())); - } - - public SignedBeaconBlock getSignedBlindedBeaconBlock( - final tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock internalBlock) { - - return new SignedBeaconBlock( - getBlindedBlock(internalBlock.getMessage()), - new BLSSignature(internalBlock.getSignature())); - } - public BeaconBlock getBeaconBlock( final tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock block) { return getBeaconBlock(block, spec.atSlot(block.getSlot()).getMilestone()); @@ -244,17 +219,4 @@ private BlindedBeaconBlockBodyElectra getBlindedBlockBodyElectra( tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.electra .BlindedBeaconBlockBodyElectra.required(body)); } - - public BeaconState getBeaconState( - final tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState state) { - final UInt64 slot = state.getSlot(); - return switch (spec.atSlot(slot).getMilestone()) { - case PHASE0 -> new BeaconStatePhase0(state); - case ALTAIR -> new BeaconStateAltair(state); - case BELLATRIX -> new BeaconStateBellatrix(state); - case CAPELLA -> new BeaconStateCapella(state); - case DENEB -> new BeaconStateDeneb(state); - case ELECTRA -> new BeaconStateElectra(state); - }; - } } diff --git a/data/provider/src/test/java/tech/pegasys/teku/api/ConfigProviderTest.java b/data/provider/src/test/java/tech/pegasys/teku/api/ConfigProviderTest.java deleted file mode 100644 index db6878f874d..00000000000 --- a/data/provider/src/test/java/tech/pegasys/teku/api/ConfigProviderTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2022 - * - * 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 static org.assertj.core.api.Assertions.assertThat; - -import java.util.Map; -import org.junit.jupiter.api.Test; -import tech.pegasys.teku.spec.Spec; -import tech.pegasys.teku.spec.SpecFactory; -import tech.pegasys.teku.spec.config.SpecConfig; -import tech.pegasys.teku.spec.config.SpecConfigLoader; - -class ConfigProviderTest { - private final Spec spec = SpecFactory.create("holesky"); - - private final ConfigProvider configProvider = new ConfigProvider(spec); - - @Test - void shouldParseResultOfConfig() { - final Map configMap = configProvider.getConfig(); - final SpecConfig specConfig = SpecConfigLoader.loadRemoteConfig(configMap); - final SpecConfig expectedConfig = spec.getGenesisSpecConfig(); - assertThat(specConfig).isEqualToComparingFieldByField(expectedConfig); - } - - @Test - void nullInNullOut() { - assertThat(ConfigProvider.formatValue(null)).isNull(); - } -} diff --git a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/package-info.java b/data/serializer/src/main/java/tech/pegasys/teku/api/schema/package-info.java new file mode 100644 index 00000000000..7a0ca0f4fc3 --- /dev/null +++ b/data/serializer/src/main/java/tech/pegasys/teku/api/schema/package-info.java @@ -0,0 +1,5 @@ +/** + * @deprecated As of release 2024.09.00, api.schema is not maintained any longer. + */ +@Deprecated +package tech.pegasys.teku.api.schema; diff --git a/data/serializer/src/main/java/tech/pegasys/teku/provider/BLSPubKeyDeserializer.java b/data/serializer/src/main/java/tech/pegasys/teku/provider/BLSPubKeyDeserializer.java deleted file mode 100644 index 21cddc4ac6a..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/provider/BLSPubKeyDeserializer.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2022 - * - * 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.provider; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import java.io.IOException; -import org.apache.tuweni.bytes.Bytes; -import tech.pegasys.teku.api.schema.BLSPubKey; - -public class BLSPubKeyDeserializer extends JsonDeserializer { - @Override - public BLSPubKey deserialize(final JsonParser p, final DeserializationContext ctxt) - throws IOException { - return new BLSPubKey(Bytes.fromHexString(p.getValueAsString())); - } -} diff --git a/data/serializer/src/main/java/tech/pegasys/teku/provider/BLSPubKeySerializer.java b/data/serializer/src/main/java/tech/pegasys/teku/provider/BLSPubKeySerializer.java deleted file mode 100644 index d6329260a65..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/provider/BLSPubKeySerializer.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2022 - * - * 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.provider; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; -import java.io.IOException; -import java.util.Locale; -import tech.pegasys.teku.api.schema.BLSPubKey; - -public class BLSPubKeySerializer extends JsonSerializer { - @Override - public void serialize( - final BLSPubKey value, final JsonGenerator gen, final SerializerProvider serializers) - throws IOException { - gen.writeString(value.toHexString().toLowerCase(Locale.ROOT)); - } -} diff --git a/data/serializer/src/main/java/tech/pegasys/teku/provider/BLSSignatureDeserializer.java b/data/serializer/src/main/java/tech/pegasys/teku/provider/BLSSignatureDeserializer.java deleted file mode 100644 index 1b258b18a9e..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/provider/BLSSignatureDeserializer.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2022 - * - * 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.provider; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import java.io.IOException; -import tech.pegasys.teku.api.schema.BLSSignature; - -public class BLSSignatureDeserializer extends JsonDeserializer { - @Override - public BLSSignature deserialize(final JsonParser p, final DeserializationContext ctxt) - throws IOException { - return BLSSignature.fromHexString(p.getValueAsString()); - } -} diff --git a/data/serializer/src/main/java/tech/pegasys/teku/provider/BLSSignatureSerializer.java b/data/serializer/src/main/java/tech/pegasys/teku/provider/BLSSignatureSerializer.java deleted file mode 100644 index abd376ec189..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/provider/BLSSignatureSerializer.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2022 - * - * 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.provider; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; -import java.io.IOException; -import java.util.Locale; -import tech.pegasys.teku.api.schema.BLSSignature; - -public class BLSSignatureSerializer extends JsonSerializer { - @Override - public void serialize( - final BLSSignature value, final JsonGenerator gen, final SerializerProvider serializers) - throws IOException { - gen.writeString(value.toHexString().toLowerCase(Locale.ROOT)); - } -} diff --git a/data/serializer/src/main/java/tech/pegasys/teku/provider/GetNewBlindedBlockResponseDeserializer.java b/data/serializer/src/main/java/tech/pegasys/teku/provider/GetNewBlindedBlockResponseDeserializer.java deleted file mode 100644 index 5debd77e176..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/provider/GetNewBlindedBlockResponseDeserializer.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2022 - * - * 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.provider; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.util.Locale; -import tech.pegasys.teku.api.response.v1.validator.GetNewBlindedBlockResponse; -import tech.pegasys.teku.api.schema.BeaconBlock; -import tech.pegasys.teku.api.schema.Version; -import tech.pegasys.teku.api.schema.altair.BeaconBlockAltair; -import tech.pegasys.teku.api.schema.bellatrix.BlindedBlockBellatrix; -import tech.pegasys.teku.api.schema.phase0.BeaconBlockPhase0; - -public class GetNewBlindedBlockResponseDeserializer - extends JsonDeserializer { - private final ObjectMapper mapper; - - public GetNewBlindedBlockResponseDeserializer(final ObjectMapper mapper) { - this.mapper = mapper; - } - - @Override - public GetNewBlindedBlockResponse deserialize( - final JsonParser jp, final DeserializationContext ctxt) throws IOException { - JsonNode node = jp.getCodec().readTree(jp); - final Version version = - Version.valueOf(node.findValue("version").asText().toLowerCase(Locale.ROOT)); - final BeaconBlock block; - switch (version) { - case bellatrix: - block = mapper.treeToValue(node.findValue("data"), BlindedBlockBellatrix.class); - break; - case altair: - block = mapper.treeToValue(node.findValue("data"), BeaconBlockAltair.class); - break; - case phase0: - block = mapper.treeToValue(node.findValue("data"), BeaconBlockPhase0.class); - break; - default: - throw new IOException("Milestone was not able to be decoded"); - } - return new GetNewBlindedBlockResponse(version, block); - } -} diff --git a/data/serializer/src/main/java/tech/pegasys/teku/provider/GetNewBlockResponseV1Deserializer.java b/data/serializer/src/main/java/tech/pegasys/teku/provider/GetNewBlockResponseV1Deserializer.java deleted file mode 100644 index 2b7a3eeee75..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/provider/GetNewBlockResponseV1Deserializer.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2022 - * - * 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.provider; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import tech.pegasys.teku.api.response.v1.validator.GetNewBlockResponse; -import tech.pegasys.teku.api.schema.BeaconBlock; -import tech.pegasys.teku.api.schema.phase0.BeaconBlockPhase0; - -public class GetNewBlockResponseV1Deserializer extends JsonDeserializer { - private final ObjectMapper mapper; - - public GetNewBlockResponseV1Deserializer(final ObjectMapper mapper) { - this.mapper = mapper; - } - - @Override - public GetNewBlockResponse deserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - JsonNode node = jp.getCodec().readTree(jp); - final BeaconBlock block = mapper.treeToValue(node.findValue("data"), BeaconBlockPhase0.class); - return new GetNewBlockResponse(block); - } -} diff --git a/data/serializer/src/main/java/tech/pegasys/teku/provider/GetNewBlockResponseV2Deserializer.java b/data/serializer/src/main/java/tech/pegasys/teku/provider/GetNewBlockResponseV2Deserializer.java deleted file mode 100644 index 75c9af5af95..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/provider/GetNewBlockResponseV2Deserializer.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2022 - * - * 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.provider; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.util.Locale; -import tech.pegasys.teku.api.response.v2.validator.GetNewBlockResponseV2; -import tech.pegasys.teku.api.schema.BeaconBlock; -import tech.pegasys.teku.api.schema.Version; -import tech.pegasys.teku.api.schema.altair.BeaconBlockAltair; -import tech.pegasys.teku.api.schema.bellatrix.BeaconBlockBellatrix; -import tech.pegasys.teku.api.schema.phase0.BeaconBlockPhase0; - -public class GetNewBlockResponseV2Deserializer extends JsonDeserializer { - private final ObjectMapper mapper; - - public GetNewBlockResponseV2Deserializer(final ObjectMapper mapper) { - this.mapper = mapper; - } - - @Override - public GetNewBlockResponseV2 deserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - JsonNode node = jp.getCodec().readTree(jp); - final Version version = - Version.valueOf(node.findValue("version").asText().toLowerCase(Locale.ROOT)); - final BeaconBlock block; - switch (version) { - case bellatrix: - block = mapper.treeToValue(node.findValue("data"), BeaconBlockBellatrix.class); - break; - case altair: - block = mapper.treeToValue(node.findValue("data"), BeaconBlockAltair.class); - break; - case phase0: - block = mapper.treeToValue(node.findValue("data"), BeaconBlockPhase0.class); - break; - default: - throw new IOException("Milestone was not able to be decoded"); - } - return new GetNewBlockResponseV2(version, block); - } -} diff --git a/data/serializer/src/main/java/tech/pegasys/teku/provider/GetStateResponseV2Deserializer.java b/data/serializer/src/main/java/tech/pegasys/teku/provider/GetStateResponseV2Deserializer.java deleted file mode 100644 index 23e71d11bdb..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/provider/GetStateResponseV2Deserializer.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2022 - * - * 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.provider; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.util.Locale; -import tech.pegasys.teku.api.response.v2.debug.GetStateResponseV2; -import tech.pegasys.teku.api.schema.BeaconState; -import tech.pegasys.teku.api.schema.Version; -import tech.pegasys.teku.api.schema.altair.BeaconStateAltair; -import tech.pegasys.teku.api.schema.phase0.BeaconStatePhase0; - -public class GetStateResponseV2Deserializer extends JsonDeserializer { - private final ObjectMapper mapper; - - public GetStateResponseV2Deserializer(final ObjectMapper mapper) { - this.mapper = mapper; - } - - @Override - public GetStateResponseV2 deserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - JsonNode node = jp.getCodec().readTree(jp); - final Version version = - Version.valueOf(node.findValue("version").asText().toLowerCase(Locale.ROOT)); - final boolean executionOptimistic = node.findValue("execution_optimistic").asBoolean(); - final BeaconState state; - switch (version) { - case altair: - state = mapper.treeToValue(node.findValue("data"), BeaconStateAltair.class); - break; - case phase0: - state = mapper.treeToValue(node.findValue("data"), BeaconStatePhase0.class); - break; - default: - throw new IOException("Milestone was not able to be decoded"); - } - return new GetStateResponseV2(version, executionOptimistic, state); - } -} diff --git a/data/serializer/src/main/java/tech/pegasys/teku/provider/JsonProvider.java b/data/serializer/src/main/java/tech/pegasys/teku/provider/JsonProvider.java deleted file mode 100644 index 63ff0486c65..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/provider/JsonProvider.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2022 - * - * 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.provider; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.Version; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.module.SimpleModule; -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.bytes.Bytes48; -import org.apache.tuweni.units.bigints.UInt256; -import tech.pegasys.teku.api.response.v1.validator.GetNewBlindedBlockResponse; -import tech.pegasys.teku.api.response.v1.validator.GetNewBlockResponse; -import tech.pegasys.teku.api.response.v2.debug.GetStateResponseV2; -import tech.pegasys.teku.api.response.v2.validator.GetNewBlockResponseV2; -import tech.pegasys.teku.api.schema.BLSPubKey; -import tech.pegasys.teku.api.schema.BLSSignature; -import tech.pegasys.teku.api.schema.KZGCommitment; -import tech.pegasys.teku.api.schema.KZGProof; -import tech.pegasys.teku.bls.BLSPublicKey; -import tech.pegasys.teku.ethereum.execution.types.Eth1Address; -import tech.pegasys.teku.ethereum.jackson.Eth1AddressDeserializer; -import tech.pegasys.teku.infrastructure.bytes.Bytes20; -import tech.pegasys.teku.infrastructure.bytes.Bytes4; -import tech.pegasys.teku.infrastructure.jackson.deserializers.bytes.ByteArrayDeserializer; -import tech.pegasys.teku.infrastructure.jackson.deserializers.bytes.ByteArraySerializer; -import tech.pegasys.teku.infrastructure.jackson.deserializers.bytes.Bytes20Deserializer; -import tech.pegasys.teku.infrastructure.jackson.deserializers.bytes.Bytes20Serializer; -import tech.pegasys.teku.infrastructure.jackson.deserializers.bytes.Bytes32Deserializer; -import tech.pegasys.teku.infrastructure.jackson.deserializers.bytes.Bytes48KeyDeserializer; -import tech.pegasys.teku.infrastructure.jackson.deserializers.bytes.Bytes4Deserializer; -import tech.pegasys.teku.infrastructure.jackson.deserializers.bytes.Bytes4Serializer; -import tech.pegasys.teku.infrastructure.jackson.deserializers.bytes.BytesDeserializer; -import tech.pegasys.teku.infrastructure.jackson.deserializers.bytes.BytesSerializer; -import tech.pegasys.teku.infrastructure.jackson.deserializers.bytes.DoubleDeserializer; -import tech.pegasys.teku.infrastructure.jackson.deserializers.bytes.DoubleSerializer; -import tech.pegasys.teku.infrastructure.jackson.deserializers.uints.UInt256Deserializer; -import tech.pegasys.teku.infrastructure.jackson.deserializers.uints.UInt256Serializer; -import tech.pegasys.teku.infrastructure.jackson.deserializers.uints.UInt64Deserializer; -import tech.pegasys.teku.infrastructure.jackson.deserializers.uints.UInt64Serializer; -import tech.pegasys.teku.infrastructure.ssz.collections.SszBitvector; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; - -public class JsonProvider { - private void addTekuMappers() { - SimpleModule module = new SimpleModule("TekuJson", new Version(1, 0, 0, null, null, null)); - - module.addSerializer(SszBitvector.class, new SszBitvectorSerializer()); - - module.addSerializer(BLSPubKey.class, new BLSPubKeySerializer()); - module.addDeserializer(BLSPubKey.class, new BLSPubKeyDeserializer()); - module.addDeserializer(BLSPublicKey.class, new BLSPublicKeyDeserializer()); - module.addSerializer(BLSPublicKey.class, new BLSPublicKeySerializer()); - module.addDeserializer(BLSSignature.class, new BLSSignatureDeserializer()); - module.addSerializer(BLSSignature.class, new BLSSignatureSerializer()); - - module.addKeyDeserializer(Bytes48.class, new Bytes48KeyDeserializer()); - - module.addDeserializer(Bytes32.class, new Bytes32Deserializer()); - module.addDeserializer(Bytes4.class, new Bytes4Deserializer()); - module.addSerializer(Bytes4.class, new Bytes4Serializer()); - module.addDeserializer(Bytes20.class, new Bytes20Deserializer()); - module.addDeserializer(Eth1Address.class, new Eth1AddressDeserializer()); - - module.addSerializer(Bytes20.class, new Bytes20Serializer()); - module.addDeserializer(Bytes.class, new BytesDeserializer()); - module.addSerializer(Bytes.class, new BytesSerializer()); - module.addDeserializer(Double.class, new DoubleDeserializer()); - module.addSerializer(Double.class, new DoubleSerializer()); - - module.addDeserializer(UInt64.class, new UInt64Deserializer()); - module.addSerializer(UInt64.class, new UInt64Serializer()); - - module.addDeserializer(UInt256.class, new UInt256Deserializer()); - module.addSerializer(UInt256.class, new UInt256Serializer()); - - module.addSerializer(byte[].class, new ByteArraySerializer()); - module.addDeserializer(byte[].class, new ByteArrayDeserializer()); - - module.addSerializer(KZGCommitment.class, new KZGCommitmentSerializer()); - module.addDeserializer(KZGCommitment.class, new KZGCommitmentDeserializer()); - module.addDeserializer( - GetNewBlockResponse.class, new GetNewBlockResponseV1Deserializer(objectMapper)); - - module.addDeserializer( - GetNewBlockResponseV2.class, new GetNewBlockResponseV2Deserializer(objectMapper)); - module.addDeserializer( - GetStateResponseV2.class, new GetStateResponseV2Deserializer(objectMapper)); - module.addDeserializer( - GetNewBlindedBlockResponse.class, new GetNewBlindedBlockResponseDeserializer(objectMapper)); - - module.addSerializer(KZGProof.class, new KZGProofSerializer()); - module.addDeserializer(KZGProof.class, new KZGProofDeserializer()); - - objectMapper.registerModule(module); - } - - private final ObjectMapper objectMapper; - - public JsonProvider() { - objectMapper = new ObjectMapper(); - objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - addTekuMappers(); - } - - public String objectToJSON(final T object) throws JsonProcessingException { - return objectMapper.writeValueAsString(object); - } - - public String objectToPrettyJSON(final T object) throws JsonProcessingException { - return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(object); - } - - public T jsonToObject(final String json, final Class clazz) - throws JsonProcessingException { - return objectMapper.readValue(json, clazz); - } - - public ObjectMapper getObjectMapper() { - return objectMapper; - } -} diff --git a/data/serializer/src/main/java/tech/pegasys/teku/provider/KZGCommitmentDeserializer.java b/data/serializer/src/main/java/tech/pegasys/teku/provider/KZGCommitmentDeserializer.java deleted file mode 100644 index 29c75ef3fd1..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/provider/KZGCommitmentDeserializer.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2022 - * - * 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.provider; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import java.io.IOException; -import org.apache.tuweni.bytes.Bytes; -import tech.pegasys.teku.api.schema.KZGCommitment; - -public class KZGCommitmentDeserializer extends JsonDeserializer { - @Override - public KZGCommitment deserialize(final JsonParser p, final DeserializationContext ctxt) - throws IOException { - return new KZGCommitment(Bytes.fromHexString(p.getValueAsString())); - } -} diff --git a/data/serializer/src/main/java/tech/pegasys/teku/provider/KZGCommitmentSerializer.java b/data/serializer/src/main/java/tech/pegasys/teku/provider/KZGCommitmentSerializer.java deleted file mode 100644 index ef219cfe2fc..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/provider/KZGCommitmentSerializer.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2022 - * - * 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.provider; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; -import java.io.IOException; -import java.util.Locale; -import tech.pegasys.teku.api.schema.KZGCommitment; - -public class KZGCommitmentSerializer extends JsonSerializer { - @Override - public void serialize( - final KZGCommitment value, final JsonGenerator gen, final SerializerProvider serializers) - throws IOException { - gen.writeString(value.toHexString().toLowerCase(Locale.ROOT)); - } -} diff --git a/data/serializer/src/main/java/tech/pegasys/teku/provider/KZGProofDeserializer.java b/data/serializer/src/main/java/tech/pegasys/teku/provider/KZGProofDeserializer.java deleted file mode 100644 index 48a221df1e7..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/provider/KZGProofDeserializer.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2022 - * - * 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.provider; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import java.io.IOException; -import org.apache.tuweni.bytes.Bytes; -import tech.pegasys.teku.api.schema.KZGProof; - -public class KZGProofDeserializer extends JsonDeserializer { - @Override - public KZGProof deserialize(final JsonParser p, final DeserializationContext ignore) - throws IOException { - return new KZGProof(Bytes.fromHexString(p.getValueAsString())); - } -} diff --git a/data/serializer/src/main/java/tech/pegasys/teku/provider/KZGProofSerializer.java b/data/serializer/src/main/java/tech/pegasys/teku/provider/KZGProofSerializer.java deleted file mode 100644 index 60343505098..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/provider/KZGProofSerializer.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2022 - * - * 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.provider; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; -import java.io.IOException; -import java.util.Locale; -import tech.pegasys.teku.api.schema.KZGProof; - -public class KZGProofSerializer extends JsonSerializer { - @Override - public void serialize( - final KZGProof value, final JsonGenerator gen, final SerializerProvider serializers) - throws IOException { - gen.writeString(value.toHexString().toLowerCase(Locale.ROOT)); - } -} diff --git a/data/serializer/src/main/java/tech/pegasys/teku/provider/SszBitvectorSerializer.java b/data/serializer/src/main/java/tech/pegasys/teku/provider/SszBitvectorSerializer.java deleted file mode 100644 index af7c94eb838..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/provider/SszBitvectorSerializer.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2022 - * - * 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.provider; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; -import java.io.IOException; -import java.util.Locale; -import tech.pegasys.teku.infrastructure.ssz.collections.SszBitvector; - -public class SszBitvectorSerializer extends JsonSerializer { - @Override - public void serialize( - final SszBitvector value, final JsonGenerator gen, final SerializerProvider serializers) - throws IOException { - gen.writeString(value.sszSerialize().toHexString().toLowerCase(Locale.ROOT)); - } -} diff --git a/data/serializer/src/property-test/java/tech/pegasys/teku/provider/JsonProviderPropertyTest.java b/data/serializer/src/property-test/java/tech/pegasys/teku/provider/JsonProviderPropertyTest.java deleted file mode 100644 index 287565f5dba..00000000000 --- a/data/serializer/src/property-test/java/tech/pegasys/teku/provider/JsonProviderPropertyTest.java +++ /dev/null @@ -1,428 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2022 - * - * 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.provider; - -import static java.nio.charset.StandardCharsets.UTF_8; -import static org.apache.commons.lang3.StringEscapeUtils.unescapeJava; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; - -import com.fasterxml.jackson.core.JsonProcessingException; -import java.lang.reflect.Constructor; -import java.util.Arrays; -import java.util.Locale; -import java.util.Map; -import net.jqwik.api.ForAll; -import net.jqwik.api.Property; -import net.jqwik.api.constraints.IntRange; -import net.jqwik.api.constraints.Size; -import org.apache.commons.lang3.ArrayUtils; -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt256; -import tech.pegasys.teku.api.schema.Attestation; -import tech.pegasys.teku.api.schema.AttestationData; -import tech.pegasys.teku.api.schema.AttesterSlashing; -import tech.pegasys.teku.api.schema.BLSPubKey; -import tech.pegasys.teku.api.schema.BLSSignature; -import tech.pegasys.teku.api.schema.BeaconBlockHeader; -import tech.pegasys.teku.api.schema.BeaconState; -import tech.pegasys.teku.api.schema.Checkpoint; -import tech.pegasys.teku.api.schema.Deposit; -import tech.pegasys.teku.api.schema.DepositData; -import tech.pegasys.teku.api.schema.Eth1Data; -import tech.pegasys.teku.api.schema.Fork; -import tech.pegasys.teku.api.schema.IndexedAttestation; -import tech.pegasys.teku.api.schema.KZGCommitment; -import tech.pegasys.teku.api.schema.PendingAttestation; -import tech.pegasys.teku.api.schema.ProposerSlashing; -import tech.pegasys.teku.api.schema.SignedBeaconBlock; -import tech.pegasys.teku.api.schema.Validator; -import tech.pegasys.teku.api.schema.VoluntaryExit; -import tech.pegasys.teku.api.schema.altair.BeaconStateAltair; -import tech.pegasys.teku.api.schema.altair.SignedBeaconBlockAltair; -import tech.pegasys.teku.api.schema.bellatrix.BeaconStateBellatrix; -import tech.pegasys.teku.api.schema.bellatrix.SignedBeaconBlockBellatrix; -import tech.pegasys.teku.api.schema.capella.BeaconStateCapella; -import tech.pegasys.teku.api.schema.capella.SignedBeaconBlockCapella; -import tech.pegasys.teku.api.schema.deneb.BeaconStateDeneb; -import tech.pegasys.teku.api.schema.deneb.SignedBeaconBlockDeneb; -import tech.pegasys.teku.api.schema.electra.BeaconStateElectra; -import tech.pegasys.teku.api.schema.electra.SignedBeaconBlockElectra; -import tech.pegasys.teku.api.schema.phase0.BeaconStatePhase0; -import tech.pegasys.teku.api.schema.phase0.SignedBeaconBlockPhase0; -import tech.pegasys.teku.infrastructure.json.JsonUtil; -import tech.pegasys.teku.infrastructure.json.types.DeserializableTypeDefinition; -import tech.pegasys.teku.infrastructure.ssz.SszData; -import tech.pegasys.teku.infrastructure.ssz.collections.SszBitvector; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.spec.Spec; -import tech.pegasys.teku.spec.SpecMilestone; -import tech.pegasys.teku.spec.TestSpecFactory; -import tech.pegasys.teku.spec.networks.Eth2Network; -import tech.pegasys.teku.spec.propertytest.suppliers.SpecSupplier; -import tech.pegasys.teku.spec.util.DataStructureUtil; - -public class JsonProviderPropertyTest { - private static final String Q = "\""; - private final JsonProvider jsonProvider = new JsonProvider(); - - private static final Map> - SIGNED_BEACON_BLOCK_CLASS_MAP = - Map.of( - SpecMilestone.PHASE0, - SignedBeaconBlockPhase0.class, - SpecMilestone.ALTAIR, - SignedBeaconBlockAltair.class, - SpecMilestone.BELLATRIX, - SignedBeaconBlockBellatrix.class, - SpecMilestone.CAPELLA, - SignedBeaconBlockCapella.class, - SpecMilestone.DENEB, - SignedBeaconBlockDeneb.class, - SpecMilestone.ELECTRA, - SignedBeaconBlockElectra.class); - - private static final Map> BEACON_STATE_CLASS_MAP = - Map.of( - SpecMilestone.PHASE0, - BeaconStatePhase0.class, - SpecMilestone.ALTAIR, - BeaconStateAltair.class, - SpecMilestone.BELLATRIX, - BeaconStateBellatrix.class, - SpecMilestone.CAPELLA, - BeaconStateCapella.class, - SpecMilestone.DENEB, - BeaconStateDeneb.class, - SpecMilestone.ELECTRA, - BeaconStateElectra.class); - - @Property - void roundTripBytes32(@ForAll @Size(32) final byte[] value) throws JsonProcessingException { - Bytes32 data = Bytes32.wrap(value); - String serialized = jsonProvider.objectToJSON(data); - assertEquals(Q + data.toHexString().toLowerCase(Locale.ROOT) + Q, serialized); - Bytes32 deserialize = jsonProvider.jsonToObject(serialized, Bytes32.class); - assertEquals(data, deserialize); - } - - @Property - void roundTripUInt256(@ForAll @Size(32) final byte[] value) throws JsonProcessingException { - final Bytes bytes = Bytes.wrap(value); - final UInt256 original = UInt256.fromBytes(bytes); - final String serialized = jsonProvider.objectToJSON(original); - assertEquals(serialized, Q + original.toDecimalString() + Q); - final UInt256 deserialized = jsonProvider.jsonToObject(serialized, UInt256.class); - assertEquals(deserialized, original); - } - - @Property - void roundTripUInt64(@ForAll final long value) throws JsonProcessingException { - final UInt64 original = UInt64.fromLongBits(value); - final String serialized = jsonProvider.objectToJSON(original); - assertEquals(serialized, Q + original.toString() + Q); - final UInt64 deserialized = jsonProvider.jsonToObject(serialized, UInt64.class); - assertEquals(deserialized, original); - } - - @Property - void serializeString(@ForAll final String original) throws JsonProcessingException { - final String serialized = jsonProvider.objectToJSON(original); - assertThat(unescapeJava(serialized).getBytes(UTF_8)) - .isEqualTo((Q + original + Q).getBytes(UTF_8)); - } - - @Property - void roundTripByteArray(@ForAll final byte[] original) throws JsonProcessingException { - final String serialized = jsonProvider.objectToJSON(original); - assertEquals(serialized, byteArrayToUnsignedStringWithQuotesAndNoSpaces(original)); - final byte[] deserialized = jsonProvider.jsonToObject(serialized, byte[].class); - assertThat(deserialized).isEqualTo(original); - } - - static String byteArrayToUnsignedStringWithQuotesAndNoSpaces(final byte[] bytes) { - return Arrays.toString( - Arrays.asList(ArrayUtils.toObject(bytes)).stream() - .map(Byte::toUnsignedInt) - .map(s -> Q + s + Q) - .toArray()) - .replace(" ", ""); - } - - @Property - void roundTripBlsPubKey( - @ForAll final int seed, @ForAll(supplier = SpecSupplier.class) final Spec spec) - throws JsonProcessingException { - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final BLSPubKey original = new BLSPubKey(dataStructureUtil.randomPublicKey()); - final String serialized = jsonProvider.objectToJSON(original); - final BLSPubKey deserialized = jsonProvider.jsonToObject(serialized, BLSPubKey.class); - assertThat(deserialized).isEqualTo(original); - } - - @Property - void roundTripBlsSignature( - @ForAll final int seed, @ForAll(supplier = SpecSupplier.class) final Spec spec) - throws JsonProcessingException { - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final BLSSignature original = new BLSSignature(dataStructureUtil.randomSignature()); - final String serialized = jsonProvider.objectToJSON(original); - final BLSSignature deserialized = jsonProvider.jsonToObject(serialized, BLSSignature.class); - assertThat(deserialized).isEqualTo(original); - } - - @Property - public void roundTripBitVector( - @ForAll final int seed, - @ForAll(supplier = SpecSupplier.class) final Spec spec, - @ForAll @IntRange(min = 1, max = 1000) final int size) - throws JsonProcessingException { - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final SszBitvector original = dataStructureUtil.randomSszBitvector(size); - final String serialized = jsonProvider.objectToJSON(original); - final SszBitvector deserialized = - JsonUtil.parse(serialized, original.getSchema().getJsonTypeDefinition()); - assertThat(deserialized).isEqualTo(original); - } - - @Property - public void roundTripFork( - @ForAll final int seed, @ForAll(supplier = SpecSupplier.class) final Spec spec) - throws JsonProcessingException { - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final Fork original = new Fork(dataStructureUtil.randomFork()); - final String serialized = jsonProvider.objectToJSON(original); - final Object deserialized = jsonProvider.jsonToObject(serialized, Fork.class); - assertThat(deserialized).isEqualToComparingFieldByField(original); - } - - @Property - public void roundTripCheckpoint( - @ForAll final int seed, - @ForAll(supplier = SpecSupplier.class) final Spec spec, - @ForAll final long epoch) - throws JsonProcessingException { - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final Checkpoint original = - new Checkpoint(dataStructureUtil.randomCheckpoint(UInt64.fromLongBits(epoch))); - final String serialized = jsonProvider.objectToJSON(original); - final Object deserialized = jsonProvider.jsonToObject(serialized, Checkpoint.class); - assertThat(deserialized).isEqualToComparingFieldByField(original); - } - - @Property - public void roundTripValidator( - @ForAll final int seed, @ForAll(supplier = SpecSupplier.class) final Spec spec) - throws JsonProcessingException { - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final Validator original = new Validator(dataStructureUtil.randomValidator()); - final String serialized = jsonProvider.objectToJSON(original); - final Object deserialized = jsonProvider.jsonToObject(serialized, Validator.class); - assertThat(deserialized).isEqualToComparingFieldByField(original); - } - - @Property - public void roundTripAttestationData( - @ForAll final int seed, @ForAll(supplier = SpecSupplier.class) final Spec spec) - throws JsonProcessingException { - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final AttestationData original = new AttestationData(dataStructureUtil.randomAttestationData()); - final String serialized = jsonProvider.objectToJSON(original); - final Object deserialized = jsonProvider.jsonToObject(serialized, AttestationData.class); - assertThat(deserialized).isEqualToComparingFieldByField(original); - } - - @Property - public void roundTripIndexedAttestation( - @ForAll final int seed, @ForAll(supplier = SpecSupplier.class) final Spec spec) - throws JsonProcessingException { - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final IndexedAttestation original = - new IndexedAttestation(dataStructureUtil.randomIndexedAttestation()); - final String serialized = jsonProvider.objectToJSON(original); - final Object deserialized = jsonProvider.jsonToObject(serialized, IndexedAttestation.class); - assertThat(deserialized).isEqualToComparingFieldByField(original); - } - - @Property - public void roundTripPendingAttestation(@ForAll final int seed, @ForAll final Eth2Network network) - throws JsonProcessingException { - final SpecMilestone specMilestone = SpecMilestone.PHASE0; - final Spec spec = TestSpecFactory.create(specMilestone, network); - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final PendingAttestation original = - new PendingAttestation(dataStructureUtil.randomPendingAttestation()); - final String serialized = jsonProvider.objectToJSON(original); - final Object deserialized = jsonProvider.jsonToObject(serialized, PendingAttestation.class); - assertThat(deserialized).isEqualToComparingFieldByField(original); - } - - @Property - public void roundTripEth1Data( - @ForAll final int seed, @ForAll(supplier = SpecSupplier.class) final Spec spec) - throws JsonProcessingException { - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final Eth1Data original = new Eth1Data(dataStructureUtil.randomEth1Data()); - final String serialized = jsonProvider.objectToJSON(original); - final Object deserialized = jsonProvider.jsonToObject(serialized, Eth1Data.class); - assertThat(deserialized).isEqualToComparingFieldByField(original); - } - - @Property - public void roundTripDepositData( - @ForAll final int seed, @ForAll(supplier = SpecSupplier.class) final Spec spec) - throws JsonProcessingException { - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final DepositData original = new DepositData(dataStructureUtil.randomDepositData()); - final String serialized = jsonProvider.objectToJSON(original); - final Object deserialized = jsonProvider.jsonToObject(serialized, DepositData.class); - assertThat(deserialized).isEqualToComparingFieldByField(original); - } - - @Property - public void roundTripBeaconBlockHeader( - @ForAll final int seed, @ForAll(supplier = SpecSupplier.class) final Spec spec) - throws JsonProcessingException { - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final BeaconBlockHeader original = - new BeaconBlockHeader(dataStructureUtil.randomBeaconBlockHeader()); - final String serialized = jsonProvider.objectToJSON(original); - final Object deserialized = jsonProvider.jsonToObject(serialized, BeaconBlockHeader.class); - assertThat(deserialized).isEqualToComparingFieldByField(original); - } - - @Property - public void roundTripBeaconProposerSlashing( - @ForAll final int seed, @ForAll(supplier = SpecSupplier.class) final Spec spec) - throws JsonProcessingException { - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final ProposerSlashing original = - new ProposerSlashing(dataStructureUtil.randomProposerSlashing()); - final String serialized = jsonProvider.objectToJSON(original); - final Object deserialized = jsonProvider.jsonToObject(serialized, ProposerSlashing.class); - assertThat(deserialized).isEqualToComparingFieldByField(original); - } - - @Property - public void roundTripBeaconAttesterSlashing( - @ForAll final int seed, @ForAll(supplier = SpecSupplier.class) final Spec spec) - throws JsonProcessingException { - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final AttesterSlashing original = - new AttesterSlashing(dataStructureUtil.randomAttesterSlashing()); - final String serialized = jsonProvider.objectToJSON(original); - final Object deserialized = jsonProvider.jsonToObject(serialized, AttesterSlashing.class); - assertThat(deserialized).isEqualToComparingFieldByField(original); - } - - @Property - public void roundTripBeaconAttestation( - @ForAll final int seed, @ForAll(supplier = SpecSupplier.class) final Spec spec) - throws JsonProcessingException { - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final Attestation original = new Attestation(dataStructureUtil.randomAttestation()); - final String serialized = jsonProvider.objectToJSON(original); - final Object deserialized = jsonProvider.jsonToObject(serialized, Attestation.class); - assertThat(deserialized).isEqualToComparingFieldByField(original); - } - - @Property - public void roundTripDeposit( - @ForAll final int seed, @ForAll(supplier = SpecSupplier.class) final Spec spec) - throws JsonProcessingException { - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final Deposit original = new Deposit(dataStructureUtil.randomDeposit()); - final String serialized = jsonProvider.objectToJSON(original); - final Object deserialized = jsonProvider.jsonToObject(serialized, Deposit.class); - assertThat(deserialized).isEqualToComparingFieldByField(original); - } - - @Property - public void roundTripVoluntaryExit( - @ForAll final int seed, @ForAll(supplier = SpecSupplier.class) final Spec spec) - throws JsonProcessingException { - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final VoluntaryExit original = new VoluntaryExit(dataStructureUtil.randomVoluntaryExit()); - final String serialized = jsonProvider.objectToJSON(original); - final Object deserialized = jsonProvider.jsonToObject(serialized, VoluntaryExit.class); - assertThat(deserialized).isEqualToComparingFieldByField(original); - } - - @Property(tries = 100) - public void roundTripSignedBeaconBlock( - @ForAll final int seed, - @ForAll(supplier = SpecSupplier.class) final Spec spec, - @ForAll final long slot, - @ForAll @Size(32) final byte[] parentRoot, - @ForAll @Size(32) final byte[] stateRoot, - @ForAll final boolean isFull) - throws Exception { - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final Class clazz = - SIGNED_BEACON_BLOCK_CLASS_MAP.get(spec.getForkSchedule().getHighestSupportedMilestone()); - final Constructor constructor = - clazz.getConstructor(tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock.class); - final Object original = - constructor.newInstance( - dataStructureUtil.signedBlock( - dataStructureUtil.randomBeaconBlock( - UInt64.fromLongBits(slot), - Bytes32.wrap(parentRoot), - Bytes32.wrap(stateRoot), - isFull))); - final String serialized = jsonProvider.objectToJSON(original); - final Object deserialized = jsonProvider.jsonToObject(serialized, clazz); - assertThat(deserialized).isEqualToComparingFieldByField(original); - } - - @Property(tries = 100) - public void roundTripBeaconState( - @ForAll final int seed, - @ForAll(supplier = SpecSupplier.class) final Spec spec, - @ForAll @IntRange(max = 1000) final int validatorCount, - @ForAll @IntRange(max = 1000) final int numItemsInSSZLists) - throws Exception { - final SpecMilestone specMilestone = spec.getForkSchedule().getHighestSupportedMilestone(); - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final Class clazz = BEACON_STATE_CLASS_MAP.get(specMilestone); - final Constructor constructor = - clazz.getConstructor( - tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState.class); - final BeaconState original = - constructor.newInstance( - dataStructureUtil.randomBeaconState(validatorCount, numItemsInSSZLists)); - final DeserializableTypeDefinition stateTypeDefinition = - spec.forMilestone(specMilestone) - .getSchemaDefinitions() - .getBeaconStateSchema() - .getJsonTypeDefinition(); - - final String serialized = jsonProvider.objectToJSON(original); - final SszData deserialized = JsonUtil.parse(serialized, stateTypeDefinition); - assertThat(deserialized.hashTreeRoot()) - .isEqualTo(original.asInternalBeaconState(spec).hashTreeRoot()); - } - - @Property - void roundTripKZGCommitment(@ForAll final int seed) throws JsonProcessingException { - final SpecMilestone specMilestone = SpecMilestone.DENEB; - final Spec spec = TestSpecFactory.create(specMilestone, Eth2Network.MINIMAL); - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final KZGCommitment original = new KZGCommitment(dataStructureUtil.randomKZGCommitment()); - final String serialized = jsonProvider.objectToJSON(original); - final KZGCommitment deserialized = jsonProvider.jsonToObject(serialized, KZGCommitment.class); - assertThat(deserialized).isEqualTo(original); - } -} diff --git a/data/serializer/src/test/java/tech/pegasys/teku/provider/JsonProviderTest.java b/data/serializer/src/test/java/tech/pegasys/teku/provider/JsonProviderTest.java deleted file mode 100644 index 0d093028591..00000000000 --- a/data/serializer/src/test/java/tech/pegasys/teku/provider/JsonProviderTest.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2022 - * - * 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.provider; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.fasterxml.jackson.core.JsonProcessingException; -import java.util.Locale; -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt256; -import org.junit.jupiter.api.Test; -import tech.pegasys.teku.api.schema.BeaconState; -import tech.pegasys.teku.api.schema.phase0.BeaconStatePhase0; -import tech.pegasys.teku.infrastructure.ssz.collections.SszBitvector; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.spec.TestSpecFactory; -import tech.pegasys.teku.spec.util.DataStructureUtil; - -class JsonProviderTest { - private static final String Q = "\""; - private final DataStructureUtil dataStructureUtil = - new DataStructureUtil(TestSpecFactory.createDefault()); - private final JsonProvider jsonProvider = new JsonProvider(); - - @Test - public void bytes32ShouldSerializeToJsonAndBack() throws JsonProcessingException { - Bytes32 data = Bytes32.random(); - String serialized = jsonProvider.objectToJSON(data); - assertEquals(Q + data.toHexString().toLowerCase(Locale.ROOT) + Q, serialized); - - Bytes32 deserialize = jsonProvider.jsonToObject(serialized, Bytes32.class); - assertEquals(data, deserialize); - } - - @Test - public void minUInt256ShouldSerializeAndDeserialize() throws JsonProcessingException { - final UInt256 data = UInt256.ZERO; - final String serialized = jsonProvider.objectToJSON(data); - assertEquals(serialized, Q + "0" + Q); - final UInt256 data2 = jsonProvider.jsonToObject(serialized, UInt256.class); - assertEquals(data2, data); - } - - @Test - public void UInt64ShouldSerializeAndDeserialize() throws JsonProcessingException { - final UInt64 data = dataStructureUtil.randomUInt64(); - final String serialized = jsonProvider.objectToJSON(data); - assertEquals(serialized, Q + data.toString() + Q); - final UInt64 data2 = jsonProvider.jsonToObject(serialized, UInt64.class); - assertEquals(data2, data); - } - - @Test - public void maxUInt64ShouldSerializeAndDeserialize() throws JsonProcessingException { - final UInt64 data = UInt64.MAX_VALUE; - final String serialized = jsonProvider.objectToJSON(data); - assertEquals(serialized, Q + data.toString() + Q); - final UInt64 data2 = jsonProvider.jsonToObject(serialized, UInt64.class); - assertEquals(data2, data); - } - - @Test - public void UInt256ShouldSerializeAndDeserialize() throws JsonProcessingException { - final UInt256 data = dataStructureUtil.randomUInt256(); - final String serialized = jsonProvider.objectToJSON(data); - assertEquals(serialized, Q + data.toDecimalString() + Q); - final UInt256 data2 = jsonProvider.jsonToObject(serialized, UInt256.class); - assertEquals(data2, data); - } - - @Test - public void maxUInt256ShouldSerializeAndDeserialize() throws JsonProcessingException { - final UInt256 data = UInt256.MAX_VALUE; - final String serialized = jsonProvider.objectToJSON(data); - assertEquals(serialized, Q + data.toDecimalString() + Q); - final UInt256 data2 = jsonProvider.jsonToObject(serialized, UInt256.class); - assertEquals(data2, data); - } - - @Test - public void UInt64ShouldDeserializeNonHex() throws JsonProcessingException { - final UInt256 data = jsonProvider.jsonToObject("10", UInt256.class); - assertEquals(data, UInt256.fromHexString("0xa")); - } - - @Test - public void bitVectorShouldSerializeAsSsz() throws JsonProcessingException { - final int bitvectorSize = 40; - final SszBitvector data = dataStructureUtil.randomSszBitvector(bitvectorSize); - final String asJson = jsonProvider.objectToJSON(data); - final String hexData = jsonProvider.jsonToObject(asJson, String.class); - final SszBitvector asData = data.getSchema().sszDeserialize(Bytes.fromHexString(hexData)); - - assertThat(data).isEqualTo(asData); - assertThat(asData.size()).isEqualTo(bitvectorSize); - } - - @Test - public void doubleShouldSerializeAndDeserialize() throws JsonProcessingException { - Double fewDecimals = 1.4; - final String serializedFewDecimals = jsonProvider.objectToJSON(fewDecimals); - final Double deserializedFewDecimals = - jsonProvider.jsonToObject(serializedFewDecimals, Double.class); - assertThat(fewDecimals).isEqualTo(deserializedFewDecimals); - - Double multipleDecimals = 1.41234; - Double truncatedMultipleDecimals = 1.4123; - final String serializedMultipleDecimals = jsonProvider.objectToJSON(multipleDecimals); - final Double deserializedMultipleDecimals = - jsonProvider.jsonToObject(serializedMultipleDecimals, Double.class); - assertThat(truncatedMultipleDecimals).isEqualTo(deserializedMultipleDecimals); - } - - @Test - public void stringShouldSerializeToJson() throws JsonProcessingException { - String data = "test"; - assertEquals(Q + data + Q, jsonProvider.objectToJSON(data)); - } - - @Test - public void byteArrayShouldSerializeToJson() throws JsonProcessingException { - final byte[] bytes = Bytes.fromHexString("0x00A0F0FF").toArray(); - assertEquals("[\"0\",\"160\",\"240\",\"255\"]", jsonProvider.objectToJSON(bytes)); - } - - @Test - public void zeroLengthByteArrayShouldSerializeToJson() throws JsonProcessingException { - assertEquals("[]", jsonProvider.objectToJSON(new byte[0])); - } - - @Test - public void deserializeToBytesShouldAllowZeroLengthArray() throws JsonProcessingException { - assertThat(jsonProvider.jsonToObject("[]", byte[].class)).isEqualTo(new byte[0]); - } - - @Test - public void deserializeToBytesShouldHandleSignedBits() throws JsonProcessingException { - assertThat(jsonProvider.jsonToObject("[\"0\",\"160\",\"240\",\"255\"]", byte[].class)) - .isEqualTo(Bytes.fromHexString("0x00A0F0FF").toArray()); - } - - @Test - public void deserializeToBytesShouldRejectValuesThatAreTooLarge() { - assertThatThrownBy(() -> jsonProvider.jsonToObject("[\"256\"]", byte[].class)) - .hasMessage("Expected \"256\" to be a byte value between 0 and 255 inclusive"); - } - - @Test - public void deserializeToBytesShouldRejectValuesThatAreBelowZero() { - assertThatThrownBy(() -> jsonProvider.jsonToObject("[\"-999\"]", byte[].class)) - .hasMessage("Expected \"-999\" to be a byte value between 0 and 255 inclusive"); - } - - @Test - public void deserializeToBytesShouldRejectValuesThatNotNumeric() { - assertThatThrownBy(() -> jsonProvider.jsonToObject("[\"a\"]", byte[].class)) - .hasMessage("Expected \"a\" to be a byte value between 0 and 255 inclusive"); - } - - @Test - void beaconStateJsonTest() throws JsonProcessingException { - tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState stateInternal = - dataStructureUtil.randomBeaconState(UInt64.valueOf(16)); - BeaconState state = new BeaconStatePhase0(stateInternal); - String jsonState = jsonProvider.objectToJSON(state); - assertTrue(jsonState.length() > 0); - } -} diff --git a/ethereum/weaksubjectivity/src/test/java/tech/pegasys/teku/weaksubjectivity/config/WeakSubjectivityConfigTest.java b/ethereum/weaksubjectivity/src/test/java/tech/pegasys/teku/weaksubjectivity/config/WeakSubjectivityConfigTest.java index 00d7d4287fa..7c0c5fc1422 100644 --- a/ethereum/weaksubjectivity/src/test/java/tech/pegasys/teku/weaksubjectivity/config/WeakSubjectivityConfigTest.java +++ b/ethereum/weaksubjectivity/src/test/java/tech/pegasys/teku/weaksubjectivity/config/WeakSubjectivityConfigTest.java @@ -66,7 +66,7 @@ public void updated_shouldCloneAllProperties() { WeakSubjectivityConfig configB = configA.updated((__) -> {}); assertThat(configA).isEqualTo(configB); - assertThat(configA).isEqualToComparingFieldByField(configB); + assertThat(configA).isEqualTo(configB); } @Test From ac813a2a9a6739259e096c468bbd6943d538a3d2 Mon Sep 17 00:00:00 2001 From: Paul Harris Date: Thu, 10 Oct 2024 07:38:24 +1000 Subject: [PATCH 2/2] Cleanup JsonProvider and unused serializers Signed-off-by: Paul Harris --- .../proposerconfig/loader}/BLSPublicKeyDeserializer.java | 4 ++-- .../client/proposerconfig/loader}/BLSPublicKeySerializer.java | 4 ++-- .../client/proposerconfig/loader/ProposerConfigLoader.java | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) rename {data/serializer/src/main/java/tech/pegasys/teku/provider => validator/client/src/main/java/tech/pegasys/teku/validator/client/proposerconfig/loader}/BLSPublicKeyDeserializer.java (88%) rename {data/serializer/src/main/java/tech/pegasys/teku/provider => validator/client/src/main/java/tech/pegasys/teku/validator/client/proposerconfig/loader}/BLSPublicKeySerializer.java (89%) diff --git a/data/serializer/src/main/java/tech/pegasys/teku/provider/BLSPublicKeyDeserializer.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/proposerconfig/loader/BLSPublicKeyDeserializer.java similarity index 88% rename from data/serializer/src/main/java/tech/pegasys/teku/provider/BLSPublicKeyDeserializer.java rename to validator/client/src/main/java/tech/pegasys/teku/validator/client/proposerconfig/loader/BLSPublicKeyDeserializer.java index f99c5cfc50c..d859f3ef5a3 100644 --- a/data/serializer/src/main/java/tech/pegasys/teku/provider/BLSPublicKeyDeserializer.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/proposerconfig/loader/BLSPublicKeyDeserializer.java @@ -11,7 +11,7 @@ * specific language governing permissions and limitations under the License. */ -package tech.pegasys.teku.provider; +package tech.pegasys.teku.validator.client.proposerconfig.loader; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationContext; @@ -19,7 +19,7 @@ import java.io.IOException; import tech.pegasys.teku.bls.BLSPublicKey; -public class BLSPublicKeyDeserializer extends JsonDeserializer { +class BLSPublicKeyDeserializer extends JsonDeserializer { @Override public BLSPublicKey deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException { diff --git a/data/serializer/src/main/java/tech/pegasys/teku/provider/BLSPublicKeySerializer.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/proposerconfig/loader/BLSPublicKeySerializer.java similarity index 89% rename from data/serializer/src/main/java/tech/pegasys/teku/provider/BLSPublicKeySerializer.java rename to validator/client/src/main/java/tech/pegasys/teku/validator/client/proposerconfig/loader/BLSPublicKeySerializer.java index a133ee4fe28..d7d48bea2dd 100644 --- a/data/serializer/src/main/java/tech/pegasys/teku/provider/BLSPublicKeySerializer.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/proposerconfig/loader/BLSPublicKeySerializer.java @@ -11,7 +11,7 @@ * specific language governing permissions and limitations under the License. */ -package tech.pegasys.teku.provider; +package tech.pegasys.teku.validator.client.proposerconfig.loader; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; @@ -20,7 +20,7 @@ import java.util.Locale; import tech.pegasys.teku.bls.BLSPublicKey; -public class BLSPublicKeySerializer extends JsonSerializer { +class BLSPublicKeySerializer extends JsonSerializer { @Override public void serialize( final BLSPublicKey value, final JsonGenerator gen, final SerializerProvider serializers) diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/proposerconfig/loader/ProposerConfigLoader.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/proposerconfig/loader/ProposerConfigLoader.java index 5f871d9811a..543025c9317 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/proposerconfig/loader/ProposerConfigLoader.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/proposerconfig/loader/ProposerConfigLoader.java @@ -28,8 +28,6 @@ import tech.pegasys.teku.infrastructure.exceptions.InvalidConfigurationException; import tech.pegasys.teku.infrastructure.http.UrlSanitizer; import tech.pegasys.teku.infrastructure.jackson.deserializers.bytes.Bytes48KeyDeserializer; -import tech.pegasys.teku.provider.BLSPublicKeyDeserializer; -import tech.pegasys.teku.provider.BLSPublicKeySerializer; import tech.pegasys.teku.validator.client.ProposerConfig; public class ProposerConfigLoader {