Decouple JsonRpcError enum from the data field (#5629)

Signed-off-by: George Tebrean <george@web3labs.com>
Co-authored-by: Simon Dudley <simon.dudley@consensys.net>
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
pull/5710/head
George Tebrean 1 year ago committed by GitHub
parent 1a087709ac
commit 47a61ddb11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 5
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/ExpectJsonRpcError.java
  3. 4
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivConditions.java
  4. 8
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/EnclaveErrorAcceptanceTest.java
  5. 14
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyValidationFailAcceptanceTest.java
  6. 4
      consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/CliqueGetSigners.java
  7. 4
      consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/CliqueGetSignersAtHash.java
  8. 4
      consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/Propose.java
  9. 4
      consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/CliqueGetSignersAtHashTest.java
  10. 4
      consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/CliqueGetSignersTest.java
  11. 6
      consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/ProposeTest.java
  12. 4
      consensus/common/src/main/java/org/hyperledger/besu/consensus/common/jsonrpc/AbstractGetSignerMetricsMethod.java
  13. 4
      consensus/common/src/main/java/org/hyperledger/besu/consensus/common/jsonrpc/AbstractVoteProposerMethod.java
  14. 4
      consensus/common/src/test/java/org/hyperledger/besu/consensus/common/jsonrpc/AbstractVoteProposerMethodTest.java
  15. 4
      consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftDiscardValidatorVote.java
  16. 4
      consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftProposeValidatorVote.java
  17. 4
      consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftDiscardValidatorVoteTest.java
  18. 4
      consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftProposeValidatorVoteTest.java
  19. 10
      ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthCallIntegrationTest.java
  20. 4
      ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthEstimateGasIntegrationTest.java
  21. 8
      ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthGetFilterChangesIntegrationTest.java
  22. 12
      ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthCallIntegrationTest.java
  23. 8
      ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthGetFilterChangesIntegrationTest.java
  24. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/AbstractJsonRpcExecutor.java
  25. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/AuthenticationHandler.java
  26. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcArrayExecutor.java
  27. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcExecutorHandler.java
  28. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcObjectExecutor.java
  29. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcParserHandler.java
  30. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcEnclaveErrorConverter.java
  31. 58
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java
  32. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/AuthenticatedJsonRpcProcessor.java
  33. 8
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/BaseJsonRpcProcessor.java
  34. 12
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/JsonRpcExecutor.java
  35. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/TracedJsonRpcProcessor.java
  36. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/DebugReplayBlock.java
  37. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AbstractBlockParameterMethod.java
  38. 14
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AbstractBlockParameterOrBlockHashMethod.java
  39. 22
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AbstractEstimateGas.java
  40. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminChangeLogLevel.java
  41. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminLogsRemoveCache.java
  42. 16
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminModifyPeer.java
  43. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminNodeInfo.java
  44. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminPeers.java
  45. 12
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugAccountAt.java
  46. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugGetRawBlock.java
  47. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugGetRawHeader.java
  48. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugSetHead.java
  49. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStandardTraceBadBlockToFile.java
  50. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStandardTraceBlockToFile.java
  51. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlock.java
  52. 30
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthCall.java
  53. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthCoinbase.java
  54. 12
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthCreateAccessList.java
  55. 8
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGas.java
  56. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthFeeHistory.java
  57. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetFilterChanges.java
  58. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetFilterLogs.java
  59. 8
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetLogs.java
  60. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetProof.java
  61. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionByHash.java
  62. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetWork.java
  63. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthNewFilter.java
  64. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSendRawTransaction.java
  65. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSendTransaction.java
  66. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSubmitWork.java
  67. 8
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/ExecutionEngineJsonRpcMethod.java
  68. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/NetEnode.java
  69. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/NetPeerCount.java
  70. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/PluginJsonRpcMethod.java
  71. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/PluginsReloadConfiguration.java
  72. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceCall.java
  73. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceCallMany.java
  74. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceGet.java
  75. 8
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceRawTransaction.java
  76. 8
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/Web3Sha3.java
  77. 8
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineForkchoiceUpdated.java
  78. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineGetPayload.java
  79. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java
  80. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineForkchoiceUpdatedV1.java
  81. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByHashV1.java
  82. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByRangeV1.java
  83. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EnginePreparePayloadDebug.java
  84. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerChangeTargetGasLimit.java
  85. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetCoinbase.java
  86. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerStart.java
  87. 16
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddAccountsToAllowlist.java
  88. 20
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToAllowlist.java
  89. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetAccountsAllowlist.java
  90. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetNodesAllowlist.java
  91. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermReloadPermissionsFromFile.java
  92. 16
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveAccountsFromAllowlist.java
  93. 22
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromAllowlist.java
  94. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/DisabledPrivacyRpcMethod.java
  95. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/MultiTenancyRpcMethodDecorator.java
  96. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/PrivGetFilterChanges.java
  97. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/PrivGetFilterLogs.java
  98. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/AbstractEeaSendRawTransaction.java
  99. 8
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/JsonRpcErrorResponseException.java
  100. 8
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedFlexibleEeaSendRawTransaction.java
  101. Some files were not shown because too many files have changed in this diff Show More

@ -13,6 +13,7 @@
- Improve lifecycle management of the transaction pool [#5634](https://github.com/hyperledger/besu/pull/5634)
- Add extension points in AbstractCreateOperation for EVM libraries to react to contract creations [#5656](https://github.com/hyperledger/besu/pull/5656)
- Update to Tuweni 2.4.2. [#5684](https://github.com/hyperledger/besu/pull/5684)
- Decouple data field from Enum JsonRpcError by creating new enum holder RpcErrorType[#5629](https://github.com/hyperledger/besu/pull/5629)
### Bug Fixes
- Use the node's configuration to determine if DNS enode URLs are allowed in calls to `admin_addPeer` and `admin_removePeer` [#5584](https://github.com/hyperledger/besu/pull/5584)

@ -17,6 +17,7 @@ package org.hyperledger.besu.tests.acceptance.dsl.condition.priv;
import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition;
import org.hyperledger.besu.tests.acceptance.dsl.node.Node;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction;
@ -34,6 +35,10 @@ public class ExpectJsonRpcError implements Condition {
this.error = error;
}
public ExpectJsonRpcError(final Transaction<?> transaction, final RpcErrorType error) {
this(transaction, new JsonRpcError(error));
}
@Override
public void verify(final Node node) {
try {

@ -16,7 +16,7 @@ package org.hyperledger.besu.tests.acceptance.dsl.condition.priv;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.privacy.PrivateTransaction;
import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction;
@ -109,7 +109,7 @@ public class PrivConditions {
}
public Condition multiTenancyValidationFail(
final Transaction<?> transaction, final JsonRpcError error) {
final Transaction<?> transaction, final RpcErrorType error) {
return new ExpectJsonRpcError(transaction, error);
}
}

@ -20,7 +20,7 @@ import static org.hyperledger.enclave.testutil.EnclaveEncryptorType.EC;
import static org.hyperledger.enclave.testutil.EnclaveEncryptorType.NACL;
import static org.hyperledger.enclave.testutil.EnclaveType.TESSERA;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyAcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.account.PrivacyAccountResolver;
@ -116,7 +116,7 @@ public class EnclaveErrorAcceptanceTest extends PrivacyAcceptanceTestBase {
assertThat(throwable)
.hasMessageContaining(
JsonRpcError.PRIVATE_FROM_DOES_NOT_MATCH_ENCLAVE_PUBLIC_KEY.getMessage());
RpcErrorType.PRIVATE_FROM_DOES_NOT_MATCH_ENCLAVE_PUBLIC_KEY.getMessage());
}
@Test
@ -131,7 +131,7 @@ public class EnclaveErrorAcceptanceTest extends PrivacyAcceptanceTestBase {
alice.getEnclaveKey(),
wrongPublicKey)));
final String tesseraMessage = JsonRpcError.TESSERA_NODE_MISSING_PEER_URL.getMessage();
final String tesseraMessage = RpcErrorType.TESSERA_NODE_MISSING_PEER_URL.getMessage();
assertThat(throwable.getMessage()).has(matchTesseraEnclaveMessage(tesseraMessage));
}
@ -213,7 +213,7 @@ public class EnclaveErrorAcceptanceTest extends PrivacyAcceptanceTestBase {
public void createPrivacyGroupReturnsCorrectError() {
final Throwable throwable =
catchThrowable(() -> alice.execute(privacyTransactions.createPrivacyGroup(null, null)));
final String tesseraMessage = JsonRpcError.TESSERA_CREATE_GROUP_INCLUDE_SELF.getMessage();
final String tesseraMessage = RpcErrorType.TESSERA_CREATE_GROUP_INCLUDE_SELF.getMessage();
assertThat(throwable.getMessage()).has(matchTesseraEnclaveMessage(tesseraMessage));
}

@ -18,11 +18,11 @@ import static com.github.tomakehurst.wiremock.client.WireMock.ok;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.DELETE_PRIVACY_GROUP_ERROR;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.ENCLAVE_ERROR;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.FIND_PRIVACY_GROUP_ERROR;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.GET_PRIVATE_TRANSACTION_NONCE_ERROR;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.PRIVATE_FROM_DOES_NOT_MATCH_ENCLAVE_PUBLIC_KEY;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.DELETE_PRIVACY_GROUP_ERROR;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.ENCLAVE_ERROR;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.FIND_PRIVACY_GROUP_ERROR;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.GET_PRIVATE_TRANSACTION_NONCE_ERROR;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.PRIVATE_FROM_DOES_NOT_MATCH_ENCLAVE_PUBLIC_KEY;
import org.hyperledger.besu.crypto.SignatureAlgorithm;
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
@ -30,7 +30,7 @@ import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.enclave.types.PrivacyGroup;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.privacy.PrivateTransaction;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.plugin.data.Restriction;
@ -102,7 +102,7 @@ public class MultiTenancyValidationFailAcceptanceTest extends AcceptanceTestBase
getRLPOutput(validSignedPrivateTransaction).encoded().toHexString());
node.verify(
priv.multiTenancyValidationFail(
transaction, JsonRpcError.PRIVATE_FROM_DOES_NOT_MATCH_ENCLAVE_PUBLIC_KEY));
transaction, RpcErrorType.PRIVATE_FROM_DOES_NOT_MATCH_ENCLAVE_PUBLIC_KEY));
}
@Test

@ -19,10 +19,10 @@ 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.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockWithMetadata;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.BlockHeader;
@ -63,7 +63,7 @@ public class CliqueGetSigners implements JsonRpcMethod {
addresses -> new JsonRpcSuccessResponse(requestContext.getRequest().getId(), addresses))
.orElse(
new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INTERNAL_ERROR));
requestContext.getRequest().getId(), RpcErrorType.INTERNAL_ERROR));
}
private Optional<BlockHeader> determineBlockHeader(final JsonRpcRequestContext request) {

@ -19,10 +19,10 @@ 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.methods.JsonRpcMethod;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockWithMetadata;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.BlockHeader;
@ -63,7 +63,7 @@ public class CliqueGetSignersAtHash implements JsonRpcMethod {
addresses -> new JsonRpcSuccessResponse(requestContext.getRequest().getId(), addresses))
.orElse(
new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INTERNAL_ERROR));
requestContext.getRequest().getId(), RpcErrorType.INTERNAL_ERROR));
}
private Optional<BlockHeader> determineBlockHeader(final JsonRpcRequestContext request) {

@ -22,10 +22,10 @@ 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.methods.JsonRpcMethod;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
/** The Propose Json Rpc method. */
public class Propose implements JsonRpcMethod {
@ -53,7 +53,7 @@ public class Propose implements JsonRpcMethod {
final Boolean auth = requestContext.getRequiredParameter(1, Boolean.class);
if (address.equals(CliqueBlockInterface.NO_VOTE_SUBJECT)) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_REQUEST);
requestContext.getRequest().getId(), RpcErrorType.INVALID_REQUEST);
}
if (auth) {

@ -27,9 +27,9 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest;
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.JsonRpcError;
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.BlockWithMetadata;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata;
@ -130,6 +130,6 @@ public class CliqueGetSignersAtHashTest {
.thenReturn(Optional.empty());
final JsonRpcErrorResponse response = (JsonRpcErrorResponse) method.response(request);
assertThat(response.getError().name()).isEqualTo(JsonRpcError.INTERNAL_ERROR.name());
assertThat(response.getErrorType()).isEqualTo(RpcErrorType.INTERNAL_ERROR);
}
}

@ -25,9 +25,9 @@ import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
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.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockWithMetadata;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata;
@ -117,6 +117,6 @@ public class CliqueGetSignersTest {
when(blockchainQueries.blockByNumber(4660)).thenReturn(Optional.empty());
final JsonRpcErrorResponse response = (JsonRpcErrorResponse) method.response(request);
assertThat(response.getError().name()).isEqualTo(JsonRpcError.INTERNAL_ERROR.name());
assertThat(response.getErrorType()).isEqualTo(RpcErrorType.INTERNAL_ERROR);
}
}

@ -25,11 +25,11 @@ import org.hyperledger.besu.consensus.common.validator.blockbased.BlockValidator
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
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.JsonRpcResponseType;
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.chain.Blockchain;
import org.junit.jupiter.api.BeforeEach;
@ -74,7 +74,7 @@ public class ProposeTest {
assertThat(validatorProvider.getVoteProviderAtHead().get().getProposals().get(a0)).isNull();
assertThat(response.getType()).isEqualTo(JsonRpcResponseType.ERROR);
final JsonRpcErrorResponse errorResponse = (JsonRpcErrorResponse) response;
assertThat(errorResponse.getError()).isEqualTo(JsonRpcError.INVALID_REQUEST);
assertThat(errorResponse.getErrorType()).isEqualTo(RpcErrorType.INVALID_REQUEST);
}
@Test
@ -101,7 +101,7 @@ public class ProposeTest {
assertThat(validatorProvider.getVoteProviderAtHead().get().getProposals().get(a0)).isNull();
assertThat(response.getType()).isEqualTo(JsonRpcResponseType.ERROR);
final JsonRpcErrorResponse errorResponse = (JsonRpcErrorResponse) response;
assertThat(errorResponse.getError()).isEqualTo(JsonRpcError.INVALID_REQUEST);
assertThat(errorResponse.getErrorType()).isEqualTo(RpcErrorType.INVALID_REQUEST);
}
@Test

@ -19,10 +19,10 @@ import org.hyperledger.besu.consensus.common.validator.ValidatorProvider;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.SignerMetricResult;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.BlockHeader;
@ -76,7 +76,7 @@ public abstract class AbstractGetSignerMetricsMethod {
if (!isValidParameters(fromBlockNumber, toBlockNumber)) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
final Map<Address, SignerMetricResult> proposersMap = new HashMap<>();

@ -17,10 +17,10 @@ package org.hyperledger.besu.consensus.common.jsonrpc;
import org.hyperledger.besu.consensus.common.validator.ValidatorProvider;
import org.hyperledger.besu.consensus.common.validator.VoteType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import java.util.Map;
import java.util.stream.Collectors;
@ -57,7 +57,7 @@ public class AbstractVoteProposerMethod {
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), proposals);
} else {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.METHOD_NOT_ENABLED);
requestContext.getRequest().getId(), RpcErrorType.METHOD_NOT_ENABLED);
}
}
}

@ -24,10 +24,10 @@ import org.hyperledger.besu.consensus.common.validator.VoteType;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import java.util.Optional;
@ -84,7 +84,7 @@ public abstract class AbstractVoteProposerMethodTest {
new JsonRpcRequestContext(
new JsonRpcRequest(JSON_RPC_VERSION, getMethodName(), new Object[] {}));
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.METHOD_NOT_ENABLED);
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.METHOD_NOT_ENABLED);
when(validatorProvider.getVoteProviderAtHead()).thenReturn(Optional.empty());
final JsonRpcResponse response = getMethod().response(request);

@ -19,10 +19,10 @@ 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.methods.JsonRpcMethod;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -56,7 +56,7 @@ public class QbftDiscardValidatorVote implements JsonRpcMethod {
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), true);
} else {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.METHOD_NOT_ENABLED);
requestContext.getRequest().getId(), RpcErrorType.METHOD_NOT_ENABLED);
}
}
}

@ -20,10 +20,10 @@ 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.methods.JsonRpcMethod;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -66,7 +66,7 @@ public class QbftProposeValidatorVote implements JsonRpcMethod {
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), true);
} else {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.METHOD_NOT_ENABLED);
requestContext.getRequest().getId(), RpcErrorType.METHOD_NOT_ENABLED);
}
}
}

@ -26,10 +26,10 @@ import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest;
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.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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import java.util.Optional;
@ -72,7 +72,7 @@ public class QbftDiscardValidatorVoteTest {
public void methodNotEnabledWhenNoVoteProvider() {
final JsonRpcRequestContext request = requestWithParams(Address.fromHexString("1"));
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.METHOD_NOT_ENABLED);
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.METHOD_NOT_ENABLED);
when(validatorProvider.getVoteProviderAtHead()).thenReturn(Optional.empty());
final JsonRpcResponse response = method.response(request);

@ -26,10 +26,10 @@ import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest;
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.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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import java.util.Optional;
@ -86,7 +86,7 @@ public class QbftProposeValidatorVoteTest {
public void methodNotEnabledWhenNoVoteProvider() {
final JsonRpcRequestContext request = requestWithParams(Address.fromHexString("1"));
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.METHOD_NOT_ENABLED);
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.METHOD_NOT_ENABLED);
when(validatorProvider.getVoteProviderAtHead()).thenReturn(Optional.empty());
final JsonRpcResponse response = method.response(request);

@ -24,10 +24,10 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonCallParameter;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.testutil.BlockTestUtil;
import java.util.Map;
@ -151,7 +151,7 @@ public class EthCallIntegrationTest {
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(null, JsonRpcError.INTRINSIC_GAS_EXCEEDS_LIMIT);
new JsonRpcErrorResponse(null, RpcErrorType.INTRINSIC_GAS_EXCEEDS_LIMIT);
final JsonRpcResponse response = method.response(request);
@ -174,7 +174,7 @@ public class EthCallIntegrationTest {
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(null, JsonRpcError.TRANSACTION_UPFRONT_COST_EXCEEDS_BALANCE);
new JsonRpcErrorResponse(null, RpcErrorType.TRANSACTION_UPFRONT_COST_EXCEEDS_BALANCE);
final JsonRpcResponse response = method.response(request);
@ -221,7 +221,7 @@ public class EthCallIntegrationTest {
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(null, JsonRpcError.TRANSACTION_UPFRONT_COST_EXCEEDS_BALANCE);
new JsonRpcErrorResponse(null, RpcErrorType.TRANSACTION_UPFRONT_COST_EXCEEDS_BALANCE);
final JsonRpcResponse response = method.response(request);
@ -268,7 +268,7 @@ public class EthCallIntegrationTest {
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(null, JsonRpcError.TRANSACTION_UPFRONT_COST_EXCEEDS_BALANCE);
new JsonRpcErrorResponse(null, RpcErrorType.TRANSACTION_UPFRONT_COST_EXCEEDS_BALANCE);
final JsonRpcResponse response = method.response(request);

@ -24,10 +24,10 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonCallParameter;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.testutil.BlockTestUtil;
import java.util.Map;
@ -158,7 +158,7 @@ public class EthEstimateGasIntegrationTest {
null);
final JsonRpcRequestContext request = requestWithParams(callParameter);
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(null, JsonRpcError.TRANSACTION_UPFRONT_COST_EXCEEDS_BALANCE);
new JsonRpcErrorResponse(null, RpcErrorType.TRANSACTION_UPFRONT_COST_EXCEEDS_BALANCE);
final JsonRpcResponse response = method.response(request);
assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse);

@ -32,10 +32,10 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManagerBuilder;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.EthGetFilterChanges;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.Block;
@ -136,7 +136,7 @@ public class EthGetFilterChangesIntegrationTest {
public void shouldReturnErrorResponseIfFilterNotFound() {
final JsonRpcRequestContext request = requestWithParams("0");
final JsonRpcResponse expected = new JsonRpcErrorResponse(null, JsonRpcError.FILTER_NOT_FOUND);
final JsonRpcResponse expected = new JsonRpcErrorResponse(null, RpcErrorType.FILTER_NOT_FOUND);
final JsonRpcResponse actual = method.response(request);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
@ -260,8 +260,8 @@ public class EthGetFilterChangesIntegrationTest {
return true;
} else {
assertThat(response).isInstanceOf(JsonRpcErrorResponse.class);
assertThat(((JsonRpcErrorResponse) response).getError())
.isEqualTo(JsonRpcError.FILTER_NOT_FOUND);
assertThat(((JsonRpcErrorResponse) response).getErrorType())
.isEqualTo(RpcErrorType.FILTER_NOT_FOUND);
return false;
}
}

@ -24,10 +24,10 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonCallParameter;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.testutil.BlockTestUtil;
import java.util.Map;
@ -101,7 +101,7 @@ public class EthCallIntegrationTest {
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(null, JsonRpcError.TRANSACTION_UPFRONT_COST_EXCEEDS_BALANCE);
new JsonRpcErrorResponse(null, RpcErrorType.TRANSACTION_UPFRONT_COST_EXCEEDS_BALANCE);
final JsonRpcResponse response = method.response(request);
@ -148,7 +148,7 @@ public class EthCallIntegrationTest {
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(null, JsonRpcError.GAS_PRICE_BELOW_CURRENT_BASE_FEE);
new JsonRpcErrorResponse(null, RpcErrorType.GAS_PRICE_BELOW_CURRENT_BASE_FEE);
final JsonRpcResponse response = method.response(request);
@ -219,7 +219,7 @@ public class EthCallIntegrationTest {
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(null, JsonRpcError.GAS_PRICE_BELOW_CURRENT_BASE_FEE);
new JsonRpcErrorResponse(null, RpcErrorType.GAS_PRICE_BELOW_CURRENT_BASE_FEE);
final JsonRpcResponse response = method.response(request);
@ -243,7 +243,7 @@ public class EthCallIntegrationTest {
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(
null, JsonRpcError.MAX_PRIORITY_FEE_PER_GAS_EXCEEDS_MAX_FEE_PER_GAS);
null, RpcErrorType.MAX_PRIORITY_FEE_PER_GAS_EXCEEDS_MAX_FEE_PER_GAS);
final JsonRpcResponse response = method.response(request);
@ -266,7 +266,7 @@ public class EthCallIntegrationTest {
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(null, JsonRpcError.TRANSACTION_UPFRONT_COST_EXCEEDS_BALANCE);
new JsonRpcErrorResponse(null, RpcErrorType.TRANSACTION_UPFRONT_COST_EXCEEDS_BALANCE);
final JsonRpcResponse response = method.response(request);

@ -32,10 +32,10 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManagerBuilder;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.EthGetFilterChanges;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.Block;
@ -136,7 +136,7 @@ public class EthGetFilterChangesIntegrationTest {
public void shouldReturnErrorResponseIfFilterNotFound() {
final JsonRpcRequestContext request = requestWithParams("0");
final JsonRpcResponse expected = new JsonRpcErrorResponse(null, JsonRpcError.FILTER_NOT_FOUND);
final JsonRpcResponse expected = new JsonRpcErrorResponse(null, RpcErrorType.FILTER_NOT_FOUND);
final JsonRpcResponse actual = method.response(request);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
@ -260,8 +260,8 @@ public class EthGetFilterChangesIntegrationTest {
return true;
} else {
assertThat(response).isInstanceOf(JsonRpcErrorResponse.class);
assertThat(((JsonRpcErrorResponse) response).getError())
.isEqualTo(JsonRpcError.FILTER_NOT_FOUND);
assertThat(((JsonRpcErrorResponse) response).getErrorType())
.isEqualTo(RpcErrorType.FILTER_NOT_FOUND);
return false;
}
}

@ -20,9 +20,9 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.context.ContextKey;
import org.hyperledger.besu.ethereum.api.jsonrpc.execution.JsonRpcExecutor;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest;
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.RpcErrorType;
import java.io.IOException;
import java.util.Optional;
@ -94,7 +94,7 @@ public abstract class AbstractJsonRpcExecutor {
}
protected static void handleJsonRpcError(
final RoutingContext routingContext, final Object id, final JsonRpcError error) {
final RoutingContext routingContext, final Object id, final RpcErrorType error) {
final HttpServerResponse response = routingContext.response();
if (!response.closed()) {
response
@ -103,7 +103,7 @@ public abstract class AbstractJsonRpcExecutor {
}
}
private static HttpResponseStatus statusCodeFromError(final JsonRpcError error) {
private static HttpResponseStatus statusCodeFromError(final RpcErrorType error) {
return switch (error) {
case INVALID_REQUEST, PARSE_ERROR -> HttpResponseStatus.BAD_REQUEST;
default -> HttpResponseStatus.OK;

@ -17,8 +17,8 @@ package org.hyperledger.besu.ethereum.api.handlers;
import org.hyperledger.besu.ethereum.api.jsonrpc.authentication.AuthenticationService;
import org.hyperledger.besu.ethereum.api.jsonrpc.authentication.AuthenticationUtils;
import org.hyperledger.besu.ethereum.api.jsonrpc.context.ContextKey;
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.RpcErrorType;
import java.util.Collection;
@ -58,7 +58,7 @@ public class AuthenticationHandler {
if (!response.closed()) {
response
.setStatusCode(HttpResponseStatus.UNAUTHORIZED.code())
.end(Json.encode(new JsonRpcErrorResponse(null, JsonRpcError.UNAUTHORIZED)));
.end(Json.encode(new JsonRpcErrorResponse(null, RpcErrorType.UNAUTHORIZED)));
}
}
}

@ -14,16 +14,16 @@
*/
package org.hyperledger.besu.ethereum.api.handlers;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.INVALID_REQUEST;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INVALID_REQUEST;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonResponseStreamer;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.context.ContextKey;
import org.hyperledger.besu.ethereum.api.jsonrpc.execution.JsonRpcExecutor;
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.JsonRpcResponseType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import java.io.IOException;
@ -58,7 +58,7 @@ public class JsonRpcArrayExecutor extends AbstractJsonRpcExecutor {
executeRpcRequestBatch(batchJsonRequest, streamer);
}
} else {
handleJsonRpcError(ctx, null, JsonRpcError.EXCEEDS_RPC_MAX_BATCH_SIZE);
handleJsonRpcError(ctx, null, RpcErrorType.EXCEEDS_RPC_MAX_BATCH_SIZE);
}
}

@ -19,7 +19,7 @@ import static org.hyperledger.besu.ethereum.api.handlers.AbstractJsonRpcExecutor
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.context.ContextKey;
import org.hyperledger.besu.ethereum.api.jsonrpc.execution.JsonRpcExecutor;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import java.io.IOException;
import java.util.Optional;
@ -61,9 +61,9 @@ public class JsonRpcExecutorHandler {
throw new RuntimeException(e);
}
},
() -> handleJsonRpcError(ctx, null, JsonRpcError.PARSE_ERROR));
() -> handleJsonRpcError(ctx, null, RpcErrorType.PARSE_ERROR));
} catch (final RuntimeException e) {
handleJsonRpcError(ctx, null, JsonRpcError.INTERNAL_ERROR);
handleJsonRpcError(ctx, null, RpcErrorType.INTERNAL_ERROR);
}
};
}

@ -20,10 +20,10 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.JsonResponseStreamer;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.context.ContextKey;
import org.hyperledger.besu.ethereum.api.jsonrpc.execution.JsonRpcExecutor;
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.JsonRpcResponseType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import java.io.IOException;
@ -85,7 +85,7 @@ public class JsonRpcObjectExecutor extends AbstractJsonRpcExecutor {
private static HttpResponseStatus status(final JsonRpcResponse response) {
return switch (response.getType()) {
case UNAUTHORIZED -> HttpResponseStatus.UNAUTHORIZED;
case ERROR -> statusCodeFromError(((JsonRpcErrorResponse) response).getError());
case ERROR -> statusCodeFromError(((JsonRpcErrorResponse) response).getErrorType());
default -> HttpResponseStatus.OK;
};
}
@ -97,7 +97,7 @@ public class JsonRpcObjectExecutor extends AbstractJsonRpcExecutor {
.with(JsonGenerator.Feature.AUTO_CLOSE_TARGET);
}
private static HttpResponseStatus statusCodeFromError(final JsonRpcError error) {
private static HttpResponseStatus statusCodeFromError(final RpcErrorType error) {
return switch (error) {
case INVALID_REQUEST, PARSE_ERROR -> HttpResponseStatus.BAD_REQUEST;
default -> HttpResponseStatus.OK;

@ -15,8 +15,8 @@
package org.hyperledger.besu.ethereum.api.handlers;
import org.hyperledger.besu.ethereum.api.jsonrpc.context.ContextKey;
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.RpcErrorType;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.vertx.core.Handler;
@ -34,7 +34,7 @@ public class JsonRpcParserHandler {
return ctx -> {
final HttpServerResponse response = ctx.response();
if (ctx.getBody() == null) {
errorResponse(response, JsonRpcError.PARSE_ERROR);
errorResponse(response, RpcErrorType.PARSE_ERROR);
} else {
try {
ctx.put(ContextKey.REQUEST_BODY_AS_JSON_OBJECT.name(), ctx.getBodyAsJson());
@ -42,13 +42,13 @@ public class JsonRpcParserHandler {
try {
final JsonArray batchRequest = ctx.getBodyAsJsonArray();
if (batchRequest.isEmpty()) {
errorResponse(response, JsonRpcError.INVALID_REQUEST);
errorResponse(response, RpcErrorType.INVALID_REQUEST);
return;
} else {
ctx.put(ContextKey.REQUEST_BODY_AS_JSON_ARRAY.name(), batchRequest);
}
} catch (DecodeException | ClassCastException jsonArrayDecodeException) {
errorResponse(response, JsonRpcError.PARSE_ERROR);
errorResponse(response, RpcErrorType.PARSE_ERROR);
return;
}
}
@ -58,7 +58,7 @@ public class JsonRpcParserHandler {
}
private static void errorResponse(
final HttpServerResponse response, final JsonRpcError rpcError) {
final HttpServerResponse response, final RpcErrorType rpcError) {
if (!response.closed()) {
response
.setStatusCode(HttpResponseStatus.BAD_REQUEST.code())

@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import java.util.Arrays;
import java.util.List;
@ -22,17 +22,17 @@ import java.util.stream.Collectors;
public class JsonRpcEnclaveErrorConverter {
public static JsonRpcError convertEnclaveInvalidReason(final String reason) {
public static RpcErrorType convertEnclaveInvalidReason(final String reason) {
final List<JsonRpcError> err =
Arrays.stream(JsonRpcError.values())
final List<RpcErrorType> err =
Arrays.stream(RpcErrorType.values())
.filter(e -> e.getMessage().equals(reason))
.collect(Collectors.toList());
if (err.size() == 1) {
return err.get(0);
} else {
return JsonRpcError.ENCLAVE_ERROR;
return RpcErrorType.ENCLAVE_ERROR;
}
}
}

@ -14,71 +14,71 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
public class JsonRpcErrorConverter {
public static JsonRpcError convertTransactionInvalidReason(
public static RpcErrorType convertTransactionInvalidReason(
final TransactionInvalidReason reason) {
switch (reason) {
case NONCE_TOO_LOW:
case PRIVATE_NONCE_TOO_LOW:
return JsonRpcError.NONCE_TOO_LOW;
return RpcErrorType.NONCE_TOO_LOW;
case NONCE_TOO_HIGH:
case PRIVATE_NONCE_TOO_HIGH:
return JsonRpcError.NONCE_TOO_HIGH;
return RpcErrorType.NONCE_TOO_HIGH;
case INVALID_SIGNATURE:
return JsonRpcError.INVALID_TRANSACTION_SIGNATURE;
return RpcErrorType.INVALID_TRANSACTION_SIGNATURE;
case INTRINSIC_GAS_EXCEEDS_GAS_LIMIT:
return JsonRpcError.INTRINSIC_GAS_EXCEEDS_LIMIT;
return RpcErrorType.INTRINSIC_GAS_EXCEEDS_LIMIT;
case UPFRONT_COST_EXCEEDS_BALANCE:
return JsonRpcError.TRANSACTION_UPFRONT_COST_EXCEEDS_BALANCE;
return RpcErrorType.TRANSACTION_UPFRONT_COST_EXCEEDS_BALANCE;
case EXCEEDS_BLOCK_GAS_LIMIT:
return JsonRpcError.EXCEEDS_BLOCK_GAS_LIMIT;
return RpcErrorType.EXCEEDS_BLOCK_GAS_LIMIT;
case WRONG_CHAIN_ID:
return JsonRpcError.WRONG_CHAIN_ID;
return RpcErrorType.WRONG_CHAIN_ID;
case REPLAY_PROTECTED_SIGNATURES_NOT_SUPPORTED:
return JsonRpcError.REPLAY_PROTECTED_SIGNATURES_NOT_SUPPORTED;
return RpcErrorType.REPLAY_PROTECTED_SIGNATURES_NOT_SUPPORTED;
case REPLAY_PROTECTED_SIGNATURE_REQUIRED:
return JsonRpcError.REPLAY_PROTECTED_SIGNATURE_REQUIRED;
return RpcErrorType.REPLAY_PROTECTED_SIGNATURE_REQUIRED;
case TX_SENDER_NOT_AUTHORIZED:
return JsonRpcError.TX_SENDER_NOT_AUTHORIZED;
return RpcErrorType.TX_SENDER_NOT_AUTHORIZED;
// Private Transaction Invalid Reasons
case PRIVATE_TRANSACTION_INVALID:
return JsonRpcError.PRIVATE_TRANSACTION_INVALID;
return RpcErrorType.PRIVATE_TRANSACTION_INVALID;
case PRIVATE_TRANSACTION_FAILED:
return JsonRpcError.PRIVATE_TRANSACTION_FAILED;
return RpcErrorType.PRIVATE_TRANSACTION_FAILED;
case PRIVATE_UNIMPLEMENTED_TRANSACTION_TYPE:
return JsonRpcError.UNSUPPORTED_PRIVATE_TRANSACTION_TYPE;
return RpcErrorType.UNSUPPORTED_PRIVATE_TRANSACTION_TYPE;
case CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE:
return JsonRpcError.CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE;
return RpcErrorType.CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE;
case GAS_PRICE_TOO_LOW:
return JsonRpcError.GAS_PRICE_TOO_LOW;
return RpcErrorType.GAS_PRICE_TOO_LOW;
case GAS_PRICE_BELOW_CURRENT_BASE_FEE:
return JsonRpcError.GAS_PRICE_BELOW_CURRENT_BASE_FEE;
return RpcErrorType.GAS_PRICE_BELOW_CURRENT_BASE_FEE;
case TX_FEECAP_EXCEEDED:
return JsonRpcError.TX_FEECAP_EXCEEDED;
return RpcErrorType.TX_FEECAP_EXCEEDED;
case MAX_PRIORITY_FEE_PER_GAS_EXCEEDS_MAX_FEE_PER_GAS:
return JsonRpcError.MAX_PRIORITY_FEE_PER_GAS_EXCEEDS_MAX_FEE_PER_GAS;
return RpcErrorType.MAX_PRIORITY_FEE_PER_GAS_EXCEEDS_MAX_FEE_PER_GAS;
case OFFCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST:
return JsonRpcError.OFFCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST;
return RpcErrorType.OFFCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST;
case INVALID_TRANSACTION_FORMAT:
return JsonRpcError.INVALID_TRANSACTION_TYPE;
return RpcErrorType.INVALID_TRANSACTION_TYPE;
case TRANSACTION_ALREADY_KNOWN:
return JsonRpcError.ETH_SEND_TX_ALREADY_KNOWN;
return RpcErrorType.ETH_SEND_TX_ALREADY_KNOWN;
case TRANSACTION_REPLACEMENT_UNDERPRICED:
return JsonRpcError.ETH_SEND_TX_REPLACEMENT_UNDERPRICED;
return RpcErrorType.ETH_SEND_TX_REPLACEMENT_UNDERPRICED;
case NONCE_TOO_FAR_IN_FUTURE_FOR_SENDER:
return JsonRpcError.NONCE_TOO_FAR_IN_FUTURE_FOR_SENDER;
return RpcErrorType.NONCE_TOO_FAR_IN_FUTURE_FOR_SENDER;
case LOWER_NONCE_INVALID_TRANSACTION_EXISTS:
return JsonRpcError.LOWER_NONCE_INVALID_TRANSACTION_EXISTS;
return RpcErrorType.LOWER_NONCE_INVALID_TRANSACTION_EXISTS;
case TOTAL_DATA_GAS_TOO_HIGH:
return JsonRpcError.TOTAL_DATA_GAS_TOO_HIGH;
return RpcErrorType.TOTAL_DATA_GAS_TOO_HIGH;
case TX_POOL_DISABLED:
return JsonRpcError.TX_POOL_DISABLED;
return RpcErrorType.TX_POOL_DISABLED;
default:
return JsonRpcError.INTERNAL_ERROR;
return RpcErrorType.INTERNAL_ERROR;
}
}
}

@ -18,9 +18,9 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.authentication.AuthenticationSe
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestId;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcUnauthorizedResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import java.util.Collection;
@ -50,6 +50,6 @@ public class AuthenticatedJsonRpcProcessor implements JsonRpcProcessor {
if (authenticationService.isPermitted(request.getUser(), method, noAuthRpcApis)) {
return rpcProcessor.process(id, method, metricSpan, request);
}
return new JsonRpcUnauthorizedResponse(id, JsonRpcError.UNAUTHORIZED);
return new JsonRpcUnauthorizedResponse(id, RpcErrorType.UNAUTHORIZED);
}
}

@ -18,10 +18,10 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestId;
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.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.JsonRpcUnauthorizedResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.privacy.MultiTenancyValidationException;
import io.opentelemetry.api.trace.Span;
@ -44,13 +44,13 @@ public class BaseJsonRpcProcessor implements JsonRpcProcessor {
return method.response(request);
} catch (final InvalidJsonRpcParameters e) {
LOG.debug("Invalid Params for method: {}", method.getName(), e);
return new JsonRpcErrorResponse(id, JsonRpcError.INVALID_PARAMS);
return new JsonRpcErrorResponse(id, RpcErrorType.INVALID_PARAMS);
} catch (final MultiTenancyValidationException e) {
return new JsonRpcUnauthorizedResponse(id, JsonRpcError.UNAUTHORIZED);
return new JsonRpcUnauthorizedResponse(id, RpcErrorType.UNAUTHORIZED);
} catch (final RuntimeException e) {
final JsonArray params = JsonObject.mapFrom(request.getRequest()).getJsonArray("params");
LOG.error(String.format("Error processing method: %s %s", method.getName(), params), e);
return new JsonRpcErrorResponse(id, JsonRpcError.INTERNAL_ERROR);
return new JsonRpcErrorResponse(id, RpcErrorType.INTERNAL_ERROR);
}
}
}

@ -14,17 +14,17 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.execution;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.INVALID_REQUEST;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INVALID_REQUEST;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestId;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
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.JsonRpcNoResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import java.util.Map;
import java.util.Optional;
@ -81,7 +81,7 @@ public class JsonRpcExecutor {
} else {
span = Span.getInvalid();
}
final Optional<JsonRpcError> unavailableMethod = validateMethodAvailability(requestBody);
final Optional<RpcErrorType> unavailableMethod = validateMethodAvailability(requestBody);
if (unavailableMethod.isPresent()) {
span.setStatus(StatusCode.ERROR, "method unavailable");
return new JsonRpcErrorResponse(id, unavailableMethod.get());
@ -101,7 +101,7 @@ public class JsonRpcExecutor {
}
}
private Optional<JsonRpcError> validateMethodAvailability(final JsonRpcRequest request) {
private Optional<RpcErrorType> validateMethodAvailability(final JsonRpcRequest request) {
final String name = request.getMethod();
if (LOG.isDebugEnabled()) {
@ -113,10 +113,10 @@ public class JsonRpcExecutor {
if (method == null) {
if (!RpcMethod.rpcMethodExists(name)) {
return Optional.of(JsonRpcError.METHOD_NOT_FOUND);
return Optional.of(RpcErrorType.METHOD_NOT_FOUND);
}
if (!rpcMethods.containsKey(name)) {
return Optional.of(JsonRpcError.METHOD_NOT_ENABLED);
return Optional.of(RpcErrorType.METHOD_NOT_ENABLED);
}
}

@ -41,7 +41,7 @@ public class TracedJsonRpcProcessor implements JsonRpcProcessor {
JsonRpcResponse jsonRpcResponse = rpcProcessor.process(id, method, metricSpan, request);
if (JsonRpcResponseType.ERROR == jsonRpcResponse.getType()) {
JsonRpcErrorResponse errorResponse = (JsonRpcErrorResponse) jsonRpcResponse;
switch (errorResponse.getError()) {
switch (errorResponse.getErrorType()) {
case INVALID_PARAMS:
metricSpan.setStatus(StatusCode.ERROR, "Invalid Params");
break;

@ -14,8 +14,8 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.INTERNAL_ERROR;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.UNKNOWN_BLOCK;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INTERNAL_ERROR;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.UNKNOWN_BLOCK;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;

@ -16,10 +16,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
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;
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;
@ -77,7 +77,7 @@ public abstract class AbstractBlockParameterMethod implements JsonRpcMethod {
.map(header -> resultByBlockNumber(request, header.getNumber()))
.orElseGet(
() ->
new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.UNKNOWN_BLOCK));
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.UNKNOWN_BLOCK));
}
protected Object findResultByParamType(final JsonRpcRequestContext request) {

@ -17,10 +17,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash;
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;
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;
@ -86,7 +86,7 @@ public abstract class AbstractBlockParameterOrBlockHashMethod implements JsonRpc
.map(header -> resultByBlockHash(request, header.getBlockHash()))
.orElseGet(
() ->
new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.UNKNOWN_BLOCK));
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.UNKNOWN_BLOCK));
}
protected Object handleParamTypes(final JsonRpcRequestContext requestContext) {
@ -106,10 +106,10 @@ public abstract class AbstractBlockParameterOrBlockHashMethod implements JsonRpc
final OptionalLong blockNumber = blockParameterOrBlockHash.getNumber();
if (blockNumber.isEmpty() || blockNumber.getAsLong() < 0) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
} else if (blockNumber.getAsLong() > getBlockchainQueries().headBlockNumber()) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.BLOCK_NOT_FOUND);
requestContext.getRequest().getId(), RpcErrorType.BLOCK_NOT_FOUND);
}
result =
@ -123,7 +123,7 @@ public abstract class AbstractBlockParameterOrBlockHashMethod implements JsonRpc
Optional<Hash> blockHash = blockParameterOrBlockHash.getHash();
if (blockHash.isEmpty()) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
// return error if block hash does not find a block
@ -131,13 +131,13 @@ public abstract class AbstractBlockParameterOrBlockHashMethod implements JsonRpc
getBlockchainQueries().getBlockHeaderByHash(blockHash.get());
if (maybeBlockHeader.isEmpty()) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.BLOCK_NOT_FOUND);
requestContext.getRequest().getId(), RpcErrorType.BLOCK_NOT_FOUND);
}
if (Boolean.TRUE.equals(blockParameterOrBlockHash.getRequireCanonical())
&& !getBlockchainQueries().blockIsOnCanonicalChain(blockHash.get())) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.JSON_RPC_NOT_CANONICAL_ERROR);
requestContext.getRequest().getId(), RpcErrorType.JSON_RPC_NOT_CANONICAL_ERROR);
}
result = resultByBlockHash(requestContext, blockHash.get());

@ -21,6 +21,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonR
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonCallParameter;
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.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
@ -96,24 +97,29 @@ public abstract class AbstractEstimateGas implements JsonRpcMethod {
protected JsonRpcErrorResponse errorResponse(
final JsonRpcRequestContext request, final TransactionSimulatorResult result) {
final JsonRpcError jsonRpcError;
final ValidationResult<TransactionInvalidReason> validationResult =
result.getValidationResult();
if (validationResult != null && !validationResult.isValid()) {
jsonRpcError =
return errorResponse(
request,
JsonRpcErrorConverter.convertTransactionInvalidReason(
validationResult.getInvalidReason());
validationResult.getInvalidReason()));
} else {
final TransactionProcessingResult resultTrx = result.getResult();
if (resultTrx != null && resultTrx.getRevertReason().isPresent()) {
jsonRpcError = JsonRpcError.REVERT_ERROR;
jsonRpcError.setData(resultTrx.getRevertReason().get().toHexString());
} else {
jsonRpcError = JsonRpcError.INTERNAL_ERROR;
return errorResponse(
request,
new JsonRpcError(
RpcErrorType.REVERT_ERROR, resultTrx.getRevertReason().get().toHexString()));
}
return errorResponse(request, RpcErrorType.INTERNAL_ERROR);
}
return errorResponse(request, jsonRpcError);
}
protected JsonRpcErrorResponse errorResponse(
final JsonRpcRequestContext request, final RpcErrorType rpcErrorType) {
return errorResponse(request, new JsonRpcError(rpcErrorType));
}
protected JsonRpcErrorResponse errorResponse(

@ -17,10 +17,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.util.LogConfigurator;
import java.util.Arrays;
@ -47,7 +47,7 @@ public class AdminChangeLogLevel implements JsonRpcMethod {
final String logLevel = requestContext.getRequiredParameter(0, String.class);
if (!VALID_PARAMS.contains(logLevel)) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
final Optional<String[]> optionalLogFilters =
requestContext.getOptionalParameter(1, String[].class);
@ -58,7 +58,7 @@ public class AdminChangeLogLevel implements JsonRpcMethod {
return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
} catch (InvalidJsonRpcParameters invalidJsonRpcParameters) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
}

@ -17,10 +17,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.parameters.BlockParameter;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.api.query.cache.TransactionLogBloomCacher;
import org.hyperledger.besu.ethereum.core.BlockHeader;
@ -81,7 +81,7 @@ public class AdminLogsRemoveCache implements JsonRpcMethod {
if (stopBlock < startBlock) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
final TransactionLogBloomCacher transactionLogBloomCacher =

@ -16,9 +16,9 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.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.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.RpcErrorType;
import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork;
import org.hyperledger.besu.ethereum.p2p.network.exceptions.P2PDisabledException;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeDnsConfiguration;
@ -40,35 +40,35 @@ public abstract class AdminModifyPeer implements JsonRpcMethod {
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
if (requestContext.getRequest().getParamLength() != 1) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
try {
final String enodeString = requestContext.getRequiredParameter(0, String.class);
return performOperation(requestContext.getRequest().getId(), enodeString);
} catch (final InvalidJsonRpcParameters e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
} catch (final IllegalArgumentException e) {
if (e.getMessage()
.endsWith(
"Invalid node ID: node ID must have exactly 128 hexadecimal characters and should not include any '0x' hex prefix.")) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ENODE_ID_INVALID);
requestContext.getRequest().getId(), RpcErrorType.ENODE_ID_INVALID);
} else {
if (e.getMessage().endsWith("Invalid ip address.")) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.DNS_NOT_ENABLED);
requestContext.getRequest().getId(), RpcErrorType.DNS_NOT_ENABLED);
} else if (e.getMessage().endsWith("dns-update-enabled flag is false.")) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.CANT_RESOLVE_PEER_ENODE_DNS);
requestContext.getRequest().getId(), RpcErrorType.CANT_RESOLVE_PEER_ENODE_DNS);
} else {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.PARSE_ERROR);
requestContext.getRequest().getId(), RpcErrorType.PARSE_ERROR);
}
}
} catch (final P2PDisabledException e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.P2P_DISABLED);
requestContext.getRequest().getId(), RpcErrorType.P2P_DISABLED);
}
}

@ -17,10 +17,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.config.GenesisConfigOptions;
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.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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.chain.ChainHead;
import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork;
@ -75,12 +75,12 @@ public class AdminNodeInfo implements JsonRpcMethod {
if (!peerNetwork.isP2pEnabled()) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.P2P_DISABLED);
requestContext.getRequest().getId(), RpcErrorType.P2P_DISABLED);
}
final Optional<EnodeURL> maybeEnode = peerNetwork.getLocalEnode();
if (maybeEnode.isEmpty()) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.P2P_NETWORK_NOT_RUNNING);
requestContext.getRequest().getId(), RpcErrorType.P2P_NETWORK_NOT_RUNNING);
}
final EnodeURL enode = maybeEnode.get();

@ -16,10 +16,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.PeerResult;
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
import org.hyperledger.besu.ethereum.p2p.network.exceptions.P2PDisabledException;
@ -47,7 +47,7 @@ public class AdminPeers implements JsonRpcMethod {
ethPeers.streamAllPeers().map(PeerResult::fromEthPeer).collect(Collectors.toList()));
} catch (P2PDisabledException e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.P2P_DISABLED);
requestContext.getRequest().getId(), RpcErrorType.P2P_DISABLED);
}
}
}

@ -23,8 +23,8 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace;
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.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.ImmutableDebugAccountAtResult;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity;
import org.hyperledger.besu.ethereum.api.query.BlockWithMetadata;
@ -79,13 +79,13 @@ public class DebugAccountAt extends AbstractBlockParameterOrBlockHashMethod {
blockchainQueries.get().blockByHash(blockHash);
if (block.isEmpty()) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.BLOCK_NOT_FOUND);
requestContext.getRequest().getId(), RpcErrorType.BLOCK_NOT_FOUND);
}
List<TransactionWithMetadata> transactions = block.get().getTransactions();
if (transactions.isEmpty() || txIndex < 0 || txIndex > block.get().getTransactions().size()) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
return Tracer.processTracing(
@ -113,7 +113,7 @@ public class DebugAccountAt extends AbstractBlockParameterOrBlockHashMethod {
if (transactionTrace.isEmpty()) {
return Optional.of(
new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.TRANSACTION_NOT_FOUND));
requestContext.getRequest().getId(), RpcErrorType.TRANSACTION_NOT_FOUND));
}
Optional<Account> account =
@ -125,7 +125,7 @@ public class DebugAccountAt extends AbstractBlockParameterOrBlockHashMethod {
if (account.isEmpty()) {
return Optional.of(
new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.NO_ACCOUNT_FOUND));
requestContext.getRequest().getId(), RpcErrorType.NO_ACCOUNT_FOUND));
}
return Optional.of(
@ -137,7 +137,7 @@ public class DebugAccountAt extends AbstractBlockParameterOrBlockHashMethod {
})
.orElse(
new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.WORLD_STATE_UNAVAILABLE));
requestContext.getRequest().getId(), RpcErrorType.WORLD_STATE_UNAVAILABLE));
}
protected ImmutableDebugAccountAtResult debugAccountAtResult(

@ -17,8 +17,8 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.parameters.BlockParameter;
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.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.rlp.RLP;
@ -51,6 +51,6 @@ public class DebugGetRawBlock extends AbstractBlockParameterMethod {
.orElseGet(
() ->
new JsonRpcErrorResponse(
request.getRequest().getId(), JsonRpcError.BLOCK_NOT_FOUND));
request.getRequest().getId(), RpcErrorType.BLOCK_NOT_FOUND));
}
}

@ -17,8 +17,8 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.parameters.BlockParameter;
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.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.rlp.RLP;
@ -50,6 +50,6 @@ public class DebugGetRawHeader extends AbstractBlockParameterMethod {
.orElseGet(
() ->
new JsonRpcErrorResponse(
request.getRequest().getId(), JsonRpcError.BLOCK_NOT_FOUND));
request.getRequest().getId(), RpcErrorType.BLOCK_NOT_FOUND));
}
}

@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.UNKNOWN_BLOCK;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.UNKNOWN_BLOCK;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.ProtocolContext;

@ -19,10 +19,10 @@ 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.parameters.TransactionTraceParams;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTracer;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.chain.Blockchain;
@ -73,6 +73,6 @@ public class DebugStandardTraceBadBlockToFile extends DebugStandardTraceBlockToF
traceBlock(block, transactionTraceParams)))
.orElse(
new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.BLOCK_NOT_FOUND));
requestContext.getRequest().getId(), RpcErrorType.BLOCK_NOT_FOUND));
}
}

@ -22,10 +22,10 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
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.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;
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;
@ -75,7 +75,7 @@ public class DebugStandardTraceBlockToFile implements JsonRpcMethod {
traceBlock(block, transactionTraceParams)))
.orElse(
new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.BLOCK_NOT_FOUND));
requestContext.getRequest().getId(), RpcErrorType.BLOCK_NOT_FOUND));
}
protected List<String> traceBlock(

@ -20,10 +20,10 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.Transaction
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
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;
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.core.Block;
@ -71,7 +71,7 @@ public class DebugTraceBlock implements JsonRpcMethod {
} catch (final RLPException e) {
LOG.debug("Failed to parse block RLP", e);
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
final TraceOptions traceOptions =
requestContext
@ -95,7 +95,7 @@ public class DebugTraceBlock implements JsonRpcMethod {
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), results);
} else {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.PARENT_BLOCK_NOT_FOUND);
requestContext.getRequest().getId(), RpcErrorType.PARENT_BLOCK_NOT_FOUND);
}
}
}

@ -14,8 +14,8 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.BLOCK_NOT_FOUND;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.INTERNAL_ERROR;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.BLOCK_NOT_FOUND;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INTERNAL_ERROR;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
@ -28,6 +28,7 @@ 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;
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;
import org.hyperledger.besu.ethereum.mainnet.ImmutableTransactionValidationParams;
@ -92,8 +93,8 @@ public class EthCall extends AbstractBlockParameterOrBlockHashMethod {
result.getOutput().toString())
: errorResponse(request, result)),
reason ->
new JsonRpcErrorResponse(
request.getRequest().getId(),
errorResponse(
request,
JsonRpcErrorConverter.convertTransactionInvalidReason(
reason)))),
header)
@ -107,24 +108,24 @@ public class EthCall extends AbstractBlockParameterOrBlockHashMethod {
private JsonRpcErrorResponse errorResponse(
final JsonRpcRequestContext request, final TransactionSimulatorResult result) {
final JsonRpcError jsonRpcError;
final ValidationResult<TransactionInvalidReason> validationResult =
result.getValidationResult();
if (validationResult != null && !validationResult.isValid()) {
jsonRpcError =
return errorResponse(
request,
JsonRpcErrorConverter.convertTransactionInvalidReason(
validationResult.getInvalidReason());
validationResult.getInvalidReason()));
} else {
final TransactionProcessingResult resultTrx = result.getResult();
if (resultTrx != null && resultTrx.getRevertReason().isPresent()) {
jsonRpcError = JsonRpcError.REVERT_ERROR;
jsonRpcError.setData(resultTrx.getRevertReason().get().toHexString());
} else {
jsonRpcError = JsonRpcError.INTERNAL_ERROR;
return errorResponse(
request,
new JsonRpcError(
RpcErrorType.REVERT_ERROR, resultTrx.getRevertReason().get().toHexString()));
}
return errorResponse(request, RpcErrorType.INTERNAL_ERROR);
}
return errorResponse(request, jsonRpcError);
}
private JsonRpcErrorResponse errorResponse(
@ -132,6 +133,11 @@ public class EthCall extends AbstractBlockParameterOrBlockHashMethod {
return new JsonRpcErrorResponse(request.getRequest().getId(), jsonRpcError);
}
private JsonRpcErrorResponse errorResponse(
final JsonRpcRequestContext request, final RpcErrorType rpcErrorType) {
return errorResponse(request, new JsonRpcError(rpcErrorType));
}
private TransactionValidationParams buildTransactionValidationParams(
final BlockHeader header, final JsonCallParameter callParams) {

@ -17,10 +17,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import java.util.Optional;
@ -46,6 +46,6 @@ public class EthCoinbase implements JsonRpcMethod {
requestContext.getRequest().getId(), coinbase.get().toString());
}
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.COINBASE_NOT_SPECIFIED);
requestContext.getRequest().getId(), RpcErrorType.COINBASE_NOT_SPECIFIED);
}
}

@ -18,9 +18,9 @@ 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.parameters.JsonCallParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
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.CreateAccessListResult;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.BlockHeader;
@ -53,7 +53,7 @@ public class EthCreateAccessList extends AbstractEstimateGas {
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final JsonCallParameter jsonCallParameter = validateAndGetCallParams(requestContext);
final BlockHeader blockHeader = blockHeader();
final Optional<JsonRpcError> jsonRpcError = validateBlockHeader(blockHeader);
final Optional<RpcErrorType> jsonRpcError = validateBlockHeader(blockHeader);
if (jsonRpcError.isPresent()) {
return errorResponse(requestContext, jsonRpcError.get());
}
@ -70,14 +70,14 @@ public class EthCreateAccessList extends AbstractEstimateGas {
}
}
private Optional<JsonRpcError> validateBlockHeader(final BlockHeader blockHeader) {
private Optional<RpcErrorType> validateBlockHeader(final BlockHeader blockHeader) {
if (blockHeader == null) {
return Optional.of(JsonRpcError.INTERNAL_ERROR);
return Optional.of(RpcErrorType.INTERNAL_ERROR);
}
if (!blockchainQueries
.getWorldStateArchive()
.isWorldStateAvailable(blockHeader.getStateRoot(), blockHeader.getHash())) {
return Optional.of(JsonRpcError.WORLD_STATE_UNAVAILABLE);
return Optional.of(RpcErrorType.WORLD_STATE_UNAVAILABLE);
}
return Optional.empty();
}
@ -87,7 +87,7 @@ public class EthCreateAccessList extends AbstractEstimateGas {
return result
.getResult()
.map(createResponse(requestContext, result.getTracer()))
.orElse(errorResponse(requestContext, JsonRpcError.INTERNAL_ERROR));
.orElse(errorResponse(requestContext, RpcErrorType.INTERNAL_ERROR));
}
private TransactionValidationParams transactionValidationParams(

@ -17,9 +17,9 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.parameters.JsonCallParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
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.Quantity;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.BlockHeader;
@ -50,12 +50,12 @@ public class EthEstimateGas extends AbstractEstimateGas {
final BlockHeader blockHeader = blockHeader();
if (blockHeader == null) {
return errorResponse(requestContext, JsonRpcError.INTERNAL_ERROR);
return errorResponse(requestContext, RpcErrorType.INTERNAL_ERROR);
}
if (!blockchainQueries
.getWorldStateArchive()
.isWorldStateAvailable(blockHeader.getStateRoot(), blockHeader.getHash())) {
return errorResponse(requestContext, JsonRpcError.WORLD_STATE_UNAVAILABLE);
return errorResponse(requestContext, RpcErrorType.WORLD_STATE_UNAVAILABLE);
}
final CallParameter modifiedCallParams =
@ -70,7 +70,7 @@ public class EthEstimateGas extends AbstractEstimateGas {
blockHeader, modifiedCallParams, operationTracer, isAllowExceedingBalance);
if (gasUsed.isEmpty()) {
return errorResponse(requestContext, JsonRpcError.INTERNAL_ERROR);
return errorResponse(requestContext, RpcErrorType.INTERNAL_ERROR);
}
// if the transaction is invalid or doesn't have enough gas with the max it never will!

@ -21,10 +21,10 @@ 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.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.UnsignedIntParameter;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.FeeHistory;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.ImmutableFeeHistory;
import org.hyperledger.besu.ethereum.chain.Blockchain;
@ -69,7 +69,7 @@ public class EthFeeHistory implements JsonRpcMethod {
final int blockCount = request.getRequiredParameter(0, UnsignedIntParameter.class).getValue();
if (blockCount < 1 || blockCount > 1024) {
return new JsonRpcErrorResponse(requestId, JsonRpcError.INVALID_PARAMS);
return new JsonRpcErrorResponse(requestId, RpcErrorType.INVALID_PARAMS);
}
final BlockParameter highestBlock = request.getRequiredParameter(1, BlockParameter.class);
final Optional<List<Double>> maybeRewardPercentiles =
@ -84,7 +84,7 @@ public class EthFeeHistory implements JsonRpcMethod {
chainHeadBlockNumber /* both latest and pending use the head block until we have pending block support */);
if (resolvedHighestBlockNumber > chainHeadBlockNumber) {
return new JsonRpcErrorResponse(requestId, JsonRpcError.INVALID_PARAMS);
return new JsonRpcErrorResponse(requestId, RpcErrorType.INVALID_PARAMS);
}
final long oldestBlock = Math.max(0, resolvedHighestBlockNumber - (blockCount - 1));

@ -18,10 +18,10 @@ 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.filter.FilterManager;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.LogsResult;
import org.hyperledger.besu.ethereum.core.LogWithMetadata;
@ -66,6 +66,6 @@ public class EthGetFilterChanges implements JsonRpcMethod {
// Filter was not found.
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.FILTER_NOT_FOUND);
requestContext.getRequest().getId(), RpcErrorType.FILTER_NOT_FOUND);
}
}

@ -17,10 +17,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.filter.FilterManager;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.LogsResult;
import org.hyperledger.besu.ethereum.core.LogWithMetadata;
@ -49,6 +49,6 @@ public class EthGetFilterLogs implements JsonRpcMethod {
}
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.LOGS_FILTER_NOT_FOUND);
requestContext.getRequest().getId(), RpcErrorType.LOGS_FILTER_NOT_FOUND);
}
}

@ -17,10 +17,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.parameters.FilterParameter;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.LogsResult;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.LogWithMetadata;
@ -57,7 +57,7 @@ public class EthGetLogs implements JsonRpcMethod {
if (!filter.isValid()) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
final AtomicReference<Exception> ex = new AtomicReference<>();
@ -111,10 +111,10 @@ public class EthGetLogs implements JsonRpcMethod {
.log();
if (ex.get() instanceof IllegalArgumentException) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.EXCEEDS_RPC_MAX_BLOCK_RANGE);
requestContext.getRequest().getId(), RpcErrorType.EXCEEDS_RPC_MAX_BLOCK_RANGE);
}
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
return new JsonRpcSuccessResponse(

@ -19,10 +19,10 @@ 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.parameters.BlockParameterOrBlockHash;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.proof.GetProofResult;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.proof.WorldStateProof;
@ -77,11 +77,11 @@ public class EthGetProof extends AbstractBlockParameterOrBlockHashMethod {
Optional.of(
new JsonRpcErrorResponse(
requestContext.getRequest().getId(),
JsonRpcError.NO_ACCOUNT_FOUND)));
RpcErrorType.NO_ACCOUNT_FOUND)));
})
.orElse(
new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.WORLD_STATE_UNAVAILABLE));
requestContext.getRequest().getId(), RpcErrorType.WORLD_STATE_UNAVAILABLE));
}
@Override

@ -17,10 +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.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;
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.TransactionPendingResult;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
@ -48,7 +48,7 @@ public class EthGetTransactionByHash implements JsonRpcMethod {
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
if (requestContext.getRequest().getParamLength() != 1) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
final Hash hash = requestContext.getRequiredParameter(0, Hash.class);
final JsonRpcSuccessResponse jsonRpcSuccessResponse =

@ -16,10 +16,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator;
@ -66,7 +66,7 @@ public class EthGetWork implements JsonRpcMethod {
return new JsonRpcSuccessResponse(requestId, response);
} else {
LOG.trace("Mining is not operational, eth_getWork request cannot be processed");
return new JsonRpcErrorResponse(requestId, JsonRpcError.NO_MINING_WORK_FOUND);
return new JsonRpcErrorResponse(requestId, RpcErrorType.NO_MINING_WORK_FOUND);
}
}

@ -18,10 +18,10 @@ 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.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.FilterParameter;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
public class EthNewFilter implements JsonRpcMethod {
@ -42,7 +42,7 @@ public class EthNewFilter implements JsonRpcMethod {
if (!filter.isValid()) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
final String logFilterId =

@ -19,10 +19,10 @@ 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.InvalidJsonRpcRequestException;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.util.DomainObjectDecodeUtils;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
@ -62,7 +62,7 @@ public class EthSendRawTransaction implements JsonRpcMethod {
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
if (requestContext.getRequest().getParamLength() != 1) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
final String rawTransaction = requestContext.getRequiredParameter(0, String.class);
@ -73,15 +73,15 @@ public class EthSendRawTransaction implements JsonRpcMethod {
} catch (final RLPException e) {
LOG.debug("RLPException: {} caused by {}", e.getMessage(), e.getCause());
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
} catch (final InvalidJsonRpcRequestException i) {
LOG.debug("InvalidJsonRpcRequestException: {} caused by {}", i.getMessage(), i.getCause());
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
} catch (final IllegalArgumentException ill) {
LOG.debug("IllegalArgumentException: {} caused by {}", ill.getMessage(), ill.getCause());
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
final ValidationResult<TransactionInvalidReason> validationResult =

@ -16,9 +16,9 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.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.RpcErrorType;
public class EthSendTransaction implements JsonRpcMethod {
@ -30,6 +30,6 @@ public class EthSendTransaction implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ETH_SEND_TX_NOT_AVAILABLE);
requestContext.getRequest().getId(), RpcErrorType.ETH_SEND_TX_NOT_AVAILABLE);
}
}

@ -17,10 +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.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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.mainnet.PoWSolution;
import org.hyperledger.besu.ethereum.mainnet.PoWSolverInputs;
@ -60,7 +60,7 @@ public class EthSubmitWork implements JsonRpcMethod {
} else {
LOG.trace("Mining is not operational, eth_submitWork request cannot be processed");
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.NO_MINING_WORK_FOUND);
requestContext.getRequest().getId(), RpcErrorType.NO_MINING_WORK_FOUND);
}
}
}

@ -18,9 +18,9 @@ import org.hyperledger.besu.consensus.merge.MergeContext;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineCallListener;
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.RpcErrorType;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
@ -91,17 +91,17 @@ public abstract class ExecutionEngineJsonRpcMethod implements JsonRpcMethod {
.log();
}
return new JsonRpcErrorResponse(
request.getRequest().getId(), JsonRpcError.INVALID_REQUEST);
request.getRequest().getId(), RpcErrorType.INVALID_REQUEST);
})
.result()));
try {
return cf.get();
} catch (InterruptedException e) {
LOG.error("Failed to get execution engine response", e);
return new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.TIMEOUT_ERROR);
return new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.TIMEOUT_ERROR);
} catch (ExecutionException e) {
LOG.error("Failed to get execution engine response", e);
return new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.INTERNAL_ERROR);
return new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INTERNAL_ERROR);
}
}

@ -16,10 +16,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork;
import org.hyperledger.besu.plugin.data.EnodeURL;
@ -54,11 +54,11 @@ public class NetEnode implements JsonRpcMethod {
}
private JsonRpcErrorResponse p2pDisabledResponse(final JsonRpcRequestContext requestContext) {
return new JsonRpcErrorResponse(requestContext.getRequest().getId(), JsonRpcError.P2P_DISABLED);
return new JsonRpcErrorResponse(requestContext.getRequest().getId(), RpcErrorType.P2P_DISABLED);
}
private JsonRpcErrorResponse enodeUrlNotAvailable(final JsonRpcRequestContext requestContext) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.P2P_NETWORK_NOT_RUNNING);
requestContext.getRequest().getId(), RpcErrorType.P2P_NETWORK_NOT_RUNNING);
}
}

@ -16,10 +16,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity;
import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork;
import org.hyperledger.besu.ethereum.p2p.network.exceptions.P2PDisabledException;
@ -43,7 +43,7 @@ public class NetPeerCount implements JsonRpcMethod {
requestContext.getRequest().getId(), Quantity.create(p2pNetwork.getPeerCount()));
} catch (final P2PDisabledException e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.P2P_DISABLED);
requestContext.getRequest().getId(), RpcErrorType.P2P_DISABLED);
}
}
}

@ -14,8 +14,8 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.INTERNAL_ERROR;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.PLUGIN_INTERNAL_ERROR;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INTERNAL_ERROR;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.PLUGIN_INTERNAL_ERROR;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
@ -53,13 +53,13 @@ public class PluginJsonRpcMethod implements JsonRpcMethod {
final Object result = function.apply(() -> request.getRequest().getParams());
return new JsonRpcSuccessResponse(request.getRequest().getId(), result);
} catch (final PluginRpcEndpointException ex) {
final JsonRpcError error = PLUGIN_INTERNAL_ERROR;
error.setData(ex.getMessage());
final JsonRpcError error = new JsonRpcError(PLUGIN_INTERNAL_ERROR, ex.getMessage());
LOG.error("Error calling plugin JSON-RPC endpoint", ex);
return new JsonRpcErrorResponse(request.getRequest().getId(), error);
} catch (final Exception ex) {
LOG.error("Error calling plugin JSON-RPC endpoint", ex);
return new JsonRpcErrorResponse(request.getRequest().getId(), INTERNAL_ERROR);
return new JsonRpcErrorResponse(
request.getRequest().getId(), new JsonRpcError(INTERNAL_ERROR));
}
}
}

@ -17,10 +17,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.plugin.BesuPlugin;
import java.util.Map;
@ -52,13 +52,13 @@ public class PluginsReloadConfiguration implements JsonRpcMethod {
"Plugin cannot be reloaded because no plugin has been registered with specified name: {}.",
pluginName);
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.PLUGIN_NOT_FOUND);
requestContext.getRequest().getId(), RpcErrorType.PLUGIN_NOT_FOUND);
}
reloadPluginConfig(namedPlugins.get(pluginName));
return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
} catch (InvalidJsonRpcParameters invalidJsonRpcParameters) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
}

@ -14,8 +14,8 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.BLOCK_NOT_FOUND;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.INTERNAL_ERROR;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.BLOCK_NOT_FOUND;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INTERNAL_ERROR;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;

@ -14,8 +14,8 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.BLOCK_NOT_FOUND;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.INTERNAL_ERROR;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.BLOCK_NOT_FOUND;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INTERNAL_ERROR;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
@ -24,8 +24,8 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonCallPar
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceCallManyParameter;
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.JsonRpcError;
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.core.BlockHeader;
@ -79,7 +79,7 @@ public class TraceCallMany extends TraceCall implements JsonRpcMethod {
if (requestContext.getRequest().getParamLength() != 2) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
final TraceCallManyParameter[] transactionsAndTraceTypeParameters;
@ -96,7 +96,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(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
final Optional<BlockHeader> maybeBlockHeader =

@ -18,10 +18,10 @@ 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.processor.BlockTracer;
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;
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;
@ -51,7 +51,7 @@ public class TraceGet extends AbstractTraceByHash implements JsonRpcMethod {
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
if (requestContext.getRequest().getParamLength() != 2) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
final Hash transactionHash = requestContext.getRequiredParameter(0, Hash.class);

@ -14,16 +14,16 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.INTERNAL_ERROR;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INTERNAL_ERROR;
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.parameters.TraceTypeParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.api.util.DomainObjectDecodeUtils;
import org.hyperledger.besu.ethereum.core.Block;
@ -67,7 +67,7 @@ public class TraceRawTransaction extends AbstractTraceByBlock implements JsonRpc
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
if (requestContext.getRequest().getParamLength() != 2) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
final var rawTransaction = requestContext.getRequiredParameter(0, String.class);
@ -85,7 +85,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(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
final Set<TraceTypeParameter.TraceType> traceTypes = traceTypeParameter.getTraceTypes();

@ -17,10 +17,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.crypto.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.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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.apache.tuweni.bytes.Bytes;
@ -38,14 +38,14 @@ public class Web3Sha3 implements JsonRpcMethod {
if (requestContext.getRequest().getParamLength() != 1) {
// Do we want custom messages for each different type of invalid params?
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
final String data = requestContext.getRequiredParameter(0, String.class);
if (!data.isEmpty() && !data.startsWith("0x")) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
try {
@ -54,7 +54,7 @@ public class Web3Sha3 implements JsonRpcMethod {
requestContext.getRequest().getId(), Hash.keccak256(byteData).toString());
} catch (final IllegalArgumentException err) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
}
}
}

@ -30,10 +30,10 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngin
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EngineForkchoiceUpdatedParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadAttributesParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EngineUpdateForkchoiceResult;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Withdrawal;
@ -113,7 +113,7 @@ public abstract class AbstractEngineForkchoiceUpdated extends ExecutionEngineJso
if (!isValidForkchoiceState(
forkChoice.getSafeBlockHash(), forkChoice.getFinalizedBlockHash(), newHead)) {
logForkchoiceUpdatedCall(INVALID, forkChoice);
return new JsonRpcErrorResponse(requestId, JsonRpcError.INVALID_FORKCHOICE_STATE);
return new JsonRpcErrorResponse(requestId, RpcErrorType.INVALID_FORKCHOICE_STATE);
}
// TODO: post-merge cleanup, this should be unnecessary after merge
@ -310,8 +310,8 @@ public abstract class AbstractEngineForkchoiceUpdated extends ExecutionEngineJso
return false;
}
protected JsonRpcError getInvalidPayloadError() {
return JsonRpcError.INVALID_PARAMS;
protected RpcErrorType getInvalidPayloadError() {
return RpcErrorType.INVALID_PARAMS;
}
// fcU calls are synchronous, no need to make volatile

@ -20,9 +20,9 @@ import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod;
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.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResultFactory;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockWithReceipts;
@ -63,7 +63,7 @@ public abstract class AbstractEngineGetPayload extends ExecutionEngineJsonRpcMet
LOG.atDebug().setMessage("assembledBlock {}").addArgument(() -> proposal).log();
return createResponse(request, payloadId, proposal);
}
return new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.UNKNOWN_PAYLOAD);
return new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.UNKNOWN_PAYLOAD);
}
protected void logProposal(

@ -22,7 +22,7 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.Executi
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.VALID;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.DepositsValidatorProvider.getDepositsValidator;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.WithdrawalsValidatorProvider.getWithdrawalsValidator;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.INVALID_PARAMS;
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.Hash;
@ -34,10 +34,10 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngin
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameter;
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.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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EnginePayloadStatusResult;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockBody;
@ -261,7 +261,7 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet
if (executionResult.causedBy().isPresent()) {
Throwable causedBy = executionResult.causedBy().get();
if (causedBy instanceof StorageException || causedBy instanceof MerkleTrieException) {
JsonRpcError error = JsonRpcError.INTERNAL_ERROR;
RpcErrorType error = RpcErrorType.INTERNAL_ERROR;
JsonRpcErrorResponse response = new JsonRpcErrorResponse(reqId, error);
return response;
}

@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import io.vertx.core.Vertx;
@ -44,7 +44,7 @@ public class EngineForkchoiceUpdatedV1 extends AbstractEngineForkchoiceUpdated {
}
@Override
protected JsonRpcError getInvalidPayloadError() {
return JsonRpcError.INVALID_PAYLOAD_ATTRIBUTES;
protected RpcErrorType getInvalidPayloadError() {
return RpcErrorType.INVALID_PAYLOAD_ATTRIBUTES;
}
}

@ -19,10 +19,10 @@ 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.methods.ExecutionEngineJsonRpcMethod;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResultFactory;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EngineGetPayloadBodiesResultV1;
import org.hyperledger.besu.ethereum.chain.Blockchain;
@ -69,7 +69,7 @@ public class EngineGetPayloadBodiesByHashV1 extends ExecutionEngineJsonRpcMethod
.log();
if (blockHashes.length > getMaxRequestBlocks()) {
return new JsonRpcErrorResponse(reqId, JsonRpcError.INVALID_RANGE_REQUEST_TOO_LARGE);
return new JsonRpcErrorResponse(reqId, RpcErrorType.INVALID_RANGE_REQUEST_TOO_LARGE);
}
final Blockchain blockchain = protocolContext.getBlockchain();

@ -19,10 +19,10 @@ 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.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.UnsignedLongParameter;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResultFactory;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EngineGetPayloadBodiesResultV1;
import org.hyperledger.besu.ethereum.chain.Blockchain;
@ -70,11 +70,11 @@ public class EngineGetPayloadBodiesByRangeV1 extends ExecutionEngineJsonRpcMetho
.log();
if (startBlockNumber < 1 || count < 1) {
return new JsonRpcErrorResponse(reqId, JsonRpcError.INVALID_PARAMS);
return new JsonRpcErrorResponse(reqId, RpcErrorType.INVALID_PARAMS);
}
if (count > getMaxRequestBlocks()) {
return new JsonRpcErrorResponse(reqId, JsonRpcError.INVALID_RANGE_REQUEST_TOO_LARGE);
return new JsonRpcErrorResponse(reqId, RpcErrorType.INVALID_RANGE_REQUEST_TOO_LARGE);
}
final Blockchain blockchain = protocolContext.getBlockchain();

@ -26,10 +26,10 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePreparePayloadParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EnginePreparePayloadResult;
import org.hyperledger.besu.ethereum.core.Withdrawal;
@ -80,7 +80,7 @@ public class EnginePreparePayloadDebug extends ExecutionEngineJsonRpcMethod {
payloadIdentifier ->
new JsonRpcSuccessResponse(
requestId, new EnginePreparePayloadResult(VALID, payloadIdentifier)))
.orElseGet(() -> new JsonRpcErrorResponse(requestId, JsonRpcError.INVALID_PARAMS));
.orElseGet(() -> new JsonRpcErrorResponse(requestId, RpcErrorType.INVALID_PARAMS));
}
@VisibleForTesting

@ -17,10 +17,10 @@ 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.methods.JsonRpcMethod;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
public class MinerChangeTargetGasLimit implements JsonRpcMethod {
@ -43,11 +43,11 @@ public class MinerChangeTargetGasLimit implements JsonRpcMethod {
return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
} catch (final IllegalArgumentException invalidJsonRpcParameters) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
} catch (final UnsupportedOperationException unsupportedOperationException) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(),
JsonRpcError.TARGET_GAS_LIMIT_MODIFICATION_UNSUPPORTED);
RpcErrorType.TARGET_GAS_LIMIT_MODIFICATION_UNSUPPORTED);
}
}
}

@ -18,10 +18,10 @@ 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.methods.JsonRpcMethod;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
public class MinerSetCoinbase implements JsonRpcMethod {
@ -45,7 +45,7 @@ public class MinerSetCoinbase implements JsonRpcMethod {
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), true);
} catch (final UnsupportedOperationException ex) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_REQUEST);
requestContext.getRequest().getId(), RpcErrorType.INVALID_REQUEST);
}
}
}

@ -17,10 +17,10 @@ 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.methods.JsonRpcMethod;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.blockcreation.CoinbaseNotSetException;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
@ -44,7 +44,7 @@ public class MinerStart implements JsonRpcMethod {
enabled = miningCoordinator.enable();
} catch (final CoinbaseNotSetException e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.COINBASE_NOT_SET);
requestContext.getRequest().getId(), RpcErrorType.COINBASE_NOT_SET);
}
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), enabled);

@ -17,10 +17,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning
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.methods.JsonRpcMethod;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController;
import org.hyperledger.besu.ethereum.permissioning.AllowlistOperationResult;
@ -53,22 +53,22 @@ public class PermAddAccountsToAllowlist implements JsonRpcMethod {
switch (addResult) {
case ERROR_EMPTY_ENTRY:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ACCOUNT_ALLOWLIST_EMPTY_ENTRY);
requestContext.getRequest().getId(), RpcErrorType.ACCOUNT_ALLOWLIST_EMPTY_ENTRY);
case ERROR_INVALID_ENTRY:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ACCOUNT_ALLOWLIST_INVALID_ENTRY);
requestContext.getRequest().getId(), RpcErrorType.ACCOUNT_ALLOWLIST_INVALID_ENTRY);
case ERROR_EXISTING_ENTRY:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ACCOUNT_ALLOWLIST_EXISTING_ENTRY);
requestContext.getRequest().getId(), RpcErrorType.ACCOUNT_ALLOWLIST_EXISTING_ENTRY);
case ERROR_DUPLICATED_ENTRY:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ACCOUNT_ALLOWLIST_DUPLICATED_ENTRY);
requestContext.getRequest().getId(), RpcErrorType.ACCOUNT_ALLOWLIST_DUPLICATED_ENTRY);
case ERROR_ALLOWLIST_PERSIST_FAIL:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ALLOWLIST_PERSIST_FAILURE);
requestContext.getRequest().getId(), RpcErrorType.ALLOWLIST_PERSIST_FAILURE);
case ERROR_ALLOWLIST_FILE_SYNC:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ALLOWLIST_FILE_SYNC);
requestContext.getRequest().getId(), RpcErrorType.ALLOWLIST_FILE_SYNC);
case SUCCESS:
return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
default:
@ -77,7 +77,7 @@ public class PermAddAccountsToAllowlist implements JsonRpcMethod {
}
} else {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ACCOUNT_ALLOWLIST_NOT_ENABLED);
requestContext.getRequest().getId(), RpcErrorType.ACCOUNT_ALLOWLIST_NOT_ENABLED);
}
}
}

@ -18,10 +18,10 @@ 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.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.StringListParameter;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.p2p.network.exceptions.P2PDisabledException;
import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController;
import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult;
@ -61,37 +61,37 @@ public class PermAddNodesToAllowlist implements JsonRpcMethod {
return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
case ERROR_EMPTY_ENTRY:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY);
requestContext.getRequest().getId(), RpcErrorType.NODE_ALLOWLIST_EMPTY_ENTRY);
case ERROR_EXISTING_ENTRY:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EXISTING_ENTRY);
requestContext.getRequest().getId(), RpcErrorType.NODE_ALLOWLIST_EXISTING_ENTRY);
case ERROR_DUPLICATED_ENTRY:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(),
JsonRpcError.NODE_ALLOWLIST_DUPLICATED_ENTRY);
RpcErrorType.NODE_ALLOWLIST_DUPLICATED_ENTRY);
case ERROR_ALLOWLIST_PERSIST_FAIL:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ALLOWLIST_PERSIST_FAILURE);
requestContext.getRequest().getId(), RpcErrorType.ALLOWLIST_PERSIST_FAILURE);
case ERROR_ALLOWLIST_FILE_SYNC:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ALLOWLIST_FILE_SYNC);
requestContext.getRequest().getId(), RpcErrorType.ALLOWLIST_FILE_SYNC);
default:
throw new Exception();
}
} catch (IllegalArgumentException e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_INVALID_ENTRY);
requestContext.getRequest().getId(), RpcErrorType.NODE_ALLOWLIST_INVALID_ENTRY);
} catch (Exception e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INTERNAL_ERROR);
requestContext.getRequest().getId(), RpcErrorType.INTERNAL_ERROR);
}
} else {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_NOT_ENABLED);
requestContext.getRequest().getId(), RpcErrorType.NODE_ALLOWLIST_NOT_ENABLED);
}
} catch (P2PDisabledException e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.P2P_DISABLED);
requestContext.getRequest().getId(), RpcErrorType.P2P_DISABLED);
}
}
}

@ -17,10 +17,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning
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.methods.JsonRpcMethod;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController;
import java.util.Optional;
@ -46,7 +46,7 @@ public class PermGetAccountsAllowlist implements JsonRpcMethod {
requestContext.getRequest().getId(), allowlistController.get().getAccountAllowlist());
} else {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ACCOUNT_ALLOWLIST_NOT_ENABLED);
requestContext.getRequest().getId(), RpcErrorType.ACCOUNT_ALLOWLIST_NOT_ENABLED);
}
}
}

@ -17,10 +17,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning
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.methods.JsonRpcMethod;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.p2p.network.exceptions.P2PDisabledException;
import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController;
@ -52,11 +52,11 @@ public class PermGetNodesAllowlist implements JsonRpcMethod {
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), enodeList);
} else {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_NOT_ENABLED);
requestContext.getRequest().getId(), RpcErrorType.NODE_ALLOWLIST_NOT_ENABLED);
}
} catch (P2PDisabledException e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.P2P_DISABLED);
requestContext.getRequest().getId(), RpcErrorType.P2P_DISABLED);
}
}
}

@ -17,10 +17,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning
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.methods.JsonRpcMethod;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController;
import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController;
@ -47,7 +47,7 @@ public class PermReloadPermissionsFromFile implements JsonRpcMethod {
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
if (!accountAllowlistController.isPresent() && !nodesAllowlistController.isPresent()) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.PERMISSIONING_NOT_ENABLED);
requestContext.getRequest().getId(), RpcErrorType.PERMISSIONING_NOT_ENABLED);
}
try {
@ -56,7 +56,7 @@ public class PermReloadPermissionsFromFile implements JsonRpcMethod {
return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
} catch (Exception e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ALLOWLIST_RELOAD_ERROR);
requestContext.getRequest().getId(), RpcErrorType.ALLOWLIST_RELOAD_ERROR);
}
}
}

@ -17,10 +17,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning
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.methods.JsonRpcMethod;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController;
import org.hyperledger.besu.ethereum.permissioning.AllowlistOperationResult;
@ -52,22 +52,22 @@ public class PermRemoveAccountsFromAllowlist implements JsonRpcMethod {
switch (removeResult) {
case ERROR_EMPTY_ENTRY:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ACCOUNT_ALLOWLIST_EMPTY_ENTRY);
requestContext.getRequest().getId(), RpcErrorType.ACCOUNT_ALLOWLIST_EMPTY_ENTRY);
case ERROR_INVALID_ENTRY:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ACCOUNT_ALLOWLIST_INVALID_ENTRY);
requestContext.getRequest().getId(), RpcErrorType.ACCOUNT_ALLOWLIST_INVALID_ENTRY);
case ERROR_ABSENT_ENTRY:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ACCOUNT_ALLOWLIST_ABSENT_ENTRY);
requestContext.getRequest().getId(), RpcErrorType.ACCOUNT_ALLOWLIST_ABSENT_ENTRY);
case ERROR_DUPLICATED_ENTRY:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ACCOUNT_ALLOWLIST_DUPLICATED_ENTRY);
requestContext.getRequest().getId(), RpcErrorType.ACCOUNT_ALLOWLIST_DUPLICATED_ENTRY);
case ERROR_ALLOWLIST_PERSIST_FAIL:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ALLOWLIST_PERSIST_FAILURE);
requestContext.getRequest().getId(), RpcErrorType.ALLOWLIST_PERSIST_FAILURE);
case ERROR_ALLOWLIST_FILE_SYNC:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ALLOWLIST_FILE_SYNC);
requestContext.getRequest().getId(), RpcErrorType.ALLOWLIST_FILE_SYNC);
case SUCCESS:
return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
default:
@ -76,7 +76,7 @@ public class PermRemoveAccountsFromAllowlist implements JsonRpcMethod {
}
} else {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ACCOUNT_ALLOWLIST_NOT_ENABLED);
requestContext.getRequest().getId(), RpcErrorType.ACCOUNT_ALLOWLIST_NOT_ENABLED);
}
}
}

@ -18,10 +18,10 @@ 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.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.StringListParameter;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.p2p.network.exceptions.P2PDisabledException;
import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController;
import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult;
@ -60,41 +60,41 @@ public class PermRemoveNodesFromAllowlist implements JsonRpcMethod {
return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
case ERROR_EMPTY_ENTRY:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY);
requestContext.getRequest().getId(), RpcErrorType.NODE_ALLOWLIST_EMPTY_ENTRY);
case ERROR_ABSENT_ENTRY:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_MISSING_ENTRY);
requestContext.getRequest().getId(), RpcErrorType.NODE_ALLOWLIST_MISSING_ENTRY);
case ERROR_DUPLICATED_ENTRY:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(),
JsonRpcError.NODE_ALLOWLIST_DUPLICATED_ENTRY);
RpcErrorType.NODE_ALLOWLIST_DUPLICATED_ENTRY);
case ERROR_ALLOWLIST_PERSIST_FAIL:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ALLOWLIST_PERSIST_FAILURE);
requestContext.getRequest().getId(), RpcErrorType.ALLOWLIST_PERSIST_FAILURE);
case ERROR_ALLOWLIST_FILE_SYNC:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.ALLOWLIST_FILE_SYNC);
requestContext.getRequest().getId(), RpcErrorType.ALLOWLIST_FILE_SYNC);
case ERROR_FIXED_NODE_CANNOT_BE_REMOVED:
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(),
JsonRpcError.NODE_ALLOWLIST_FIXED_NODE_CANNOT_BE_REMOVED);
RpcErrorType.NODE_ALLOWLIST_FIXED_NODE_CANNOT_BE_REMOVED);
default:
throw new Exception();
}
} catch (IllegalArgumentException e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_INVALID_ENTRY);
requestContext.getRequest().getId(), RpcErrorType.NODE_ALLOWLIST_INVALID_ENTRY);
} catch (Exception e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INTERNAL_ERROR);
requestContext.getRequest().getId(), RpcErrorType.INTERNAL_ERROR);
}
} else {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_NOT_ENABLED);
requestContext.getRequest().getId(), RpcErrorType.NODE_ALLOWLIST_NOT_ENABLED);
}
} catch (P2PDisabledException e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.P2P_DISABLED);
requestContext.getRequest().getId(), RpcErrorType.P2P_DISABLED);
}
}
}

@ -16,9 +16,9 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
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.RpcErrorType;
public class DisabledPrivacyRpcMethod implements JsonRpcMethod {
@ -36,6 +36,6 @@ public class DisabledPrivacyRpcMethod implements JsonRpcMethod {
@Override
public final JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.PRIVACY_NOT_ENABLED);
requestContext.getRequest().getId(), RpcErrorType.PRIVACY_NOT_ENABLED);
}
}

@ -16,10 +16,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
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.JsonRpcUnauthorizedResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import java.util.Optional;
@ -46,10 +46,10 @@ public class MultiTenancyRpcMethodDecorator implements JsonRpcMethod {
final Object id = requestContext.getRequest().getId();
if (user.isEmpty()) {
LOG.error("Request does not contain an authorization token");
return new JsonRpcUnauthorizedResponse(id, JsonRpcError.UNAUTHORIZED);
return new JsonRpcUnauthorizedResponse(id, RpcErrorType.UNAUTHORIZED);
} else if (MultiTenancyUserUtil.privacyUserId(user).isEmpty()) {
LOG.error("Request token does not contain an enclave public key");
return new JsonRpcErrorResponse(id, JsonRpcError.INVALID_REQUEST);
return new JsonRpcErrorResponse(id, RpcErrorType.INVALID_REQUEST);
} else {
return rpcMethod.response(requestContext);
}

@ -18,10 +18,10 @@ 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.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.LogsResult;
import org.hyperledger.besu.ethereum.core.LogWithMetadata;
import org.hyperledger.besu.ethereum.privacy.MultiTenancyPrivacyController;
@ -63,7 +63,7 @@ public class PrivGetFilterChanges implements JsonRpcMethod {
}
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.FILTER_NOT_FOUND);
requestContext.getRequest().getId(), RpcErrorType.FILTER_NOT_FOUND);
}
private void checkIfPrivacyGroupMatchesAuthenticatedPrivacyUserId(

@ -18,10 +18,10 @@ 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.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.LogsResult;
import org.hyperledger.besu.ethereum.core.LogWithMetadata;
import org.hyperledger.besu.ethereum.privacy.MultiTenancyPrivacyController;
@ -64,7 +64,7 @@ public class PrivGetFilterLogs implements JsonRpcMethod {
}
return new JsonRpcErrorResponse(
request.getRequest().getId(), JsonRpcError.LOGS_FILTER_NOT_FOUND);
request.getRequest().getId(), RpcErrorType.LOGS_FILTER_NOT_FOUND);
}
private void checkIfPrivacyGroupMatchesAuthenticatedPrivacyUserId(

@ -16,7 +16,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea;
import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcEnclaveErrorConverter.convertEnclaveInvalidReason;
import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcErrorConverter.convertTransactionInvalidReason;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.DECODE_ERROR;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.DECODE_ERROR;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.TransactionType;
@ -25,10 +25,10 @@ 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.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider;
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;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
@ -112,7 +112,7 @@ public abstract class AbstractEeaSendRawTransaction implements JsonRpcMethod {
JsonRpcErrorResponse getJsonRpcErrorResponse(
final Object id, final TransactionInvalidReason errorReason) {
if (errorReason.equals(TransactionInvalidReason.INTRINSIC_GAS_EXCEEDS_GAS_LIMIT)) {
return new JsonRpcErrorResponse(id, JsonRpcError.PMT_FAILED_INTRINSIC_GAS_EXCEEDS_LIMIT);
return new JsonRpcErrorResponse(id, RpcErrorType.PMT_FAILED_INTRINSIC_GAS_EXCEEDS_LIMIT);
}
return new JsonRpcErrorResponse(id, convertTransactionInvalidReason(errorReason));
}

@ -14,18 +14,18 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
public class JsonRpcErrorResponseException extends RuntimeException {
private final JsonRpcError jsonRpcError;
private final RpcErrorType jsonRpcError;
public JsonRpcErrorResponseException(final JsonRpcError error) {
public JsonRpcErrorResponseException(final RpcErrorType error) {
super();
this.jsonRpcError = error;
}
public JsonRpcError getJsonRpcError() {
public RpcErrorType getJsonRpcError() {
return jsonRpcError;
}
}

@ -19,7 +19,7 @@ import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIV
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.enclave.types.PrivacyGroup;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
@ -71,7 +71,7 @@ public class RestrictedFlexibleEeaSendRawTransaction extends AbstractEeaSendRawT
final Optional<User> user) {
final Optional<Bytes> maybePrivacyGroupId = privateTransaction.getPrivacyGroupId();
if (maybePrivacyGroupId.isEmpty()) {
throw new JsonRpcErrorResponseException(JsonRpcError.FLEXIBLE_PRIVACY_GROUP_ID_NOT_AVAILABLE);
throw new JsonRpcErrorResponseException(RpcErrorType.FLEXIBLE_PRIVACY_GROUP_ID_NOT_AVAILABLE);
}
final Bytes privacyGroupId = maybePrivacyGroupId.get();
@ -83,7 +83,7 @@ public class RestrictedFlexibleEeaSendRawTransaction extends AbstractEeaSendRawT
final boolean isGroupAdditionTransaction =
FlexibleUtil.isGroupAdditionTransaction(privateTransaction);
if (maybePrivacyGroup.isEmpty() && !isGroupAdditionTransaction) {
throw new JsonRpcErrorResponseException(JsonRpcError.FLEXIBLE_PRIVACY_GROUP_DOES_NOT_EXIST);
throw new JsonRpcErrorResponseException(RpcErrorType.FLEXIBLE_PRIVACY_GROUP_DOES_NOT_EXIST);
}
if (isGroupAdditionTransaction) {
@ -104,7 +104,7 @@ public class RestrictedFlexibleEeaSendRawTransaction extends AbstractEeaSendRawT
}
if (!maybePrivacyGroup.get().getMembers().contains(privacyUserId)) {
throw new JsonRpcErrorResponseException(JsonRpcError.FLEXIBLE_PRIVACY_GROUP_DOES_NOT_EXIST);
throw new JsonRpcErrorResponseException(RpcErrorType.FLEXIBLE_PRIVACY_GROUP_DOES_NOT_EXIST);
}
final String pmtPayload =

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save