5098 branch 5 update invalid auth params (#7406)

* 5098: Add RpcErrorTypes

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

* 5098: Modify InvalidJsonRpcParameters and InvalidJsonRpcRequestException, apply spotless

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

* 5098: Modify InvalidJsonRpcParameters and InvalidJsonRpcRequestException, apply spotless

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

* 5098: Add JsonRpcParameterException for later use

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

* 5098: Update locations for RpcErrorType.INVALID_ACCOUNTS_PARAMS

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

* 5098: Address review comments, apply spotless

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

* 5098: Update with changes from branch 1

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

* 5098: Update code to use RpcErrorType.INVALID_ADDRESS_HASH_PARAMS

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

* 5098: apply spotless

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

* 5098: apply spotless

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

* 5098: Update plugin-api gradle hash

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

* 5098: Add comment on INVALID_PARAMS_ERROR_CODE

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

* 5098: Apply spotless on latest changes

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

* 5098: Update code to use RpcErrorType.INVALID_ADDRESS_PARAMS

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

* 5098: Fix broken unit test

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

* 5098: Fix broken unit test

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

* 5098: Update with usage of RpcErrorType.INVALID_AUTH_PARAMS

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

* 5098: Add index to exception messages

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

* 5098: apoply spotless

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

* 5098: Update BaseJsonRpcProcessor to utilise RpcErrorType from InvalidJsonRpcParameters

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

* 5098: Include parameter index in INVALID_AUTH_PARAMS

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

* 5098: Rename INVALID_AUTH_PARAMS to INVALID_PROPOSAL_PARAMS

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/7422/head
Matilda-Clerke 4 months ago committed by GitHub
parent 419995248b
commit 1958df9651
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/Propose.java
  2. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/TracedJsonRpcProcessor.java
  3. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/RpcErrorType.java

@ -57,7 +57,13 @@ public class Propose implements JsonRpcMethod {
throw new InvalidJsonRpcParameters(
"Invalid address parameter (index 0)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
}
final Boolean auth = requestContext.getRequiredParameter(1, Boolean.class);
final Boolean auth;
try {
auth = requestContext.getRequiredParameter(1, Boolean.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid auth parameter (index 1)", RpcErrorType.INVALID_PROPOSAL_PARAMS, e);
}
if (address.equals(CliqueBlockInterface.NO_VOTE_SUBJECT)) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_REQUEST);

@ -60,7 +60,6 @@ public class TracedJsonRpcProcessor implements JsonRpcProcessor {
case INVALID_ACCOUNT_PARAMS:
case INVALID_ADDRESS_HASH_PARAMS:
case INVALID_ADDRESS_PARAMS:
case INVALID_AUTH_PARAMS:
case INVALID_BLOB_COUNT:
case INVALID_BLOB_GAS_USED_PARAMS:
case INVALID_BLOCK_PARAMS:
@ -104,6 +103,7 @@ public class TracedJsonRpcProcessor implements JsonRpcProcessor {
case INVALID_PRIVACY_GROUP_PARAMS:
case INVALID_PRIVATE_FROM_PARAMS:
case INVALID_PRIVATE_FOR_PARAMS:
case INVALID_PROPOSAL_PARAMS:
case INVALID_REMOTE_CAPABILITIES_PARAMS:
case INVALID_REWARD_PERCENTILES_PARAMS:
case INVALID_SEALER_ID_PARAMS:

@ -31,7 +31,6 @@ public enum RpcErrorType implements RpcMethodError {
INVALID_ACCOUNT_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid account params"),
INVALID_ADDRESS_HASH_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid address hash params"),
INVALID_ADDRESS_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid address params"),
INVALID_AUTH_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid auth params"),
INVALID_BLOB_COUNT(
INVALID_PARAMS_ERROR_CODE,
"Invalid blob count (blob transactions must have at least one blob)"),
@ -89,6 +88,7 @@ public enum RpcErrorType implements RpcMethodError {
INVALID_PRIVACY_GROUP_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid privacy group params"),
INVALID_PRIVATE_FROM_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid private from params"),
INVALID_PRIVATE_FOR_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid private for params"),
INVALID_PROPOSAL_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid proposal params"),
INVALID_REMOTE_CAPABILITIES_PARAMS(
INVALID_PARAMS_ERROR_CODE, "Invalid remote capabilities params"),
INVALID_REWARD_PERCENTILES_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid reward percentiles params"),

Loading…
Cancel
Save