5098 branch 7 update invalid blob gas used params (#7408)

* 5098: Add RpcErrorTypes

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

---------

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
Signed-off-by: Matilda-Clerke <matilda.clerke@consensys.net>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
pull/7452/head
Matilda-Clerke 3 months ago committed by GitHub
parent 8fc80ade8d
commit 067be8cccc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java
  2. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2.java
  3. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3.java
  4. 8
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4.java
  5. 5
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2Test.java
  6. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java

@ -497,7 +497,7 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet
if (header.getBlobGasUsed().isPresent() && maybeVersionedHashes.isPresent()) { if (header.getBlobGasUsed().isPresent() && maybeVersionedHashes.isPresent()) {
if (!validateBlobGasUsed(header, maybeVersionedHashes.get(), protocolSpec)) { if (!validateBlobGasUsed(header, maybeVersionedHashes.get(), protocolSpec)) {
return ValidationResult.invalid( return ValidationResult.invalid(
RpcErrorType.INVALID_PARAMS, RpcErrorType.INVALID_BLOB_GAS_USED_PARAMS,
"Payload BlobGasUsed does not match calculated BlobGasUsed"); "Payload BlobGasUsed does not match calculated BlobGasUsed");
} }
} }

@ -56,7 +56,7 @@ public class EngineNewPayloadV2 extends AbstractEngineNewPayload {
final Optional<String> maybeBeaconBlockRootParam) { final Optional<String> maybeBeaconBlockRootParam) {
if (payloadParameter.getBlobGasUsed() != null) { if (payloadParameter.getBlobGasUsed() != null) {
return ValidationResult.invalid( return ValidationResult.invalid(
RpcErrorType.INVALID_PARAMS, "non-null BlobGasUsed pre-cancun"); RpcErrorType.INVALID_BLOB_GAS_USED_PARAMS, "Missing blob gas used field");
} }
if (payloadParameter.getExcessBlobGas() != null) { if (payloadParameter.getExcessBlobGas() != null) {
return ValidationResult.invalid( return ValidationResult.invalid(

@ -55,7 +55,10 @@ public class EngineNewPayloadV3 extends AbstractEngineNewPayload {
final EnginePayloadParameter payloadParameter, final EnginePayloadParameter payloadParameter,
final Optional<List<String>> maybeVersionedHashParam, final Optional<List<String>> maybeVersionedHashParam,
final Optional<String> maybeBeaconBlockRootParam) { final Optional<String> maybeBeaconBlockRootParam) {
if (payloadParameter.getBlobGasUsed() == null || payloadParameter.getExcessBlobGas() == null) { if (payloadParameter.getBlobGasUsed() == null) {
return ValidationResult.invalid(
RpcErrorType.INVALID_BLOB_GAS_USED_PARAMS, "Missing blob gas used field");
} else if (payloadParameter.getExcessBlobGas() == null) {
return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing blob gas fields"); return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing blob gas fields");
} else if (maybeVersionedHashParam == null || maybeVersionedHashParam.isEmpty()) { } else if (maybeVersionedHashParam == null || maybeVersionedHashParam.isEmpty()) {
return ValidationResult.invalid( return ValidationResult.invalid(

@ -55,8 +55,12 @@ public class EngineNewPayloadV4 extends AbstractEngineNewPayload {
final EnginePayloadParameter payloadParameter, final EnginePayloadParameter payloadParameter,
final Optional<List<String>> maybeVersionedHashParam, final Optional<List<String>> maybeVersionedHashParam,
final Optional<String> maybeBeaconBlockRootParam) { final Optional<String> maybeBeaconBlockRootParam) {
if (payloadParameter.getBlobGasUsed() == null || payloadParameter.getExcessBlobGas() == null) { if (payloadParameter.getBlobGasUsed() == null) {
return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing blob gas fields"); return ValidationResult.invalid(
RpcErrorType.INVALID_BLOB_GAS_USED_PARAMS, "Missing blob gas used field");
} else if (payloadParameter.getExcessBlobGas() == null) {
return ValidationResult.invalid(
RpcErrorType.INVALID_PARAMS, "non-null ExcessBlobGas pre-cancun");
} else if (maybeVersionedHashParam == null || maybeVersionedHashParam.isEmpty()) { } else if (maybeVersionedHashParam == null || maybeVersionedHashParam.isEmpty()) {
return ValidationResult.invalid( return ValidationResult.invalid(
RpcErrorType.INVALID_PARAMS, "Missing versioned hashes field"); RpcErrorType.INVALID_PARAMS, "Missing versioned hashes field");

@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameterTestFixture.WITHDRAWAL_PARAM_1; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameterTestFixture.WITHDRAWAL_PARAM_1;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INVALID_BLOB_GAS_USED_PARAMS;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INVALID_PARAMS; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INVALID_PARAMS;
import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
@ -149,8 +150,8 @@ public class EngineNewPayloadV2Test extends AbstractEngineNewPayloadTest {
var resp = var resp =
resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of(), null, null, null)); resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of(), null, null, null));
final JsonRpcError jsonRpcError = fromErrorResp(resp); final JsonRpcError jsonRpcError = fromErrorResp(resp);
assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode()); assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_BLOB_GAS_USED_PARAMS.getCode());
assertThat(jsonRpcError.getData()).isEqualTo("non-null BlobGasUsed pre-cancun"); assertThat(jsonRpcError.getData()).isEqualTo("Missing blob gas used field");
verify(engineCallListener, times(1)).executionEngineCalled(); verify(engineCallListener, times(1)).executionEngineCalled();
} }

@ -198,7 +198,7 @@ public class EngineNewPayloadV3Test extends EngineNewPayloadV2Test {
final JsonRpcError jsonRpcError = fromErrorResp(resp); final JsonRpcError jsonRpcError = fromErrorResp(resp);
assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode()); assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode());
assertThat(jsonRpcError.getData()).isEqualTo("Missing blob gas fields"); assertThat(jsonRpcError.getData()).isEqualTo("Missing blob gas used field");
verify(engineCallListener, times(1)).executionEngineCalled(); verify(engineCallListener, times(1)).executionEngineCalled();
} }

Loading…
Cancel
Save