diff --git a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/PendingBalanceDeposit.java b/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/PendingBalanceDeposit.java deleted file mode 100644 index 4f6a1b4b3bd..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/PendingBalanceDeposit.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2024 - * - * 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.electra; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Optional; -import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt64; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.spec.SpecVersion; -import tech.pegasys.teku.spec.schemas.SchemaDefinitionsElectra; - -public class PendingBalanceDeposit { - - @JsonProperty("index") - public final int index; - - @JsonProperty("amount") - public final UInt64 amount; - - public PendingBalanceDeposit( - final @JsonProperty("index") int index, final @JsonProperty("amount") UInt64 amount) { - this.index = index; - this.amount = amount; - } - - public PendingBalanceDeposit( - final tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingBalanceDeposit - internalPendingBalanceDeposit) { - this.index = internalPendingBalanceDeposit.getIndex(); - this.amount = internalPendingBalanceDeposit.getAmount(); - } - - public tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingBalanceDeposit - asInternalPendingBalanceDeposit(final SpecVersion spec) { - final Optional schemaDefinitionsElectra = - spec.getSchemaDefinitions().toVersionElectra(); - if (schemaDefinitionsElectra.isEmpty()) { - throw new IllegalArgumentException( - "Could not create PendingBalanceDeposit for pre-electra spec"); - } - return schemaDefinitionsElectra - .get() - .getPendingBalanceDepositSchema() - .create(SszUInt64.of(UInt64.valueOf(this.index)), SszUInt64.of(this.amount)); - } -} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/state/versions/electra/PendingBalanceDeposit.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/state/versions/electra/PendingBalanceDeposit.java deleted file mode 100644 index 5add848267c..00000000000 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/state/versions/electra/PendingBalanceDeposit.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2024 - * - * 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.spec.datastructures.state.versions.electra; - -import tech.pegasys.teku.infrastructure.ssz.containers.Container2; -import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema2; -import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt64; -import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas; -import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; - -public class PendingBalanceDeposit extends Container2 { - public static class PendingBalanceDepositSchema - extends ContainerSchema2 { - - public PendingBalanceDepositSchema() { - super( - "PendingBalanceDeposit", - namedSchema("index", SszPrimitiveSchemas.UINT64_SCHEMA), - namedSchema("amount", SszPrimitiveSchemas.UINT64_SCHEMA)); - } - - @Override - public PendingBalanceDeposit createFromBackingNode(final TreeNode node) { - return new PendingBalanceDeposit(this, node); - } - - public PendingBalanceDeposit create(final SszUInt64 index, final SszUInt64 amount) { - return new PendingBalanceDeposit(this, index, amount); - } - - public SszUInt64 getIndexSchema() { - return (SszUInt64) getFieldSchema0(); - } - - public SszUInt64 getAmountSchema() { - return (SszUInt64) getFieldSchema1(); - } - } - - private PendingBalanceDeposit( - final PendingBalanceDepositSchema type, final TreeNode backingNode) { - super(type, backingNode); - } - - private PendingBalanceDeposit( - final PendingBalanceDepositSchema type, final SszUInt64 index, final SszUInt64 amount) { - super(type, index, amount); - } - - public int getIndex() { - return ((SszUInt64) get(0)).get().intValue(); - } - - public UInt64 getAmount() { - return ((SszUInt64) get(1)).get(); - } -} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsElectra.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsElectra.java index d65e2141f42..1f730bfad8a 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsElectra.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsElectra.java @@ -60,7 +60,6 @@ import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.BeaconStateElectra; import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.BeaconStateSchemaElectra; import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.MutableBeaconStateElectra; -import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingBalanceDeposit; import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingConsolidation; import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingDeposit; import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingPartialWithdrawal; @@ -97,7 +96,6 @@ public class SchemaDefinitionsElectra extends SchemaDefinitionsDeneb { private final WithdrawalRequestSchema withdrawalRequestSchema; private final ConsolidationRequestSchema consolidationRequestSchema; - private final PendingBalanceDeposit.PendingBalanceDepositSchema pendingBalanceDepositSchema; private final PendingDeposit.PendingDepositSchema pendingDepositSchema; private final PendingPartialWithdrawal.PendingPartialWithdrawalSchema @@ -171,7 +169,6 @@ public SchemaDefinitionsElectra(final SchemaRegistry schemaRegistry) { this.depositRequestSchema = DepositRequest.SSZ_SCHEMA; this.withdrawalRequestSchema = WithdrawalRequest.SSZ_SCHEMA; this.consolidationRequestSchema = ConsolidationRequest.SSZ_SCHEMA; - this.pendingBalanceDepositSchema = new PendingBalanceDeposit.PendingBalanceDepositSchema(); this.pendingDepositSchema = new PendingDeposit.PendingDepositSchema(); this.pendingPartialWithdrawalSchema = new PendingPartialWithdrawal.PendingPartialWithdrawalSchema(); @@ -320,10 +317,6 @@ public WithdrawalRequestSchema getWithdrawalRequestSchema() { return withdrawalRequestSchema; } - public PendingBalanceDeposit.PendingBalanceDepositSchema getPendingBalanceDepositSchema() { - return pendingBalanceDepositSchema; - } - public PendingDeposit.PendingDepositSchema getPendingDepositSchema() { return pendingDepositSchema; } diff --git a/ethereum/spec/src/property-test/java/tech/pegasys/teku/spec/datastructures/state/PendingBalanceDepositPropertyTest.java b/ethereum/spec/src/property-test/java/tech/pegasys/teku/spec/datastructures/state/PendingDepositPropertyTest.java similarity index 72% rename from ethereum/spec/src/property-test/java/tech/pegasys/teku/spec/datastructures/state/PendingBalanceDepositPropertyTest.java rename to ethereum/spec/src/property-test/java/tech/pegasys/teku/spec/datastructures/state/PendingDepositPropertyTest.java index a2d214b3d7b..d77c2272a8f 100644 --- a/ethereum/spec/src/property-test/java/tech/pegasys/teku/spec/datastructures/state/PendingBalanceDepositPropertyTest.java +++ b/ethereum/spec/src/property-test/java/tech/pegasys/teku/spec/datastructures/state/PendingDepositPropertyTest.java @@ -19,23 +19,21 @@ import com.fasterxml.jackson.core.JsonProcessingException; import net.jqwik.api.ForAll; import net.jqwik.api.Property; -import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingBalanceDeposit; -import tech.pegasys.teku.spec.propertytest.suppliers.state.PendingBalanceDepositSupplier; +import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingDeposit; +import tech.pegasys.teku.spec.propertytest.suppliers.state.PendingDepositSupplier; -public class PendingBalanceDepositPropertyTest { +public class PendingDepositPropertyTest { @Property void roundTrip( - @ForAll(supplier = PendingBalanceDepositSupplier.class) - final PendingBalanceDeposit pendingBalanceDeposit) + @ForAll(supplier = PendingDepositSupplier.class) final PendingDeposit pendingDeposit) throws JsonProcessingException { - assertRoundTrip(pendingBalanceDeposit); + assertRoundTrip(pendingDeposit); } @Property void deserializeMutated( - @ForAll(supplier = PendingBalanceDepositSupplier.class) - final PendingBalanceDeposit pendingBalanceDeposit, + @ForAll(supplier = PendingDepositSupplier.class) final PendingDeposit pendingDeposit, @ForAll final int seed) { - assertDeserializeMutatedThrowsExpected(pendingBalanceDeposit, seed); + assertDeserializeMutatedThrowsExpected(pendingDeposit, seed); } } diff --git a/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/propertytest/suppliers/state/PendingBalanceDepositSupplier.java b/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/propertytest/suppliers/state/PendingDepositSupplier.java similarity index 77% rename from ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/propertytest/suppliers/state/PendingBalanceDepositSupplier.java rename to ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/propertytest/suppliers/state/PendingDepositSupplier.java index c414c62d15e..04647731dae 100644 --- a/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/propertytest/suppliers/state/PendingBalanceDepositSupplier.java +++ b/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/propertytest/suppliers/state/PendingDepositSupplier.java @@ -14,13 +14,12 @@ package tech.pegasys.teku.spec.propertytest.suppliers.state; import tech.pegasys.teku.spec.SpecMilestone; -import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingBalanceDeposit; +import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingDeposit; import tech.pegasys.teku.spec.propertytest.suppliers.DataStructureUtilSupplier; import tech.pegasys.teku.spec.util.DataStructureUtil; -public class PendingBalanceDepositSupplier - extends DataStructureUtilSupplier { - public PendingBalanceDepositSupplier() { - super(DataStructureUtil::randomPendingBalanceDeposit, SpecMilestone.ELECTRA); +public class PendingDepositSupplier extends DataStructureUtilSupplier { + public PendingDepositSupplier() { + super(DataStructureUtil::randomPendingDeposit, SpecMilestone.ELECTRA); } } diff --git a/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java b/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java index d453b02bc73..8a46648f436 100644 --- a/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java +++ b/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java @@ -180,8 +180,8 @@ import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.altair.BeaconStateSchemaAltair; import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.BeaconStateSchemaPhase0; import tech.pegasys.teku.spec.datastructures.state.versions.capella.HistoricalSummary; -import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingBalanceDeposit; import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingConsolidation; +import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingDeposit; import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingPartialWithdrawal; import tech.pegasys.teku.spec.datastructures.type.SszKZGCommitment; import tech.pegasys.teku.spec.datastructures.type.SszKZGProof; @@ -2531,10 +2531,15 @@ public WithdrawalRequest withdrawalRequest(final Validator validator, final UInt .create(executionAddress, validator.getPublicKey(), amount); } - public PendingBalanceDeposit randomPendingBalanceDeposit() { + public PendingDeposit randomPendingDeposit() { return getElectraSchemaDefinitions(randomSlot()) - .getPendingBalanceDepositSchema() - .create(SszUInt64.of(randomUInt64()), SszUInt64.of(randomUInt64())); + .getPendingDepositSchema() + .create( + randomSszPublicKey(), + SszBytes32.of(randomEth1WithdrawalCredentials()), + SszUInt64.of(randomUInt64()), + randomSszSignature(), + SszUInt64.of(randomUInt64())); } public ConsolidationRequest randomConsolidationRequest() {