Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate builder bids to schema registry #8836

Merged
merged 3 commits into from
Nov 21, 2024
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,23 +13,26 @@

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

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

import tech.pegasys.teku.bls.BLSSignature;
import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema2;
import tech.pegasys.teku.infrastructure.ssz.schema.SszContainerSchema;
import tech.pegasys.teku.infrastructure.ssz.schema.SszSchema;
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 SignedBuilderBidSchema
extends ContainerSchema2<SignedBuilderBid, BuilderBid, SszSignature>
implements SszContainerSchema<SignedBuilderBid> {

public SignedBuilderBidSchema(
final String schemaName, final BuilderBidSchema<?> builderBidSchema) {
public SignedBuilderBidSchema(final String schemaName, final SchemaRegistry schemaRegistry) {
super(
schemaName,
namedSchema("message", SszSchema.as(BuilderBid.class, builderBidSchema)),
namedSchema(
"message", SszSchema.as(BuilderBid.class, schemaRegistry.get(BUILDER_BID_SCHEMA))),
namedSchema("signature", SszSignatureSchema.INSTANCE));
}

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

package tech.pegasys.teku.spec.datastructures.builder.versions.bellatrix;

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

import java.util.function.Consumer;
import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema3;
import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt256;
Expand All @@ -23,21 +25,22 @@
import tech.pegasys.teku.spec.datastructures.builder.BuilderBidBuilder;
import tech.pegasys.teku.spec.datastructures.builder.BuilderBidSchema;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeaderSchema;
import tech.pegasys.teku.spec.datastructures.type.SszPublicKey;
import tech.pegasys.teku.spec.datastructures.type.SszPublicKeySchema;
import tech.pegasys.teku.spec.schemas.registry.SchemaRegistry;

public class BuilderBidSchemaBellatrix
extends ContainerSchema3<BuilderBidBellatrix, ExecutionPayloadHeader, SszUInt256, SszPublicKey>
implements BuilderBidSchema<BuilderBidBellatrix> {

public BuilderBidSchemaBellatrix(
final String containerName,
final ExecutionPayloadHeaderSchema<?> executionPayloadHeaderSchema) {
final String containerName, final SchemaRegistry schemaRegistry) {
super(
containerName,
namedSchema(
"header", SszSchema.as(ExecutionPayloadHeader.class, executionPayloadHeaderSchema)),
"header",
SszSchema.as(
ExecutionPayloadHeader.class, schemaRegistry.get(EXECUTION_PAYLOAD_HEADER_SCHEMA))),
namedSchema("value", SszPrimitiveSchemas.UINT256_SCHEMA),
namedSchema("pubkey", SszPublicKeySchema.INSTANCE));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@

package tech.pegasys.teku.spec.datastructures.builder.versions.deneb;

import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BLOB_KZG_COMMITMENTS_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.EXECUTION_PAYLOAD_HEADER_SCHEMA;

import java.util.function.Consumer;
import tech.pegasys.teku.infrastructure.ssz.SszList;
import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema4;
import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt256;
import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas;
import tech.pegasys.teku.infrastructure.ssz.schema.SszSchema;
import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobKzgCommitmentsSchema;
import tech.pegasys.teku.spec.datastructures.builder.BuilderBid;
import tech.pegasys.teku.spec.datastructures.builder.BuilderBidBuilder;
import tech.pegasys.teku.spec.datastructures.builder.BuilderBidSchema;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeaderSchema;
import tech.pegasys.teku.spec.datastructures.type.SszKZGCommitment;
import tech.pegasys.teku.spec.datastructures.type.SszPublicKey;
import tech.pegasys.teku.spec.datastructures.type.SszPublicKeySchema;
import tech.pegasys.teku.spec.schemas.registry.SchemaRegistry;

public class BuilderBidSchemaDeneb
extends ContainerSchema4<
Expand All @@ -39,15 +41,14 @@ public class BuilderBidSchemaDeneb
SszPublicKey>
implements BuilderBidSchema<BuilderBidDenebImpl> {

public BuilderBidSchemaDeneb(
final String containerName,
final ExecutionPayloadHeaderSchema<?> executionPayloadHeaderSchema,
final BlobKzgCommitmentsSchema blobKzgCommitmentsSchema) {
public BuilderBidSchemaDeneb(final String containerName, final SchemaRegistry schemaRegistry) {
super(
containerName,
namedSchema(
"header", SszSchema.as(ExecutionPayloadHeader.class, executionPayloadHeaderSchema)),
namedSchema("blob_kzg_commitments", blobKzgCommitmentsSchema),
"header",
SszSchema.as(
ExecutionPayloadHeader.class, schemaRegistry.get(EXECUTION_PAYLOAD_HEADER_SCHEMA))),
namedSchema("blob_kzg_commitments", schemaRegistry.get(BLOB_KZG_COMMITMENTS_SCHEMA)),
namedSchema("value", SszPrimitiveSchemas.UINT256_SCHEMA),
namedSchema("pubkey", SszPublicKeySchema.INSTANCE));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,26 @@

package tech.pegasys.teku.spec.datastructures.builder.versions.electra;

import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BLOB_KZG_COMMITMENTS_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.EXECUTION_PAYLOAD_HEADER_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.EXECUTION_REQUESTS_SCHEMA;

import java.util.function.Consumer;
import tech.pegasys.teku.infrastructure.ssz.SszList;
import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema5;
import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt256;
import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas;
import tech.pegasys.teku.infrastructure.ssz.schema.SszSchema;
import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobKzgCommitmentsSchema;
import tech.pegasys.teku.spec.datastructures.builder.BuilderBid;
import tech.pegasys.teku.spec.datastructures.builder.BuilderBidBuilder;
import tech.pegasys.teku.spec.datastructures.builder.BuilderBidSchema;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeaderSchema;
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionRequests;
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionRequestsSchema;
import tech.pegasys.teku.spec.datastructures.type.SszKZGCommitment;
import tech.pegasys.teku.spec.datastructures.type.SszPublicKey;
import tech.pegasys.teku.spec.datastructures.type.SszPublicKeySchema;
import tech.pegasys.teku.spec.schemas.registry.SchemaRegistry;

public class BuilderBidSchemaElectra
extends ContainerSchema5<
Expand All @@ -42,17 +44,15 @@ public class BuilderBidSchemaElectra
SszPublicKey>
implements BuilderBidSchema<BuilderBidElectraImpl> {

public BuilderBidSchemaElectra(
final String containerName,
final ExecutionPayloadHeaderSchema<?> executionPayloadHeaderSchema,
final BlobKzgCommitmentsSchema blobKzgCommitmentsSchema,
final ExecutionRequestsSchema executionRequestsSchema) {
public BuilderBidSchemaElectra(final String containerName, final SchemaRegistry schemaRegistry) {
super(
containerName,
namedSchema(
"header", SszSchema.as(ExecutionPayloadHeader.class, executionPayloadHeaderSchema)),
namedSchema("blob_kzg_commitments", blobKzgCommitmentsSchema),
namedSchema("execution_requests", executionRequestsSchema),
"header",
SszSchema.as(
ExecutionPayloadHeader.class, schemaRegistry.get(EXECUTION_PAYLOAD_HEADER_SCHEMA))),
namedSchema("blob_kzg_commitments", schemaRegistry.get(BLOB_KZG_COMMITMENTS_SCHEMA)),
namedSchema("execution_requests", schemaRegistry.get(EXECUTION_REQUESTS_SCHEMA)),
namedSchema("value", SszPrimitiveSchemas.UINT256_SCHEMA),
namedSchema("pubkey", SszPublicKeySchema.INSTANCE));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
import static com.google.common.base.Preconditions.checkArgument;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BLINDED_BEACON_BLOCK_BODY_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BLINDED_BEACON_BLOCK_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BUILDER_BID_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.EXECUTION_PAYLOAD_HEADER_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.EXECUTION_PAYLOAD_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_BLINDED_BEACON_BLOCK_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_BUILDER_BID_SCHEMA;

import java.util.Optional;
import tech.pegasys.teku.spec.datastructures.blocks.BeaconBlockSchema;
Expand All @@ -34,7 +36,6 @@
import tech.pegasys.teku.spec.datastructures.builder.BuilderBidSchema;
import tech.pegasys.teku.spec.datastructures.builder.BuilderPayloadSchema;
import tech.pegasys.teku.spec.datastructures.builder.SignedBuilderBidSchema;
import tech.pegasys.teku.spec.datastructures.builder.versions.bellatrix.BuilderBidSchemaBellatrix;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeaderSchema;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadSchema;
import tech.pegasys.teku.spec.schemas.registry.SchemaRegistry;
Expand All @@ -55,10 +56,8 @@ public SchemaDefinitionsBellatrix(final SchemaRegistry schemaRegistry) {
this.blindedBeaconBlockBodySchema = schemaRegistry.get(BLINDED_BEACON_BLOCK_BODY_SCHEMA);
this.blindedBeaconBlockSchema = schemaRegistry.get(BLINDED_BEACON_BLOCK_SCHEMA);
this.signedBlindedBeaconBlockSchema = schemaRegistry.get(SIGNED_BLINDED_BEACON_BLOCK_SCHEMA);
this.builderBidSchema =
new BuilderBidSchemaBellatrix("BuilderBidBellatrix", executionPayloadHeaderSchema);
this.signedBuilderBidSchema =
new SignedBuilderBidSchema("SignedBuilderBidBellatrix", builderBidSchema);
this.builderBidSchema = schemaRegistry.get(BUILDER_BID_SCHEMA);
this.signedBuilderBidSchema = schemaRegistry.get(SIGNED_BUILDER_BID_SCHEMA);
}

public static SchemaDefinitionsBellatrix required(final SchemaDefinitions schemaDefinitions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
import tech.pegasys.teku.infrastructure.ssz.schema.SszListSchema;
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBodyBuilder;
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.capella.BeaconBlockBodyBuilderCapella;
import tech.pegasys.teku.spec.datastructures.builder.BuilderBidSchema;
import tech.pegasys.teku.spec.datastructures.builder.SignedBuilderBidSchema;
import tech.pegasys.teku.spec.datastructures.builder.versions.bellatrix.BuilderBidSchemaBellatrix;
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 All @@ -37,10 +34,7 @@ public class SchemaDefinitionsCapella extends SchemaDefinitionsBellatrix {
private final WithdrawalSchema withdrawalSchema;

private final BlsToExecutionChangeSchema blsToExecutionChangeSchema;

private final SignedBlsToExecutionChangeSchema signedBlsToExecutionChangeSchema;
private final BuilderBidSchema<?> builderBidSchemaCapella;
private final SignedBuilderBidSchema signedBuilderBidSchemaCapella;

private final SszListSchema<HistoricalSummary, ?> historicalSummariesSchema;

Expand All @@ -51,10 +45,6 @@ public SchemaDefinitionsCapella(final SchemaRegistry schemaRegistry) {
this.signedBlsToExecutionChangeSchema =
schemaRegistry.get(SIGNED_BLS_TO_EXECUTION_CHANGE_SCHEMA);
this.withdrawalSchema = schemaRegistry.get(WITHDRAWAL_SCHEMA);
this.builderBidSchemaCapella =
new BuilderBidSchemaBellatrix("BuilderBidCapella", getExecutionPayloadHeaderSchema());
this.signedBuilderBidSchemaCapella =
new SignedBuilderBidSchema("SignedBuilderBidCapella", builderBidSchemaCapella);
}

public static SchemaDefinitionsCapella required(final SchemaDefinitions schemaDefinitions) {
Expand Down Expand Up @@ -89,16 +79,6 @@ public HistoricalSummarySchema getHistoricalSummarySchema() {
return (HistoricalSummarySchema) historicalSummariesSchema.getElementSchema();
}

@Override
public BuilderBidSchema<?> getBuilderBidSchema() {
return builderBidSchemaCapella;
}

@Override
public SignedBuilderBidSchema getSignedBuilderBidSchema() {
return signedBuilderBidSchemaCapella;
}

@Override
public Optional<SchemaDefinitionsCapella> toVersionCapella() {
return Optional.of(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,14 @@
import tech.pegasys.teku.spec.datastructures.blocks.versions.deneb.BlockContentsSchema;
import tech.pegasys.teku.spec.datastructures.blocks.versions.deneb.SignedBlockContentsSchema;
import tech.pegasys.teku.spec.datastructures.builder.BlobsBundleSchema;
import tech.pegasys.teku.spec.datastructures.builder.BuilderBidSchema;
import tech.pegasys.teku.spec.datastructures.builder.BuilderPayloadSchema;
import tech.pegasys.teku.spec.datastructures.builder.ExecutionPayloadAndBlobsBundleSchema;
import tech.pegasys.teku.spec.datastructures.builder.SignedBuilderBidSchema;
import tech.pegasys.teku.spec.datastructures.builder.versions.deneb.BuilderBidSchemaDeneb;
import tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.BlobSidecarsByRootRequestMessageSchema;
import tech.pegasys.teku.spec.schemas.registry.SchemaRegistry;

public class SchemaDefinitionsDeneb extends SchemaDefinitionsCapella {
private final BlobKzgCommitmentsSchema blobKzgCommitmentsSchema;

private final BuilderBidSchema<?> builderBidSchemaDeneb;
private final SignedBuilderBidSchema signedBuilderBidSchemaDeneb;

private final BlobSchema blobSchema;
private final SszListSchema<Blob, ? extends SszList<Blob>> blobsInBlockSchema;
private final BlobSidecarSchema blobSidecarSchema;
Expand All @@ -65,11 +59,6 @@ public SchemaDefinitionsDeneb(final SchemaRegistry schemaRegistry) {
super(schemaRegistry);
final SpecConfigDeneb specConfig = SpecConfigDeneb.required(schemaRegistry.getSpecConfig());
this.blobKzgCommitmentsSchema = schemaRegistry.get(BLOB_KZG_COMMITMENTS_SCHEMA);
this.builderBidSchemaDeneb =
new BuilderBidSchemaDeneb(
"BuilderBidDeneb", getExecutionPayloadHeaderSchema(), blobKzgCommitmentsSchema);
this.signedBuilderBidSchemaDeneb =
new SignedBuilderBidSchema("SignedBuilderBidDeneb", builderBidSchemaDeneb);

this.blobSchema = schemaRegistry.get(BLOB_SCHEMA);
this.blobsInBlockSchema = schemaRegistry.get(BLOBS_IN_BLOCK_SCHEMA);
Expand Down Expand Up @@ -106,16 +95,6 @@ public SignedBlockContainerSchema<SignedBlockContainer> getSignedBlockContainerS
return getSignedBlockContentsSchema().castTypeToSignedBlockContainer();
}

@Override
public BuilderBidSchema<?> getBuilderBidSchema() {
return builderBidSchemaDeneb;
}

@Override
public SignedBuilderBidSchema getSignedBuilderBidSchema() {
return signedBuilderBidSchemaDeneb;
}

@Override
public BuilderPayloadSchema<?> getBuilderPayloadSchema() {
return getExecutionPayloadAndBlobsBundleSchema();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.electra.BeaconBlockBodyBuilderElectra;
import tech.pegasys.teku.spec.datastructures.blocks.versions.deneb.BlockContentsSchema;
import tech.pegasys.teku.spec.datastructures.blocks.versions.deneb.SignedBlockContentsSchema;
import tech.pegasys.teku.spec.datastructures.builder.BuilderBidSchema;
import tech.pegasys.teku.spec.datastructures.builder.BuilderPayloadSchema;
import tech.pegasys.teku.spec.datastructures.builder.ExecutionPayloadAndBlobsBundleSchema;
import tech.pegasys.teku.spec.datastructures.builder.SignedBuilderBidSchema;
import tech.pegasys.teku.spec.datastructures.builder.versions.electra.BuilderBidSchemaElectra;
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ConsolidationRequest;
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ConsolidationRequestSchema;
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.DepositRequest;
Expand All @@ -50,9 +47,6 @@
import tech.pegasys.teku.spec.schemas.registry.SchemaRegistry;

public class SchemaDefinitionsElectra extends SchemaDefinitionsDeneb {
private final BuilderBidSchema<?> builderBidSchemaElectra;
private final SignedBuilderBidSchema signedBuilderBidSchemaElectra;

private final BlockContentsSchema blockContentsSchema;
private final SignedBlockContentsSchema signedBlockContentsSchema;
private final ExecutionPayloadAndBlobsBundleSchema executionPayloadAndBlobsBundleSchema;
Expand Down Expand Up @@ -80,15 +74,6 @@ public SchemaDefinitionsElectra(final SchemaRegistry schemaRegistry) {
this.pendingPartialWithdrawalsSchema = schemaRegistry.get(PENDING_PARTIAL_WITHDRAWALS_SCHEMA);
this.pendingConsolidationsSchema = schemaRegistry.get(PENDING_CONSOLIDATIONS_SCHEMA);

this.builderBidSchemaElectra =
new BuilderBidSchemaElectra(
"BuilderBidElectra",
getExecutionPayloadHeaderSchema(),
getBlobKzgCommitmentsSchema(),
executionRequestsSchema);
this.signedBuilderBidSchemaElectra =
new SignedBuilderBidSchema("SignedBuilderBidElectra", builderBidSchemaElectra);

this.blockContentsSchema =
BlockContentsSchema.create(
specConfig, getBeaconBlockSchema(), getBlobSchema(), "BlockContentsElectra");
Expand Down Expand Up @@ -130,16 +115,6 @@ public SignedBlockContainerSchema<SignedBlockContainer> getSignedBlockContainerS
return getSignedBlockContentsSchema().castTypeToSignedBlockContainer();
}

@Override
public BuilderBidSchema<?> getBuilderBidSchema() {
return builderBidSchemaElectra;
}

@Override
public SignedBuilderBidSchema getSignedBuilderBidSchema() {
return signedBuilderBidSchemaElectra;
}

@Override
public BuilderPayloadSchema<?> getBuilderPayloadSchema() {
return getExecutionPayloadAndBlobsBundleSchema();
Expand Down
Loading