Skip to content

Commit

Permalink
add utility methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdi-aouadi committed Oct 7, 2024
1 parent 5f9cc0d commit 33c8f60
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 17 deletions.
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 @@ -75,13 +75,10 @@ void engineGetPayload_shouldCallGetPayloadV2() {
verify(executionEngineClient).getPayloadV2(context.getPayloadId());
final SchemaDefinitionsCapella schemaDefinitionCapella =
spec.atSlot(slot).getSchemaDefinitions().toVersionCapella().orElseThrow();
final ExecutionPayloadSchema<?> payloadSchema =
final ExecutionPayloadSchema<?> executionPayloadSchema =
schemaDefinitionCapella.getExecutionPayloadSchema();
assertThat(future)
.isCompletedWithValue(
new GetPayloadResponse(
responseData.executionPayload.asInternalExecutionPayload(payloadSchema),
responseData.blockValue));
.isCompletedWithValue(responseData.asInternalGetPayloadResponse(executionPayloadSchema));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,12 @@ void engineGetPayload_shouldCallGetPayloadV3() {
verify(executionEngineClient).getPayloadV3(context.getPayloadId());
final SchemaDefinitionsDeneb schemaDefinitionDeneb =
spec.atSlot(slot).getSchemaDefinitions().toVersionDeneb().orElseThrow();
final ExecutionPayloadSchema<?> payloadSchema =
final ExecutionPayloadSchema<?> executionPayloadSchema =
schemaDefinitionDeneb.getExecutionPayloadSchema();
final BlobSchema blobSchema = schemaDefinitionDeneb.getBlobSchema();
assertThat(future)
.isCompletedWithValue(
new GetPayloadResponse(
responseData.executionPayload.asInternalExecutionPayload(payloadSchema),
responseData.blockValue,
responseData.blobsBundle.asInternalBlobsBundle(blobSchema),
responseData.shouldOverrideBuilder));
responseData.asInternalGetPayloadResponse(executionPayloadSchema, blobSchema));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,12 @@ void engineGetPayload_shouldCallGetPayloadV4() {
verify(executionEngineClient).getPayloadV4(context.getPayloadId());
final SchemaDefinitionsElectra schemaDefinitionElectra =
spec.atSlot(slot).getSchemaDefinitions().toVersionElectra().orElseThrow();
final ExecutionPayloadSchema<?> payloadSchema =
final ExecutionPayloadSchema<?> executionPayloadSchema =
schemaDefinitionElectra.getExecutionPayloadSchema();
final BlobSchema blobSchema = schemaDefinitionElectra.getBlobSchema();
assertThat(future)
.isCompletedWithValue(
new GetPayloadResponse(
responseData.executionPayload.asInternalExecutionPayload(payloadSchema),
responseData.blockValue,
responseData.blobsBundle.asInternalBlobsBundle(blobSchema),
responseData.shouldOverrideBuilder));
responseData.asInternalGetPayloadResponse(executionPayloadSchema, blobSchema));
}

@Test
Expand Down

0 comments on commit 33c8f60

Please sign in to comment.