Skip to content

Commit

Permalink
schema registry
Browse files Browse the repository at this point in the history
  • Loading branch information
tbenr committed Nov 7, 2024
1 parent 2caae10 commit a0d9658
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import static com.google.common.base.Preconditions.checkArgument;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BLOBS_BUNDLE_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SINGLE_ATTESTATION_SCHEMA;

import java.util.Optional;
import tech.pegasys.teku.infrastructure.ssz.schema.SszListSchema;
Expand Down Expand Up @@ -94,7 +95,7 @@ public SchemaDefinitionsElectra(final SchemaRegistry schemaRegistry) {

final long maxValidatorsPerAttestation = getMaxValidatorsPerAttestation(specConfig);

this.singleAttestationSchema = new SingleAttestationSchema();
this.singleAttestationSchema = schemaRegistry.get(SINGLE_ATTESTATION_SCHEMA);

this.executionRequestsSchema = new ExecutionRequestsSchema(specConfig);
this.beaconStateSchema = BeaconStateSchemaElectra.create(specConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
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.SINGLE_ATTESTATION_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;

Expand All @@ -61,6 +62,7 @@
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.SingleAttestationSchema;
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;
Expand Down Expand Up @@ -97,7 +99,16 @@ public static SchemaRegistryBuilder create() {
.addProvider(createBlobsInBlockSchemaProvider())
.addProvider(createBlobSidecarSchemaProvider())
.addProvider(createBlobSidecarsByRootRequestMessageSchemaProvider())
.addProvider(createBlobsBundleSchemaProvider());
.addProvider(createBlobsBundleSchemaProvider())

// ELECTRA
.addProvider(createSingleAttestationSchemaProvider());
}

private static SchemaProvider<?> createSingleAttestationSchemaProvider() {
return constantProviderBuilder(SINGLE_ATTESTATION_SCHEMA)
.withCreator(ELECTRA, (registry, specConfig) -> new SingleAttestationSchema())
.build();
}

private static SchemaProvider<?> createBlobsBundleSchemaProvider() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
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.SingleAttestationSchema;
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;
Expand Down Expand Up @@ -110,6 +111,10 @@ public class SchemaTypes {
public static final SchemaId<BlobsBundleSchema> BLOBS_BUNDLE_SCHEMA =
create("BLOBS_BUNDLE_SCHEMA");

// Electra
public static final SchemaId<SingleAttestationSchema> SINGLE_ATTESTATION_SCHEMA =
create("SINGLE_ATTESTATION_SCHEMA");

private SchemaTypes() {
// Prevent instantiation
}
Expand Down

0 comments on commit a0d9658

Please sign in to comment.