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

Moving requests out of ExecutionPayload #8600

Merged
merged 25 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9367d38
Created new container ExecutionRequests
lucassaldanha Sep 12, 2024
edcf31c
Spotless
lucassaldanha Sep 12, 2024
76a508d
Removing deposit_requests, withdrawal_requests and consolidation_requ…
lucassaldanha Sep 15, 2024
d0be00e
Added execution_requests to beacon block body
lucassaldanha Sep 16, 2024
da04801
Removing redundant override
lucassaldanha Sep 16, 2024
c85e0f2
Processing requests from beacon block body instead of execution payload
lucassaldanha Sep 16, 2024
71253d3
Merge branch 'master' into new-requests-2
lucassaldanha Sep 16, 2024
a46f4a2
Update ref-tests to v1.5.0-alpha.6
lucassaldanha Sep 19, 2024
923bff4
Merge branch 'master' into new-requests-2
lucassaldanha Sep 19, 2024
e211c1d
Added follow up TODOs for Electra
lucassaldanha Sep 19, 2024
19a646d
ignore warning
lucassaldanha Sep 19, 2024
e31e60b
Merge branch 'master' into new-requests-2
lucassaldanha Sep 19, 2024
a7c01b2
Update datastructure util
lucassaldanha Sep 20, 2024
fb4edbd
Updated Electra beacon api
lucassaldanha Sep 23, 2024
47f0c08
Spotless
lucassaldanha Sep 23, 2024
a526293
Merge branch 'electra-beacon-api' into new-requests-2
lucassaldanha Sep 23, 2024
4b74a3c
Fix unit tests
lucassaldanha Sep 23, 2024
17d6a82
Disabling electra AT
lucassaldanha Sep 24, 2024
3f0600c
Final TODOs
lucassaldanha Sep 24, 2024
908f6b7
Merge branch 'master' into new-requests-2
lucassaldanha Sep 24, 2024
30df3a5
Final integration tests
lucassaldanha Sep 24, 2024
22c15af
updated reference test runner to read ssz list
lucassaldanha Sep 24, 2024
fee49f5
Fix schema tests
lucassaldanha Sep 24, 2024
4de2630
latest schema updates
lucassaldanha Sep 25, 2024
8c88f58
Merge branch 'master' into new-requests-2
lucassaldanha Sep 25, 2024
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 @@ -16,6 +16,7 @@
import com.google.common.io.Resources;
import java.net.URL;
import java.util.Map;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.ethereum.execution.types.Eth1Address;
import tech.pegasys.teku.infrastructure.time.SystemTimeProvider;
Expand All @@ -30,6 +31,7 @@
import tech.pegasys.teku.test.acceptance.dsl.TekuNodeConfigBuilder;
import tech.pegasys.teku.test.acceptance.dsl.tools.deposits.ValidatorKeystores;

@Disabled("Won't work until we update Engine API for Electra + EL changes")
public class ElectraUpgradeAcceptanceTest extends AcceptanceTestBase {

private static final String NETWORK_NAME = "swift";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.google.common.io.Resources;
import java.net.URL;
import java.util.Map;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.bls.BLSPublicKey;
import tech.pegasys.teku.ethereum.execution.types.Eth1Address;
Expand All @@ -37,6 +38,7 @@ public class ExecutionLayerTriggeredExitAcceptanceTest extends AcceptanceTestBas
private static final URL JWT_FILE = Resources.getResource("auth/ee-jwt-secret.hex");

@Test
@Disabled("Won't work until we update Engine API for Electra")
void triggerValidatorExitWithFullWithdrawal() throws Exception {
final UInt64 currentTime = new SystemTimeProvider().getTimeInSeconds();
final int genesisTime =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadContext;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadResult;
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionRequestsBuilderElectra;
import tech.pegasys.teku.spec.datastructures.operations.Attestation;
import tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing;
import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing;
Expand All @@ -63,6 +64,7 @@
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 @@ -238,6 +240,15 @@ private SafeFuture<Void> setExecutionData(
requestedBuilderBoostFactor,
blockProductionPerformance);

// TODO Update as part of Electra Engine API updates
// (https://github.com/Consensys/teku/issues/8620)
if (bodyBuilder.supportsExecutionRequests()) {
bodyBuilder.executionRequests(
new ExecutionRequestsBuilderElectra(
SchemaDefinitionsElectra.required(schemaDefinitions).getExecutionRequestsSchema())
.build());
}

return SafeFuture.allOf(
cacheExecutionPayloadValue(executionPayloadResult, blockSlotState),
setPayloadOrPayloadHeader(bodyBuilder, executionPayloadResult),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import tech.pegasys.teku.spec.datastructures.execution.FallbackData;
import tech.pegasys.teku.spec.datastructures.execution.FallbackReason;
import tech.pegasys.teku.spec.datastructures.execution.GetPayloadResponse;
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionRequests;
import tech.pegasys.teku.spec.datastructures.operations.Attestation;
import tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing;
import tech.pegasys.teku.spec.datastructures.operations.Deposit;
Expand Down Expand Up @@ -1165,6 +1166,11 @@ private static class CapturingBeaconBlockBodyBuilder implements BeaconBlockBodyB
protected ExecutionPayloadHeader executionPayloadHeader;
protected SszList<SszKZGCommitment> blobKzgCommitments;

// TODO Update as part of Electra Engine API updates
// (https://github.com/Consensys/teku/issues/8620)
@SuppressWarnings("unused")
protected ExecutionRequests executionRequests;

public CapturingBeaconBlockBodyBuilder(final boolean supportsKzgCommitments) {
this.supportsKzgCommitments = supportsKzgCommitments;
}
Expand Down Expand Up @@ -1243,6 +1249,12 @@ public BeaconBlockBodyBuilder blsToExecutionChanges(
return this;
}

@Override
public BeaconBlockBodyBuilder executionRequests(final ExecutionRequests executionRequests) {
this.executionRequests = executionRequests;
return this;
}

@Override
public Boolean supportsSyncAggregate() {
return true;
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ allprojects {
}
}

def refTestVersion = 'v1.5.0-alpha.5'
def refTestVersion = 'v1.5.0-alpha.6'
def blsRefTestVersion = 'v0.1.2'
def slashingProtectionInterchangeRefTestVersion = 'v5.3.0'
def refTestBaseUrl = 'https://github.com/ethereum/consensus-spec-tests/releases/download'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import tech.pegasys.teku.api.schema.bellatrix.ExecutionPayloadBellatrix;
import tech.pegasys.teku.api.schema.capella.ExecutionPayloadCapella;
import tech.pegasys.teku.api.schema.deneb.ExecutionPayloadDeneb;
import tech.pegasys.teku.api.schema.electra.ExecutionPayloadElectra;

public interface ExecutionPayload {

Expand All @@ -32,8 +31,4 @@ default Optional<ExecutionPayloadCapella> toVersionCapella() {
default Optional<ExecutionPayloadDeneb> toVersionDeneb() {
return Optional.empty();
}

default Optional<ExecutionPayloadElectra> toVersionElectra() {
return Optional.empty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import tech.pegasys.teku.api.schema.bellatrix.ExecutionPayloadHeaderBellatrix;
import tech.pegasys.teku.api.schema.capella.ExecutionPayloadHeaderCapella;
import tech.pegasys.teku.api.schema.deneb.ExecutionPayloadHeaderDeneb;
import tech.pegasys.teku.api.schema.electra.ExecutionPayloadHeaderElectra;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeaderSchema;

public interface ExecutionPayloadHeader {
Expand All @@ -35,8 +34,4 @@ default Optional<ExecutionPayloadHeaderCapella> toVersionCapella() {
default Optional<ExecutionPayloadHeaderDeneb> toVersionDeneb() {
return Optional.empty();
}

default Optional<ExecutionPayloadHeaderElectra> toVersionElectra() {
return Optional.empty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@
import tech.pegasys.teku.api.schema.altair.BeaconBlockBodyAltair;
import tech.pegasys.teku.api.schema.altair.SyncAggregate;
import tech.pegasys.teku.api.schema.capella.SignedBlsToExecutionChange;
import tech.pegasys.teku.api.schema.deneb.ExecutionPayloadDeneb;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.ssz.schema.SszListSchema;
import tech.pegasys.teku.spec.SpecVersion;
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody;
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.electra.BeaconBlockBodySchemaElectra;
import tech.pegasys.teku.spec.datastructures.type.SszKZGCommitment;
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsElectra;

public class BeaconBlockBodyElectra extends BeaconBlockBodyAltair {

@JsonProperty("execution_payload")
public final ExecutionPayloadElectra executionPayload;
public final ExecutionPayloadDeneb executionPayload;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it worth a comment here explaining that we use ExecutionPayloadDeneb because no changes have been introduced in Electra? It's is clear now but it might be confusing in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its really common, i'd prefer no comment as its just noise.


@JsonProperty("bls_to_execution_changes")
public final List<SignedBlsToExecutionChange> blsToExecutionChanges;
Expand All @@ -62,7 +64,7 @@ public BeaconBlockBodyElectra(
@JsonProperty("deposits") final List<Deposit> deposits,
@JsonProperty("voluntary_exits") final List<SignedVoluntaryExit> voluntaryExits,
@JsonProperty("sync_aggregate") final SyncAggregate syncAggregate,
@JsonProperty("execution_payload") final ExecutionPayloadElectra executionPayload,
@JsonProperty("execution_payload") final ExecutionPayloadDeneb executionPayload,
@JsonProperty("bls_to_execution_changes")
final List<SignedBlsToExecutionChange> blsToExecutionChanges,
@JsonProperty("blob_kzg_commitments") final List<KZGCommitment> blobKZGCommitments,
Expand Down Expand Up @@ -93,7 +95,7 @@ public BeaconBlockBodyElectra(
message) {
super(message);
checkNotNull(message.getExecutionPayload(), "Execution Payload is required for Electra blocks");
this.executionPayload = new ExecutionPayloadElectra(message.getExecutionPayload());
this.executionPayload = new ExecutionPayloadDeneb(message.getExecutionPayload());
checkNotNull(
message.getBlsToExecutionChanges(),
"BlsToExecutionChanges are required for Electra blocks");
Expand All @@ -106,9 +108,19 @@ public BeaconBlockBodyElectra(
.map(SszKZGCommitment::getKZGCommitment)
.map(KZGCommitment::new)
.toList();
// TODO add execution requests from BeaconBlocBodyElectra
// (https://github.com/Consensys/teku/pull/8600)
this.executionRequests = new ExecutionRequests(List.of(), List.of(), List.of());

final List<DepositRequest> depositRequests =
message.getExecutionRequests().getDeposits().stream().map(DepositRequest::new).toList();
final List<WithdrawalRequest> withdrawalRequests =
message.getExecutionRequests().getWithdrawals().stream()
.map(WithdrawalRequest::new)
.toList();
final List<ConsolidationRequest> consolidationRequests =
message.getExecutionRequests().getConsolidations().stream()
.map(ConsolidationRequest::new)
.toList();
this.executionRequests =
new ExecutionRequests(depositRequests, withdrawalRequests, consolidationRequests);
}

@Override
Expand Down Expand Up @@ -137,7 +149,11 @@ public BeaconBlockBody asInternalBeaconBlockBody(final SpecVersion spec) {
.map(KZGCommitment::asInternalKZGCommitment)
.map(SszKZGCommitment::new)
.collect(blobKZGCommitmentsSchema.collector()));
// TODO add execution requests (https://github.com/Consensys/teku/pull/8600)
builder.executionRequests(
this.executionRequests.asInternalConsolidationRequest(
SchemaDefinitionsElectra.required(spec.getSchemaDefinitions())
.getExecutionRequestsSchema()));

return SafeFuture.COMPLETE;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@
import tech.pegasys.teku.api.schema.altair.BeaconStateAltair;
import tech.pegasys.teku.api.schema.altair.SyncCommittee;
import tech.pegasys.teku.api.schema.capella.HistoricalSummary;
import tech.pegasys.teku.api.schema.deneb.ExecutionPayloadHeaderDeneb;
import tech.pegasys.teku.infrastructure.ssz.collections.SszBitvector;
import tech.pegasys.teku.infrastructure.ssz.schema.SszListSchema;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.SpecVersion;
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionPayloadHeaderSchemaElectra;
import tech.pegasys.teku.spec.datastructures.execution.versions.deneb.ExecutionPayloadHeaderSchemaDeneb;
import tech.pegasys.teku.spec.datastructures.state.SyncCommittee.SyncCommitteeSchema;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.MutableBeaconState;
Expand All @@ -41,7 +42,7 @@
public class BeaconStateElectra extends BeaconStateAltair {

@JsonProperty("latest_execution_payload_header")
public final ExecutionPayloadHeaderElectra latestExecutionPayloadHeader;
public final ExecutionPayloadHeaderDeneb latestExecutionPayloadHeader;

@JsonProperty("next_withdrawal_index")
@Schema(type = "string", example = EXAMPLE_UINT64)
Expand Down Expand Up @@ -107,7 +108,7 @@ public BeaconStateElectra(
@JsonProperty("current_sync_committee") final SyncCommittee currentSyncCommittee,
@JsonProperty("next_sync_committee") final SyncCommittee nextSyncCommittee,
@JsonProperty("latest_execution_payload_header")
final ExecutionPayloadHeaderElectra latestExecutionPayloadHeader,
final ExecutionPayloadHeaderDeneb latestExecutionPayloadHeader,
@JsonProperty("next_withdrawal_index") final UInt64 nextWithdrawalIndex,
@JsonProperty("next_withdrawal_validator_index") final UInt64 nextWithdrawalValidatorIndex,
@JsonProperty("historical_summaries") final List<HistoricalSummary> historicalSummaries,
Expand Down Expand Up @@ -168,8 +169,9 @@ public BeaconStateElectra(final BeaconState beaconState) {
final tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra
.BeaconStateElectra
electra = beaconState.toVersionElectra().orElseThrow();

this.latestExecutionPayloadHeader =
new ExecutionPayloadHeaderElectra(electra.getLatestExecutionPayloadHeader());
new ExecutionPayloadHeaderDeneb(electra.getLatestExecutionPayloadHeader());
this.nextWithdrawalIndex = electra.getNextWithdrawalIndex();
this.nextWithdrawalValidatorIndex = electra.getNextWithdrawalValidatorIndex();
this.historicalSummaries =
Expand Down Expand Up @@ -223,7 +225,7 @@ protected static void applyElectraFields(
final SpecVersion specVersion,
final MutableBeaconStateElectra state,
final SyncCommitteeSchema syncCommitteeSchema,
final ExecutionPayloadHeaderSchemaElectra executionPayloadHeaderSchema,
final ExecutionPayloadHeaderSchemaDeneb executionPayloadHeaderSchema,
final SszListSchema<
tech.pegasys.teku.spec.datastructures.state.versions.capella.HistoricalSummary, ?>
historicalSummariesSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,28 @@
import tech.pegasys.teku.api.schema.KZGCommitment;
import tech.pegasys.teku.api.schema.ProposerSlashing;
import tech.pegasys.teku.api.schema.SignedVoluntaryExit;
import tech.pegasys.teku.api.schema.altair.BeaconBlockBodyAltair;
import tech.pegasys.teku.api.schema.altair.SyncAggregate;
import tech.pegasys.teku.api.schema.capella.SignedBlsToExecutionChange;
import tech.pegasys.teku.api.schema.deneb.BlindedBeaconBlockBodyDeneb;
import tech.pegasys.teku.api.schema.deneb.ExecutionPayloadHeaderDeneb;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.ssz.schema.SszListSchema;
import tech.pegasys.teku.spec.SpecVersion;
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody;
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.electra.BlindedBeaconBlockBodySchemaElectra;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeaderSchema;
import tech.pegasys.teku.spec.datastructures.type.SszKZGCommitment;

public class BlindedBeaconBlockBodyElectra extends BlindedBeaconBlockBodyDeneb {
public class BlindedBeaconBlockBodyElectra extends BeaconBlockBodyAltair {

@JsonProperty("execution_payload_header")
public final ExecutionPayloadHeaderDeneb executionPayloadHeader;

@JsonProperty("bls_to_execution_changes")
public final List<SignedBlsToExecutionChange> blsToExecutionChanges;

@JsonProperty("blob_kzg_commitments")
public final List<KZGCommitment> blobKZGCommitments;

@JsonProperty("execution_requests_root")
@Schema(type = "string", format = "byte", description = DESCRIPTION_BYTES32)
Expand All @@ -55,7 +68,7 @@ public BlindedBeaconBlockBodyElectra(
@JsonProperty("voluntary_exits") final List<SignedVoluntaryExit> voluntaryExits,
@JsonProperty("sync_aggregate") final SyncAggregate syncAggregate,
@JsonProperty("execution_payload_header")
final ExecutionPayloadHeaderElectra executionPayloadHeader,
final ExecutionPayloadHeaderDeneb executionPayloadHeader,
@JsonProperty("bls_to_execution_changes")
final List<SignedBlsToExecutionChange> blsToExecutionChanges,
@JsonProperty("blob_kzg_commitments") final List<KZGCommitment> blobKZGCommitments,
Expand All @@ -69,10 +82,15 @@ public BlindedBeaconBlockBodyElectra(
attestations,
deposits,
voluntaryExits,
syncAggregate,
executionPayloadHeader,
blsToExecutionChanges,
blobKZGCommitments);
syncAggregate);
checkNotNull(
executionPayloadHeader, "Execution Payload Header is required for Electra blinded blocks");
this.executionPayloadHeader = executionPayloadHeader;
checkNotNull(
blsToExecutionChanges, "blsToExecutionChanges is required for Electra blinded blocks");
this.blsToExecutionChanges = blsToExecutionChanges;
checkNotNull(blobKZGCommitments, "blobKZGCommitments is required for Electra blinded blocks");
this.blobKZGCommitments = blobKZGCommitments;
checkNotNull(
executionRequestsRoot, "execution_requests_root is required for Electra blinded blocks");
this.executionRequestsRoot = executionRequestsRoot;
Expand All @@ -83,8 +101,17 @@ public BlindedBeaconBlockBodyElectra(
.BlindedBeaconBlockBodyElectra
blockBody) {
super(blockBody);
// TODO add execution requests from BeaconBlocBodyElectra
// (https://github.com/Consensys/teku/pull/8600)
this.executionPayloadHeader =
new ExecutionPayloadHeaderDeneb(blockBody.getExecutionPayloadHeader());
this.blsToExecutionChanges =
blockBody.getBlsToExecutionChanges().stream().map(SignedBlsToExecutionChange::new).toList();
this.blobKZGCommitments =
blockBody.getBlobKzgCommitments().stream()
.map(SszKZGCommitment::getKZGCommitment)
.map(KZGCommitment::new)
.toList();
// TODO Electra Builder API changes
// (https://github.com/Consensys/teku/issues/8624)
this.executionRequestsRoot = Bytes32.ZERO;
}

Expand All @@ -101,10 +128,33 @@ public boolean isBlinded() {

@Override
public BeaconBlockBody asInternalBeaconBlockBody(final SpecVersion spec) {

final ExecutionPayloadHeaderSchema<?> executionPayloadHeaderSchema =
getBeaconBlockBodySchema(spec).getExecutionPayloadHeaderSchema();

final SszListSchema<
tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChange, ?>
blsToExecutionChangesSchema = getBeaconBlockBodySchema(spec).getBlsToExecutionChanges();

final SszListSchema<SszKZGCommitment, ?> blobKZGCommitmentsSchema =
getBeaconBlockBodySchema(spec).getBlobKzgCommitmentsSchema();

return super.asInternalBeaconBlockBody(
spec,
builder -> {
// TODO add execution requests root (https://github.com/Consensys/teku/pull/8600)
builder.executionPayloadHeader(
executionPayloadHeader.asInternalExecutionPayloadHeader(
executionPayloadHeaderSchema));
builder.blsToExecutionChanges(
this.blsToExecutionChanges.stream()
.map(b -> b.asInternalSignedBlsToExecutionChange(spec))
.collect(blsToExecutionChangesSchema.collector()));
builder.blobKzgCommitments(
this.blobKZGCommitments.stream()
.map(KZGCommitment::asInternalKZGCommitment)
.map(SszKZGCommitment::new)
.collect(blobKZGCommitmentsSchema.collector()));
// TODO Electra Builder API changes (https://github.com/Consensys/teku/pull/8600)
return SafeFuture.COMPLETE;
});
}
Expand Down
Loading