Skip to content

Commit

Permalink
Move getEngineNewPayloadRequestParams to V3
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
  • Loading branch information
Gabriel-Trintinalia committed Aug 29, 2023
1 parent b71de12 commit 40d7565
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@

import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -482,20 +481,8 @@ private Optional<List<VersionedHash>> extractVersionedHashes(
* @param requestContext the JSON-RPC request context
* @return a new instance of EngineNewPayloadRequestParameter
*/
public EngineNewPayloadRequestParameter getEngineNewPayloadRequestParams(
final JsonRpcRequestContext requestContext) {

final EngineExecutionPayloadParameter payload =
requestContext.getRequiredParameter(0, EngineExecutionPayloadParameter.class);
final String[] versionedHashes = requestContext.getRequiredParameter(1, String[].class);

final String parentBeaconBlockRoot = requestContext.getRequiredParameter(2, String.class);

return new EngineNewPayloadRequestParameter(
payload,
Optional.of(Arrays.stream(versionedHashes).toList()),
Optional.of(parentBeaconBlockRoot));
}
public abstract EngineNewPayloadRequestParameter getEngineNewPayloadRequestParams(
final JsonRpcRequestContext requestContext);

private void logImportedBlockInfo(final Block block, final double timeInS) {
final StringBuilder message = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EngineExecutionPayloadParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EngineNewPayloadRequestParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;

import java.util.Arrays;
import java.util.Optional;

import io.vertx.core.Vertx;
Expand All @@ -49,6 +52,27 @@ public String getName() {
return RpcMethod.ENGINE_NEW_PAYLOAD_V3.getMethodName();
}

/**
* Retrieves the new payload request parameters from the given JSON-RPC request context.
*
* @param requestContext the JSON-RPC request context
* @return a new instance of EngineNewPayloadRequestParameter
*/
public EngineNewPayloadRequestParameter getEngineNewPayloadRequestParams(
final JsonRpcRequestContext requestContext) {

final EngineExecutionPayloadParameter payload =
requestContext.getRequiredParameter(0, EngineExecutionPayloadParameter.class);
final String[] versionedHashes = requestContext.getRequiredParameter(1, String[].class);

final String parentBeaconBlockRoot = requestContext.getRequiredParameter(2, String.class);

return new EngineNewPayloadRequestParameter(
payload,
Optional.of(Arrays.stream(versionedHashes).toList()),
Optional.of(parentBeaconBlockRoot));
}

@Override
protected ValidationResult<RpcErrorType> validateParameters(
final EngineNewPayloadRequestParameter params) {
Expand Down

0 comments on commit 40d7565

Please sign in to comment.