Skip to content

Commit

Permalink
Merge branch 'master' into p2p-dump
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyeh committed Apr 14, 2024
2 parents fa338e6 + c8a800c commit 7c06149
Show file tree
Hide file tree
Showing 13 changed files with 244 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@

public class PendingPartialWithdrawal
extends Container3<PendingPartialWithdrawal, SszUInt64, SszUInt64, SszUInt64> {
protected PendingPartialWithdrawal(
ContainerSchema3<PendingPartialWithdrawal, SszUInt64, SszUInt64, SszUInt64> schema) {
super(schema);
}

public PendingPartialWithdrawal(
final PendingPartialWithdrawalSchema pendingPartialWithdrawalSchema,
final SszUInt64 index,
final SszUInt64 amount,
final SszUInt64 withdrawableEpoch) {
super(pendingPartialWithdrawalSchema, index, amount, withdrawableEpoch);
}

public static class PendingPartialWithdrawalSchema
extends ContainerSchema3<PendingPartialWithdrawal, SszUInt64, SszUInt64, SszUInt64> {
Expand Down Expand Up @@ -52,16 +64,13 @@ public SszUInt64 getWithdrawableEpochSchema() {

@Override
public PendingPartialWithdrawal createFromBackingNode(TreeNode node) {
return null;
return new PendingPartialWithdrawal(this, node);
}
}

private PendingPartialWithdrawal(
PendingPartialWithdrawal.PendingPartialWithdrawalSchema type,
final SszUInt64 index,
final SszUInt64 amount,
final SszUInt64 withdrawableEpoch) {
super(type, index, amount, withdrawableEpoch);
PendingPartialWithdrawal.PendingPartialWithdrawalSchema type, final TreeNode backingNode) {
super(type, backingNode);
}

public int getIndex() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public SchemaDefinitionsAltair(final SpecConfigAltair specConfig) {
public static SchemaDefinitionsAltair required(final SchemaDefinitions schemaDefinitions) {
Preconditions.checkArgument(
schemaDefinitions instanceof SchemaDefinitionsAltair,
"Expected definitions of type %s by got %s",
"Expected definitions of type %s but got %s",
SchemaDefinitionsAltair.class,
schemaDefinitions.getClass());
return (SchemaDefinitionsAltair) schemaDefinitions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public SchemaDefinitionsBellatrix(final SpecConfigBellatrix specConfig) {
public static SchemaDefinitionsBellatrix required(final SchemaDefinitions schemaDefinitions) {
checkArgument(
schemaDefinitions instanceof SchemaDefinitionsBellatrix,
"Expected definitions of type %s by got %s",
"Expected definitions of type %s but got %s",
SchemaDefinitionsBellatrix.class,
schemaDefinitions.getClass());
return (SchemaDefinitionsBellatrix) schemaDefinitions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public SchemaDefinitionsCapella(final SpecConfigCapella specConfig) {
public static SchemaDefinitionsCapella required(final SchemaDefinitions schemaDefinitions) {
checkArgument(
schemaDefinitions instanceof SchemaDefinitionsCapella,
"Expected definitions of type %s by got %s",
"Expected definitions of type %s but got %s",
SchemaDefinitionsCapella.class,
schemaDefinitions.getClass());
return (SchemaDefinitionsCapella) schemaDefinitions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public SchemaDefinitionsDeneb(final SpecConfigDeneb specConfig) {
public static SchemaDefinitionsDeneb required(final SchemaDefinitions schemaDefinitions) {
checkArgument(
schemaDefinitions instanceof SchemaDefinitionsDeneb,
"Expected definitions of type %s by got %s",
"Expected definitions of type %s but got %s",
SchemaDefinitionsDeneb.class,
schemaDefinitions.getClass());
return (SchemaDefinitionsDeneb) schemaDefinitions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public SchemaDefinitionsElectra(final SpecConfigElectra specConfig) {
public static SchemaDefinitionsElectra required(final SchemaDefinitions schemaDefinitions) {
checkArgument(
schemaDefinitions instanceof SchemaDefinitionsElectra,
"Expected definitions of type %s by got %s",
"Expected definitions of type %s but got %s",
SchemaDefinitionsElectra.class,
schemaDefinitions.getClass());
return (SchemaDefinitionsElectra) schemaDefinitions;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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;

import static tech.pegasys.teku.spec.propertytest.util.PropertyTestHelper.assertDeserializeMutatedThrowsExpected;
import static tech.pegasys.teku.spec.propertytest.util.PropertyTestHelper.assertRoundTrip;

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;

public class PendingBalanceDepositPropertyTest {
@Property
void roundTrip(
@ForAll(supplier = PendingBalanceDepositSupplier.class)
final PendingBalanceDeposit pendingBalanceDeposit)
throws JsonProcessingException {
assertRoundTrip(pendingBalanceDeposit);
}

@Property
void deserializeMutated(
@ForAll(supplier = PendingBalanceDepositSupplier.class)
final PendingBalanceDeposit pendingBalanceDeposit,
@ForAll final int seed) {
assertDeserializeMutatedThrowsExpected(pendingBalanceDeposit, seed);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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;

import static tech.pegasys.teku.spec.propertytest.util.PropertyTestHelper.assertDeserializeMutatedThrowsExpected;
import static tech.pegasys.teku.spec.propertytest.util.PropertyTestHelper.assertRoundTrip;

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.PendingConsolidation;
import tech.pegasys.teku.spec.propertytest.suppliers.state.PendingConsolidationSupplier;

public class PendingConsolidationPropertyTest {
@Property
void roundTrip(
@ForAll(supplier = PendingConsolidationSupplier.class)
final PendingConsolidation pendingConsolidation)
throws JsonProcessingException {
assertRoundTrip(pendingConsolidation);
}

@Property
void deserializeMutated(
@ForAll(supplier = PendingConsolidationSupplier.class)
final PendingConsolidation pendingConsolidation,
@ForAll final int seed) {
assertDeserializeMutatedThrowsExpected(pendingConsolidation, seed);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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;

import static tech.pegasys.teku.spec.propertytest.util.PropertyTestHelper.assertDeserializeMutatedThrowsExpected;
import static tech.pegasys.teku.spec.propertytest.util.PropertyTestHelper.assertRoundTrip;

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.PendingPartialWithdrawal;
import tech.pegasys.teku.spec.propertytest.suppliers.state.PendingPartialWithdrawalSupplier;

public class PendingPartialWithdrawalPropertyTest {
@Property
void roundTrip(
@ForAll(supplier = PendingPartialWithdrawalSupplier.class)
final PendingPartialWithdrawal pendingPartialWithdrawal)
throws JsonProcessingException {
assertRoundTrip(pendingPartialWithdrawal);
}

@Property
void deserializeMutated(
@ForAll(supplier = PendingPartialWithdrawalSupplier.class)
final PendingPartialWithdrawal pendingPartialWithdrawal,
@ForAll final int seed) {
assertDeserializeMutatedThrowsExpected(pendingPartialWithdrawal, seed);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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.propertytest.suppliers.state;

import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingBalanceDeposit;
import tech.pegasys.teku.spec.propertytest.suppliers.DataStructureUtilSupplier;
import tech.pegasys.teku.spec.util.DataStructureUtil;

public class PendingBalanceDepositSupplier
extends DataStructureUtilSupplier<PendingBalanceDeposit> {
public PendingBalanceDepositSupplier() {
super(DataStructureUtil::randomPendingBalanceDeposit, SpecMilestone.ELECTRA);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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.propertytest.suppliers.state;

import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingConsolidation;
import tech.pegasys.teku.spec.propertytest.suppliers.DataStructureUtilSupplier;
import tech.pegasys.teku.spec.util.DataStructureUtil;

public class PendingConsolidationSupplier extends DataStructureUtilSupplier<PendingConsolidation> {
public PendingConsolidationSupplier() {
super(DataStructureUtil::randomPendingConsolidation, SpecMilestone.ELECTRA);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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.propertytest.suppliers.state;

import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingPartialWithdrawal;
import tech.pegasys.teku.spec.propertytest.suppliers.DataStructureUtilSupplier;
import tech.pegasys.teku.spec.util.DataStructureUtil;

public class PendingPartialWithdrawalSupplier
extends DataStructureUtilSupplier<PendingPartialWithdrawal> {
public PendingPartialWithdrawalSupplier() {
super(DataStructureUtil::randomPendingPartialWithdrawal, SpecMilestone.ELECTRA);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@
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.PendingPartialWithdrawal;
import tech.pegasys.teku.spec.datastructures.type.SszKZGCommitment;
import tech.pegasys.teku.spec.datastructures.type.SszKZGProof;
import tech.pegasys.teku.spec.datastructures.type.SszPublicKey;
Expand Down Expand Up @@ -2461,6 +2464,27 @@ public ExecutionLayerExit executionLayerExit(final Validator validator) {
.create(executionAddress, validator.getPublicKey());
}

public PendingBalanceDeposit randomPendingBalanceDeposit() {
return getElectraSchemaDefinitions(randomSlot())
.getPendingBalanceDepositSchema()
.create(SszUInt64.of(randomUInt64()), SszUInt64.of(randomUInt64()));
}

public PendingConsolidation randomPendingConsolidation() {
return getElectraSchemaDefinitions(randomSlot())
.getPendingConsolidationSchema()
.create(SszUInt64.of(randomUInt64()), SszUInt64.of(randomUInt64()));
}

public PendingPartialWithdrawal randomPendingPartialWithdrawal() {
return getElectraSchemaDefinitions(randomSlot())
.getPendingPartialWithdrawalSchema()
.create(
SszUInt64.of(randomUInt64()),
SszUInt64.of(randomUInt64()),
SszUInt64.of(randomUInt64()));
}

public UInt64 randomBlobSidecarIndex() {
return randomUInt64(spec.getMaxBlobsPerBlock().orElseThrow());
}
Expand Down

0 comments on commit 7c06149

Please sign in to comment.