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

Switch to compounding when consolidating with source==target #8646

Merged
merged 11 commits into from
Oct 7, 2024
Prev Previous commit
Merge branch 'master' into teku-8617
  • Loading branch information
lucassaldanha committed Oct 7, 2024
commit 152142c1f37d371f860115960daf7db24bf6eb1d

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,13 @@ private enum Operation {
"operations/withdrawal_request",
new OperationsTestExecutor<>(
"withdrawal_request.ssz_snappy", Operation.WITHDRAWAL_REQUEST))
// TODO re-enable consolidation tests (https://github.com/Consensys/teku/issues/8617)
.put(
"operations/consolidation_request",
new OperationsTestExecutor<>(
"consolidation_request.ssz_snappy", Operation.CONSOLIDATION_REQUEST))
// new OperationsTestExecutor<>(
// "consolidation_request.ssz_snappy",
// Operation.CONSOLIDATION_REQUEST))
TestExecutor.IGNORE_TESTS)
.build();

private final String dataFileName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.apache.tuweni.units.bigints.UInt256;
import tech.pegasys.teku.ethereum.executionclient.serialization.UInt256AsHexDeserializer;
import tech.pegasys.teku.ethereum.executionclient.serialization.UInt256AsHexSerializer;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadSchema;
import tech.pegasys.teku.spec.datastructures.execution.GetPayloadResponse;

public class GetPayloadV2Response {
public final ExecutionPayloadV2 executionPayload;
Expand All @@ -37,4 +39,10 @@ public GetPayloadV2Response(
this.executionPayload = executionPayload;
this.blockValue = blockValue;
}

public GetPayloadResponse asInternalGetPayloadResponse(
final ExecutionPayloadSchema<?> executionPayloadSchema) {
return new GetPayloadResponse(
executionPayload.asInternalExecutionPayload(executionPayloadSchema), blockValue);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import org.apache.tuweni.units.bigints.UInt256;
import tech.pegasys.teku.ethereum.executionclient.serialization.UInt256AsHexDeserializer;
import tech.pegasys.teku.ethereum.executionclient.serialization.UInt256AsHexSerializer;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSchema;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadSchema;
import tech.pegasys.teku.spec.datastructures.execution.GetPayloadResponse;

public class GetPayloadV3Response {
public final ExecutionPayloadV3 executionPayload;
Expand All @@ -46,4 +49,13 @@ public GetPayloadV3Response(
this.blobsBundle = blobsBundle;
this.shouldOverrideBuilder = shouldOverrideBuilder;
}

public GetPayloadResponse asInternalGetPayloadResponse(
final ExecutionPayloadSchema<?> executionPayloadSchema, final BlobSchema blobSchema) {
return new GetPayloadResponse(
executionPayload.asInternalExecutionPayload(executionPayloadSchema),
blockValue,
blobsBundle.asInternalBlobsBundle(blobSchema),
shouldOverrideBuilder);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import org.apache.tuweni.units.bigints.UInt256;
import tech.pegasys.teku.ethereum.executionclient.serialization.UInt256AsHexDeserializer;
import tech.pegasys.teku.ethereum.executionclient.serialization.UInt256AsHexSerializer;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSchema;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadSchema;
import tech.pegasys.teku.spec.datastructures.execution.GetPayloadResponse;

public class GetPayloadV4Response {
public final ExecutionPayloadV3 executionPayload;
Expand All @@ -46,4 +49,13 @@ public GetPayloadV4Response(
this.blobsBundle = blobsBundle;
this.shouldOverrideBuilder = shouldOverrideBuilder;
}

public GetPayloadResponse asInternalGetPayloadResponse(
final ExecutionPayloadSchema<?> executionPayloadSchema, final BlobSchema blobSchema) {
return new GetPayloadResponse(
executionPayload.asInternalExecutionPayload(executionPayloadSchema),
blockValue,
blobsBundle.asInternalBlobsBundle(blobSchema),
shouldOverrideBuilder);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package tech.pegasys.teku.ethereum.executionlayer;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

Expand All @@ -30,10 +31,12 @@
import tech.pegasys.teku.spec.TestSpecFactory;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadContext;
import tech.pegasys.teku.spec.datastructures.execution.GetPayloadResponse;
import tech.pegasys.teku.spec.datastructures.execution.NewPayloadRequest;
import tech.pegasys.teku.spec.executionlayer.ExecutionPayloadStatus;
import tech.pegasys.teku.spec.executionlayer.ForkChoiceState;
import tech.pegasys.teku.spec.executionlayer.PayloadBuildingAttributes;
import tech.pegasys.teku.spec.executionlayer.PayloadStatus;
import tech.pegasys.teku.spec.util.DataStructureUtil;

class BellatrixExecutionClientHandlerTest extends ExecutionHandlerClientTest {
Expand All @@ -43,7 +46,6 @@ void setup() {
dataStructureUtil = new DataStructureUtil(spec);
}

@SuppressWarnings("FutureReturnValueIgnored")
@Test
void engineGetPayload_shouldCallGetPayloadV1() {
final ExecutionClientHandler handler = getHandler();
Expand All @@ -54,35 +56,36 @@ void engineGetPayload_shouldCallGetPayloadV1() {
dataStructureUtil.randomForkChoiceState(false),
dataStructureUtil.randomPayloadBuildingAttributes(false));

final ExecutionPayload executionPayload = dataStructureUtil.randomExecutionPayload();
final ExecutionPayloadV1 responseData =
ExecutionPayloadV1.fromInternalExecutionPayload(executionPayload);
final SafeFuture<Response<ExecutionPayloadV1>> dummyResponse =
SafeFuture.completedFuture(
new Response<>(
ExecutionPayloadV1.fromInternalExecutionPayload(
dataStructureUtil.randomExecutionPayload())));
SafeFuture.completedFuture(new Response<>(responseData));
when(executionEngineClient.getPayloadV1(context.getPayloadId())).thenReturn(dummyResponse);

handler.engineGetPayload(context, slot);
final SafeFuture<GetPayloadResponse> future = handler.engineGetPayload(context, slot);
verify(executionEngineClient).getPayloadV1(context.getPayloadId());
assertThat(future).isCompletedWithValue(new GetPayloadResponse(executionPayload));
}

@SuppressWarnings("FutureReturnValueIgnored")
@Test
void engineNewPayload_shouldCallNewPayloadV1() {
final ExecutionClientHandler handler = getHandler();
final ExecutionPayload payload = dataStructureUtil.randomExecutionPayload();
final NewPayloadRequest newPayloadRequest = new NewPayloadRequest(payload);
final ExecutionPayloadV1 payloadV1 = ExecutionPayloadV1.fromInternalExecutionPayload(payload);
final PayloadStatusV1 responseData =
new PayloadStatusV1(
ExecutionPayloadStatus.ACCEPTED, dataStructureUtil.randomBytes32(), null);
final SafeFuture<Response<PayloadStatusV1>> dummyResponse =
SafeFuture.completedFuture(
new Response<>(
new PayloadStatusV1(
ExecutionPayloadStatus.ACCEPTED, dataStructureUtil.randomBytes32(), null)));
SafeFuture.completedFuture(new Response<>(responseData));
when(executionEngineClient.newPayloadV1(payloadV1)).thenReturn(dummyResponse);
handler.engineNewPayload(newPayloadRequest, UInt64.ZERO);
final SafeFuture<PayloadStatus> future =
handler.engineNewPayload(newPayloadRequest, UInt64.ZERO);
verify(executionEngineClient).newPayloadV1(payloadV1);
assertThat(future).isCompletedWithValue(responseData.asInternalExecutionPayload());
}

@SuppressWarnings("FutureReturnValueIgnored")
@Test
void engineForkChoiceUpdated_shouldCallEngineForkChoiceUpdatedV1() {
final ExecutionClientHandler handler = getHandler();
Expand All @@ -101,16 +104,18 @@ void engineForkChoiceUpdated_shouldCallEngineForkChoiceUpdatedV1() {
dataStructureUtil.randomBytes32());
final Optional<PayloadAttributesV1> payloadAttributes =
PayloadAttributesV1.fromInternalPayloadBuildingAttributes(Optional.of(attributes));
final ForkChoiceUpdatedResult responseData =
new ForkChoiceUpdatedResult(
new PayloadStatusV1(
ExecutionPayloadStatus.ACCEPTED, dataStructureUtil.randomBytes32(), ""),
dataStructureUtil.randomBytes8());
final SafeFuture<Response<ForkChoiceUpdatedResult>> dummyResponse =
SafeFuture.completedFuture(
new Response<>(
new ForkChoiceUpdatedResult(
new PayloadStatusV1(
ExecutionPayloadStatus.ACCEPTED, dataStructureUtil.randomBytes32(), ""),
dataStructureUtil.randomBytes8())));
SafeFuture.completedFuture(new Response<>(responseData));
when(executionEngineClient.forkChoiceUpdatedV1(forkChoiceStateV1, payloadAttributes))
.thenReturn(dummyResponse);
handler.engineForkChoiceUpdated(forkChoiceState, Optional.of(attributes));
final SafeFuture<tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult> future =
handler.engineForkChoiceUpdated(forkChoiceState, Optional.of(attributes));
verify(executionEngineClient).forkChoiceUpdatedV1(forkChoiceStateV1, payloadAttributes);
assertThat(future).isCompletedWithValue(responseData.asInternalExecutionPayload());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import org.apache.tuweni.units.bigints.UInt256;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -35,13 +34,14 @@
import tech.pegasys.teku.spec.TestSpecFactory;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadContext;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadSchema;
import tech.pegasys.teku.spec.datastructures.execution.GetPayloadResponse;
import tech.pegasys.teku.spec.datastructures.execution.NewPayloadRequest;
import tech.pegasys.teku.spec.datastructures.execution.versions.capella.ExecutionPayloadCapella;
import tech.pegasys.teku.spec.executionlayer.ExecutionPayloadStatus;
import tech.pegasys.teku.spec.executionlayer.ForkChoiceState;
import tech.pegasys.teku.spec.executionlayer.PayloadBuildingAttributes;
import tech.pegasys.teku.spec.executionlayer.PayloadStatus;
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsCapella;
import tech.pegasys.teku.spec.util.DataStructureUtil;

public class CapellaExecutionClientHandlerTest extends ExecutionHandlerClientTest {
Expand All @@ -53,7 +53,7 @@ void setup() {
}

@Test
void engineGetPayload_shouldCallGetPayloadV2() throws ExecutionException, InterruptedException {
void engineGetPayload_shouldCallGetPayloadV2() {
final ExecutionClientHandler handler = getHandler();
final UInt64 slot = dataStructureUtil.randomUInt64(1_000_000);
final ExecutionPayloadContext context =
Expand All @@ -62,19 +62,23 @@ void engineGetPayload_shouldCallGetPayloadV2() throws ExecutionException, Interr
dataStructureUtil.randomForkChoiceState(false),
dataStructureUtil.randomPayloadBuildingAttributes(false));

final GetPayloadV2Response responseData =
new GetPayloadV2Response(
ExecutionPayloadV2.fromInternalExecutionPayload(
dataStructureUtil.randomExecutionPayload()),
UInt256.MAX_VALUE);
final SafeFuture<Response<GetPayloadV2Response>> dummyResponse =
SafeFuture.completedFuture(
new Response<>(
new GetPayloadV2Response(
ExecutionPayloadV2.fromInternalExecutionPayload(
dataStructureUtil.randomExecutionPayload()),
UInt256.MAX_VALUE)));
SafeFuture.completedFuture(new Response<>(responseData));
when(executionEngineClient.getPayloadV2(context.getPayloadId())).thenReturn(dummyResponse);

final SafeFuture<GetPayloadResponse> future = handler.engineGetPayload(context, slot);
verify(executionEngineClient).getPayloadV2(context.getPayloadId());
assertThat(future).isCompleted();
assertThat(future.get().getExecutionPayload()).isInstanceOf(ExecutionPayloadCapella.class);
final SchemaDefinitionsCapella schemaDefinitionCapella =
spec.atSlot(slot).getSchemaDefinitions().toVersionCapella().orElseThrow();
final ExecutionPayloadSchema<?> executionPayloadSchema =
schemaDefinitionCapella.getExecutionPayloadSchema();
assertThat(future)
.isCompletedWithValue(responseData.asInternalGetPayloadResponse(executionPayloadSchema));
}

@Test
Expand All @@ -83,16 +87,16 @@ void engineNewPayload_shouldCallNewPayloadV2() {
final ExecutionPayload payload = dataStructureUtil.randomExecutionPayload();
final NewPayloadRequest newPayloadRequest = new NewPayloadRequest(payload);
final ExecutionPayloadV2 payloadV2 = ExecutionPayloadV2.fromInternalExecutionPayload(payload);
final PayloadStatusV1 responseData =
new PayloadStatusV1(
ExecutionPayloadStatus.ACCEPTED, dataStructureUtil.randomBytes32(), null);
final SafeFuture<Response<PayloadStatusV1>> dummyResponse =
SafeFuture.completedFuture(
new Response<>(
new PayloadStatusV1(
ExecutionPayloadStatus.ACCEPTED, dataStructureUtil.randomBytes32(), null)));
SafeFuture.completedFuture(new Response<>(responseData));
when(executionEngineClient.newPayloadV2(payloadV2)).thenReturn(dummyResponse);
final SafeFuture<PayloadStatus> future =
handler.engineNewPayload(newPayloadRequest, UInt64.ZERO);
verify(executionEngineClient).newPayloadV2(payloadV2);
assertThat(future).isCompleted();
assertThat(future).isCompletedWithValue(responseData.asInternalExecutionPayload());
}

@Test
Expand All @@ -101,19 +105,19 @@ void engineForkChoiceUpdated_shouldCallEngineForkChoiceUpdatedV2() {
final ForkChoiceState forkChoiceState = dataStructureUtil.randomForkChoiceState(false);
final ForkChoiceStateV1 forkChoiceStateV1 =
ForkChoiceStateV1.fromInternalForkChoiceState(forkChoiceState);
final ForkChoiceUpdatedResult responseData =
new ForkChoiceUpdatedResult(
new PayloadStatusV1(
ExecutionPayloadStatus.ACCEPTED, dataStructureUtil.randomBytes32(), ""),
dataStructureUtil.randomBytes8());
final SafeFuture<Response<ForkChoiceUpdatedResult>> dummyResponse =
SafeFuture.completedFuture(
new Response<>(
new ForkChoiceUpdatedResult(
new PayloadStatusV1(
ExecutionPayloadStatus.ACCEPTED, dataStructureUtil.randomBytes32(), ""),
dataStructureUtil.randomBytes8())));
SafeFuture.completedFuture(new Response<>(responseData));
when(executionEngineClient.forkChoiceUpdatedV2(forkChoiceStateV1, Optional.empty()))
.thenReturn(dummyResponse);
final SafeFuture<tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult> future =
handler.engineForkChoiceUpdated(forkChoiceState, Optional.empty());
verify(executionEngineClient).forkChoiceUpdatedV2(forkChoiceStateV1, Optional.empty());
assertThat(future).isCompleted();
assertThat(future).isCompletedWithValue(responseData.asInternalExecutionPayload());
}

@Test
Expand Down Expand Up @@ -141,18 +145,18 @@ void engineForkChoiceUpdatedBuildingBlockOnForkTransition_shouldCallEngineForkCh
capellaStartSlot.minusMinZero(1), dataStructureUtil.randomBytes32(), false);
final ForkChoiceStateV1 forkChoiceStateV1 =
ForkChoiceStateV1.fromInternalForkChoiceState(forkChoiceState);
final ForkChoiceUpdatedResult responseData =
new ForkChoiceUpdatedResult(
new PayloadStatusV1(
ExecutionPayloadStatus.ACCEPTED, dataStructureUtil.randomBytes32(), ""),
dataStructureUtil.randomBytes8());
final SafeFuture<Response<ForkChoiceUpdatedResult>> dummyResponse =
SafeFuture.completedFuture(
new Response<>(
new ForkChoiceUpdatedResult(
new PayloadStatusV1(
ExecutionPayloadStatus.ACCEPTED, dataStructureUtil.randomBytes32(), ""),
dataStructureUtil.randomBytes8())));
SafeFuture.completedFuture(new Response<>(responseData));
when(executionEngineClient.forkChoiceUpdatedV2(forkChoiceStateV1, payloadAttributes))
.thenReturn(dummyResponse);
final SafeFuture<tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult> future =
handler.engineForkChoiceUpdated(forkChoiceState, Optional.of(attributes));
verify(executionEngineClient).forkChoiceUpdatedV2(forkChoiceStateV1, payloadAttributes);
assertThat(future).isCompleted();
assertThat(future).isCompletedWithValue(responseData.asInternalExecutionPayload());
}
}
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.