Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,22 @@

package tech.pegasys.teku.spec.datastructures.operations;

import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BLS_TO_EXECUTION_CHANGE_SCHEMA;

import tech.pegasys.teku.bls.BLSSignature;
import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema2;
import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode;
import tech.pegasys.teku.spec.datastructures.type.SszSignature;
import tech.pegasys.teku.spec.datastructures.type.SszSignatureSchema;
import tech.pegasys.teku.spec.schemas.registry.SchemaRegistry;

public class SignedBlsToExecutionChangeSchema
extends ContainerSchema2<SignedBlsToExecutionChange, BlsToExecutionChange, SszSignature> {

public SignedBlsToExecutionChangeSchema() {
public SignedBlsToExecutionChangeSchema(final SchemaRegistry schemaRegistry) {
super(
"SignedBLSToExecutionChange",
namedSchema("message", new BlsToExecutionChangeSchema()),
namedSchema("message", schemaRegistry.get(BLS_TO_EXECUTION_CHANGE_SCHEMA)),
namedSchema("signature", SszSignatureSchema.INSTANCE));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
package tech.pegasys.teku.spec.schemas;

import static com.google.common.base.Preconditions.checkArgument;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BLS_TO_EXECUTION_CHANGE_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.HISTORICAL_SUMMARY_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_BLS_TO_EXECUTION_CHANGE_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.WITHDRAWAL_SCHEMA;

import java.util.Optional;
import tech.pegasys.teku.spec.config.SpecConfigCapella;
Expand All @@ -35,7 +39,6 @@
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadSchema;
import tech.pegasys.teku.spec.datastructures.execution.versions.capella.ExecutionPayloadHeaderSchemaCapella;
import tech.pegasys.teku.spec.datastructures.execution.versions.capella.ExecutionPayloadSchemaCapella;
import tech.pegasys.teku.spec.datastructures.execution.versions.capella.Withdrawal;
import tech.pegasys.teku.spec.datastructures.execution.versions.capella.WithdrawalSchema;
import tech.pegasys.teku.spec.datastructures.operations.BlsToExecutionChangeSchema;
import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChangeSchema;
Expand Down Expand Up @@ -74,10 +77,12 @@ public class SchemaDefinitionsCapella extends SchemaDefinitionsBellatrix {
public SchemaDefinitionsCapella(final SchemaRegistry schemaRegistry) {
super(schemaRegistry);
final SpecConfigCapella specConfig = SpecConfigCapella.required(schemaRegistry.getSpecConfig());
this.historicalSummarySchema = schemaRegistry.get(HISTORICAL_SUMMARY_SCHEMA);
this.executionPayloadSchemaCapella = new ExecutionPayloadSchemaCapella(specConfig);
this.blsToExecutionChangeSchema = new BlsToExecutionChangeSchema();
this.signedBlsToExecutionChangeSchema = new SignedBlsToExecutionChangeSchema();
this.withdrawalSchema = Withdrawal.SSZ_SCHEMA;
this.blsToExecutionChangeSchema = schemaRegistry.get(BLS_TO_EXECUTION_CHANGE_SCHEMA);
this.signedBlsToExecutionChangeSchema =
schemaRegistry.get(SIGNED_BLS_TO_EXECUTION_CHANGE_SCHEMA);
this.withdrawalSchema = schemaRegistry.get(WITHDRAWAL_SCHEMA);

this.beaconStateSchema = BeaconStateSchemaCapella.create(specConfig);
this.executionPayloadHeaderSchemaCapella =
Expand Down Expand Up @@ -107,7 +112,6 @@ public SchemaDefinitionsCapella(final SchemaRegistry schemaRegistry) {
new BuilderBidSchemaBellatrix("BuilderBidCapella", executionPayloadHeaderSchemaCapella);
this.signedBuilderBidSchemaCapella =
new SignedBuilderBidSchema("SignedBuilderBidCapella", builderBidSchemaCapella);
this.historicalSummarySchema = new HistoricalSummary.HistoricalSummarySchema();
}

public static SchemaDefinitionsCapella required(final SchemaDefinitions schemaDefinitions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package tech.pegasys.teku.spec.schemas.registry;

import static tech.pegasys.teku.spec.SpecMilestone.CAPELLA;
import static tech.pegasys.teku.spec.SpecMilestone.ELECTRA;
import static tech.pegasys.teku.spec.SpecMilestone.PHASE0;
import static tech.pegasys.teku.spec.schemas.registry.BaseSchemaProvider.constantProviderBuilder;
Expand All @@ -21,10 +22,14 @@
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.ATTESTER_SLASHING_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.ATTNETS_ENR_FIELD_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BEACON_BLOCKS_BY_ROOT_REQUEST_MESSAGE_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BLS_TO_EXECUTION_CHANGE_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.HISTORICAL_BATCH_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.HISTORICAL_SUMMARY_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.INDEXED_ATTESTATION_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_AGGREGATE_AND_PROOF_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_BLS_TO_EXECUTION_CHANGE_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SYNCNETS_ENR_FIELD_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.WITHDRAWAL_SCHEMA;

import com.google.common.annotations.VisibleForTesting;
import java.util.HashSet;
Expand All @@ -33,14 +38,18 @@
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.config.SpecConfig;
import tech.pegasys.teku.spec.constants.NetworkConstants;
import tech.pegasys.teku.spec.datastructures.execution.versions.capella.WithdrawalSchema;
import tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.BeaconBlocksByRootRequestMessage.BeaconBlocksByRootRequestMessageSchema;
import tech.pegasys.teku.spec.datastructures.operations.AggregateAndProof.AggregateAndProofSchema;
import tech.pegasys.teku.spec.datastructures.operations.AttesterSlashingSchema;
import tech.pegasys.teku.spec.datastructures.operations.BlsToExecutionChangeSchema;
import tech.pegasys.teku.spec.datastructures.operations.IndexedAttestationSchema;
import tech.pegasys.teku.spec.datastructures.operations.SignedAggregateAndProof.SignedAggregateAndProofSchema;
import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChangeSchema;
import tech.pegasys.teku.spec.datastructures.operations.versions.electra.AttestationElectraSchema;
import tech.pegasys.teku.spec.datastructures.operations.versions.phase0.AttestationPhase0Schema;
import tech.pegasys.teku.spec.datastructures.state.HistoricalBatch.HistoricalBatchSchema;
import tech.pegasys.teku.spec.datastructures.state.versions.capella.HistoricalSummary.HistoricalSummarySchema;
import tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SchemaId;

public class SchemaRegistryBuilder {
Expand All @@ -59,7 +68,38 @@ public static SchemaRegistryBuilder create() {
.addProvider(createAttesterSlashingSchemaProvider())
.addProvider(createAttestationSchemaProvider())
.addProvider(createAggregateAndProofSchemaProvider())
.addProvider(createSignedAggregateAndProofSchemaProvider());
.addProvider(createSignedAggregateAndProofSchemaProvider())

// CAPELLA
.addProvider(createWithdrawalSchemaProvider())
.addProvider(createBlsToExecutionChangeSchemaProvider())
.addProvider(createSignedBlsToExecutionChangeSchemaProvider())
.addProvider(createHistoricalSummarySchemaProvider());
}

private static SchemaProvider<?> createHistoricalSummarySchemaProvider() {
return constantProviderBuilder(HISTORICAL_SUMMARY_SCHEMA)
.withCreator(CAPELLA, (registry, specConfig) -> new HistoricalSummarySchema())
.build();
}

private static SchemaProvider<?> createSignedBlsToExecutionChangeSchemaProvider() {
return constantProviderBuilder(SIGNED_BLS_TO_EXECUTION_CHANGE_SCHEMA)
.withCreator(
CAPELLA, (registry, specConfig) -> new SignedBlsToExecutionChangeSchema(registry))
.build();
}

private static SchemaProvider<?> createBlsToExecutionChangeSchemaProvider() {
return constantProviderBuilder(BLS_TO_EXECUTION_CHANGE_SCHEMA)
.withCreator(CAPELLA, (registry, specConfig) -> new BlsToExecutionChangeSchema())
.build();
}

private static SchemaProvider<?> createWithdrawalSchemaProvider() {
return constantProviderBuilder(WITHDRAWAL_SCHEMA)
.withCreator(CAPELLA, (registry, specConfig) -> new WithdrawalSchema())
.build();
}

private static SchemaProvider<?> createAttnetsENRFieldSchemaProvider() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,21 @@
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeaderSchema;
import tech.pegasys.teku.spec.datastructures.execution.versions.capella.WithdrawalSchema;
import tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.BeaconBlocksByRootRequestMessage.BeaconBlocksByRootRequestMessageSchema;
import tech.pegasys.teku.spec.datastructures.operations.AggregateAndProof.AggregateAndProofSchema;
import tech.pegasys.teku.spec.datastructures.operations.Attestation;
import tech.pegasys.teku.spec.datastructures.operations.AttestationSchema;
import tech.pegasys.teku.spec.datastructures.operations.AttesterSlashingSchema;
import tech.pegasys.teku.spec.datastructures.operations.BlsToExecutionChangeSchema;
import tech.pegasys.teku.spec.datastructures.operations.IndexedAttestationSchema;
import tech.pegasys.teku.spec.datastructures.operations.SignedAggregateAndProof.SignedAggregateAndProofSchema;
import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChangeSchema;
import tech.pegasys.teku.spec.datastructures.state.HistoricalBatch.HistoricalBatchSchema;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconStateSchema;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.MutableBeaconState;
import tech.pegasys.teku.spec.datastructures.state.versions.capella.HistoricalSummary.HistoricalSummarySchema;

public class SchemaTypes {
// PHASE0
Expand All @@ -59,17 +63,24 @@ public class SchemaTypes {
public static final SchemaId<SignedAggregateAndProofSchema> SIGNED_AGGREGATE_AND_PROOF_SCHEMA =
create("SIGNED_AGGREGATE_AND_PROOF_SCHEMA");

public static final SchemaId<ExecutionPayloadHeaderSchema<? extends ExecutionPayloadHeader>>
EXECUTION_PAYLOAD_HEADER_SCHEMA = create("EXECUTION_PAYLOAD_HEADER_SCHEMA");

public static final SchemaId<BeaconStateSchema<BeaconState, MutableBeaconState>>
BEACON_STATE_SCHEMA = create("BEACON_STATE_SCHEMA");

// Altair

// Bellatrix

public static final SchemaId<ExecutionPayloadHeaderSchema<? extends ExecutionPayloadHeader>>
EXECUTION_PAYLOAD_HEADER_SCHEMA = create("EXECUTION_PAYLOAD_HEADER_SCHEMA");

// Capella
public static final SchemaId<WithdrawalSchema> WITHDRAWAL_SCHEMA = create("WITHDRAWAL_SCHEMA");
public static final SchemaId<BlsToExecutionChangeSchema> BLS_TO_EXECUTION_CHANGE_SCHEMA =
create("BLS_TO_EXECUTION_CHANGE_SCHEMA");
public static final SchemaId<SignedBlsToExecutionChangeSchema>
SIGNED_BLS_TO_EXECUTION_CHANGE_SCHEMA = create("SIGNED_BLS_TO_EXECUTION_CHANGE_SCHEMA");
public static final SchemaId<HistoricalSummarySchema> HISTORICAL_SUMMARY_SCHEMA =
create("HISTORICAL_SUMMARY_SCHEMA");

// Deneb

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.infrastructure.bytes.Bytes20;
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.util.DataStructureUtil;

class WithdrawalTest {

private final DataStructureUtil dataStructureUtil =
new DataStructureUtil(TestSpecFactory.createMinimal(SpecMilestone.CAPELLA));
private final WithdrawalSchema withdrawalSchema = Withdrawal.SSZ_SCHEMA;
private final Spec spec = TestSpecFactory.createMinimal(SpecMilestone.CAPELLA);
private final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec);
private final WithdrawalSchema withdrawalSchema =
spec.getGenesisSchemaDefinitions().toVersionCapella().orElseThrow().getWithdrawalSchema();

private final UInt64 index = dataStructureUtil.randomUInt64();
private final UInt64 validatorIndex = dataStructureUtil.randomUInt64();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,20 @@
import tech.pegasys.teku.bls.BLSPublicKey;
import tech.pegasys.teku.infrastructure.bytes.Bytes20;
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.util.DataStructureUtil;

class BlsToExecutionChangeTest {

private final DataStructureUtil dataStructureUtil =
new DataStructureUtil(TestSpecFactory.createMinimal(SpecMilestone.CAPELLA));
private final Spec spec = TestSpecFactory.createMinimal(SpecMilestone.CAPELLA);
private final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec);

private final BlsToExecutionChangeSchema blsToExecutionChangeSchema =
new BlsToExecutionChangeSchema();
spec.getGenesisSchemaDefinitions()
.toVersionCapella()
.orElseThrow()
.getBlsToExecutionChangeSchema();

private final UInt64 validatorIndex = dataStructureUtil.randomUInt64();
private final BLSPublicKey fromBlsPubkey = dataStructureUtil.randomPublicKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@
import org.apache.tuweni.bytes.Bytes;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.bls.BLSSignature;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.TestSpecFactory;
import tech.pegasys.teku.spec.util.DataStructureUtil;

class SignedBlsToExecutionChangeTest {

private final DataStructureUtil dataStructureUtil =
new DataStructureUtil(TestSpecFactory.createMinimal(SpecMilestone.CAPELLA));
private final Spec spec = TestSpecFactory.createMinimal(SpecMilestone.CAPELLA);
private final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec);

private final SignedBlsToExecutionChangeSchema signedBlsToExecutionChangeSchema =
new SignedBlsToExecutionChangeSchema();
spec.getGenesisSchemaDefinitions()
.toVersionCapella()
.orElseThrow()
.getSignedBlsToExecutionChangeSchema();

private final BlsToExecutionChange message = dataStructureUtil.randomBlsToExecutionChange();

Expand Down