Skip to content

Commit

Permalink
Remove consolidations from electra block body (#8401)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov authored Jun 25, 2024
1 parent 970ec88 commit d55c73d
Show file tree
Hide file tree
Showing 37 changed files with 116 additions and 667 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import tech.pegasys.teku.spec.schemas.SchemaDefinitions;
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsBellatrix;
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsDeneb;
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsElectra;
import tech.pegasys.teku.statetransition.OperationPool;
import tech.pegasys.teku.statetransition.attestation.AggregatingAttestationPool;
import tech.pegasys.teku.statetransition.attestation.AttestationForkChecker;
Expand Down Expand Up @@ -177,15 +176,6 @@ public Function<BeaconBlockBodyBuilder, SafeFuture<Void>> createSelector(
final SchemaDefinitions schemaDefinitions =
spec.atSlot(blockSlotState.getSlot()).getSchemaDefinitions();

// Post-Electra: Consolidations
if (bodyBuilder.supportsConsolidations()) {
// devnet-0 blocks are empty of consolidations, so just default their list.
bodyBuilder.consolidations(
SchemaDefinitionsElectra.required(schemaDefinitions)
.getConsolidationsSchema()
.createFromElements(List.of()));
}

final SafeFuture<Void> blockProductionComplete;

// In `setExecutionData` the following fields are set:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import tech.pegasys.teku.spec.datastructures.blocks.versions.deneb.SignedBlockContents;
import tech.pegasys.teku.spec.datastructures.builder.BuilderBid;
import tech.pegasys.teku.spec.datastructures.builder.BuilderPayload;
import tech.pegasys.teku.spec.datastructures.consolidations.SignedConsolidation;
import tech.pegasys.teku.spec.datastructures.execution.BlobsBundle;
import tech.pegasys.teku.spec.datastructures.execution.BuilderBidOrFallbackData;
import tech.pegasys.teku.spec.datastructures.execution.BuilderPayloadOrFallbackData;
Expand Down Expand Up @@ -102,7 +101,6 @@
class BlockOperationSelectorFactoryTest {
private final Spec spec = TestSpecFactory.createMinimalDeneb();
private final Spec specBellatrix = TestSpecFactory.createMinimalBellatrix();
final Spec specElectra = TestSpecFactory.createMinimalElectra();
private final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec);

private final Function<UInt64, BeaconBlockBodySchema<?>> beaconBlockSchemaSupplier =
Expand Down Expand Up @@ -183,25 +181,11 @@ class BlockOperationSelectorFactoryTest {
.getHeaderOfDefaultPayload();

private final CapturingBeaconBlockBodyBuilder bodyBuilder =
new CapturingBeaconBlockBodyBuilder(false, false);
new CapturingBeaconBlockBodyBuilder(false);

private final GraffitiBuilder graffitiBuilder =
new GraffitiBuilder(ClientGraffitiAppendFormat.DISABLED);

private final BlockOperationSelectorFactory factoryElectra =
new BlockOperationSelectorFactory(
specElectra,
attestationPool,
attesterSlashingPool,
proposerSlashingPool,
voluntaryExitPool,
blsToExecutionChangePool,
contributionPool,
depositProvider,
eth1DataCache,
graffitiBuilder,
forkChoiceNotifier,
executionLayer);
private final BlockOperationSelectorFactory factory =
new BlockOperationSelectorFactory(
spec,
Expand Down Expand Up @@ -637,8 +621,7 @@ void shouldIncludeExecutionPayloadIfRequestedBlindedIsEmptyAndBuilderFlowFallsBa

final UInt256 blockExecutionValue = dataStructureUtil.randomUInt256();

final CapturingBeaconBlockBodyBuilder bodyBuilder =
new CapturingBeaconBlockBodyBuilder(true, false);
final CapturingBeaconBlockBodyBuilder bodyBuilder = new CapturingBeaconBlockBodyBuilder(true);

when(forkChoiceNotifier.getPayloadId(any(), any()))
.thenReturn(SafeFuture.completedFuture(Optional.of(executionPayloadContext)));
Expand Down Expand Up @@ -712,8 +695,7 @@ void shouldIncludeKzgCommitmentsInBlock() {
blobsBundle,
blockExecutionValue);

final CapturingBeaconBlockBodyBuilder bodyBuilder =
new CapturingBeaconBlockBodyBuilder(true, false);
final CapturingBeaconBlockBodyBuilder bodyBuilder = new CapturingBeaconBlockBodyBuilder(true);

safeJoin(
factory
Expand All @@ -735,37 +717,6 @@ void shouldIncludeKzgCommitmentsInBlock() {
.hasSameElementsAs(blobsBundle.getCommitments());
}

@Test
void shouldIncludeConsolidationsInBlock() {
final BeaconState blockSlotState = dataStructureUtil.randomBeaconState();
final ExecutionPayload randomExecutionPayload = dataStructureUtil.randomExecutionPayload();
final UInt256 blockExecutionValue = dataStructureUtil.randomUInt256();
final BlobsBundle blobsBundle = dataStructureUtil.randomBlobsBundle();

prepareBlockAndBlobsProduction(
randomExecutionPayload,
executionPayloadContext,
blockSlotState,
blobsBundle,
blockExecutionValue);

final CapturingBeaconBlockBodyBuilder bodyBuilder =
new CapturingBeaconBlockBodyBuilder(true, true);
safeJoin(
factoryElectra
.createSelector(
parentRoot,
blockSlotState,
dataStructureUtil.randomSignature(),
Optional.empty(),
Optional.of(false),
Optional.empty(),
BlockProductionPerformance.NOOP)
.apply(bodyBuilder));

assertThat(bodyBuilder.consolidations).isEmpty();
}

@Test
void shouldIncludeKzgCommitmentsInBlindedBlock() {
final BeaconState blockSlotState = dataStructureUtil.randomBeaconState();
Expand All @@ -785,8 +736,7 @@ void shouldIncludeKzgCommitmentsInBlindedBlock() {
blobKzgCommitments,
blockExecutionValue);

final CapturingBeaconBlockBodyBuilder bodyBuilder =
new CapturingBeaconBlockBodyBuilder(true, false);
final CapturingBeaconBlockBodyBuilder bodyBuilder = new CapturingBeaconBlockBodyBuilder(true);

safeJoin(
factory
Expand Down Expand Up @@ -1229,7 +1179,6 @@ private void prepareCachedFallbackData(
private static class CapturingBeaconBlockBodyBuilder implements BeaconBlockBodyBuilder {

private final boolean supportsKzgCommitments;
private final boolean supportsConsolidations;

protected BLSSignature randaoReveal;
protected Bytes32 graffiti;
Expand All @@ -1242,13 +1191,8 @@ private static class CapturingBeaconBlockBodyBuilder implements BeaconBlockBodyB
protected ExecutionPayloadHeader executionPayloadHeader;
protected SszList<SszKZGCommitment> blobKzgCommitments;

@SuppressWarnings("unused")
protected SszList<SignedConsolidation> consolidations;

public CapturingBeaconBlockBodyBuilder(
final boolean supportsKzgCommitments, final boolean supportsConsolidations) {
public CapturingBeaconBlockBodyBuilder(final boolean supportsKzgCommitments) {
this.supportsKzgCommitments = supportsKzgCommitments;
this.supportsConsolidations = supportsConsolidations;
}

@Override
Expand Down Expand Up @@ -1345,25 +1289,13 @@ public Boolean supportsKzgCommitments() {
return supportsKzgCommitments;
}

@Override
public Boolean supportsConsolidations() {
return supportsConsolidations;
}

@Override
public BeaconBlockBodyBuilder blobKzgCommitments(
final SszList<SszKZGCommitment> blobKzgCommitments) {
this.blobKzgCommitments = blobKzgCommitments;
return this;
}

@Override
public BeaconBlockBodyBuilder consolidations(
final SszList<SignedConsolidation> consolidations) {
this.consolidations = consolidations;
return this;
}

@Override
public BeaconBlockBody build() {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title" : "BeaconBlockBodyElectra",
"type" : "object",
"required" : [ "randao_reveal", "eth1_data", "graffiti", "proposer_slashings", "attester_slashings", "attestations", "deposits", "voluntary_exits", "sync_aggregate", "execution_payload", "bls_to_execution_changes", "blob_kzg_commitments", "consolidations" ],
"required" : [ "randao_reveal", "eth1_data", "graffiti", "proposer_slashings", "attester_slashings", "attestations", "deposits", "voluntary_exits", "sync_aggregate", "execution_payload", "bls_to_execution_changes", "blob_kzg_commitments" ],
"properties" : {
"randao_reveal" : {
"type" : "string",
Expand Down Expand Up @@ -68,12 +68,6 @@
"description" : "Bytes48 hexadecimal",
"format" : "bytes"
}
},
"consolidations" : {
"type" : "array",
"items" : {
"$ref" : "#/components/schemas/SignedConsolidation"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title" : "BlindedBlockBodyElectra",
"type" : "object",
"required" : [ "randao_reveal", "eth1_data", "graffiti", "proposer_slashings", "attester_slashings", "attestations", "deposits", "voluntary_exits", "sync_aggregate", "execution_payload_header", "bls_to_execution_changes", "blob_kzg_commitments", "consolidations" ],
"required" : [ "randao_reveal", "eth1_data", "graffiti", "proposer_slashings", "attester_slashings", "attestations", "deposits", "voluntary_exits", "sync_aggregate", "execution_payload_header", "bls_to_execution_changes", "blob_kzg_commitments" ],
"properties" : {
"randao_reveal" : {
"type" : "string",
Expand Down Expand Up @@ -68,12 +68,6 @@
"description" : "Bytes48 hexadecimal",
"format" : "bytes"
}
},
"consolidations" : {
"type" : "array",
"items" : {
"$ref" : "#/components/schemas/SignedConsolidation"
}
}
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,7 @@
"0x49f540426ff48680416a1a43b562d4c24d9e1b5012cefb1979a3c9c1b8fbd42b8517c05e35b3e879984ec65a9ddb52af",
"0xa99a23428f6ee3d80bb91e1cd80e3bc46cad162aa2b9c7bc5e291babfcdf69e17bb59e3819984a1ffcc715b881c2452f",
"0xbcbb1d422fbac21d01fc8547ab974f9172b015bc5882f0768caa5e73d640216c13d5649714f92a0d43e05864498aa915"
],
"consolidations": []
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,7 @@
"0xa250734616e5e744f48c493c6d932629d574d0f2b953d406c14b88999cbfbe0227821f9f2e60836eaef3cf363a0cfffd",
"0xb5716d46b630c789e9cfb067411c3bf6db77cf84701cfdc0efcccb617720768dbea1e5fd28c1635cf50b13e301d462e4",
"0x7c0e7f46d64d29bb09077be5c681fd8ec96ed2ce4dc2829266490109e8fd4fedf74293e1399ec2921fc349deac7c3731"
],
"consolidations": []
]
}
},
"kzg_proofs": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.tuweni.bytes.Bytes32;
import tech.pegasys.teku.api.schema.Attestation;
import tech.pegasys.teku.api.schema.AttesterSlashing;
Expand Down Expand Up @@ -49,9 +48,6 @@ public class BeaconBlockBodyElectra extends BeaconBlockBodyAltair {
@JsonProperty("blob_kzg_commitments")
public final List<KZGCommitment> blobKZGCommitments;

@JsonProperty("consolidations")
public final List<SignedConsolidation> consolidations;

@JsonCreator
public BeaconBlockBodyElectra(
@JsonProperty("randao_reveal") final BLSSignature randaoReveal,
Expand All @@ -66,8 +62,7 @@ public BeaconBlockBodyElectra(
@JsonProperty("execution_payload") final ExecutionPayloadElectra executionPayload,
@JsonProperty("bls_to_execution_changes")
final List<SignedBlsToExecutionChange> blsToExecutionChanges,
@JsonProperty("blob_kzg_commitments") final List<KZGCommitment> blobKZGCommitments,
@JsonProperty("consolidations") final List<SignedConsolidation> consolidations) {
@JsonProperty("blob_kzg_commitments") final List<KZGCommitment> blobKZGCommitments) {
super(
randaoReveal,
eth1Data,
Expand All @@ -84,7 +79,6 @@ public BeaconBlockBodyElectra(
this.blsToExecutionChanges = blsToExecutionChanges;
checkNotNull(blobKZGCommitments, "blobKZGCommitments is required for Electra blocks");
this.blobKZGCommitments = blobKZGCommitments;
this.consolidations = consolidations;
}

public BeaconBlockBodyElectra(
Expand All @@ -106,10 +100,6 @@ public BeaconBlockBodyElectra(
.map(SszKZGCommitment::getKZGCommitment)
.map(KZGCommitment::new)
.toList();
this.consolidations =
message.getConsolidations().stream()
.map(SignedConsolidation::new)
.collect(Collectors.toList());
}

@Override
Expand All @@ -125,8 +115,6 @@ public BeaconBlockBody asInternalBeaconBlockBody(final SpecVersion spec) {
getBeaconBlockBodySchema(spec).getBlsToExecutionChangesSchema();
final SszListSchema<SszKZGCommitment, ?> blobKZGCommitmentsSchema =
getBeaconBlockBodySchema(spec).getBlobKzgCommitmentsSchema();
final SszListSchema<tech.pegasys.teku.spec.datastructures.consolidations.SignedConsolidation, ?>
signedConsolidationSchema = getBeaconBlockBodySchema(spec).getConsolidationsSchema();
return super.asInternalBeaconBlockBody(
spec,
builder -> {
Expand All @@ -140,10 +128,6 @@ public BeaconBlockBody asInternalBeaconBlockBody(final SpecVersion spec) {
.map(KZGCommitment::asInternalKZGCommitment)
.map(SszKZGCommitment::new)
.collect(blobKZGCommitmentsSchema.collector()));
builder.consolidations(
this.consolidations.stream()
.map(b -> b.asInternalSignedConsolidation(spec))
.collect(signedConsolidationSchema.collector()));
return SafeFuture.COMPLETE;
});
}
Expand Down
Loading

0 comments on commit d55c73d

Please sign in to comment.