diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineForkchoiceUpdated.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineForkchoiceUpdated.java index 1cde6c259a0..b64fca8d429 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineForkchoiceUpdated.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineForkchoiceUpdated.java @@ -69,7 +69,8 @@ public AbstractEngineForkchoiceUpdated( } protected ValidationResult validateParameter( - final EngineForkchoiceUpdatedParameter forkchoiceUpdatedParameter) { + final EngineForkchoiceUpdatedParameter forkchoiceUpdatedParameter, + final Optional maybePayloadAttributes) { return ValidationResult.valid(); } @@ -85,21 +86,21 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext) requestContext.getOptionalParameter(1, EnginePayloadAttributesParameter.class); LOG.debug("Forkchoice parameters {}", forkChoice); + ValidationResult parameterValidationResult = + validateParameter(forkChoice, maybePayloadAttributes); + if (!parameterValidationResult.isValid()) { + return new JsonRpcErrorResponse(requestId, parameterValidationResult); + } if (maybePayloadAttributes.isPresent()) { final EnginePayloadAttributesParameter payloadAttributes = maybePayloadAttributes.get(); ValidationResult forkValidationResult = validateForkSupported(payloadAttributes.getTimestamp()); if (!forkValidationResult.isValid()) { - return new JsonRpcSuccessResponse(requestId, forkValidationResult); + return new JsonRpcErrorResponse(requestId, forkValidationResult); } } - ValidationResult parameterValidationResult = validateParameter(forkChoice); - if (!parameterValidationResult.isValid()) { - return new JsonRpcSuccessResponse(requestId, parameterValidationResult); - } - mergeContext .get() .fireNewUnverifiedForkchoiceEvent( diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineGetPayload.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineGetPayload.java index 5cb72d0cb82..a714b25d8b4 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineGetPayload.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineGetPayload.java @@ -22,7 +22,6 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResultFactory; import org.hyperledger.besu.ethereum.core.BlockHeader; @@ -79,7 +78,7 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext request) { ValidationResult forkValidationResult = validateForkSupported(proposal.getHeader().getTimestamp()); if (!forkValidationResult.isValid()) { - return new JsonRpcSuccessResponse(request.getRequest().getId(), forkValidationResult); + return new JsonRpcErrorResponse(request.getRequest().getId(), forkValidationResult); } return createResponse(request, payloadId, proposal); } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineForkchoiceUpdatedV3.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineForkchoiceUpdatedV3.java index 31dc738fa39..2d25e12cefd 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineForkchoiceUpdatedV3.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineForkchoiceUpdatedV3.java @@ -18,6 +18,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EngineForkchoiceUpdatedParameter; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadAttributesParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec; @@ -48,7 +49,8 @@ public String getName() { @Override protected ValidationResult validateParameter( - final EngineForkchoiceUpdatedParameter fcuParameter) { + final EngineForkchoiceUpdatedParameter fcuParameter, + final Optional maybePayloadAttributes) { if (fcuParameter.getHeadBlockHash() == null) { return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing head block hash"); } else if (fcuParameter.getSafeBlockHash() == null) { @@ -56,6 +58,12 @@ protected ValidationResult validateParameter( } else if (fcuParameter.getFinalizedBlockHash() == null) { return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing finalized block hash"); } + if (maybePayloadAttributes.isPresent()) { + if (maybePayloadAttributes.get().getParentBeaconBlockRoot() == null) { + return ValidationResult.invalid( + RpcErrorType.INVALID_PARAMS, "Missing parent beacon block root hash"); + } + } return ValidationResult.valid(); }