5098 branch 15 update remaining invalid engine params (#7443)

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
pull/7453/head
Matilda-Clerke 3 months ago committed by GitHub
parent ac9f8bbd91
commit a3b6fd5402
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/TracedJsonRpcProcessor.java
  2. 24
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineForkchoiceUpdated.java
  3. 12
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java
  4. 36
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EnginePreparePayloadDebug.java
  5. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/RpcErrorType.java

@ -74,8 +74,8 @@ public class TracedJsonRpcProcessor implements JsonRpcProcessor {
case INVALID_DEPOSIT_REQUEST_PARAMS:
case INVALID_ENGINE_EXCHANGE_TRANSITION_CONFIGURATION_PARAMS:
case INVALID_ENGINE_FORKCHOICE_UPDATED_PARAMS:
case INVALID_ENGINE_PAYLOAD_ATTRIBUTES_PARAMS:
case INVALID_ENGINE_PAYLOAD_PARAMS:
case INVALID_ENGINE_FORKCHOICE_UPDATED_PAYLOAD_ATTRIBUTES:
case INVALID_ENGINE_NEW_PAYLOAD_PARAMS:
case INVALID_ENGINE_PREPARE_PAYLOAD_PARAMS:
case INVALID_ENODE_PARAMS:
case INVALID_EXCESS_BLOB_GAS_PARAMS:

@ -27,6 +27,7 @@ import org.hyperledger.besu.consensus.merge.blockcreation.PayloadIdentifier;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EngineForkchoiceUpdatedParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadAttributesParameter;
@ -80,10 +81,25 @@ public abstract class AbstractEngineForkchoiceUpdated extends ExecutionEngineJso
final Object requestId = requestContext.getRequest().getId();
final EngineForkchoiceUpdatedParameter forkChoice =
requestContext.getRequiredParameter(0, EngineForkchoiceUpdatedParameter.class);
final Optional<EnginePayloadAttributesParameter> maybePayloadAttributes =
requestContext.getOptionalParameter(1, EnginePayloadAttributesParameter.class);
final EngineForkchoiceUpdatedParameter forkChoice;
try {
forkChoice = requestContext.getRequiredParameter(0, EngineForkchoiceUpdatedParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid engine forkchoice updated parameter (index 0)",
RpcErrorType.INVALID_ENGINE_FORKCHOICE_UPDATED_PARAMS,
e);
}
final Optional<EnginePayloadAttributesParameter> maybePayloadAttributes;
try {
maybePayloadAttributes =
requestContext.getOptionalParameter(1, EnginePayloadAttributesParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid engine payload attributes parameter (index 1)",
RpcErrorType.INVALID_ENGINE_FORKCHOICE_UPDATED_PAYLOAD_ATTRIBUTES,
e);
}
LOG.debug("Forkchoice parameters {}", forkChoice);
mergeContext

@ -35,6 +35,7 @@ import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.BlockProcessingResult;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcRequestException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.ConsolidationRequestParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositRequestParameter;
@ -107,8 +108,15 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet
public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext) {
engineCallListener.executionEngineCalled();
final EnginePayloadParameter blockParam =
requestContext.getRequiredParameter(0, EnginePayloadParameter.class);
final EnginePayloadParameter blockParam;
try {
blockParam = requestContext.getRequiredParameter(0, EnginePayloadParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcRequestException(
"Invalid engine payload parameter (index 0)",
RpcErrorType.INVALID_ENGINE_NEW_PAYLOAD_PARAMS,
e);
}
final Optional<List<String>> maybeVersionedHashParam =
requestContext.getOptionalList(1, String.class);

@ -23,6 +23,7 @@ import org.hyperledger.besu.consensus.merge.blockcreation.PayloadIdentifier;
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.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePreparePayloadParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter;
@ -58,17 +59,25 @@ public class EnginePreparePayloadDebug extends ExecutionEngineJsonRpcMethod {
@Override
public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext) {
final EnginePreparePayloadParameter enginePreparePayloadParameter =
requestContext
.getOptionalParameter(0, EnginePreparePayloadParameter.class)
.orElse(
new EnginePreparePayloadParameter(
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty()));
final EnginePreparePayloadParameter enginePreparePayloadParameter;
try {
enginePreparePayloadParameter =
requestContext
.getOptionalParameter(0, EnginePreparePayloadParameter.class)
.orElse(
new EnginePreparePayloadParameter(
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty()));
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid engine prepare payload parameter (index 0)",
RpcErrorType.INVALID_ENGINE_PREPARE_PAYLOAD_PARAMS,
e);
}
final var requestId = requestContext.getRequest().getId();
@ -81,7 +90,10 @@ public class EnginePreparePayloadDebug extends ExecutionEngineJsonRpcMethod {
payloadIdentifier ->
new JsonRpcSuccessResponse(
requestId, new EnginePreparePayloadResult(VALID, payloadIdentifier)))
.orElseGet(() -> new JsonRpcErrorResponse(requestId, RpcErrorType.INVALID_PARAMS));
.orElseGet(
() ->
new JsonRpcErrorResponse(
requestId, RpcErrorType.INVALID_ENGINE_PREPARE_PAYLOAD_PARAMS));
}
@VisibleForTesting

@ -52,9 +52,9 @@ public enum RpcErrorType implements RpcMethodError {
INVALID_PARAMS_ERROR_CODE, "Invalid engine exchange transition configuration params"),
INVALID_ENGINE_FORKCHOICE_UPDATED_PARAMS(
INVALID_PARAMS_ERROR_CODE, "Invalid engine forkchoice updated params"),
INVALID_ENGINE_PAYLOAD_ATTRIBUTES_PARAMS(
INVALID_ENGINE_FORKCHOICE_UPDATED_PAYLOAD_ATTRIBUTES(
INVALID_PARAMS_ERROR_CODE, "Invalid engine payload attributes parameter"),
INVALID_ENGINE_PAYLOAD_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid engine payload parameter"),
INVALID_ENGINE_NEW_PAYLOAD_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid engine payload parameter"),
INVALID_ENGINE_PREPARE_PAYLOAD_PARAMS(
INVALID_PARAMS_ERROR_CODE, "Invalid engine prepare payload parameter"),
INVALID_ENODE_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid enode params"),

Loading…
Cancel
Save