for fcu v2 use correct invalid params error code (#6766)

* fcu v2 use invalid params error code per spec

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>

---------

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
pull/6788/head
Sally MacFarlane 8 months ago committed by GitHub
parent 6337689e09
commit 380c0c93f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      acceptance-tests/tests/src/test/resources/jsonrpc/engine/shanghai/test-cases/05_shanghai_prepare_payload_invalid_null_withdrawals.json
  2. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineForkchoiceUpdated.java
  3. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineForkchoiceUpdatedV1.java
  4. 8
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineForkchoiceUpdatedV2.java
  5. 20
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineForkchoiceUpdatedV3.java
  6. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineForkchoiceUpdatedTest.java
  7. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineForkchoiceUpdatedV2Test.java

@ -20,8 +20,8 @@
"jsonrpc" : "2.0",
"id" : 67,
"error" : {
"code" : -38003,
"message" : "Invalid payload attributes"
"code" : -32602,
"message" : "Invalid params"
}
},
"statusCode" : 200

@ -172,7 +172,7 @@ public abstract class AbstractEngineForkchoiceUpdated extends ExecutionEngineJso
if (!getWithdrawalsValidator(
protocolSchedule.get(), newHead, maybePayloadAttributes.get().getTimestamp())
.validateWithdrawals(withdrawals)) {
return new JsonRpcErrorResponse(requestId, getInvalidPayloadError());
return new JsonRpcErrorResponse(requestId, getInvalidParametersError());
}
}
@ -241,7 +241,7 @@ public abstract class AbstractEngineForkchoiceUpdated extends ExecutionEngineJso
if (payloadAttributes.getTimestamp() <= headBlockHeader.getTimestamp()) {
LOG.warn(
"Payload attributes timestamp is smaller than timestamp of header in fork choice update");
return Optional.of(new JsonRpcErrorResponse(requestId, getInvalidPayloadError()));
return Optional.of(new JsonRpcErrorResponse(requestId, getInvalidPayloadAttributesError()));
}
return Optional.empty();
@ -364,10 +364,14 @@ public abstract class AbstractEngineForkchoiceUpdated extends ExecutionEngineJso
return false;
}
protected RpcErrorType getInvalidPayloadError() {
protected RpcErrorType getInvalidParametersError() {
return RpcErrorType.INVALID_PARAMS;
}
protected RpcErrorType getInvalidPayloadAttributesError() {
return RpcErrorType.INVALID_PAYLOAD_ATTRIBUTES;
}
// fcU calls are synchronous, no need to make volatile
private long lastFcuInfoLog = System.currentTimeMillis();
private static final String logMessage =

@ -54,7 +54,7 @@ public class EngineForkchoiceUpdatedV1 extends AbstractEngineForkchoiceUpdated {
}
@Override
protected RpcErrorType getInvalidPayloadError() {
protected RpcErrorType getInvalidParametersError() {
return RpcErrorType.INVALID_PAYLOAD_ATTRIBUTES;
}
}

@ -62,15 +62,9 @@ public class EngineForkchoiceUpdatedV2 extends AbstractEngineForkchoiceUpdated {
} else if (payloadAttributes.getParentBeaconBlockRoot() != null) {
LOG.error(
"Parent beacon block root hash present in payload attributes before cancun hardfork");
return Optional.of(
new JsonRpcErrorResponse(requestId, RpcErrorType.INVALID_PAYLOAD_ATTRIBUTES));
return Optional.of(new JsonRpcErrorResponse(requestId, getInvalidPayloadAttributesError()));
} else {
return Optional.empty();
}
}
@Override
protected RpcErrorType getInvalidPayloadError() {
return RpcErrorType.INVALID_PAYLOAD_ATTRIBUTES;
}
}

@ -56,16 +56,19 @@ public class EngineForkchoiceUpdatedV3 extends AbstractEngineForkchoiceUpdated {
final EngineForkchoiceUpdatedParameter fcuParameter,
final Optional<EnginePayloadAttributesParameter> maybePayloadAttributes) {
if (fcuParameter.getHeadBlockHash() == null) {
return ValidationResult.invalid(getInvalidPayloadError(), "Missing head block hash");
return ValidationResult.invalid(
getInvalidPayloadAttributesError(), "Missing head block hash");
} else if (fcuParameter.getSafeBlockHash() == null) {
return ValidationResult.invalid(getInvalidPayloadError(), "Missing safe block hash");
return ValidationResult.invalid(
getInvalidPayloadAttributesError(), "Missing safe block hash");
} else if (fcuParameter.getFinalizedBlockHash() == null) {
return ValidationResult.invalid(getInvalidPayloadError(), "Missing finalized block hash");
return ValidationResult.invalid(
getInvalidPayloadAttributesError(), "Missing finalized block hash");
}
if (maybePayloadAttributes.isPresent()) {
if (maybePayloadAttributes.get().getParentBeaconBlockRoot() == null) {
return ValidationResult.invalid(
getInvalidPayloadError(), "Missing parent beacon block root hash");
getInvalidPayloadAttributesError(), "Missing parent beacon block root hash");
}
}
return ValidationResult.valid();
@ -93,18 +96,13 @@ public class EngineForkchoiceUpdatedV3 extends AbstractEngineForkchoiceUpdated {
if (payloadAttributes.getParentBeaconBlockRoot() == null) {
LOG.error(
"Parent beacon block root hash not present in payload attributes after cancun hardfork");
return Optional.of(new JsonRpcErrorResponse(requestId, getInvalidPayloadError()));
return Optional.of(new JsonRpcErrorResponse(requestId, getInvalidPayloadAttributesError()));
} else if (payloadAttributes.getTimestamp().longValue() == 0) {
return Optional.of(new JsonRpcErrorResponse(requestId, getInvalidPayloadError()));
return Optional.of(new JsonRpcErrorResponse(requestId, getInvalidPayloadAttributesError()));
} else if (payloadAttributes.getTimestamp() < cancun.get().milestone()) {
return Optional.of(new JsonRpcErrorResponse(requestId, RpcErrorType.UNSUPPORTED_FORK));
} else {
return Optional.empty();
}
}
@Override
protected RpcErrorType getInvalidPayloadError() {
return RpcErrorType.INVALID_PAYLOAD_ATTRIBUTES;
}
}

@ -475,7 +475,7 @@ public abstract class AbstractEngineForkchoiceUpdatedTest {
mockHeader.getHash(), Hash.ZERO, mockParent.getHash()),
Optional.of(payloadParams));
assertInvalidForkchoiceState(resp, expectedInvalidPayloadError());
assertInvalidForkchoiceState(resp, RpcErrorType.INVALID_PAYLOAD_ATTRIBUTES);
verify(engineCallListener, times(1)).executionEngineCalled();
}

@ -46,6 +46,6 @@ public class EngineForkchoiceUpdatedV2Test extends AbstractEngineForkchoiceUpdat
@Override
protected RpcErrorType expectedInvalidPayloadError() {
return RpcErrorType.INVALID_PAYLOAD_ATTRIBUTES;
return RpcErrorType.INVALID_PARAMS;
}
}

Loading…
Cancel
Save