Skip to content

Commit

Permalink
add update payload with inclusion list egine api method
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdi-aouadi committed Jan 31, 2025
1 parent dc90a57 commit cb304ee
Show file tree
Hide file tree
Showing 14 changed files with 226 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadAttributesV3;
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadStatusV1;
import tech.pegasys.teku.ethereum.executionclient.schema.Response;
import tech.pegasys.teku.ethereum.executionclient.schema.UpdatePayloadWithInclusionListV1Response;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.bytes.Bytes8;
import tech.pegasys.teku.spec.datastructures.execution.PowBlock;
Expand Down Expand Up @@ -91,4 +92,7 @@ SafeFuture<Response<ForkChoiceUpdatedResult>> forkChoiceUpdatedV3(
SafeFuture<Response<List<BlobAndProofV1>>> getBlobsV1(List<VersionedHash> blobVersionedHashes);

SafeFuture<Response<GetInclusionListV1Response>> getInclusionListV1(Bytes32 parentHash);

SafeFuture<Response<UpdatePayloadWithInclusionListV1Response>> updatePayloadWithInclusionListV1(
Bytes8 payloadId, List<Bytes> inclusionList);
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadAttributesV3;
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadStatusV1;
import tech.pegasys.teku.ethereum.executionclient.schema.Response;
import tech.pegasys.teku.ethereum.executionclient.schema.UpdatePayloadWithInclusionListV1Response;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.async.ThrottlingTaskQueue;
import tech.pegasys.teku.infrastructure.bytes.Bytes8;
Expand Down Expand Up @@ -184,4 +185,11 @@ public SafeFuture<Response<GetInclusionListV1Response>> getInclusionListV1(
final Bytes32 parentHash) {
return taskQueue.queueTask(() -> delegate.getInclusionListV1(parentHash));
}

@Override
public SafeFuture<Response<UpdatePayloadWithInclusionListV1Response>>
updatePayloadWithInclusionListV1(final Bytes8 payloadId, final List<Bytes> inclusionList) {
return taskQueue.queueTask(
() -> delegate.updatePayloadWithInclusionListV1(payloadId, inclusionList));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public enum EngineApiMethod {
ENGINE_NEW_PAYLOAD("engine_newPayload"),
ENGINE_GET_PAYLOAD("engine_getPayload"),
ENGINE_FORK_CHOICE_UPDATED("engine_forkchoiceUpdated"),
ENGINE_GET_INCLUSION_LIST("engine_getInclusionList");
ENGINE_GET_INCLUSION_LIST("engine_getInclusionList"),
ENGINE_UPDATE_PAYLOAD_WITH_INCLUSION_LIST("engine_updatePayloadWithInclusionList");

private final String name;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright Consensys Software Inc., 2025
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.ethereum.executionclient.methods;

import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.tuweni.bytes.Bytes;
import tech.pegasys.teku.ethereum.executionclient.ExecutionEngineClient;
import tech.pegasys.teku.ethereum.executionclient.response.ResponseUnwrapper;
import tech.pegasys.teku.ethereum.executionclient.schema.UpdatePayloadWithInclusionListV1Response;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.bytes.Bytes8;
import tech.pegasys.teku.spec.datastructures.execution.versions.eip7805.UpdatePayloadWithInclusionListResponse;

public class EngineUpdatePayloadWithInclusionListV1
extends AbstractEngineJsonRpcMethod<UpdatePayloadWithInclusionListResponse> {

private static final Logger LOG = LogManager.getLogger();

public EngineUpdatePayloadWithInclusionListV1(final ExecutionEngineClient executionEngineClient) {
super(executionEngineClient);
}

@Override
public String getName() {
return EngineApiMethod.ENGINE_UPDATE_PAYLOAD_WITH_INCLUSION_LIST.getName();
}

@Override
public int getVersion() {
return 1;
}

@Override
public SafeFuture<UpdatePayloadWithInclusionListResponse> execute(
final JsonRpcRequestParams params) {
final Bytes8 payloadId = params.getRequiredParameter(0, Bytes8.class);
final List<Bytes> inclusionList = params.getRequiredListParameter(1, Bytes.class);

LOG.trace(
"Calling {}(payloadId={}, inclusionList={})", getVersionedName(), payloadId, inclusionList);

return executionEngineClient
.updatePayloadWithInclusionListV1(payloadId, inclusionList)
.thenApply(ResponseUnwrapper::unwrapExecutionClientResponseOrThrow)
.thenApply(
UpdatePayloadWithInclusionListV1Response
::asInternalUpdatePayloadWithInclusionListResponse)
.thenPeek(
updatePayloadWithInclusionListResponse ->
LOG.trace(
"Response {}(payloadId={}) -> {}",
getVersionedName(),
updatePayloadWithInclusionListResponse.payloadId(),
updatePayloadWithInclusionListResponse));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadAttributesV3;
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadStatusV1;
import tech.pegasys.teku.ethereum.executionclient.schema.Response;
import tech.pegasys.teku.ethereum.executionclient.schema.UpdatePayloadWithInclusionListV1Response;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.bytes.Bytes8;
import tech.pegasys.teku.infrastructure.metrics.MetricsCountersByIntervals;
Expand Down Expand Up @@ -71,6 +72,8 @@ public class MetricRecordingExecutionEngineClient extends MetricRecordingAbstrac
public static final String GET_CLIENT_VERSION_V1_METHOD = "get_client_versionV1";
public static final String GET_BLOBS_V1_METHOD = "get_blobs_versionV1";
public static final String GET_INCLUSION_LIST_V1_METHOD = "get_inclusion_list_versionV1";
public static final String UPDATE_PAYLOAD_WITH_INCLUSION_LIST_V1_METHOD =
"update_payload_with_inclusion_list_versionV1";

private final ExecutionEngineClient delegate;

Expand Down Expand Up @@ -231,4 +234,12 @@ public SafeFuture<Response<GetInclusionListV1Response>> getInclusionListV1(
return countRequest(
() -> delegate.getInclusionListV1(parentHash), GET_INCLUSION_LIST_V1_METHOD);
}

@Override
public SafeFuture<Response<UpdatePayloadWithInclusionListV1Response>>
updatePayloadWithInclusionListV1(final Bytes8 payloadId, final List<Bytes> inclusionList) {
return countRequest(
() -> delegate.updatePayloadWithInclusionListV1(payloadId, inclusionList),
UPDATE_PAYLOAD_WITH_INCLUSION_LIST_V1_METHOD);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright Consensys Software Inc., 2025
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.ethereum.executionclient.schema;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes8Deserializer;
import tech.pegasys.teku.infrastructure.bytes.Bytes8;
import tech.pegasys.teku.spec.datastructures.execution.versions.eip7805.UpdatePayloadWithInclusionListResponse;

public class UpdatePayloadWithInclusionListV1Response {

@JsonDeserialize(using = Bytes8Deserializer.class)
private final Bytes8 payloadId;

public UpdatePayloadWithInclusionListV1Response(
@JsonProperty("payloadId") final Bytes8 payloadId) {
this.payloadId = payloadId;
}

public UpdatePayloadWithInclusionListResponse asInternalUpdatePayloadWithInclusionListResponse() {
return new UpdatePayloadWithInclusionListResponse(payloadId);
}

public Bytes8 getPayloadId() {
return payloadId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadAttributesV3;
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadStatusV1;
import tech.pegasys.teku.ethereum.executionclient.schema.Response;
import tech.pegasys.teku.ethereum.executionclient.schema.UpdatePayloadWithInclusionListV1Response;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.bytes.Bytes8;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
Expand All @@ -56,6 +57,7 @@ public class Web3JExecutionEngineClient implements ExecutionEngineClient {
private static final Duration GET_CLIENT_VERSION_TIMEOUT = Duration.ofSeconds(1);
private static final Duration GET_BLOBS_TIMEOUT = Duration.ofSeconds(1);
private static final Duration GET_INCLUSION_LIST_TIMEOUT = Duration.ofSeconds(1);
private static final Duration UPDATE_PAYLOAD_WITH_INCLUSION_LIST_TIMEOUT = Duration.ofSeconds(1);

private final Web3JClient web3JClient;

Expand Down Expand Up @@ -314,6 +316,18 @@ public SafeFuture<Response<GetInclusionListV1Response>> getInclusionListV1(
return web3JClient.doRequest(web3jRequest, GET_INCLUSION_LIST_TIMEOUT);
}

@Override
public SafeFuture<Response<UpdatePayloadWithInclusionListV1Response>>
updatePayloadWithInclusionListV1(final Bytes8 payloadId, final List<Bytes> inclusionList) {
final Request<?, UpdatePayloadWithInclusionListV1Web3jResponse> web3jRequest =
new Request<>(
"engine_updatePayloadWithInclusionListV1",
list(payloadId, inclusionList),
web3JClient.getWeb3jService(),
UpdatePayloadWithInclusionListV1Web3jResponse.class);
return web3JClient.doRequest(web3jRequest, UPDATE_PAYLOAD_WITH_INCLUSION_LIST_TIMEOUT);
}

static class ExecutionPayloadV1Web3jResponse
extends org.web3j.protocol.core.Response<ExecutionPayloadV1> {}

Expand Down Expand Up @@ -344,6 +358,9 @@ static class GetBlobsVersionV1Web3jResponse
static class GetnclusionListVersionV1Web3jResponse
extends org.web3j.protocol.core.Response<GetInclusionListV1Response> {}

static class UpdatePayloadWithInclusionListV1Web3jResponse
extends org.web3j.protocol.core.Response<UpdatePayloadWithInclusionListV1Response> {}

/**
* Returns a list that supports null items.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.Optional;
import org.apache.tuweni.bytes.Bytes32;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.bytes.Bytes8;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.datastructures.execution.BlobAndProof;
import tech.pegasys.teku.spec.datastructures.execution.ClientVersion;
Expand Down Expand Up @@ -52,4 +53,7 @@ SafeFuture<List<BlobAndProof>> engineGetBlobs(
List<VersionedHash> blobVersionedHashes, UInt64 slot);

SafeFuture<List<Transaction>> engineGetInclusionList(Bytes32 parentHash, UInt64 slot);

SafeFuture<Bytes8> engineUpdatePayloadWithInclusionList(
Bytes8 payloadId, List<Transaction> inclusionList, UInt64 slot);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import tech.pegasys.teku.ethereum.executionclient.methods.JsonRpcRequestParams;
import tech.pegasys.teku.ethereum.executionclient.response.ResponseUnwrapper;
import tech.pegasys.teku.ethereum.executionclient.schema.ClientVersionV1;
import tech.pegasys.teku.ethereum.executionclient.schema.UpdatePayloadWithInclusionListV1Response;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.bytes.Bytes8;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSchema;
Expand Down Expand Up @@ -176,4 +178,21 @@ public SafeFuture<List<Transaction>> engineGetInclusionList(
return response.transactions.stream().map(transactionSchema::fromBytes).toList();
});
}

@Override
public SafeFuture<Bytes8> engineUpdatePayloadWithInclusionList(
final Bytes8 payloadId, final List<Transaction> inclusionList, final UInt64 slot) {
final TransactionSchema transactionSchema =
spec.atSlot(slot)
.getSchemaDefinitions()
.toVersionEip7805()
.orElseThrow()
.getInclusionListSchema()
.getTransactionSchema();
return executionEngineClient
.updatePayloadWithInclusionListV1(
payloadId, inclusionList.stream().map(transactionSchema::sszSerialize).toList())
.thenApply(ResponseUnwrapper::unwrapExecutionClientResponseOrThrow)
.thenApply(UpdatePayloadWithInclusionListV1Response::getPayloadId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import tech.pegasys.teku.ethereum.executionclient.web3j.Web3JExecutionEngineClient;
import tech.pegasys.teku.ethereum.performance.trackers.BlockProductionPerformance;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.bytes.Bytes8;
import tech.pegasys.teku.infrastructure.logging.EventLogger;
import tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory;
import tech.pegasys.teku.infrastructure.ssz.SszList;
Expand Down Expand Up @@ -234,11 +235,22 @@ public SafeFuture<List<Optional<BlobAndProof>>> engineGetBlobs(
@Override
public SafeFuture<List<Transaction>> engineGetInclusionList(
final Bytes32 parentHash, final UInt64 slot) {
LOG.trace(
"calling engineGetInclusionList(engineGetInclusionList={}, slot={})", parentHash, slot);
LOG.trace("calling engineGetInclusionList(parentHash={}, slot={})", parentHash, slot);
return executionClientHandler.engineGetInclusionList(parentHash, slot);
}

@Override
public SafeFuture<Bytes8> engineUpdatePayloadWithInclusionList(
final Bytes8 payloadId, final List<Transaction> inclusionList, final UInt64 slot) {
LOG.trace(
"calling engineUpdatePayloadWithInclusionList(payloadId={}, inclusionList={}, slot={})",
payloadId,
inclusionList,
slot);
return executionClientHandler.engineUpdatePayloadWithInclusionList(
payloadId, inclusionList, slot);
}

@Override
public SafeFuture<Void> builderRegisterValidators(
final SszList<SignedValidatorRegistration> signedValidatorRegistrations, final UInt64 slot) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static tech.pegasys.teku.ethereum.executionclient.methods.EngineApiMethod.ENGINE_GET_INCLUSION_LIST;
import static tech.pegasys.teku.ethereum.executionclient.methods.EngineApiMethod.ENGINE_GET_PAYLOAD;
import static tech.pegasys.teku.ethereum.executionclient.methods.EngineApiMethod.ENGINE_NEW_PAYLOAD;
import static tech.pegasys.teku.ethereum.executionclient.methods.EngineApiMethod.ENGINE_UPDATE_PAYLOAD_WITH_INCLUSION_LIST;

import java.util.Collections;
import java.util.EnumMap;
Expand All @@ -41,6 +42,7 @@
import tech.pegasys.teku.ethereum.executionclient.methods.EngineNewPayloadV3;
import tech.pegasys.teku.ethereum.executionclient.methods.EngineNewPayloadV4;
import tech.pegasys.teku.ethereum.executionclient.methods.EngineNewPayloadV5;
import tech.pegasys.teku.ethereum.executionclient.methods.EngineUpdatePayloadWithInclusionListV1;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.datastructures.util.ForkAndSpecMilestone;
Expand Down Expand Up @@ -133,6 +135,9 @@ private Map<EngineApiMethod, EngineJsonRpcMethod<?>> eip7805SupportedMethods() {
methods.put(ENGINE_GET_PAYLOAD, new EngineGetPayloadV4(executionEngineClient, spec));
methods.put(ENGINE_FORK_CHOICE_UPDATED, new EngineForkChoiceUpdatedV3(executionEngineClient));
methods.put(ENGINE_GET_INCLUSION_LIST, new EngineGetInclusionListV1(executionEngineClient));
methods.put(
ENGINE_UPDATE_PAYLOAD_WITH_INCLUSION_LIST,
new EngineUpdatePayloadWithInclusionListV1(executionEngineClient));

return methods;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright Consensys Software Inc., 2025
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.spec.datastructures.execution.versions.eip7805;

import tech.pegasys.teku.infrastructure.bytes.Bytes8;

public record UpdatePayloadWithInclusionListResponse(Bytes8 payloadId) {}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import tech.pegasys.teku.ethereum.performance.trackers.BlockProductionPerformance;
import tech.pegasys.teku.ethereum.performance.trackers.BlockPublishingPerformance;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.bytes.Bytes8;
import tech.pegasys.teku.infrastructure.events.ChannelInterface;
import tech.pegasys.teku.infrastructure.ssz.SszList;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
Expand Down Expand Up @@ -93,6 +94,12 @@ public SafeFuture<List<Transaction>> engineGetInclusionList(
return SafeFuture.completedFuture(Collections.emptyList());
}

@Override
public SafeFuture<Bytes8> engineUpdatePayloadWithInclusionList(
final Bytes8 payloadId, final List<Transaction> inclusionList, final UInt64 slot) {
return SafeFuture.completedFuture(null);
}

@Override
public SafeFuture<Void> builderRegisterValidators(
final SszList<SignedValidatorRegistration> signedValidatorRegistrations,
Expand Down Expand Up @@ -137,6 +144,9 @@ SafeFuture<List<Optional<BlobAndProof>>> engineGetBlobs(

SafeFuture<List<Transaction>> engineGetInclusionList(Bytes32 parentHash, UInt64 slot);

SafeFuture<Bytes8> engineUpdatePayloadWithInclusionList(
Bytes8 payloadId, List<Transaction> inclusionList, UInt64 slot);

/**
* This is low level method, use {@link
* ExecutionLayerBlockProductionManager#initiateBlockProduction(ExecutionPayloadContext,
Expand Down
Loading

0 comments on commit cb304ee

Please sign in to comment.