Skip to content

Commit

Permalink
remove GetPayloadResponse versions
Browse files Browse the repository at this point in the history
  • Loading branch information
tbenr committed May 5, 2023
1 parent 53d624c commit 8ae4561
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 200 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
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.versions.bellatrix.GetPayloadResponseBellatrix;
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsBellatrix;

public class EngineGetPayloadV1 extends AbstractEngineJsonRpcMethod<GetPayloadResponse> {
Expand Down Expand Up @@ -67,9 +66,7 @@ public SafeFuture<GetPayloadResponse> execute(final JsonRpcRequestParams params)
final ExecutionPayloadSchema<?> payloadSchema =
SchemaDefinitionsBellatrix.required(spec.atSlot(slot).getSchemaDefinitions())
.getExecutionPayloadSchema();
return (GetPayloadResponse)
new GetPayloadResponseBellatrix(
payload.asInternalExecutionPayload(payloadSchema));
return new GetPayloadResponse(payload.asInternalExecutionPayload(payloadSchema));
})
.thenPeek(
payloadAndValue ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
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.versions.capella.GetPayloadResponseCapella;
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsBellatrix;

public class EngineGetPayloadV2 extends AbstractEngineJsonRpcMethod<GetPayloadResponse> {
Expand Down Expand Up @@ -67,10 +66,9 @@ public SafeFuture<GetPayloadResponse> execute(final JsonRpcRequestParams params)
final ExecutionPayloadSchema<?> payloadSchema =
SchemaDefinitionsBellatrix.required(spec.atSlot(slot).getSchemaDefinitions())
.getExecutionPayloadSchema();
return (GetPayloadResponse)
new GetPayloadResponseCapella(
response.executionPayload.asInternalExecutionPayload(payloadSchema),
response.blockValue);
return new GetPayloadResponse(
response.executionPayload.asInternalExecutionPayload(payloadSchema),
response.blockValue);
})
.thenPeek(
payloadAndValue ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
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.versions.deneb.GetPayloadResponseDeneb;
import tech.pegasys.teku.spec.schemas.SchemaDefinitions;
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsBellatrix;
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsDeneb;
Expand Down Expand Up @@ -74,11 +73,10 @@ public SafeFuture<GetPayloadResponse> execute(final JsonRpcRequestParams params)
SchemaDefinitionsBellatrix.required(schemaDefinitions)
.getExecutionPayloadSchema();
final BlobsBundle blobsBundle = getBlobsBundle(response, schemaDefinitions);
return (GetPayloadResponse)
new GetPayloadResponseDeneb(
response.executionPayload.asInternalExecutionPayload(payloadSchema),
response.blockValue,
blobsBundle);
return new GetPayloadResponse(
response.executionPayload.asInternalExecutionPayload(payloadSchema),
response.blockValue,
blobsBundle);
})
.thenPeek(
payloadAndValue ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import tech.pegasys.teku.spec.datastructures.execution.GetPayloadResponse;
import tech.pegasys.teku.spec.datastructures.execution.versions.bellatrix.ExecutionPayloadBellatrix;
import tech.pegasys.teku.spec.datastructures.execution.versions.capella.ExecutionPayloadCapella;
import tech.pegasys.teku.spec.datastructures.execution.versions.capella.GetPayloadResponseCapella;
import tech.pegasys.teku.spec.util.DataStructureUtil;

class EngineGetPayloadV2Test {
Expand Down Expand Up @@ -131,7 +130,7 @@ public void shouldCallGetPayloadV2AndParseResponseSuccessfullyWhenInBellatrix()
jsonRpcMethod = new EngineGetPayloadV2(executionEngineClient, bellatrixSpec);

final GetPayloadResponse expectedGetPayloadResponse =
new GetPayloadResponseCapella(executionPayloadBellatrix, blockValue);
new GetPayloadResponse(executionPayloadBellatrix, blockValue);
assertThat(jsonRpcMethod.execute(params)).isCompletedWithValue(expectedGetPayloadResponse);

verify(executionEngineClient).getPayloadV2(eq(executionPayloadContext.getPayloadId()));
Expand Down Expand Up @@ -159,7 +158,7 @@ public void shouldCallGetPayloadV2AndParseResponseSuccessfullyWhenInCapella() {
jsonRpcMethod = new EngineGetPayloadV2(executionEngineClient, capellaSpec);

final GetPayloadResponse expectedGetPayloadResponse =
new GetPayloadResponseCapella(executionPayloadCapella, blockValue);
new GetPayloadResponse(executionPayloadCapella, blockValue);
assertThat(jsonRpcMethod.execute(params)).isCompletedWithValue(expectedGetPayloadResponse);

verify(executionEngineClient).getPayloadV2(eq(executionPayloadContext.getPayloadId()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import tech.pegasys.teku.spec.datastructures.execution.versions.bellatrix.ExecutionPayloadBellatrix;
import tech.pegasys.teku.spec.datastructures.execution.versions.capella.ExecutionPayloadCapella;
import tech.pegasys.teku.spec.datastructures.execution.versions.deneb.ExecutionPayloadDeneb;
import tech.pegasys.teku.spec.datastructures.execution.versions.deneb.GetPayloadResponseDeneb;
import tech.pegasys.teku.spec.util.DataStructureUtil;

class EngineGetPayloadV3Test {
Expand Down Expand Up @@ -136,7 +135,7 @@ public void shouldCallGetPayloadV3AndParseResponseSuccessfullyWhenInBellatrix()
jsonRpcMethod = new EngineGetPayloadV3(executionEngineClient, bellatrixSpec);

final GetPayloadResponse expectedGetPayloadResponse =
new GetPayloadResponseDeneb(executionPayloadBellatrix, blockValue, blobsBundle);
new GetPayloadResponse(executionPayloadBellatrix, blockValue, blobsBundle);
assertThat(jsonRpcMethod.execute(params)).isCompletedWithValue(expectedGetPayloadResponse);

verify(executionEngineClient).getPayloadV3(eq(executionPayloadContext.getPayloadId()));
Expand Down Expand Up @@ -165,7 +164,7 @@ public void shouldCallGetPayloadV3AndParseResponseSuccessfullyWhenInCapella() {
jsonRpcMethod = new EngineGetPayloadV3(executionEngineClient, capellaSpec);

final GetPayloadResponse expectedGetPayloadResponse =
new GetPayloadResponseDeneb(executionPayloadCapella, blockValue, blobsBundle);
new GetPayloadResponse(executionPayloadCapella, blockValue, blobsBundle);
assertThat(jsonRpcMethod.execute(params)).isCompletedWithValue(expectedGetPayloadResponse);

verify(executionEngineClient).getPayloadV3(eq(executionPayloadContext.getPayloadId()));
Expand Down Expand Up @@ -193,7 +192,7 @@ public void shouldCallGetPayloadV3AndParseResponseSuccessfullyWhenInDeneb() {
jsonRpcMethod = new EngineGetPayloadV3(executionEngineClient, denebSpec);

final GetPayloadResponse expectedGetPayloadResponse =
new GetPayloadResponseDeneb(executionPayloadDeneb, blockValue, blobsBundle);
new GetPayloadResponse(executionPayloadDeneb, blockValue, blobsBundle);
assertThat(jsonRpcMethod.execute(params)).isCompletedWithValue(expectedGetPayloadResponse);

verify(executionEngineClient).getPayloadV3(eq(executionPayloadContext.getPayloadId()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
import tech.pegasys.teku.spec.datastructures.execution.FallbackReason;
import tech.pegasys.teku.spec.datastructures.execution.GetPayloadResponse;
import tech.pegasys.teku.spec.datastructures.execution.HeaderWithFallbackData;
import tech.pegasys.teku.spec.datastructures.execution.versions.capella.GetPayloadResponseCapella;
import tech.pegasys.teku.spec.datastructures.execution.versions.deneb.GetPayloadResponseDeneb;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
import tech.pegasys.teku.spec.util.DataStructureUtil;

Expand Down Expand Up @@ -441,7 +439,7 @@ private ExecutionPayload prepareEngineGetPayloadResponse(
final UInt64 slot) {
final ExecutionPayload payload = dataStructureUtil.randomExecutionPayload();
when(executionClientHandler.engineGetPayload(executionPayloadContext, slot))
.thenReturn(SafeFuture.completedFuture(new GetPayloadResponseCapella(payload, blockValue)));
.thenReturn(SafeFuture.completedFuture(new GetPayloadResponse(payload, blockValue)));
return payload;
}

Expand All @@ -451,8 +449,8 @@ private GetPayloadResponse prepareEngineGetPayloadResponseDeneb(
final UInt64 slot) {
final ExecutionPayload payload = dataStructureUtil.randomExecutionPayload();
final BlobsBundle blobsBundle = dataStructureUtil.randomBlobsBundle();
final GetPayloadResponseDeneb getPayloadResponse =
new GetPayloadResponseDeneb(payload, blockValue, blobsBundle);
final GetPayloadResponse getPayloadResponse =
new GetPayloadResponse(payload, blockValue, blobsBundle);
when(executionClientHandler.engineGetPayload(executionPayloadContext, slot))
.thenReturn(SafeFuture.completedFuture(getPayloadResponse));
return getPayloadResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import tech.pegasys.teku.spec.datastructures.execution.FallbackReason;
import tech.pegasys.teku.spec.datastructures.execution.GetPayloadResponse;
import tech.pegasys.teku.spec.datastructures.execution.HeaderWithFallbackData;
import tech.pegasys.teku.spec.datastructures.execution.versions.capella.GetPayloadResponseCapella;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
import tech.pegasys.teku.spec.util.DataStructureUtil;

Expand Down Expand Up @@ -805,8 +804,7 @@ private GetPayloadResponse prepareEngineGetPayloadResponse(
final UInt256 blockValue,
final UInt64 slot) {
final ExecutionPayload payload = dataStructureUtil.randomExecutionPayload();
final GetPayloadResponseCapella getPayloadResponse =
new GetPayloadResponseCapella(payload, blockValue);
final GetPayloadResponse getPayloadResponse = new GetPayloadResponse(payload, blockValue);
when(executionClientHandler.engineGetPayload(executionPayloadContext, slot))
.thenReturn(SafeFuture.completedFuture(getPayloadResponse));
return getPayloadResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,41 @@
import org.apache.tuweni.units.bigints.UInt256;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobsBundle;

public interface GetPayloadResponse {
public class GetPayloadResponse {
private final ExecutionPayload executionPayload;
private final UInt256 blockValue;
private final BlobsBundle blobsBundle;

ExecutionPayload getExecutionPayload();
public GetPayloadResponse(final ExecutionPayload executionPayload) {
this.executionPayload = executionPayload;
this.blockValue = UInt256.ZERO;
this.blobsBundle = BlobsBundle.EMPTY_BUNDLE;
}

public GetPayloadResponse(final ExecutionPayload executionPayload, final UInt256 blockValue) {
this.executionPayload = executionPayload;
this.blockValue = blockValue;
this.blobsBundle = BlobsBundle.EMPTY_BUNDLE;
}

public GetPayloadResponse(
final ExecutionPayload executionPayload,
final UInt256 blockValue,
final BlobsBundle blobsBundle) {
this.executionPayload = executionPayload;
this.blockValue = blockValue;
this.blobsBundle = blobsBundle;
}

public ExecutionPayload getExecutionPayload() {
return executionPayload;
}

default UInt256 getBlockValue() {
return UInt256.ZERO;
public UInt256 getBlockValue() {
return blockValue;
}

default BlobsBundle getBlobsBundle() {
return BlobsBundle.EMPTY_BUNDLE;
public BlobsBundle getBlobsBundle() {
return blobsBundle;
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 8ae4561

Please sign in to comment.