Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5098 branch 9 update invalid block count params #7410

Merged
Show file tree
Hide file tree
Changes from 83 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
e41cf31
5098: Add RpcErrorTypes
Matilda-Clerke Jul 29, 2024
147d580
5098: Modify InvalidJsonRpcParameters and InvalidJsonRpcRequestExcept…
Matilda-Clerke Jul 29, 2024
8da4815
5098: Modify InvalidJsonRpcParameters and InvalidJsonRpcRequestExcept…
Matilda-Clerke Jul 30, 2024
8ca34d7
5098: Add JsonRpcParameterException for later use
Matilda-Clerke Jul 30, 2024
5b5631a
5098: Update locations for RpcErrorType.INVALID_ACCOUNTS_PARAMS
Matilda-Clerke Jul 30, 2024
950117b
5098: Address review comments, apply spotless
Matilda-Clerke Jul 30, 2024
0004fa2
Merge branch 'refs/heads/5098-branch-1-add-rpc-error-types' into 5098…
Matilda-Clerke Jul 30, 2024
7fc2c2b
5098: Update with changes from branch 1
Matilda-Clerke Jul 30, 2024
b70da06
Merge branch 'main' into 5098-branch-1-add-rpc-error-types
Matilda-Clerke Jul 30, 2024
a54a5aa
5098: Update code to use RpcErrorType.INVALID_ADDRESS_HASH_PARAMS
Matilda-Clerke Jul 30, 2024
5acb2d7
5098: apply spotless
Matilda-Clerke Jul 30, 2024
aba28d4
Merge branch 'refs/heads/5098-branch-2-update-invalid-accounts-params…
Matilda-Clerke Jul 30, 2024
afb8860
5098: apply spotless
Matilda-Clerke Jul 30, 2024
0d4a9b3
5098: Update plugin-api gradle hash
Matilda-Clerke Jul 30, 2024
ad7d7b3
Merge branch 'refs/heads/5098-branch-1-add-rpc-error-types' into 5098…
Matilda-Clerke Jul 30, 2024
8aac343
Merge branch 'refs/heads/5098-branch-2-update-invalid-accounts-params…
Matilda-Clerke Jul 30, 2024
9ba006b
5098: Add comment on INVALID_PARAMS_ERROR_CODE
Matilda-Clerke Jul 30, 2024
531c530
5098: Apply spotless on latest changes
Matilda-Clerke Jul 30, 2024
e946b06
Merge branch 'main' into 5098-branch-1-add-rpc-error-types
Matilda-Clerke Jul 30, 2024
b0dc1a8
Merge branch 'refs/heads/5098-branch-1-add-rpc-error-types' into 5098…
Matilda-Clerke Jul 30, 2024
cc6bdf3
Merge branch 'refs/heads/5098-branch-2-update-invalid-accounts-params…
Matilda-Clerke Jul 30, 2024
983ac77
Merge branch 'main' into 5098-branch-2-update-invalid-accounts-params
Matilda-Clerke Jul 30, 2024
6fc67ee
5098: Update code to use RpcErrorType.INVALID_ADDRESS_PARAMS
Matilda-Clerke Jul 30, 2024
728ab2c
5098: Fix broken unit test
Matilda-Clerke Jul 30, 2024
6480308
Merge remote-tracking branch 'origin/5098-branch-2-update-invalid-acc…
Matilda-Clerke Jul 30, 2024
8b72fbc
Merge branch 'refs/heads/5098-branch-2-update-invalid-accounts-params…
Matilda-Clerke Jul 30, 2024
a60966c
Merge branch 'refs/heads/5098-branch-3-update-invalid-address-hash-pa…
Matilda-Clerke Jul 30, 2024
0fb6919
5098: Fix broken unit test
Matilda-Clerke Jul 31, 2024
e967e32
Merge branch 'refs/heads/5098-branch-2-update-invalid-accounts-params…
Matilda-Clerke Jul 31, 2024
32db32b
Merge branch 'refs/heads/5098-branch-3-update-invalid-address-hash-pa…
Matilda-Clerke Jul 31, 2024
9f53648
5098: Update with usage of RpcErrorType.INVALID_AUTH_PARAMS
Matilda-Clerke Jul 31, 2024
3cfe6dd
5098: Update with usage of RpcErrorType.INVALID_BLOB_COUNT
Matilda-Clerke Jul 31, 2024
7414843
5098: Update with usage of RpcErrorType.INVALID_BLOB_GAS_USED_PARAMS
Matilda-Clerke Jul 31, 2024
c3e8d22
5098: Update with usage of RpcErrorType.INVALID_BLOCK_PARAMS
Matilda-Clerke Jul 31, 2024
73c45b0
Merge branch 'main' into 5098-branch-3-update-invalid-address-hash-pa…
Matilda-Clerke Jul 31, 2024
75dff8f
5098: Update with usage of RpcErrorType.INVALID_BLOCK_PARAMS
Matilda-Clerke Jul 31, 2024
dd6c10b
5098: Update with usage of RpcErrorType.INVALID_BLOCK_PARAMS
Matilda-Clerke Jul 31, 2024
7d41fac
5098: Update with usage of RpcErrorType.INVALID_BLOCK_COUNT_PARAMS
Matilda-Clerke Jul 31, 2024
e316045
5098: Fix broken integration test
Matilda-Clerke Jul 31, 2024
d7a7dba
Merge branch 'refs/heads/5098-branch-8-update-invalid-block-params' i…
Matilda-Clerke Jul 31, 2024
670c6fa
Merge branch 'main' into 5098-branch-3-update-invalid-address-hash-pa…
Matilda-Clerke Jul 31, 2024
724dd14
Merge branch 'refs/heads/5098-branch-3-update-invalid-address-hash-pa…
Matilda-Clerke Jul 31, 2024
ab04552
Merge branch 'refs/heads/5098-branch-4-update-invalid-address-params'…
Matilda-Clerke Jul 31, 2024
8e1a740
Merge branch 'refs/heads/5098-branch-5-update-invalid-auth-params' in…
Matilda-Clerke Jul 31, 2024
71cad41
Merge branch 'refs/heads/5098-branch-6-update-invalid-blob-count' int…
Matilda-Clerke Jul 31, 2024
25c68b8
Merge branch 'refs/heads/5098-branch-7-update-invalid-blob-gas-used-p…
Matilda-Clerke Jul 31, 2024
167a416
Merge branch 'refs/heads/5098-branch-8-update-invalid-block-params' i…
Matilda-Clerke Jul 31, 2024
4fef179
Merge branch 'main' into 5098-branch-4-update-invalid-address-params
macfarla Jul 31, 2024
bd6b7d3
5098: Add index to exception messages
Matilda-Clerke Jul 31, 2024
eda22ac
5098: apoply spotless
Matilda-Clerke Jul 31, 2024
6ce053b
5098: Update BaseJsonRpcProcessor to utilise RpcErrorType from Invali…
Matilda-Clerke Aug 1, 2024
943426b
Merge branch 'refs/heads/5098-branch-4-update-invalid-address-params'…
Matilda-Clerke Aug 1, 2024
d441737
5098: Include parameter index in INVALID_AUTH_PARAMS
Matilda-Clerke Aug 1, 2024
11b4839
Merge branch 'refs/heads/5098-branch-5-update-invalid-auth-params' in…
Matilda-Clerke Aug 1, 2024
3459365
Merge branch 'refs/heads/5098-branch-6-update-invalid-blob-count' int…
Matilda-Clerke Aug 1, 2024
f46c23a
Merge branch 'refs/heads/5098-branch-7-update-invalid-blob-gas-used-p…
Matilda-Clerke Aug 1, 2024
93594a9
5098: Include parameter index in INVALID_BLOCK_PARAMS
Matilda-Clerke Aug 1, 2024
d8f6f3e
Merge branch 'refs/heads/5098-branch-8-update-invalid-block-params' i…
Matilda-Clerke Aug 1, 2024
f2fb791
5098: Include parameter index in INVALID_BLOCK_COUNT_PARAMS
Matilda-Clerke Aug 1, 2024
0b3d153
Merge branch 'main' into 5098-branch-4-update-invalid-address-params
Matilda-Clerke Aug 1, 2024
6e106de
Merge branch 'main' into 5098-branch-4-update-invalid-address-params
Matilda-Clerke Aug 1, 2024
625b75f
Merge branch 'main' into 5098-branch-4-update-invalid-address-params
Matilda-Clerke Aug 1, 2024
373d5c9
Merge branch 'refs/heads/5098-branch-4-update-invalid-address-params'…
Matilda-Clerke Aug 1, 2024
876e74d
Merge branch 'refs/heads/5098-branch-5-update-invalid-auth-params' in…
Matilda-Clerke Aug 1, 2024
9e2ff60
Merge branch 'refs/heads/5098-branch-6-update-invalid-blob-count' int…
Matilda-Clerke Aug 1, 2024
85eda97
Merge branch 'refs/heads/5098-branch-7-update-invalid-blob-gas-used-p…
Matilda-Clerke Aug 1, 2024
68b3d29
Merge branch 'refs/heads/5098-branch-8-update-invalid-block-params' i…
Matilda-Clerke Aug 1, 2024
0c06cac
Merge branch 'main' into 5098-branch-5-update-invalid-auth-params
Matilda-Clerke Aug 2, 2024
005640e
5098: Fix broken integration test
Matilda-Clerke Aug 2, 2024
89a9fb4
Merge branch 'refs/heads/5098-branch-5-update-invalid-auth-params' in…
Matilda-Clerke Aug 2, 2024
42cce8f
Merge branch 'refs/heads/5098-branch-6-update-invalid-blob-count' int…
Matilda-Clerke Aug 2, 2024
a0e0e43
Merge branch 'refs/heads/5098-branch-7-update-invalid-blob-gas-used-p…
Matilda-Clerke Aug 2, 2024
94c319d
Merge branch 'refs/heads/5098-branch-8-update-invalid-block-params' i…
Matilda-Clerke Aug 2, 2024
792f328
5098: Rename INVALID_AUTH_PARAMS to INVALID_PROPOSAL_PARAMS
Matilda-Clerke Aug 2, 2024
e840fea
Merge branch 'refs/heads/5098-branch-5-update-invalid-auth-params' in…
Matilda-Clerke Aug 2, 2024
e4c663a
Merge branch 'refs/heads/5098-branch-6-update-invalid-blob-count' int…
Matilda-Clerke Aug 2, 2024
5d7e9c9
Merge branch 'refs/heads/5098-branch-7-update-invalid-blob-gas-used-p…
Matilda-Clerke Aug 2, 2024
355a02a
Merge branch 'refs/heads/5098-branch-8-update-invalid-block-params' i…
Matilda-Clerke Aug 2, 2024
ff2db15
5098: apply spotless
Matilda-Clerke Aug 2, 2024
07b758f
Merge branch 'refs/heads/5098-branch-8-update-invalid-block-params' i…
Matilda-Clerke Aug 2, 2024
437c5a2
Merge branch 'main' into 5098-branch-7-update-invalid-blob-gas-used-p…
Matilda-Clerke Aug 11, 2024
2b68b15
Merge branch 'refs/heads/5098-branch-7-update-invalid-blob-gas-used-p…
Matilda-Clerke Aug 11, 2024
bd85d0e
Merge branch 'refs/heads/5098-branch-8-update-invalid-block-params' i…
Matilda-Clerke Aug 11, 2024
e2d2f4c
5098: Fix broken unit test
Matilda-Clerke Aug 11, 2024
98b48b0
Merge branch 'refs/heads/5098-branch-8-update-invalid-block-params' i…
Matilda-Clerke Aug 11, 2024
c562abf
Merge branch 'main' into 5098-branch-8-update-invalid-block-params
Matilda-Clerke Aug 12, 2024
cce32cc
5098: Fix broken tests
Matilda-Clerke Aug 12, 2024
16c7d9d
Merge remote-tracking branch 'origin/5098-branch-8-update-invalid-blo…
Matilda-Clerke Aug 12, 2024
9758f31
Merge branch 'refs/heads/5098-branch-8-update-invalid-block-params' i…
Matilda-Clerke Aug 12, 2024
7c14379
Merge branch 'main' into 5098-branch-9-update-invalid-block-count-params
Matilda-Clerke Aug 12, 2024
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 @@ -17,6 +17,7 @@
import org.hyperledger.besu.consensus.common.validator.ValidatorProvider;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
Expand Down Expand Up @@ -67,8 +68,13 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
}

private Optional<BlockHeader> determineBlockHeader(final JsonRpcRequestContext request) {
final Optional<BlockParameter> blockParameter =
request.getOptionalParameter(0, BlockParameter.class);
final Optional<BlockParameter> blockParameter;
try {
blockParameter = request.getOptionalParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
final long latest = blockchainQueries.headBlockNumber();
final long blockNumber = blockParameter.map(b -> b.getNumber().orElse(latest)).orElse(latest);
return blockchainQueries.blockByNumber(blockNumber).map(BlockWithMetadata::getHeader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
import org.hyperledger.besu.consensus.common.BlockInterface;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.AbstractBlockParameterMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.BlockHeader;

Expand Down Expand Up @@ -50,7 +52,12 @@ public IbftGetValidatorsByBlockNumber(

@Override
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
return request.getRequiredParameter(0, BlockParameter.class);
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.AbstractBlockParameterMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.BlockHeader;

Expand Down Expand Up @@ -50,7 +52,12 @@ public QbftGetValidatorsByBlockNumber(

@Override
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
return request.getRequiredParameter(0, BlockParameter.class);
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public void missingTagParameterBlockHashes() {

assertThat(thrown)
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessageContaining("Invalid json rpc parameter at index 0");
.hasMessageContaining("Invalid block parameter");
}

/** The Tag | Quantity is the first parameter, either a String or a number */
Expand All @@ -422,7 +422,7 @@ public void missingTagParameterBlockTransactions() {

assertThat(thrown)
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessageContaining("Invalid json rpc parameter at index 0");
.hasMessageContaining("Invalid block parameter");
}

/**
Expand All @@ -437,7 +437,6 @@ public void missingHashesOrTransactionParameter() {

assertThat(thrown)
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasNoCause()
.hasMessage("Missing required json rpc parameter at index 1");
}

Expand All @@ -453,8 +452,7 @@ public void missingAllParameters() {

assertThat(thrown)
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasNoCause()
.hasMessage("Missing required json rpc parameter at index 0");
.hasMessage("Invalid block parameter (index 0)");
}

private JsonRpcRequestContext requestWithParams(final Object... params) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@

import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.AbstractBlockParameterMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
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.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
Expand Down Expand Up @@ -56,7 +58,12 @@ public String getName() {

@Override
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
return request.getRequiredParameter(0, BlockParameter.class);
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter.TraceType;

import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.TraceCallResult;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.diff.StateDiffGenerator;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.diff.StateDiffTrace;
Expand Down Expand Up @@ -62,8 +64,13 @@ protected AbstractTraceByBlock(

@Override
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
final Optional<BlockParameter> maybeBlockParameter =
request.getOptionalParameter(2, BlockParameter.class);
final Optional<BlockParameter> maybeBlockParameter;
try {
maybeBlockParameter = request.getOptionalParameter(2, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 2)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}

if (maybeBlockParameter.isPresent()) {
return maybeBlockParameter.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@

import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
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.query.BlockchainQueries;

import java.util.Optional;
Expand All @@ -38,8 +40,13 @@ public String getName() {

@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final Optional<BlockParameter> startBlockParam =
requestContext.getOptionalParameter(0, BlockParameter.class);
final Optional<BlockParameter> startBlockParam;
try {
startBlockParam = requestContext.getOptionalParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid start block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
final long startBlock;
if (startBlockParam.isEmpty() || startBlockParam.get().isEarliest()) {
startBlock = 0;
Expand All @@ -50,8 +57,13 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
startBlock = Long.MAX_VALUE;
}

final Optional<BlockParameter> stopBlockParam =
requestContext.getOptionalParameter(1, BlockParameter.class);
final Optional<BlockParameter> stopBlockParam;
try {
stopBlockParam = requestContext.getOptionalParameter(1, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid stop block parameter (index 1)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
final long stopBlock;
if (stopBlockParam.isEmpty()) {
if (startBlockParam.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ public String getName() {
@Override
protected BlockParameterOrBlockHash blockParameterOrBlockHash(
final JsonRpcRequestContext requestContext) {
return requestContext.getRequiredParameter(0, BlockParameterOrBlockHash.class);
try {
return requestContext.getRequiredParameter(0, BlockParameterOrBlockHash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block or block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,16 @@ public String getName() {

@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final BlockParameterOrBlockHash blockParameterOrBlockHash =
requestContext.getRequiredParameter(0, BlockParameterOrBlockHash.class);
final BlockParameterOrBlockHash blockParameterOrBlockHash;
try {
blockParameterOrBlockHash =
requestContext.getRequiredParameter(0, BlockParameterOrBlockHash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block parameter or block hash parameter (index 0)",
RpcErrorType.INVALID_BLOCK_PARAMS,
e);
}
final String addressHash;
try {
addressHash = requestContext.getRequiredParameter(2, String.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
Expand All @@ -37,7 +38,12 @@ public String getName() {

@Override
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
return request.getRequiredParameter(0, BlockParameter.class);
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
Expand All @@ -37,7 +38,12 @@ public String getName() {

@Override
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
return request.getRequiredParameter(0, BlockParameter.class);
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.rlp.RLP;
Expand All @@ -40,7 +42,12 @@ public String getName() {
@Override
protected BlockParameterOrBlockHash blockParameterOrBlockHash(
final JsonRpcRequestContext request) {
return request.getRequiredParameter(0, BlockParameterOrBlockHash.class);
try {
return request.getRequiredParameter(0, BlockParameterOrBlockHash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block or block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
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.query.BlockchainQueries;

import java.util.Optional;
Expand All @@ -43,7 +45,12 @@ public String getName() {

@Override
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
return request.getRequiredParameter(0, BlockParameter.class);
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,14 @@ public String getName() {

@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final BlockParameterOrBlockHash blockParameterOrBlockHash =
requestContext.getRequiredParameter(0, BlockParameterOrBlockHash.class);
final BlockParameterOrBlockHash blockParameterOrBlockHash;
try {
blockParameterOrBlockHash =
requestContext.getRequiredParameter(0, BlockParameterOrBlockHash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block or block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
final int transactionIndex = requestContext.getRequiredParameter(1, Integer.class);
final Address accountAddress;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TransactionTraceParams;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
Expand Down Expand Up @@ -69,9 +70,12 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
try {
block = Block.readFrom(RLP.input(Bytes.fromHexString(input)), this.blockHeaderFunctions);
} catch (final RLPException e) {
LOG.debug("Failed to parse block RLP", e);
LOG.debug("Failed to parse block RLP (index 0)", e);
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_BLOCK_PARAMS);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block params (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
final TraceOptions traceOptions =
requestContext
Expand Down
Loading
Loading