Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public AbstractEngineForkchoiceUpdated(
}

protected ValidationResult<RpcErrorType> validateParameter(
final EngineForkchoiceUpdatedParameter forkchoiceUpdatedParameter) {
final EngineForkchoiceUpdatedParameter forkchoiceUpdatedParameter,
final Optional<EnginePayloadAttributesParameter> maybePayloadAttributes) {
return ValidationResult.valid();
}

Expand All @@ -85,21 +86,21 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext)
requestContext.getOptionalParameter(1, EnginePayloadAttributesParameter.class);

LOG.debug("Forkchoice parameters {}", forkChoice);
ValidationResult<RpcErrorType> parameterValidationResult =
validateParameter(forkChoice, maybePayloadAttributes);
if (!parameterValidationResult.isValid()) {
return new JsonRpcErrorResponse(requestId, parameterValidationResult);
}

if (maybePayloadAttributes.isPresent()) {
final EnginePayloadAttributesParameter payloadAttributes = maybePayloadAttributes.get();
ValidationResult<RpcErrorType> forkValidationResult =
validateForkSupported(payloadAttributes.getTimestamp());
if (!forkValidationResult.isValid()) {
return new JsonRpcSuccessResponse(requestId, forkValidationResult);
return new JsonRpcErrorResponse(requestId, forkValidationResult);
}
}

ValidationResult<RpcErrorType> parameterValidationResult = validateParameter(forkChoice);
if (!parameterValidationResult.isValid()) {
return new JsonRpcSuccessResponse(requestId, parameterValidationResult);
}

mergeContext
.get()
.fireNewUnverifiedForkchoiceEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -79,7 +78,7 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext request) {
ValidationResult<RpcErrorType> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -48,14 +49,21 @@ public String getName() {

@Override
protected ValidationResult<RpcErrorType> validateParameter(
final EngineForkchoiceUpdatedParameter fcuParameter) {
final EngineForkchoiceUpdatedParameter fcuParameter,
final Optional<EnginePayloadAttributesParameter> maybePayloadAttributes) {
if (fcuParameter.getHeadBlockHash() == null) {
return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing head block hash");
} else if (fcuParameter.getSafeBlockHash() == null) {
return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing safe block hash");
} else if (fcuParameter.getFinalizedBlockHash() == null) {
return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing finalized block hash");
}
if (maybePayloadAttributes.isPresent()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the parameter checking you mean that will potentially conflict with the larger refactor?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think fine to fix it like this in the short-term to clear the noise for the hive tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would not necessarily have to validate this if the plans are to use strict JSON validation

if (maybePayloadAttributes.get().getParentBeaconBlockRoot() == null) {
return ValidationResult.invalid(
RpcErrorType.INVALID_PARAMS, "Missing parent beacon block root hash");
}
}
return ValidationResult.valid();
}

Expand Down