Skip to content

Commit

Permalink
fix config and schema refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tbenr committed Sep 12, 2024
1 parent b65a915 commit b72530e
Show file tree
Hide file tree
Showing 18 changed files with 151 additions and 218 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,6 @@ public int getReorgParentWeightThreshold() {
return specConfig.getReorgParentWeightThreshold();
}

@Override
public long getMaxValidatorPerAttestation() {
return specConfig.getMaxValidatorsPerCommittee();
}

@Override
public long getDepositChainId() {
return specConfig.getDepositChainId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ default int getMillisPerSlot() {

int getReorgParentWeightThreshold();

long getMaxValidatorPerAttestation();

// Casters
default Optional<SpecConfigAltair> toVersionAltair() {
return Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,6 @@ public int getMaxPendingPartialsPerWithdrawalsSweep() {
return maxPendingPartialsPerWithdrawalsSweep;
}

@Override
public long getMaxValidatorPerAttestation() {
return (long) specConfig.getMaxValidatorsPerCommittee() * specConfig.getMaxCommitteesPerSlot();
}

@Override
public Optional<SpecConfigElectra> toVersionElectra() {
return Optional.of(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,6 @@ public int getReorgParentWeightThreshold() {
return reorgParentWeightThreshold;
}

@Override
public long getMaxValidatorPerAttestation() {
return maxValidatorsPerCommittee;
}

@Override
public int getProposerScoreBoost() {
return proposerScoreBoost;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

package tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair;

import static tech.pegasys.teku.spec.schemas.SchemaTypes.ATTESTATION_SCHEMA;
import static tech.pegasys.teku.spec.schemas.SchemaTypes.ATTESTER_SLASHING_SCHEMA;

import it.unimi.dsi.fastutil.longs.LongList;
import java.util.function.Function;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
Expand All @@ -32,11 +35,9 @@
import tech.pegasys.teku.spec.datastructures.operations.Deposit;
import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing;
import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit;
import tech.pegasys.teku.spec.datastructures.operations.versions.phase0.AttestationPhase0Schema;
import tech.pegasys.teku.spec.datastructures.operations.versions.phase0.AttesterSlashingPhase0Schema;
import tech.pegasys.teku.spec.datastructures.operations.versions.phase0.IndexedAttestationPhase0Schema;
import tech.pegasys.teku.spec.datastructures.type.SszSignature;
import tech.pegasys.teku.spec.datastructures.type.SszSignatureSchema;
import tech.pegasys.teku.spec.schemas.SchemaRegistry;

public class BeaconBlockBodySchemaAltairImpl
extends ContainerSchema9<
Expand Down Expand Up @@ -78,7 +79,7 @@ private BeaconBlockBodySchemaAltairImpl(

public static BeaconBlockBodySchemaAltairImpl create(
final SpecConfig specConfig,
final long maxValidatorsPerAttestation,
final SchemaRegistry schemaRegistry,
final String containerName) {
return new BeaconBlockBodySchemaAltairImpl(
containerName,
Expand All @@ -92,17 +93,12 @@ public static BeaconBlockBodySchemaAltairImpl create(
namedSchema(
BlockBodyFields.ATTESTER_SLASHINGS,
SszListSchema.create(
new AttesterSlashingPhase0Schema(
new IndexedAttestationPhase0Schema(maxValidatorsPerAttestation)
.castTypeToIndexedAttestationSchema())
.castTypeToAttesterSlashingSchema(),
schemaRegistry.get(ATTESTER_SLASHING_SCHEMA),
specConfig.getMaxAttesterSlashings())),
namedSchema(
BlockBodyFields.ATTESTATIONS,
SszListSchema.create(
new AttestationPhase0Schema(maxValidatorsPerAttestation)
.castTypeToAttestationSchema(),
specConfig.getMaxAttestations())),
schemaRegistry.get(ATTESTATION_SCHEMA), specConfig.getMaxAttestations())),
namedSchema(
BlockBodyFields.DEPOSITS,
SszListSchema.create(Deposit.SSZ_SCHEMA, specConfig.getMaxDeposits())),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

package tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.bellatrix;

import static tech.pegasys.teku.spec.schemas.SchemaTypes.ATTESTATION_SCHEMA;
import static tech.pegasys.teku.spec.schemas.SchemaTypes.ATTESTER_SLASHING_SCHEMA;
import static tech.pegasys.teku.spec.schemas.SchemaTypes.EXECUTION_PAYLOAD_SCHEMA;

import it.unimi.dsi.fastutil.longs.LongList;
import java.util.function.Function;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
Expand All @@ -38,11 +42,9 @@
import tech.pegasys.teku.spec.datastructures.operations.Deposit;
import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing;
import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit;
import tech.pegasys.teku.spec.datastructures.operations.versions.phase0.AttestationPhase0Schema;
import tech.pegasys.teku.spec.datastructures.operations.versions.phase0.AttesterSlashingPhase0Schema;
import tech.pegasys.teku.spec.datastructures.operations.versions.phase0.IndexedAttestationPhase0Schema;
import tech.pegasys.teku.spec.datastructures.type.SszSignature;
import tech.pegasys.teku.spec.datastructures.type.SszSignatureSchema;
import tech.pegasys.teku.spec.schemas.SchemaRegistry;

public class BeaconBlockBodySchemaBellatrixImpl
extends ContainerSchema10<
Expand Down Expand Up @@ -87,10 +89,8 @@ private BeaconBlockBodySchemaBellatrixImpl(

public static BeaconBlockBodySchemaBellatrixImpl create(
final SpecConfigBellatrix specConfig,
final long maxValidatorsPerAttestation,
final SchemaRegistry schemaRegistry,
final String containerName) {
final ExecutionPayloadSchemaBellatrix executionPayloadSchemaBellatrix =
new ExecutionPayloadSchemaBellatrix(specConfig);
return new BeaconBlockBodySchemaBellatrixImpl(
containerName,
namedSchema(BlockBodyFields.RANDAO_REVEAL, SszSignatureSchema.INSTANCE),
Expand All @@ -103,17 +103,12 @@ public static BeaconBlockBodySchemaBellatrixImpl create(
namedSchema(
BlockBodyFields.ATTESTER_SLASHINGS,
SszListSchema.create(
new AttesterSlashingPhase0Schema(
new IndexedAttestationPhase0Schema(maxValidatorsPerAttestation)
.castTypeToIndexedAttestationSchema())
.castTypeToAttesterSlashingSchema(),
schemaRegistry.get(ATTESTER_SLASHING_SCHEMA),
specConfig.getMaxAttesterSlashings())),
namedSchema(
BlockBodyFields.ATTESTATIONS,
SszListSchema.create(
new AttestationPhase0Schema(maxValidatorsPerAttestation)
.castTypeToAttestationSchema(),
specConfig.getMaxAttestations())),
schemaRegistry.get(ATTESTATION_SCHEMA), specConfig.getMaxAttestations())),
namedSchema(
BlockBodyFields.DEPOSITS,
SszListSchema.create(Deposit.SSZ_SCHEMA, specConfig.getMaxDeposits())),
Expand All @@ -124,7 +119,9 @@ public static BeaconBlockBodySchemaBellatrixImpl create(
namedSchema(
BlockBodyFields.SYNC_AGGREGATE,
SyncAggregateSchema.create(specConfig.getSyncCommitteeSize())),
namedSchema(BlockBodyFields.EXECUTION_PAYLOAD, executionPayloadSchemaBellatrix));
namedSchema(
BlockBodyFields.EXECUTION_PAYLOAD,
(ExecutionPayloadSchemaBellatrix) schemaRegistry.get(EXECUTION_PAYLOAD_SCHEMA)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

package tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.bellatrix;

import static tech.pegasys.teku.spec.schemas.SchemaTypes.ATTESTATION_SCHEMA;
import static tech.pegasys.teku.spec.schemas.SchemaTypes.ATTESTER_SLASHING_SCHEMA;
import static tech.pegasys.teku.spec.schemas.SchemaTypes.EXECUTION_PAYLOAD_HEADER_SCHEMA;

import it.unimi.dsi.fastutil.longs.LongList;
import java.util.function.Function;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
Expand All @@ -37,11 +41,9 @@
import tech.pegasys.teku.spec.datastructures.operations.Deposit;
import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing;
import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit;
import tech.pegasys.teku.spec.datastructures.operations.versions.phase0.AttestationPhase0Schema;
import tech.pegasys.teku.spec.datastructures.operations.versions.phase0.AttesterSlashingPhase0Schema;
import tech.pegasys.teku.spec.datastructures.operations.versions.phase0.IndexedAttestationPhase0Schema;
import tech.pegasys.teku.spec.datastructures.type.SszSignature;
import tech.pegasys.teku.spec.datastructures.type.SszSignatureSchema;
import tech.pegasys.teku.spec.schemas.SchemaRegistry;

public class BlindedBeaconBlockBodySchemaBellatrixImpl
extends ContainerSchema10<
Expand Down Expand Up @@ -86,9 +88,8 @@ private BlindedBeaconBlockBodySchemaBellatrixImpl(

public static BlindedBeaconBlockBodySchemaBellatrixImpl create(
final SpecConfigBellatrix specConfig,
final long maxValidatorsPerAttestation,
final String containerName,
final ExecutionPayloadHeaderSchemaBellatrix executionPayloadHeaderSchema) {
final SchemaRegistry schemaRegistry,
final String containerName) {
return new BlindedBeaconBlockBodySchemaBellatrixImpl(
containerName,
namedSchema(BlockBodyFields.RANDAO_REVEAL, SszSignatureSchema.INSTANCE),
Expand All @@ -101,17 +102,12 @@ public static BlindedBeaconBlockBodySchemaBellatrixImpl create(
namedSchema(
BlockBodyFields.ATTESTER_SLASHINGS,
SszListSchema.create(
new AttesterSlashingPhase0Schema(
new IndexedAttestationPhase0Schema(maxValidatorsPerAttestation)
.castTypeToIndexedAttestationSchema())
.castTypeToAttesterSlashingSchema(),
schemaRegistry.get(ATTESTER_SLASHING_SCHEMA),
specConfig.getMaxAttesterSlashings())),
namedSchema(
BlockBodyFields.ATTESTATIONS,
SszListSchema.create(
new AttestationPhase0Schema(maxValidatorsPerAttestation)
.castTypeToAttestationSchema(),
specConfig.getMaxAttestations())),
schemaRegistry.get(ATTESTATION_SCHEMA), specConfig.getMaxAttestations())),
namedSchema(
BlockBodyFields.DEPOSITS,
SszListSchema.create(Deposit.SSZ_SCHEMA, specConfig.getMaxDeposits())),
Expand All @@ -122,7 +118,10 @@ public static BlindedBeaconBlockBodySchemaBellatrixImpl create(
namedSchema(
BlockBodyFields.SYNC_AGGREGATE,
SyncAggregateSchema.create(specConfig.getSyncCommitteeSize())),
namedSchema(BlockBodyFields.EXECUTION_PAYLOAD_HEADER, executionPayloadHeaderSchema));
namedSchema(
BlockBodyFields.EXECUTION_PAYLOAD_HEADER,
(ExecutionPayloadHeaderSchemaBellatrix)
schemaRegistry.get(EXECUTION_PAYLOAD_HEADER_SCHEMA)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@

package tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.capella;

import static tech.pegasys.teku.spec.schemas.SchemaTypes.ATTESTATION_SCHEMA;
import static tech.pegasys.teku.spec.schemas.SchemaTypes.ATTESTER_SLASHING_SCHEMA;
import static tech.pegasys.teku.spec.schemas.SchemaTypes.EXECUTION_PAYLOAD_SCHEMA;
import static tech.pegasys.teku.spec.schemas.SchemaTypes.SIGNED_BLS_TO_EXECUTION_CHANGE_SCHEMA;

import it.unimi.dsi.fastutil.longs.LongList;
import java.util.function.Function;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
Expand All @@ -38,13 +43,10 @@
import tech.pegasys.teku.spec.datastructures.operations.Deposit;
import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing;
import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChange;
import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChangeSchema;
import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit;
import tech.pegasys.teku.spec.datastructures.operations.versions.phase0.AttestationPhase0Schema;
import tech.pegasys.teku.spec.datastructures.operations.versions.phase0.AttesterSlashingPhase0Schema;
import tech.pegasys.teku.spec.datastructures.operations.versions.phase0.IndexedAttestationPhase0Schema;
import tech.pegasys.teku.spec.datastructures.type.SszSignature;
import tech.pegasys.teku.spec.datastructures.type.SszSignatureSchema;
import tech.pegasys.teku.spec.schemas.SchemaRegistry;

public class BeaconBlockBodySchemaCapellaImpl
extends ContainerSchema11<
Expand Down Expand Up @@ -92,8 +94,7 @@ protected BeaconBlockBodySchemaCapellaImpl(

public static BeaconBlockBodySchemaCapellaImpl create(
final SpecConfigCapella specConfig,
final SignedBlsToExecutionChangeSchema blsToExecutionChangeSchema,
final long maxValidatorsPerAttestation,
final SchemaRegistry schemaRegistry,
final String containerName) {
return new BeaconBlockBodySchemaCapellaImpl(
containerName,
Expand All @@ -107,17 +108,12 @@ public static BeaconBlockBodySchemaCapellaImpl create(
namedSchema(
BlockBodyFields.ATTESTER_SLASHINGS,
SszListSchema.create(
new AttesterSlashingPhase0Schema(
new IndexedAttestationPhase0Schema(maxValidatorsPerAttestation)
.castTypeToIndexedAttestationSchema())
.castTypeToAttesterSlashingSchema(),
schemaRegistry.get(ATTESTER_SLASHING_SCHEMA),
specConfig.getMaxAttesterSlashings())),
namedSchema(
BlockBodyFields.ATTESTATIONS,
SszListSchema.create(
new AttestationPhase0Schema(maxValidatorsPerAttestation)
.castTypeToAttestationSchema(),
specConfig.getMaxAttestations())),
schemaRegistry.get(ATTESTATION_SCHEMA), specConfig.getMaxAttestations())),
namedSchema(
BlockBodyFields.DEPOSITS,
SszListSchema.create(Deposit.SSZ_SCHEMA, specConfig.getMaxDeposits())),
Expand All @@ -129,11 +125,13 @@ public static BeaconBlockBodySchemaCapellaImpl create(
BlockBodyFields.SYNC_AGGREGATE,
SyncAggregateSchema.create(specConfig.getSyncCommitteeSize())),
namedSchema(
BlockBodyFields.EXECUTION_PAYLOAD, new ExecutionPayloadSchemaCapella(specConfig)),
BlockBodyFields.EXECUTION_PAYLOAD,
(ExecutionPayloadSchemaCapella) schemaRegistry.get(EXECUTION_PAYLOAD_SCHEMA)),
namedSchema(
BlockBodyFields.BLS_TO_EXECUTION_CHANGES,
SszListSchema.create(
blsToExecutionChangeSchema, specConfig.getMaxBlsToExecutionChanges())));
schemaRegistry.get(SIGNED_BLS_TO_EXECUTION_CHANGE_SCHEMA),
specConfig.getMaxBlsToExecutionChanges())));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@

package tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.capella;

import static tech.pegasys.teku.spec.schemas.SchemaTypes.ATTESTATION_SCHEMA;
import static tech.pegasys.teku.spec.schemas.SchemaTypes.ATTESTER_SLASHING_SCHEMA;
import static tech.pegasys.teku.spec.schemas.SchemaTypes.EXECUTION_PAYLOAD_HEADER_SCHEMA;
import static tech.pegasys.teku.spec.schemas.SchemaTypes.SIGNED_BLS_TO_EXECUTION_CHANGE_SCHEMA;

import it.unimi.dsi.fastutil.longs.LongList;
import java.util.function.Function;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
Expand All @@ -37,13 +42,10 @@
import tech.pegasys.teku.spec.datastructures.operations.Deposit;
import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing;
import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChange;
import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChangeSchema;
import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit;
import tech.pegasys.teku.spec.datastructures.operations.versions.phase0.AttestationPhase0Schema;
import tech.pegasys.teku.spec.datastructures.operations.versions.phase0.AttesterSlashingPhase0Schema;
import tech.pegasys.teku.spec.datastructures.operations.versions.phase0.IndexedAttestationPhase0Schema;
import tech.pegasys.teku.spec.datastructures.type.SszSignature;
import tech.pegasys.teku.spec.datastructures.type.SszSignatureSchema;
import tech.pegasys.teku.spec.schemas.SchemaRegistry;

public class BlindedBeaconBlockBodySchemaCapellaImpl
extends ContainerSchema11<
Expand Down Expand Up @@ -91,8 +93,7 @@ private BlindedBeaconBlockBodySchemaCapellaImpl(

public static BlindedBeaconBlockBodySchemaCapellaImpl create(
final SpecConfigCapella specConfig,
final SignedBlsToExecutionChangeSchema signedBlsToExecutionChangeSchema,
final long maxValidatorsPerAttestation,
final SchemaRegistry schemaRegistry,
final String containerName) {
return new BlindedBeaconBlockBodySchemaCapellaImpl(
containerName,
Expand All @@ -106,17 +107,12 @@ public static BlindedBeaconBlockBodySchemaCapellaImpl create(
namedSchema(
BlockBodyFields.ATTESTER_SLASHINGS,
SszListSchema.create(
new AttesterSlashingPhase0Schema(
new IndexedAttestationPhase0Schema(maxValidatorsPerAttestation)
.castTypeToIndexedAttestationSchema())
.castTypeToAttesterSlashingSchema(),
schemaRegistry.get(ATTESTER_SLASHING_SCHEMA),
specConfig.getMaxAttesterSlashings())),
namedSchema(
BlockBodyFields.ATTESTATIONS,
SszListSchema.create(
new AttestationPhase0Schema(maxValidatorsPerAttestation)
.castTypeToAttestationSchema(),
specConfig.getMaxAttestations())),
schemaRegistry.get(ATTESTATION_SCHEMA), specConfig.getMaxAttestations())),
namedSchema(
BlockBodyFields.DEPOSITS,
SszListSchema.create(Deposit.SSZ_SCHEMA, specConfig.getMaxDeposits())),
Expand All @@ -129,11 +125,13 @@ public static BlindedBeaconBlockBodySchemaCapellaImpl create(
SyncAggregateSchema.create(specConfig.getSyncCommitteeSize())),
namedSchema(
BlockBodyFields.EXECUTION_PAYLOAD_HEADER,
new ExecutionPayloadHeaderSchemaCapella(specConfig)),
(ExecutionPayloadHeaderSchemaCapella)
schemaRegistry.get(EXECUTION_PAYLOAD_HEADER_SCHEMA)),
namedSchema(
BlockBodyFields.BLS_TO_EXECUTION_CHANGES,
SszListSchema.create(
signedBlsToExecutionChangeSchema, specConfig.getMaxBlsToExecutionChanges())));
schemaRegistry.get(SIGNED_BLS_TO_EXECUTION_CHANGE_SCHEMA),
specConfig.getMaxBlsToExecutionChanges())));
}

@Override
Expand Down
Loading

0 comments on commit b72530e

Please sign in to comment.