mirror of
https://github.com/vacp2p/status-linea-besu.git
synced 2026-01-08 23:08:15 -05:00
5098 branch 22 update more invalid params (#7472)
* 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>
This commit is contained in:
@@ -60,7 +60,13 @@ public class IbftProposeValidatorVote implements JsonRpcMethod {
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid address parameter (index 0)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
|
||||
}
|
||||
final Boolean add = requestContext.getRequiredParameter(1, Boolean.class);
|
||||
final Boolean add;
|
||||
try {
|
||||
add = requestContext.getRequiredParameter(1, Boolean.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid vote type parameter (index 1)", RpcErrorType.INVALID_VOTE_TYPE_PARAMS, e);
|
||||
}
|
||||
LOG.trace(
|
||||
"Received RPC rpcName={} voteType={} address={}",
|
||||
getName(),
|
||||
|
||||
@@ -63,7 +63,7 @@ public class IbftProposeValidatorVoteTest {
|
||||
public void exceptionWhenNoAuthSupplied() {
|
||||
assertThatThrownBy(() -> method.response(requestWithParams(Address.fromHexString("1"))))
|
||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
||||
.hasMessage("Missing required json rpc parameter at index 1");
|
||||
.hasMessage("Invalid vote type parameter (index 1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -77,7 +77,7 @@ public class IbftProposeValidatorVoteTest {
|
||||
public void exceptionWhenInvalidBoolParameterSupplied() {
|
||||
assertThatThrownBy(() -> method.response(requestWithParams(Address.fromHexString("1"), "c")))
|
||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
||||
.hasMessageContaining("Invalid json rpc parameter at index 1");
|
||||
.hasMessageContaining("Invalid vote type parameter (index 1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -60,7 +60,13 @@ public class QbftProposeValidatorVote implements JsonRpcMethod {
|
||||
RpcErrorType.INVALID_ADDRESS_PARAMS,
|
||||
e);
|
||||
}
|
||||
final Boolean add = requestContext.getRequiredParameter(1, Boolean.class);
|
||||
final Boolean add;
|
||||
try {
|
||||
add = requestContext.getRequiredParameter(1, Boolean.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid vote type parameter (index 1)", RpcErrorType.INVALID_VOTE_TYPE_PARAMS, e);
|
||||
}
|
||||
LOG.trace(
|
||||
"Received RPC rpcName={} voteType={} address={}",
|
||||
getName(),
|
||||
|
||||
@@ -65,7 +65,7 @@ public class QbftProposeValidatorVoteTest {
|
||||
public void exceptionWhenNoAuthSupplied() {
|
||||
assertThatThrownBy(() -> method.response(requestWithParams(Address.fromHexString("1"))))
|
||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
||||
.hasMessage("Missing required json rpc parameter at index 1");
|
||||
.hasMessage("Invalid vote type parameter (index 1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -79,7 +79,7 @@ public class QbftProposeValidatorVoteTest {
|
||||
public void exceptionWhenInvalidBoolParameterSupplied() {
|
||||
assertThatThrownBy(() -> method.response(requestWithParams(Address.fromHexString("1"), "c")))
|
||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
||||
.hasMessageContaining("Invalid json rpc parameter at index 1");
|
||||
.hasMessageContaining("Invalid vote type parameter (index 1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -78,7 +78,15 @@ public class DebugAccountAt extends AbstractBlockParameterOrBlockHashMethod {
|
||||
@Override
|
||||
protected Object resultByBlockHash(
|
||||
final JsonRpcRequestContext requestContext, final Hash blockHash) {
|
||||
final Integer txIndex = requestContext.getRequiredParameter(1, Integer.class);
|
||||
final Integer txIndex;
|
||||
try {
|
||||
txIndex = requestContext.getRequiredParameter(1, Integer.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction index parameter (index 1)",
|
||||
RpcErrorType.INVALID_TRANSACTION_INDEX_PARAMS,
|
||||
e);
|
||||
}
|
||||
final Address address;
|
||||
try {
|
||||
address = requestContext.getRequiredParameter(2, Address.class);
|
||||
@@ -97,7 +105,7 @@ public class DebugAccountAt extends AbstractBlockParameterOrBlockHashMethod {
|
||||
List<TransactionWithMetadata> transactions = block.get().getTransactions();
|
||||
if (transactions.isEmpty() || txIndex < 0 || txIndex > block.get().getTransactions().size()) {
|
||||
return new JsonRpcErrorResponse(
|
||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
|
||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_TRANSACTION_PARAMS);
|
||||
}
|
||||
|
||||
return Tracer.processTracing(
|
||||
|
||||
@@ -17,8 +17,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
|
||||
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.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 org.hyperledger.besu.ethereum.core.Transaction;
|
||||
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
|
||||
@@ -38,7 +40,15 @@ public class DebugGetRawTransaction implements JsonRpcMethod {
|
||||
|
||||
@Override
|
||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||
final Hash txHash = requestContext.getRequiredParameter(0, Hash.class);
|
||||
final Hash txHash;
|
||||
try {
|
||||
txHash = requestContext.getRequiredParameter(0, Hash.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction hash parameter (index 0)",
|
||||
RpcErrorType.INVALID_TRANSACTION_HASH_PARAMS,
|
||||
e);
|
||||
}
|
||||
|
||||
return blockchainQueries
|
||||
.transactionByHash(txHash)
|
||||
|
||||
@@ -60,8 +60,15 @@ public class DebugStandardTraceBadBlockToFile extends DebugStandardTraceBlockToF
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
|
||||
}
|
||||
final Optional<TransactionTraceParams> transactionTraceParams =
|
||||
requestContext.getOptionalParameter(1, TransactionTraceParams.class);
|
||||
final Optional<TransactionTraceParams> transactionTraceParams;
|
||||
try {
|
||||
transactionTraceParams = requestContext.getOptionalParameter(1, TransactionTraceParams.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction trace parameters (index 1)",
|
||||
RpcErrorType.INVALID_TRANSACTION_TRACE_PARAMS,
|
||||
e);
|
||||
}
|
||||
|
||||
final BadBlockManager badBlockManager = protocolContext.getBadBlockManager();
|
||||
|
||||
|
||||
@@ -67,8 +67,15 @@ public class DebugStandardTraceBlockToFile implements JsonRpcMethod {
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
|
||||
}
|
||||
final Optional<TransactionTraceParams> transactionTraceParams =
|
||||
requestContext.getOptionalParameter(1, TransactionTraceParams.class);
|
||||
final Optional<TransactionTraceParams> transactionTraceParams;
|
||||
try {
|
||||
transactionTraceParams = requestContext.getOptionalParameter(1, TransactionTraceParams.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction trace parameters (index 1)",
|
||||
RpcErrorType.INVALID_TRANSACTION_TRACE_PARAMS,
|
||||
e);
|
||||
}
|
||||
|
||||
return blockchainQueries
|
||||
.get()
|
||||
|
||||
@@ -77,7 +77,15 @@ public class DebugStorageRangeAt implements JsonRpcMethod {
|
||||
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 int transactionIndex;
|
||||
try {
|
||||
transactionIndex = requestContext.getRequiredParameter(1, Integer.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction index parameter (index 1)",
|
||||
RpcErrorType.INVALID_TRANSACTION_INDEX_PARAMS,
|
||||
e);
|
||||
}
|
||||
final Address accountAddress;
|
||||
try {
|
||||
accountAddress = requestContext.getRequiredParameter(2, Address.class);
|
||||
@@ -92,7 +100,13 @@ public class DebugStorageRangeAt implements JsonRpcMethod {
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid data start hash parameter (index 3)", RpcErrorType.INVALID_DATA_HASH_PARAMS, e);
|
||||
}
|
||||
final int limit = requestContext.getRequiredParameter(4, Integer.class);
|
||||
final int limit;
|
||||
try {
|
||||
limit = requestContext.getRequiredParameter(4, Integer.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid limit parameter (index 4)", RpcErrorType.INVALID_TRANSACTION_LIMIT_PARAMS, e);
|
||||
}
|
||||
|
||||
final Optional<Hash> blockHashOptional = hashFromParameter(blockParameterOrBlockHash);
|
||||
if (blockHashOptional.isEmpty()) {
|
||||
|
||||
@@ -77,11 +77,19 @@ public class DebugTraceBlock implements JsonRpcMethod {
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid block params (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
|
||||
}
|
||||
final TraceOptions traceOptions =
|
||||
requestContext
|
||||
.getOptionalParameter(1, TransactionTraceParams.class)
|
||||
.map(TransactionTraceParams::traceOptions)
|
||||
.orElse(TraceOptions.DEFAULT);
|
||||
final TraceOptions traceOptions;
|
||||
try {
|
||||
traceOptions =
|
||||
requestContext
|
||||
.getOptionalParameter(1, TransactionTraceParams.class)
|
||||
.map(TransactionTraceParams::traceOptions)
|
||||
.orElse(TraceOptions.DEFAULT);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction trace parameter (index 1)",
|
||||
RpcErrorType.INVALID_TRANSACTION_TRACE_PARAMS,
|
||||
e);
|
||||
}
|
||||
|
||||
if (this.blockchainQueries.blockByHash(block.getHeader().getParentHash()).isPresent()) {
|
||||
final Collection<DebugTraceTransactionResult> results =
|
||||
|
||||
@@ -59,11 +59,19 @@ public class DebugTraceBlockByHash implements JsonRpcMethod {
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
|
||||
}
|
||||
final TraceOptions traceOptions =
|
||||
requestContext
|
||||
.getOptionalParameter(1, TransactionTraceParams.class)
|
||||
.map(TransactionTraceParams::traceOptions)
|
||||
.orElse(TraceOptions.DEFAULT);
|
||||
final TraceOptions traceOptions;
|
||||
try {
|
||||
traceOptions =
|
||||
requestContext
|
||||
.getOptionalParameter(1, TransactionTraceParams.class)
|
||||
.map(TransactionTraceParams::traceOptions)
|
||||
.orElse(TraceOptions.DEFAULT);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction trace parameters (index 1)",
|
||||
RpcErrorType.INVALID_TRANSACTION_TRACE_PARAMS,
|
||||
e);
|
||||
}
|
||||
|
||||
final Collection<DebugTraceTransactionResult> results =
|
||||
Tracer.processTracing(
|
||||
|
||||
@@ -61,11 +61,19 @@ public class DebugTraceBlockByNumber extends AbstractBlockParameterMethod {
|
||||
protected Object resultByBlockNumber(
|
||||
final JsonRpcRequestContext request, final long blockNumber) {
|
||||
final Optional<Hash> blockHash = getBlockchainQueries().getBlockHashByNumber(blockNumber);
|
||||
final TraceOptions traceOptions =
|
||||
request
|
||||
.getOptionalParameter(1, TransactionTraceParams.class)
|
||||
.map(TransactionTraceParams::traceOptions)
|
||||
.orElse(TraceOptions.DEFAULT);
|
||||
final TraceOptions traceOptions;
|
||||
try {
|
||||
traceOptions =
|
||||
request
|
||||
.getOptionalParameter(1, TransactionTraceParams.class)
|
||||
.map(TransactionTraceParams::traceOptions)
|
||||
.orElse(TraceOptions.DEFAULT);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction trace parameter (index 1)",
|
||||
RpcErrorType.INVALID_TRANSACTION_TRACE_PARAMS,
|
||||
e);
|
||||
}
|
||||
|
||||
return blockHash
|
||||
.flatMap(
|
||||
|
||||
@@ -55,10 +55,17 @@ public class DebugTraceCall extends AbstractTraceCall {
|
||||
|
||||
@Override
|
||||
protected TraceOptions getTraceOptions(final JsonRpcRequestContext requestContext) {
|
||||
return requestContext
|
||||
.getOptionalParameter(2, TransactionTraceParams.class)
|
||||
.map(TransactionTraceParams::traceOptions)
|
||||
.orElse(TraceOptions.DEFAULT);
|
||||
try {
|
||||
return requestContext
|
||||
.getOptionalParameter(2, TransactionTraceParams.class)
|
||||
.map(TransactionTraceParams::traceOptions)
|
||||
.orElse(TraceOptions.DEFAULT);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction trace parameters (index 2)",
|
||||
RpcErrorType.INVALID_TRANSACTION_TRACE_PARAMS,
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,11 +17,13 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
|
||||
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.TransactionTraceParams;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTracer;
|
||||
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.DebugTraceTransactionResult;
|
||||
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
|
||||
import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata;
|
||||
@@ -48,15 +50,31 @@ public class DebugTraceTransaction implements JsonRpcMethod {
|
||||
|
||||
@Override
|
||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||
final Hash hash = requestContext.getRequiredParameter(0, Hash.class);
|
||||
final Hash hash;
|
||||
try {
|
||||
hash = requestContext.getRequiredParameter(0, Hash.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction hash parameter (index 0)",
|
||||
RpcErrorType.INVALID_TRANSACTION_HASH_PARAMS,
|
||||
e);
|
||||
}
|
||||
final Optional<TransactionWithMetadata> transactionWithMetadata =
|
||||
blockchain.transactionByHash(hash);
|
||||
if (transactionWithMetadata.isPresent()) {
|
||||
final TraceOptions traceOptions =
|
||||
requestContext
|
||||
.getOptionalParameter(1, TransactionTraceParams.class)
|
||||
.map(TransactionTraceParams::traceOptions)
|
||||
.orElse(TraceOptions.DEFAULT);
|
||||
final TraceOptions traceOptions;
|
||||
try {
|
||||
traceOptions =
|
||||
requestContext
|
||||
.getOptionalParameter(1, TransactionTraceParams.class)
|
||||
.map(TransactionTraceParams::traceOptions)
|
||||
.orElse(TraceOptions.DEFAULT);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction trace parameter (index 1)",
|
||||
RpcErrorType.INVALID_TRANSACTION_TRACE_PARAMS,
|
||||
e);
|
||||
}
|
||||
final DebugTraceTransactionResult debugTraceTransactionResult =
|
||||
debugTraceTransactionResult(hash, transactionWithMetadata.get(), traceOptions);
|
||||
|
||||
|
||||
@@ -17,9 +17,11 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
|
||||
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.UnsignedIntParameter;
|
||||
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.TransactionCompleteResult;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.TransactionResult;
|
||||
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
|
||||
@@ -42,8 +44,24 @@ public class EthGetTransactionByBlockHashAndIndex implements JsonRpcMethod {
|
||||
|
||||
@Override
|
||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||
final Hash hash = requestContext.getRequiredParameter(0, Hash.class);
|
||||
final int index = requestContext.getRequiredParameter(1, UnsignedIntParameter.class).getValue();
|
||||
final Hash hash;
|
||||
try {
|
||||
hash = requestContext.getRequiredParameter(0, Hash.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction hash parameter (index 0)",
|
||||
RpcErrorType.INVALID_TRANSACTION_HASH_PARAMS,
|
||||
e);
|
||||
}
|
||||
final int index;
|
||||
try {
|
||||
index = requestContext.getRequiredParameter(1, UnsignedIntParameter.class).getValue();
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction id parameter (index 1)",
|
||||
RpcErrorType.INVALID_TRANSACTION_ID_PARAMS,
|
||||
e);
|
||||
}
|
||||
final Optional<TransactionWithMetadata> transactionWithMetadata =
|
||||
blockchain.transactionByBlockHashAndIndex(hash, index);
|
||||
final TransactionResult result =
|
||||
|
||||
@@ -50,7 +50,15 @@ public class EthGetTransactionByBlockNumberAndIndex extends AbstractBlockParamet
|
||||
@Override
|
||||
protected Object resultByBlockNumber(
|
||||
final JsonRpcRequestContext request, final long blockNumber) {
|
||||
final int index = request.getRequiredParameter(1, UnsignedIntParameter.class).getValue();
|
||||
final int index;
|
||||
try {
|
||||
index = request.getRequiredParameter(1, UnsignedIntParameter.class).getValue();
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction index parameter (index 1)",
|
||||
RpcErrorType.INVALID_TRANSACTION_INDEX_PARAMS,
|
||||
e);
|
||||
}
|
||||
final Optional<TransactionWithMetadata> transactionWithMetadata =
|
||||
getBlockchainQueries().transactionByBlockNumberAndIndex(blockNumber, index);
|
||||
return transactionWithMetadata.map(TransactionCompleteResult::new).orElse(null);
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
|
||||
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.response.JsonRpcErrorResponse;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
|
||||
@@ -50,7 +51,15 @@ public class EthGetTransactionByHash implements JsonRpcMethod {
|
||||
return new JsonRpcErrorResponse(
|
||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
|
||||
}
|
||||
final Hash hash = requestContext.getRequiredParameter(0, Hash.class);
|
||||
final Hash hash;
|
||||
try {
|
||||
hash = requestContext.getRequiredParameter(0, Hash.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction hash parameter (index 0)",
|
||||
RpcErrorType.INVALID_TRANSACTION_HASH_PARAMS,
|
||||
e);
|
||||
}
|
||||
final JsonRpcSuccessResponse jsonRpcSuccessResponse =
|
||||
new JsonRpcSuccessResponse(requestContext.getRequest().getId(), getResult(hash));
|
||||
return jsonRpcSuccessResponse;
|
||||
|
||||
@@ -17,8 +17,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
|
||||
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.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.TransactionReceiptResult;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.TransactionReceiptRootResult;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.TransactionReceiptStatusResult;
|
||||
@@ -46,7 +48,15 @@ public class EthGetTransactionReceipt implements JsonRpcMethod {
|
||||
|
||||
@Override
|
||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||
final Hash hash = requestContext.getRequiredParameter(0, Hash.class);
|
||||
final Hash hash;
|
||||
try {
|
||||
hash = requestContext.getRequiredParameter(0, Hash.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction hash parameter (index 0)",
|
||||
RpcErrorType.INVALID_TRANSACTION_HASH_PARAMS,
|
||||
e);
|
||||
}
|
||||
final TransactionReceiptResult result =
|
||||
blockchainQueries
|
||||
.transactionReceiptByTransactionHash(hash, protocolSchedule)
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.hyperledger.besu.datatypes.Hash;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcErrorConverter;
|
||||
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.exception.InvalidJsonRpcRequestException;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
||||
@@ -68,7 +69,13 @@ public class EthSendRawTransaction implements JsonRpcMethod {
|
||||
return new JsonRpcErrorResponse(
|
||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
|
||||
}
|
||||
final String rawTransaction = requestContext.getRequiredParameter(0, String.class);
|
||||
final String rawTransaction;
|
||||
try {
|
||||
rawTransaction = requestContext.getRequiredParameter(0, String.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction parameters (index 0)", RpcErrorType.INVALID_TRANSACTION_PARAMS, e);
|
||||
}
|
||||
|
||||
final Transaction transaction;
|
||||
try {
|
||||
|
||||
@@ -18,9 +18,11 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErr
|
||||
|
||||
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.TraceTypeParameter;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
||||
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.debug.TraceOptions;
|
||||
@@ -56,7 +58,12 @@ public class TraceCall extends AbstractTraceCall {
|
||||
|
||||
private Set<TraceTypeParameter.TraceType> getTraceTypes(
|
||||
final JsonRpcRequestContext requestContext) {
|
||||
return requestContext.getRequiredParameter(1, TraceTypeParameter.class).getTraceTypes();
|
||||
try {
|
||||
return requestContext.getRequiredParameter(1, TraceTypeParameter.class).getTraceTypes();
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid trace type parameter (index 1)", RpcErrorType.INVALID_TRACE_TYPE_PARAMS, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -98,7 +98,7 @@ public class TraceCallMany extends TraceCall implements JsonRpcMethod {
|
||||
} catch (final Exception e) {
|
||||
LOG.error("Error parsing trace_callMany parameters: {}", e.getLocalizedMessage());
|
||||
return new JsonRpcErrorResponse(
|
||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
|
||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_TRACE_CALL_MANY_PARAMS);
|
||||
}
|
||||
|
||||
final Optional<BlockHeader> maybeBlockHeader =
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
|
||||
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.processor.BlockTracer;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
|
||||
@@ -54,8 +55,24 @@ public class TraceGet extends AbstractTraceByHash implements JsonRpcMethod {
|
||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
|
||||
}
|
||||
|
||||
final Hash transactionHash = requestContext.getRequiredParameter(0, Hash.class);
|
||||
final List<?> traceNumbersAsStrings = requestContext.getRequiredParameter(1, List.class);
|
||||
final Hash transactionHash;
|
||||
try {
|
||||
transactionHash = requestContext.getRequiredParameter(0, Hash.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction has parameter (index 0)",
|
||||
RpcErrorType.INVALID_TRANSACTION_HASH_PARAMS,
|
||||
e);
|
||||
}
|
||||
final List<?> traceNumbersAsStrings;
|
||||
try {
|
||||
traceNumbersAsStrings = requestContext.getRequiredParameter(1, List.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid trace numbers parameters (index 1)",
|
||||
RpcErrorType.INVALID_TRACE_NUMBERS_PARAMS,
|
||||
e);
|
||||
}
|
||||
final List<Integer> traceAddress =
|
||||
traceNumbersAsStrings.stream()
|
||||
.map(t -> Integer.parseInt(((String) t).substring(2), 16))
|
||||
|
||||
@@ -18,6 +18,7 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErr
|
||||
|
||||
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.TraceTypeParameter;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
||||
@@ -70,9 +71,20 @@ public class TraceRawTransaction extends AbstractTraceByBlock implements JsonRpc
|
||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
|
||||
}
|
||||
|
||||
final var rawTransaction = requestContext.getRequiredParameter(0, String.class);
|
||||
final TraceTypeParameter traceTypeParameter =
|
||||
requestContext.getRequiredParameter(1, TraceTypeParameter.class);
|
||||
final String rawTransaction;
|
||||
try {
|
||||
rawTransaction = requestContext.getRequiredParameter(0, String.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction parameters (index 0)", RpcErrorType.INVALID_TRANSACTION_PARAMS, e);
|
||||
}
|
||||
final TraceTypeParameter traceTypeParameter;
|
||||
try {
|
||||
traceTypeParameter = requestContext.getRequiredParameter(1, TraceTypeParameter.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid trace type parameter (index 1)", RpcErrorType.INVALID_TRACE_TYPE_PARAMS, e);
|
||||
}
|
||||
LOG.trace(
|
||||
"Received RPC rpcName={} rawTx={} traceType={}",
|
||||
getName(),
|
||||
@@ -85,7 +97,7 @@ public class TraceRawTransaction extends AbstractTraceByBlock implements JsonRpc
|
||||
LOG.trace("rawTx decoded to transaction {}", transaction);
|
||||
} catch (final RLPException | IllegalArgumentException e) {
|
||||
return new JsonRpcErrorResponse(
|
||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
|
||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_TRANSACTION_PARAMS);
|
||||
}
|
||||
|
||||
final Set<TraceTypeParameter.TraceType> traceTypes = traceTypeParameter.getTraceTypes();
|
||||
|
||||
@@ -83,8 +83,13 @@ public class TraceReplayBlockTransactions extends AbstractBlockParameterMethod {
|
||||
@Override
|
||||
protected ArrayNode resultByBlockNumber(
|
||||
final JsonRpcRequestContext request, final long blockNumber) {
|
||||
final TraceTypeParameter traceTypeParameter =
|
||||
request.getRequiredParameter(1, TraceTypeParameter.class);
|
||||
final TraceTypeParameter traceTypeParameter;
|
||||
try {
|
||||
traceTypeParameter = request.getRequiredParameter(1, TraceTypeParameter.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid trace type parameter (index 1)", RpcErrorType.INVALID_TRACE_TYPE_PARAMS, e);
|
||||
}
|
||||
|
||||
LOG.trace(
|
||||
"Received RPC rpcName={} block={} traceType={}",
|
||||
|
||||
@@ -17,9 +17,11 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
|
||||
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.processor.BlockTracer;
|
||||
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 org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
||||
|
||||
@@ -45,7 +47,15 @@ public class TraceTransaction extends AbstractTraceByHash implements JsonRpcMeth
|
||||
|
||||
@Override
|
||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||
final Hash transactionHash = requestContext.getRequiredParameter(0, Hash.class);
|
||||
final Hash transactionHash;
|
||||
try {
|
||||
transactionHash = requestContext.getRequiredParameter(0, Hash.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction hash parameter (index 0)",
|
||||
RpcErrorType.INVALID_TRANSACTION_HASH_PARAMS,
|
||||
e);
|
||||
}
|
||||
LOG.trace("Received RPC rpcName={} txHash={}", getName(), transactionHash);
|
||||
|
||||
return new JsonRpcSuccessResponse(
|
||||
|
||||
@@ -54,8 +54,16 @@ public class TxPoolBesuPendingTransactions implements JsonRpcMethod {
|
||||
|
||||
final Collection<PendingTransaction> pendingTransactions =
|
||||
transactionPool.getPendingTransactions();
|
||||
final Integer limit =
|
||||
requestContext.getOptionalParameter(0, Integer.class).orElse(pendingTransactions.size());
|
||||
final int limit;
|
||||
try {
|
||||
limit =
|
||||
requestContext.getOptionalParameter(0, Integer.class).orElse(pendingTransactions.size());
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction limit parameter (index 0)",
|
||||
RpcErrorType.INVALID_TRANSACTION_LIMIT_PARAMS,
|
||||
e);
|
||||
}
|
||||
final List<Filter> filters;
|
||||
try {
|
||||
filters =
|
||||
|
||||
@@ -186,7 +186,7 @@ public abstract class AbstractEngineForkchoiceUpdated extends ExecutionEngineJso
|
||||
if (!getWithdrawalsValidator(
|
||||
protocolSchedule.get(), newHead, maybePayloadAttributes.get().getTimestamp())
|
||||
.validateWithdrawals(withdrawals)) {
|
||||
return new JsonRpcErrorResponse(requestId, getInvalidParametersError());
|
||||
return new JsonRpcErrorResponse(requestId, RpcErrorType.INVALID_WITHDRAWALS_PARAMS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.
|
||||
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.RequestValidatorProvider.getDepositRequestValidator;
|
||||
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.RequestValidatorProvider.getWithdrawalRequestValidator;
|
||||
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.WithdrawalsValidatorProvider.getWithdrawalsValidator;
|
||||
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INVALID_PARAMS;
|
||||
|
||||
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator;
|
||||
import org.hyperledger.besu.datatypes.Address;
|
||||
@@ -42,7 +41,6 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositRequ
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalRequestParameter;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
|
||||
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;
|
||||
@@ -118,8 +116,15 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet
|
||||
e);
|
||||
}
|
||||
|
||||
final Optional<List<String>> maybeVersionedHashParam =
|
||||
requestContext.getOptionalList(1, String.class);
|
||||
final Optional<List<String>> maybeVersionedHashParam;
|
||||
try {
|
||||
maybeVersionedHashParam = requestContext.getOptionalList(1, String.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcRequestException(
|
||||
"Invalid versioned hash parameters (index 1)",
|
||||
RpcErrorType.INVALID_VERSIONED_HASH_PARAMS,
|
||||
e);
|
||||
}
|
||||
|
||||
final Object reqId = requestContext.getRequest().getId();
|
||||
|
||||
@@ -174,8 +179,7 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet
|
||||
if (!getWithdrawalsValidator(
|
||||
protocolSchedule.get(), blockParam.getTimestamp(), blockParam.getBlockNumber())
|
||||
.validateWithdrawals(maybeWithdrawals)) {
|
||||
return new JsonRpcErrorResponse(
|
||||
reqId, new JsonRpcError(INVALID_PARAMS, "Invalid withdrawals"));
|
||||
return new JsonRpcErrorResponse(reqId, RpcErrorType.INVALID_WITHDRAWALS_PARAMS);
|
||||
}
|
||||
|
||||
final Optional<List<Request>> maybeDepositRequests =
|
||||
@@ -197,8 +201,7 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet
|
||||
if (!getWithdrawalRequestValidator(
|
||||
protocolSchedule.get(), blockParam.getTimestamp(), blockParam.getBlockNumber())
|
||||
.validateParameter(maybeWithdrawalRequests)) {
|
||||
return new JsonRpcErrorResponse(
|
||||
reqId, new JsonRpcError(INVALID_PARAMS, "Invalid withdrawal request"));
|
||||
return new JsonRpcErrorResponse(reqId, RpcErrorType.INVALID_WITHDRAWALS_PARAMS);
|
||||
}
|
||||
|
||||
final Optional<List<Request>> maybeConsolidationRequests =
|
||||
@@ -486,14 +489,15 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet
|
||||
|
||||
if (maybeVersionedHashes.isEmpty() && !transactionVersionedHashes.isEmpty()) {
|
||||
return ValidationResult.invalid(
|
||||
RpcErrorType.INVALID_PARAMS, "Payload must contain versioned hashes for transactions");
|
||||
RpcErrorType.INVALID_VERSIONED_HASH_PARAMS,
|
||||
"Payload must contain versioned hashes for transactions");
|
||||
}
|
||||
|
||||
// Validate versionedHashesParam
|
||||
if (maybeVersionedHashes.isPresent()
|
||||
&& !maybeVersionedHashes.get().equals(transactionVersionedHashes)) {
|
||||
return ValidationResult.invalid(
|
||||
RpcErrorType.INVALID_PARAMS,
|
||||
RpcErrorType.INVALID_VERSIONED_HASH_PARAMS,
|
||||
"Versioned hashes from blob transactions do not match expected values");
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public class EngineNewPayloadV3 extends AbstractEngineNewPayload {
|
||||
RpcErrorType.INVALID_EXCESS_BLOB_GAS_PARAMS, "Missing excess blob gas field");
|
||||
} else if (maybeVersionedHashParam == null || maybeVersionedHashParam.isEmpty()) {
|
||||
return ValidationResult.invalid(
|
||||
RpcErrorType.INVALID_PARAMS, "Missing versioned hashes field");
|
||||
RpcErrorType.INVALID_VERSIONED_HASH_PARAMS, "Missing versioned hashes field");
|
||||
} else if (maybeBeaconBlockRootParam.isEmpty()) {
|
||||
return ValidationResult.invalid(
|
||||
RpcErrorType.INVALID_PARENT_BEACON_BLOCK_ROOT_PARAMS,
|
||||
|
||||
@@ -64,7 +64,7 @@ public class EngineNewPayloadV4 extends AbstractEngineNewPayload {
|
||||
RpcErrorType.INVALID_EXCESS_BLOB_GAS_PARAMS, "Missing excess blob gas field");
|
||||
} else if (maybeVersionedHashParam == null || maybeVersionedHashParam.isEmpty()) {
|
||||
return ValidationResult.invalid(
|
||||
RpcErrorType.INVALID_PARAMS, "Missing versioned hashes field");
|
||||
RpcErrorType.INVALID_VERSIONED_HASH_PARAMS, "Missing versioned hashes field");
|
||||
} else if (maybeBeaconBlockRootParam.isEmpty()) {
|
||||
return ValidationResult.invalid(
|
||||
RpcErrorType.INVALID_PARENT_BEACON_BLOCK_ROOT_PARAMS,
|
||||
|
||||
@@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.miner;
|
||||
|
||||
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.response.JsonRpcErrorResponse;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
|
||||
@@ -43,11 +44,16 @@ public class MinerChangeTargetGasLimit implements JsonRpcMethod {
|
||||
return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
|
||||
} catch (final IllegalArgumentException invalidJsonRpcParameters) {
|
||||
return new JsonRpcErrorResponse(
|
||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
|
||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_TARGET_GAS_LIMIT_PARAMS);
|
||||
} catch (final UnsupportedOperationException unsupportedOperationException) {
|
||||
return new JsonRpcErrorResponse(
|
||||
requestContext.getRequest().getId(),
|
||||
RpcErrorType.TARGET_GAS_LIMIT_MODIFICATION_UNSUPPORTED);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid target gas limit parameter (index 0)",
|
||||
RpcErrorType.INVALID_TARGET_GAS_LIMIT_PARAMS,
|
||||
e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters;
|
||||
import static java.util.Objects.isNull;
|
||||
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -73,7 +74,9 @@ public class TraceTypeParameter {
|
||||
.collect(Collectors.joining(", "));
|
||||
|
||||
if (!unsupportedTypes.isEmpty()) {
|
||||
throw new InvalidJsonRpcParameters("Invalid trace types supplied: " + unsupportedTypes);
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid trace types supplied: " + unsupportedTypes,
|
||||
RpcErrorType.INVALID_TRACE_TYPE_PARAMS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.hyperledger.besu.datatypes.TransactionType;
|
||||
import org.hyperledger.besu.datatypes.Wei;
|
||||
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.privacy.methods.PrivacyIdProvider;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
||||
@@ -73,7 +74,13 @@ public abstract class AbstractEeaSendRawTransaction implements JsonRpcMethod {
|
||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||
final Object id = requestContext.getRequest().getId();
|
||||
final Optional<User> user = requestContext.getUser();
|
||||
final String rawPrivateTransaction = requestContext.getRequiredParameter(0, String.class);
|
||||
final String rawPrivateTransaction;
|
||||
try {
|
||||
rawPrivateTransaction = requestContext.getRequiredParameter(0, String.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction parameter (index 0)", RpcErrorType.INVALID_TRANSACTION_PARAMS, e);
|
||||
}
|
||||
|
||||
try {
|
||||
final PrivateTransaction privateTransaction =
|
||||
|
||||
@@ -23,6 +23,7 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErr
|
||||
import org.hyperledger.besu.enclave.types.PrivacyGroup;
|
||||
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.privacy.methods.PrivacyIdProvider;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
||||
@@ -70,7 +71,15 @@ public class PrivDistributeRawTransaction implements JsonRpcMethod {
|
||||
@Override
|
||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||
final Object id = requestContext.getRequest().getId();
|
||||
final String rawPrivateTransaction = requestContext.getRequiredParameter(0, String.class);
|
||||
final String rawPrivateTransaction;
|
||||
try {
|
||||
rawPrivateTransaction = requestContext.getRequiredParameter(0, String.class);
|
||||
} catch (Exception e) {
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid private transaction parameter (index 0)",
|
||||
RpcErrorType.INVALID_TRANSACTION_PARAMS,
|
||||
e);
|
||||
}
|
||||
|
||||
try {
|
||||
final PrivateTransaction privateTransaction =
|
||||
|
||||
@@ -85,7 +85,7 @@ public class PrivGetEeaTransactionCount implements JsonRpcMethod {
|
||||
privateFor = requestContext.getRequiredParameter(2, String[].class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid private for parameter (index 2)", RpcErrorType.INVALID_PRIVATE_FOR_PARAMS, e);
|
||||
"Invalid private for parameters (index 2)", RpcErrorType.INVALID_PRIVATE_FOR_PARAMS, e);
|
||||
}
|
||||
|
||||
final String privacyUserId = privacyIdProvider.getPrivacyUserId(requestContext.getUser());
|
||||
|
||||
@@ -19,11 +19,13 @@ import org.hyperledger.besu.enclave.EnclaveClientException;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcEnclaveErrorConverter;
|
||||
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.privacy.methods.PrivacyIdProvider;
|
||||
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.privacy.PrivateTransactionGroupResult;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.privacy.PrivateTransactionLegacyResult;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.privacy.PrivateTransactionResult;
|
||||
@@ -57,7 +59,15 @@ public class PrivGetPrivateTransaction implements JsonRpcMethod {
|
||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||
LOG.trace("Executing {}", RpcMethod.PRIV_GET_PRIVATE_TRANSACTION.getMethodName());
|
||||
|
||||
final Hash hash = requestContext.getRequiredParameter(0, Hash.class);
|
||||
final Hash hash;
|
||||
try {
|
||||
hash = requestContext.getRequiredParameter(0, Hash.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction hash parameter (index 0)",
|
||||
RpcErrorType.INVALID_TRANSACTION_HASH_PARAMS,
|
||||
e);
|
||||
}
|
||||
final String enclaveKey = privacyIdProvider.getPrivacyUserId(requestContext.getUser());
|
||||
|
||||
final Optional<PrivateTransaction> maybePrivateTx;
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.hyperledger.besu.enclave.EnclaveClientException;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcEnclaveErrorConverter;
|
||||
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.privacy.methods.PrivacyIdProvider;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
|
||||
@@ -66,7 +67,15 @@ public class PrivGetTransactionReceipt implements JsonRpcMethod {
|
||||
@Override
|
||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||
LOG.trace("Executing {}", RpcMethod.PRIV_GET_TRANSACTION_RECEIPT.getMethodName());
|
||||
final Hash pmtTransactionHash = requestContext.getRequiredParameter(0, Hash.class);
|
||||
final Hash pmtTransactionHash;
|
||||
try {
|
||||
pmtTransactionHash = requestContext.getRequiredParameter(0, Hash.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction hash parameter (index 0)",
|
||||
RpcErrorType.INVALID_TRANSACTION_HASH_PARAMS,
|
||||
e);
|
||||
}
|
||||
final String enclaveKey = privacyIdProvider.getPrivacyUserId(requestContext.getUser());
|
||||
|
||||
final ExecutedPrivateTransaction privateTransaction;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package org.hyperledger.besu.ethereum.api.util;
|
||||
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcRequestException;
|
||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
|
||||
import org.hyperledger.besu.ethereum.core.Transaction;
|
||||
import org.hyperledger.besu.ethereum.core.encoding.EncodingContext;
|
||||
import org.hyperledger.besu.ethereum.core.encoding.TransactionDecoder;
|
||||
@@ -30,9 +31,11 @@ public class DomainObjectDecodeUtils {
|
||||
Bytes txnBytes = Bytes.fromHexString(rawTransaction);
|
||||
return TransactionDecoder.decodeOpaqueBytes(txnBytes, EncodingContext.POOLED_TRANSACTION);
|
||||
} catch (final IllegalArgumentException e) {
|
||||
throw new InvalidJsonRpcRequestException("Invalid raw transaction hex", e);
|
||||
throw new InvalidJsonRpcRequestException(
|
||||
"Invalid raw transaction hex", RpcErrorType.INVALID_TRANSACTION_PARAMS, e);
|
||||
} catch (final RLPException r) {
|
||||
throw new InvalidJsonRpcRequestException("Invalid RLP in raw transaction hex", r);
|
||||
throw new InvalidJsonRpcRequestException(
|
||||
"Invalid RLP in raw transaction hex", RpcErrorType.INVALID_TRANSACTION_PARAMS, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ class DebugAccountAtTest {
|
||||
|
||||
Assertions.assertThat(response).isInstanceOf(JsonRpcErrorResponse.class);
|
||||
Assertions.assertThat(((JsonRpcErrorResponse) response).getErrorType())
|
||||
.isEqualByComparingTo(RpcErrorType.INVALID_PARAMS);
|
||||
.isEqualByComparingTo(RpcErrorType.INVALID_TRANSACTION_PARAMS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -129,7 +129,7 @@ class DebugAccountAtTest {
|
||||
|
||||
Assertions.assertThat(response).isInstanceOf(JsonRpcErrorResponse.class);
|
||||
Assertions.assertThat(((JsonRpcErrorResponse) response).getErrorType())
|
||||
.isEqualByComparingTo(RpcErrorType.INVALID_PARAMS);
|
||||
.isEqualByComparingTo(RpcErrorType.INVALID_TRANSACTION_PARAMS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -145,7 +145,7 @@ class DebugAccountAtTest {
|
||||
|
||||
Assertions.assertThat(response).isInstanceOf(JsonRpcErrorResponse.class);
|
||||
Assertions.assertThat(((JsonRpcErrorResponse) response).getErrorType())
|
||||
.isEqualByComparingTo(RpcErrorType.INVALID_PARAMS);
|
||||
.isEqualByComparingTo(RpcErrorType.INVALID_TRANSACTION_PARAMS);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -738,7 +738,7 @@ public abstract class AbstractEngineForkchoiceUpdatedTest {
|
||||
}
|
||||
|
||||
protected RpcErrorType expectedInvalidPayloadError() {
|
||||
return RpcErrorType.INVALID_PARAMS;
|
||||
return RpcErrorType.INVALID_WITHDRAWALS_PARAMS;
|
||||
}
|
||||
|
||||
protected JsonRpcResponse resp(
|
||||
|
||||
@@ -46,6 +46,6 @@ public class EngineForkchoiceUpdatedV1Test extends AbstractEngineForkchoiceUpdat
|
||||
|
||||
@Override
|
||||
protected RpcErrorType expectedInvalidPayloadError() {
|
||||
return RpcErrorType.INVALID_PAYLOAD_ATTRIBUTES;
|
||||
return RpcErrorType.INVALID_WITHDRAWALS_PARAMS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +92,6 @@ public class EngineForkchoiceUpdatedV2Test extends AbstractEngineForkchoiceUpdat
|
||||
|
||||
@Override
|
||||
protected RpcErrorType expectedInvalidPayloadError() {
|
||||
return RpcErrorType.INVALID_PARAMS;
|
||||
return RpcErrorType.INVALID_WITHDRAWALS_PARAMS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,8 @@ public class MinerChangeTargetGasLimitTest {
|
||||
|
||||
assertThat(minerChangeTargetGasLimit.response(request))
|
||||
.isEqualTo(
|
||||
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAMS));
|
||||
new JsonRpcErrorResponse(
|
||||
request.getRequest().getId(), RpcErrorType.INVALID_TARGET_GAS_LIMIT_PARAMS));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -78,7 +78,7 @@ public class EeaSendRawTransactionTest extends BaseEeaSendRawTransaction {
|
||||
|
||||
assertThatThrownBy(() -> method.response(request))
|
||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
||||
.hasMessage("Missing required json rpc parameter at index 0");
|
||||
.hasMessage("Invalid transaction parameter (index 0)");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -88,7 +88,7 @@ public class EeaSendRawTransactionTest extends BaseEeaSendRawTransaction {
|
||||
|
||||
assertThatThrownBy(() -> method.response(request))
|
||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
||||
.hasMessage("Missing required json rpc parameter at index 0");
|
||||
.hasMessage("Invalid transaction parameter (index 0)");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -99,7 +99,7 @@ public class EeaSendRawTransactionTest extends BaseEeaSendRawTransaction {
|
||||
|
||||
assertThatThrownBy(() -> method.response(request))
|
||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
||||
.hasMessage("Missing required json rpc parameter at index 0");
|
||||
.hasMessage("Invalid transaction parameter (index 0)");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"id": 448,
|
||||
"error": {
|
||||
"code": -32602,
|
||||
"message" : "Invalid params"
|
||||
"message" : "Invalid transaction id params"
|
||||
}
|
||||
},
|
||||
"statusCode": 200
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"id": 448,
|
||||
"error": {
|
||||
"code": -32602,
|
||||
"message" : "Invalid params"
|
||||
"message" : "Invalid transaction hash params"
|
||||
}
|
||||
},
|
||||
"statusCode": 200
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"id": 448,
|
||||
"error": {
|
||||
"code": -32602,
|
||||
"message" : "Invalid params"
|
||||
"message" : "Invalid transaction id params"
|
||||
}
|
||||
},
|
||||
"statusCode": 200
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"id": 448,
|
||||
"error": {
|
||||
"code": -32602,
|
||||
"message" : "Invalid params"
|
||||
"message" : "Invalid transaction hash params"
|
||||
}
|
||||
},
|
||||
"statusCode": 200
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"id": 448,
|
||||
"error": {
|
||||
"code": -32602,
|
||||
"message" : "Invalid params"
|
||||
"message" : "Invalid transaction id params"
|
||||
}
|
||||
},
|
||||
"statusCode": 200
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"id" : 406,
|
||||
"error" : {
|
||||
"code" : -32602,
|
||||
"message" : "Invalid params"
|
||||
"message" : "Invalid transaction hash params"
|
||||
}
|
||||
},
|
||||
"statusCode": 200
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"id": 415,
|
||||
"error": {
|
||||
"code": -32602,
|
||||
"message": "Invalid params"
|
||||
"message": "Invalid trace type params"
|
||||
}
|
||||
},
|
||||
"statusCode": 200
|
||||
|
||||
@@ -16,9 +16,11 @@ package org.hyperledger.besu.ethereum.retesteth.methods;
|
||||
|
||||
import org.hyperledger.besu.datatypes.Hash;
|
||||
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.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.TransactionReceiptWithMetadata;
|
||||
import org.hyperledger.besu.ethereum.retesteth.RetestethContext;
|
||||
import org.hyperledger.besu.ethereum.rlp.RLP;
|
||||
@@ -40,7 +42,15 @@ public class TestGetLogHash implements JsonRpcMethod {
|
||||
|
||||
@Override
|
||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||
final Hash txHash = requestContext.getRequiredParameter(0, Hash.class);
|
||||
final Hash txHash;
|
||||
try {
|
||||
txHash = requestContext.getRequiredParameter(0, Hash.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid transaction hash parameter (index 0)",
|
||||
RpcErrorType.INVALID_TRANSACTION_HASH_PARAMS,
|
||||
e);
|
||||
}
|
||||
|
||||
final Optional<TransactionReceiptWithMetadata> receipt =
|
||||
context
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
package org.hyperledger.besu.ethereum.retesteth.methods;
|
||||
|
||||
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.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.retesteth.RetestethContext;
|
||||
|
||||
public class TestModifyTimestamp implements JsonRpcMethod {
|
||||
@@ -35,7 +37,13 @@ public class TestModifyTimestamp implements JsonRpcMethod {
|
||||
|
||||
@Override
|
||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||
final long epochSeconds = requestContext.getRequiredParameter(0, Long.class);
|
||||
final long epochSeconds;
|
||||
try {
|
||||
epochSeconds = requestContext.getRequiredParameter(0, Long.class);
|
||||
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||
throw new InvalidJsonRpcParameters(
|
||||
"Invalid timestamp parameter (index 0)", RpcErrorType.INVALID_TIMESTAMP_PARAMS, e);
|
||||
}
|
||||
context.getRetestethClock().resetTime(epochSeconds);
|
||||
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user