diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/DiscardTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/DiscardTest.java index f5810520fc7..038f97e1e74 100644 --- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/DiscardTest.java +++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/DiscardTest.java @@ -28,9 +28,9 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponseType; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.chain.Blockchain; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -61,7 +61,7 @@ public void discardEmpty() { final JsonRpcResponse response = discard.response(requestWithParams(a0)); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(response.getType()).isEqualTo(RpcResponseType.SUCCESS); final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response; assertThat(successResponse.getResult()).isEqualTo(true); assertThat(validatorProvider.getVoteProviderAtHead().get().getProposals().get(a0)).isNull(); @@ -77,7 +77,7 @@ public void discardAuth() { final JsonRpcResponse response = discard.response(requestWithParams(a0)); assertThat(validatorProvider.getVoteProviderAtHead().get().getProposals().get(a0)).isNull(); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(response.getType()).isEqualTo(RpcResponseType.SUCCESS); final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response; assertThat(successResponse.getResult()).isEqualTo(true); } @@ -92,7 +92,7 @@ public void discardDrop() { final JsonRpcResponse response = discard.response(requestWithParams(a0)); assertThat(validatorProvider.getVoteProviderAtHead().get().getProposals().get(a0)).isNull(); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(response.getType()).isEqualTo(RpcResponseType.SUCCESS); final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response; assertThat(successResponse.getResult()).isEqualTo(true); } @@ -111,7 +111,7 @@ public void discardIsolation() { assertThat(validatorProvider.getVoteProviderAtHead().get().getProposals().get(a0)).isNull(); assertThat(validatorProvider.getVoteProviderAtHead().get().getProposals().get(a1)) .isEqualTo(VoteType.ADD); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(response.getType()).isEqualTo(RpcResponseType.SUCCESS); final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response; assertThat(successResponse.getResult()).isEqualTo(true); } diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/ProposeTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/ProposeTest.java index efbc78542c5..7e7d7bf7704 100644 --- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/ProposeTest.java +++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/ProposeTest.java @@ -27,10 +27,10 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; 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.hyperledger.besu.plugin.services.rpc.RpcResponseType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -59,7 +59,7 @@ public void testAuth() { assertThat(validatorProvider.getVoteProviderAtHead().get().getProposals().get(a1)) .isEqualTo(VoteType.ADD); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(response.getType()).isEqualTo(RpcResponseType.SUCCESS); final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response; assertThat(successResponse.getResult()).isEqualTo(true); } @@ -72,7 +72,7 @@ public void testAuthWithAddressZeroResultsInError() { final JsonRpcResponse response = propose.response(requestWithParams(a0, true)); assertThat(validatorProvider.getVoteProviderAtHead().get().getProposals().get(a0)).isNull(); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.ERROR); + assertThat(response.getType()).isEqualTo(RpcResponseType.ERROR); final JsonRpcErrorResponse errorResponse = (JsonRpcErrorResponse) response; assertThat(errorResponse.getErrorType()).isEqualTo(RpcErrorType.INVALID_REQUEST); } @@ -86,7 +86,7 @@ public void testDrop() { assertThat(validatorProvider.getVoteProviderAtHead().get().getProposals().get(a1)) .isEqualTo(VoteType.DROP); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(response.getType()).isEqualTo(RpcResponseType.SUCCESS); final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response; assertThat(successResponse.getResult()).isEqualTo(true); } @@ -99,7 +99,7 @@ public void testDropWithAddressZeroResultsInError() { final JsonRpcResponse response = propose.response(requestWithParams(a0, false)); assertThat(validatorProvider.getVoteProviderAtHead().get().getProposals().get(a0)).isNull(); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.ERROR); + assertThat(response.getType()).isEqualTo(RpcResponseType.ERROR); final JsonRpcErrorResponse errorResponse = (JsonRpcErrorResponse) response; assertThat(errorResponse.getErrorType()).isEqualTo(RpcErrorType.INVALID_REQUEST); } @@ -114,7 +114,7 @@ public void testRepeatAuth() { assertThat(validatorProvider.getVoteProviderAtHead().get().getProposals().get(a1)) .isEqualTo(VoteType.ADD); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(response.getType()).isEqualTo(RpcResponseType.SUCCESS); final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response; assertThat(successResponse.getResult()).isEqualTo(true); } @@ -129,7 +129,7 @@ public void testRepeatDrop() { assertThat(validatorProvider.getVoteProviderAtHead().get().getProposals().get(a1)) .isEqualTo(VoteType.DROP); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(response.getType()).isEqualTo(RpcResponseType.SUCCESS); final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response; assertThat(successResponse.getResult()).isEqualTo(true); } @@ -144,7 +144,7 @@ public void testChangeToAuth() { assertThat(validatorProvider.getVoteProviderAtHead().get().getProposals().get(a1)) .isEqualTo(VoteType.ADD); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(response.getType()).isEqualTo(RpcResponseType.SUCCESS); final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response; assertThat(successResponse.getResult()).isEqualTo(true); } @@ -159,7 +159,7 @@ public void testChangeToDrop() { assertThat(validatorProvider.getVoteProviderAtHead().get().getProposals().get(a0)) .isEqualTo(VoteType.DROP); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(response.getType()).isEqualTo(RpcResponseType.SUCCESS); final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response; assertThat(successResponse.getResult()).isEqualTo(true); } diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/DebugTraceTransactionIntegrationTest.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/DebugTraceTransactionIntegrationTest.java index d285ef3816d..5b488987169 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/DebugTraceTransactionIntegrationTest.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/DebugTraceTransactionIntegrationTest.java @@ -23,9 +23,9 @@ 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.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.results.DebugTraceTransactionResult; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; import org.hyperledger.besu.testutil.BlockTestUtil; import java.util.Map; @@ -69,7 +69,7 @@ public void debugTraceTransactionSuccessTest() { new JsonRpcRequestContext(new JsonRpcRequest("2.0", DEBUG_TRACE_TRANSACTION, params)); final JsonRpcResponse response = method.response(request); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(response.getType()).isEqualTo(RpcResponseType.SUCCESS); DebugTraceTransactionResult debugTraceTransactionResult = (DebugTraceTransactionResult) ((JsonRpcSuccessResponse) response).getResult(); assertThat(debugTraceTransactionResult.getGas()).isEqualTo(23705L); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcArrayExecutor.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcArrayExecutor.java index 5a839d8ad07..72d6c5b6152 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcArrayExecutor.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcArrayExecutor.java @@ -22,8 +22,8 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.execution.JsonRpcExecutor; 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 org.hyperledger.besu.plugin.services.rpc.RpcResponseType; import java.io.IOException; @@ -74,7 +74,7 @@ public void executeRpcRequestBatch( generator.writeStartArray(); for (int i = 0; i < rpcRequestBatch.size(); i++) { JsonRpcResponse response = processMaybeRequest(rpcRequestBatch.getValue(i)); - if (response.getType() != JsonRpcResponseType.NONE) { + if (response.getType() != RpcResponseType.NONE) { generator.writeObject(response); } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcObjectExecutor.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcObjectExecutor.java index d2a2cb37428..70c78e9ab3e 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcObjectExecutor.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcObjectExecutor.java @@ -22,8 +22,8 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.execution.JsonRpcExecutor; 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 org.hyperledger.besu.plugin.services.rpc.RpcResponseType; import java.io.IOException; @@ -70,7 +70,7 @@ private void handleJsonObjectResponse( final RoutingContext ctx) throws IOException { response.setStatusCode(status(jsonRpcResponse).code()); - if (jsonRpcResponse.getType() == JsonRpcResponseType.NONE) { + if (jsonRpcResponse.getType() == RpcResponseType.NONE) { response.end(); } else { try (final JsonResponseStreamer streamer = diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/TracedJsonRpcProcessor.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/TracedJsonRpcProcessor.java index c40c8f8c1f6..369e425b6fe 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/TracedJsonRpcProcessor.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/TracedJsonRpcProcessor.java @@ -19,11 +19,11 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponseType; import org.hyperledger.besu.metrics.BesuMetricCategory; import org.hyperledger.besu.plugin.services.MetricsSystem; import org.hyperledger.besu.plugin.services.metrics.Counter; import org.hyperledger.besu.plugin.services.metrics.LabelledMetric; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; import io.opentelemetry.api.trace.Span; import io.opentelemetry.api.trace.StatusCode; @@ -52,7 +52,7 @@ public JsonRpcResponse process( final Span metricSpan, final JsonRpcRequestContext request) { JsonRpcResponse jsonRpcResponse = rpcProcessor.process(id, method, metricSpan, request); - if (JsonRpcResponseType.ERROR == jsonRpcResponse.getType()) { + if (RpcResponseType.ERROR == jsonRpcResponse.getType()) { JsonRpcErrorResponse errorResponse = (JsonRpcErrorResponse) jsonRpcResponse; this.rpcErrorsCounter.labels(method.getName(), errorResponse.getErrorType().name()).inc(); switch (errorResponse.getErrorType()) { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcErrorResponse.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcErrorResponse.java index 3dffff4956a..4cfd7a1df37 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcErrorResponse.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcErrorResponse.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.response; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; import java.util.Arrays; import java.util.Collections; @@ -72,8 +73,8 @@ public JsonRpcError getError() { @Override @JsonIgnore - public JsonRpcResponseType getType() { - return JsonRpcResponseType.ERROR; + public RpcResponseType getType() { + return RpcResponseType.ERROR; } @Override diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcNoResponse.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcNoResponse.java index b7391a867b8..92a63174ac9 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcNoResponse.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcNoResponse.java @@ -14,10 +14,12 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.response; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; + public class JsonRpcNoResponse implements JsonRpcResponse { @Override - public JsonRpcResponseType getType() { - return JsonRpcResponseType.NONE; + public RpcResponseType getType() { + return RpcResponseType.NONE; } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcResponse.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcResponse.java index 3b308ff9d7e..6817d2cfbbd 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcResponse.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcResponse.java @@ -14,6 +14,8 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.response; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; + import com.fasterxml.jackson.annotation.JsonGetter; public interface JsonRpcResponse { @@ -23,5 +25,5 @@ default String getVersion() { return "2.0"; } - JsonRpcResponseType getType(); + RpcResponseType getType(); } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcSuccessResponse.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcSuccessResponse.java index 82b1b8835b7..e26e2cf972e 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcSuccessResponse.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcSuccessResponse.java @@ -14,6 +14,8 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.response; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; + import java.util.Objects; import com.fasterxml.jackson.annotation.JsonGetter; @@ -50,8 +52,8 @@ public Object getResult() { @Override @JsonIgnore - public JsonRpcResponseType getType() { - return JsonRpcResponseType.SUCCESS; + public RpcResponseType getType() { + return RpcResponseType.SUCCESS; } @Override diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcUnauthorizedResponse.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcUnauthorizedResponse.java index f59b49a30bd..cdf7661678b 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcUnauthorizedResponse.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcUnauthorizedResponse.java @@ -14,6 +14,8 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.response; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; + import java.util.Arrays; import java.util.Objects; @@ -50,8 +52,8 @@ public JsonRpcError getError() { @Override @JsonIgnore - public JsonRpcResponseType getType() { - return JsonRpcResponseType.UNAUTHORIZED; + public RpcResponseType getType() { + return RpcResponseType.UNAUTHORIZED; } @Override diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/ipc/JsonRpcIpcService.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/ipc/JsonRpcIpcService.java index 41214d9021a..b980c750d5c 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/ipc/JsonRpcIpcService.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/ipc/JsonRpcIpcService.java @@ -20,8 +20,8 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest; 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 org.hyperledger.besu.plugin.services.rpc.RpcResponseType; import java.io.IOException; import java.nio.file.Files; @@ -155,7 +155,7 @@ public Future start() { .filter( jsonRpcResponse -> jsonRpcResponse.getType() - != JsonRpcResponseType.NONE) + != RpcResponseType.NONE) .toArray(JsonRpcResponse[]::new); socket.write( diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketMessageHandler.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketMessageHandler.java index d88f6cba8e5..da7baa5084c 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketMessageHandler.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketMessageHandler.java @@ -20,10 +20,10 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.execution.JsonRpcExecutor; 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 org.hyperledger.besu.ethereum.api.jsonrpc.websocket.methods.WebSocketRpcRequest; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; import java.io.IOException; import java.util.ArrayList; @@ -151,7 +151,7 @@ public void handle( jsonRpcBatchResponse.stream() .filter( jsonRpcResponse -> - jsonRpcResponse.getType() != JsonRpcResponseType.NONE) + jsonRpcResponse.getType() != RpcResponseType.NONE) .toArray(JsonRpcResponse[]::new); replyToClient(websocket, completed); }) diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockByNumberTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockByNumberTest.java index 1c1cbaf6f78..b12cdbe22fd 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockByNumberTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockByNumberTest.java @@ -26,7 +26,6 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.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.api.jsonrpc.internal.results.BlockResult; @@ -41,6 +40,7 @@ import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; import java.util.List; @@ -146,7 +146,7 @@ public void exceptionWhenBoolParamInvalid() { @Test public void errorWhenAskingFinalizedButFinalizedIsNotPresent() { JsonRpcResponse resp = method.response(requestWithParams("finalized", "false")); - assertThat(resp.getType()).isEqualTo(JsonRpcResponseType.ERROR); + assertThat(resp.getType()).isEqualTo(RpcResponseType.ERROR); JsonRpcErrorResponse errorResp = (JsonRpcErrorResponse) resp; assertThat(errorResp.getErrorType()).isEqualTo(RpcErrorType.UNKNOWN_BLOCK); } @@ -154,7 +154,7 @@ public void errorWhenAskingFinalizedButFinalizedIsNotPresent() { @Test public void errorWhenAskingSafeButSafeIsNotPresent() { JsonRpcResponse resp = method.response(requestWithParams("safe", "false")); - assertThat(resp.getType()).isEqualTo(JsonRpcResponseType.ERROR); + assertThat(resp.getType()).isEqualTo(RpcResponseType.ERROR); JsonRpcErrorResponse errorResp = (JsonRpcErrorResponse) resp; assertThat(errorResp.getErrorType()).isEqualTo(RpcErrorType.UNKNOWN_BLOCK); } @@ -181,7 +181,7 @@ public void successWhenAskingSafe() { private void assertSuccess(final String tag, final long height) { JsonRpcResponse resp = method.response(requestWithParams(tag, "false")); - assertThat(resp.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(resp.getType()).isEqualTo(RpcResponseType.SUCCESS); JsonRpcSuccessResponse successResp = (JsonRpcSuccessResponse) resp; BlockResult blockResult = (BlockResult) successResp.getResult(); assertThat(blockResult.getHash()) diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineForkchoiceUpdatedTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineForkchoiceUpdatedTest.java index 4cb4c81cc9e..6936f2833d4 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineForkchoiceUpdatedTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineForkchoiceUpdatedTest.java @@ -44,7 +44,6 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter; 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.api.jsonrpc.internal.results.EngineUpdateForkchoiceResult; @@ -55,6 +54,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.WithdrawalsValidator; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; import java.util.List; import java.util.Optional; @@ -752,7 +752,7 @@ private JsonRpcResponse resp( abstract String getMethodName(); private EngineUpdateForkchoiceResult fromSuccessResp(final JsonRpcResponse resp) { - assertThat(resp.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(resp.getType()).isEqualTo(RpcResponseType.SUCCESS); return Optional.of(resp) .map(JsonRpcSuccessResponse.class::cast) .map(JsonRpcSuccessResponse::getResult) @@ -766,7 +766,7 @@ private void assertInvalidForkchoiceState(final JsonRpcResponse resp) { private void assertInvalidForkchoiceState( final JsonRpcResponse resp, final RpcErrorType jsonRpcError) { - assertThat(resp.getType()).isEqualTo(JsonRpcResponseType.ERROR); + assertThat(resp.getType()).isEqualTo(RpcResponseType.ERROR); var errorResp = (JsonRpcErrorResponse) resp; assertThat(errorResp.getErrorType()).isEqualTo(jsonRpcError); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java index 10da8a4486f..9b3e94330eb 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java @@ -47,7 +47,6 @@ 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.results.EnginePayloadStatusResult; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; @@ -66,6 +65,7 @@ import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; import org.hyperledger.besu.ethereum.trie.MerkleTrieException; import org.hyperledger.besu.plugin.services.exception.StorageException; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; import java.util.ArrayList; import java.util.Collections; @@ -459,7 +459,7 @@ protected ExecutionEngineJsonRpcMethod.EngineStatus getExpectedInvalidBlockHashS } protected EnginePayloadStatusResult fromSuccessResp(final JsonRpcResponse resp) { - assertThat(resp.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(resp.getType()).isEqualTo(RpcResponseType.SUCCESS); return Optional.of(resp) .map(JsonRpcSuccessResponse.class::cast) .map(JsonRpcSuccessResponse::getResult) @@ -468,7 +468,7 @@ protected EnginePayloadStatusResult fromSuccessResp(final JsonRpcResponse resp) } protected JsonRpcError fromErrorResp(final JsonRpcResponse resp) { - assertThat(resp.getType()).isEqualTo(JsonRpcResponseType.ERROR); + assertThat(resp.getType()).isEqualTo(RpcResponseType.ERROR); return Optional.of(resp) .map(JsonRpcErrorResponse.class::cast) .map(JsonRpcErrorResponse::getError) diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeCapabilitiesTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeCapabilitiesTest.java index e3a3268aa62..4ccd9318a25 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeCapabilitiesTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeCapabilitiesTest.java @@ -23,8 +23,8 @@ 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.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.plugin.services.rpc.RpcResponseType; import java.util.Collections; import java.util.List; @@ -85,7 +85,7 @@ private JsonRpcResponse resp(final List capabilitiesParam) { @SuppressWarnings("unchecked") private List fromSuccessResp(final JsonRpcResponse resp) { - assertThat(resp.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(resp.getType()).isEqualTo(RpcResponseType.SUCCESS); return Optional.of(resp) .map(JsonRpcSuccessResponse.class::cast) .map(JsonRpcSuccessResponse::getResult) diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfigurationTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfigurationTest.java index d3104670de8..f1575f81ab4 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfigurationTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfigurationTest.java @@ -30,7 +30,6 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EngineExchangeTransitionConfigurationParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.UnsignedLongParameter; 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.results.EngineExchangeTransitionConfigurationResult; import org.hyperledger.besu.ethereum.core.BlockHeader; @@ -39,6 +38,7 @@ import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.ParsedExtraData; import org.hyperledger.besu.evm.log.LogsBloomFilter; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; import java.math.BigInteger; import java.util.Map; @@ -223,7 +223,7 @@ private JsonRpcResponse resp(final EngineExchangeTransitionConfigurationParamete } private EngineExchangeTransitionConfigurationResult fromSuccessResp(final JsonRpcResponse resp) { - assertThat(resp.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(resp.getType()).isEqualTo(RpcResponseType.SUCCESS); return Optional.of(resp) .map(JsonRpcSuccessResponse.class::cast) .map(JsonRpcSuccessResponse::getResult) diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByHashV1Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByHashV1Test.java index 42f2a5df0be..8a99fa94392 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByHashV1Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByHashV1Test.java @@ -31,7 +31,6 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; 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.api.jsonrpc.internal.results.BlockResultFactory; @@ -40,6 +39,7 @@ import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.TransactionTestFixture; import org.hyperledger.besu.ethereum.core.Withdrawal; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; import java.util.Collections; import java.util.List; @@ -255,7 +255,7 @@ private JsonRpcResponse resp(final Hash[] hashes) { } private EngineGetPayloadBodiesResultV1 fromSuccessResp(final JsonRpcResponse resp) { - assertThat(resp.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(resp.getType()).isEqualTo(RpcResponseType.SUCCESS); return Optional.of(resp) .map(JsonRpcSuccessResponse.class::cast) .map(JsonRpcSuccessResponse::getResult) @@ -264,7 +264,7 @@ private EngineGetPayloadBodiesResultV1 fromSuccessResp(final JsonRpcResponse res } private RpcErrorType fromErrorResp(final JsonRpcResponse resp) { - assertThat(resp.getType()).isEqualTo(JsonRpcResponseType.ERROR); + assertThat(resp.getType()).isEqualTo(RpcResponseType.ERROR); return Optional.of(resp) .map(JsonRpcErrorResponse.class::cast) .map(JsonRpcErrorResponse::getErrorType) diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByRangeV1Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByRangeV1Test.java index 60fb2ed1f80..6bc89ba6791 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByRangeV1Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByRangeV1Test.java @@ -33,7 +33,6 @@ 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.results.BlockResultFactory; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EngineGetPayloadBodiesResultV1; @@ -41,6 +40,7 @@ import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.TransactionTestFixture; import org.hyperledger.besu.ethereum.core.Withdrawal; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; import java.util.Collections; import java.util.List; @@ -344,7 +344,7 @@ private JsonRpcResponse resp(final String startBlockNumber, final String range) } private EngineGetPayloadBodiesResultV1 fromSuccessResp(final JsonRpcResponse resp) { - assertThat(resp.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(resp.getType()).isEqualTo(RpcResponseType.SUCCESS); return Optional.of(resp) .map(JsonRpcSuccessResponse.class::cast) .map(JsonRpcSuccessResponse::getResult) @@ -353,7 +353,7 @@ private EngineGetPayloadBodiesResultV1 fromSuccessResp(final JsonRpcResponse res } private JsonRpcError fromErrorResp(final JsonRpcResponse resp) { - assertThat(resp.getType()).isEqualTo(JsonRpcResponseType.ERROR); + assertThat(resp.getType()).isEqualTo(RpcResponseType.ERROR); return Optional.of(resp) .map(JsonRpcErrorResponse.class::cast) .map(JsonRpcErrorResponse::getError) diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/MultiTenancyRpcMethodDecoratorTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/MultiTenancyRpcMethodDecoratorTest.java index 8803540392c..d7979dccc83 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/MultiTenancyRpcMethodDecoratorTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/MultiTenancyRpcMethodDecoratorTest.java @@ -22,10 +22,10 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; -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.JsonRpcUnauthorizedResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; import io.vertx.core.json.JsonObject; import io.vertx.ext.auth.User; @@ -58,7 +58,7 @@ public void delegatesWhenHasValidToken() { assertThat(tokenRpcDecorator.getName()).isEqualTo("delegate"); final JsonRpcResponse response = tokenRpcDecorator.response(rpcRequestContext); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(response.getType()).isEqualTo(RpcResponseType.SUCCESS); final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response; assertThat(successResponse.getResult()).isEqualTo("b"); } @@ -73,7 +73,7 @@ public void failsWhenHasNoToken() { assertThat(tokenRpcDecorator.getName()).isEqualTo("delegate"); final JsonRpcResponse response = tokenRpcDecorator.response(rpcRequestContext); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.UNAUTHORIZED); + assertThat(response.getType()).isEqualTo(RpcResponseType.UNAUTHORIZED); final JsonRpcUnauthorizedResponse errorResponse = (JsonRpcUnauthorizedResponse) response; assertThat(errorResponse.getErrorType()).isEqualTo(RpcErrorType.UNAUTHORIZED); } @@ -89,7 +89,7 @@ public void failsWhenTokenDoesNotHavePrivacyPublicKey() { assertThat(tokenRpcDecorator.getName()).isEqualTo("delegate"); final JsonRpcResponse response = tokenRpcDecorator.response(rpcRequestContext); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.ERROR); + assertThat(response.getType()).isEqualTo(RpcResponseType.ERROR); final JsonRpcErrorResponse errorResponse = (JsonRpcErrorResponse) response; assertThat(errorResponse.getErrorType()).isEqualTo(RpcErrorType.INVALID_REQUEST); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDebugGetStateRootTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDebugGetStateRootTest.java index 7c2b6162665..a7a4f6f5906 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDebugGetStateRootTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDebugGetStateRootTest.java @@ -33,11 +33,11 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponseType; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.privacy.PrivacyController; import org.hyperledger.besu.ethereum.privacy.RestrictedDefaultPrivacyController; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; import java.util.Collections; import java.util.Optional; @@ -91,7 +91,7 @@ public void shouldReturnErrorIfInvalidGroupId() { when(privacyController.findPrivacyGroupByGroupId(anyString(), anyString())) .thenReturn(Optional.empty()); final JsonRpcResponse response = method.response(request("not_base64", "latest")); - assertThat(response.getType()).isEqualByComparingTo(JsonRpcResponseType.ERROR); + assertThat(response.getType()).isEqualByComparingTo(RpcResponseType.ERROR); assertThat(((JsonRpcErrorResponse) response).getError().getMessage()) .contains(FIND_PRIVACY_GROUP_ERROR.getMessage()); } @@ -102,7 +102,7 @@ public void shouldReturnErrorIfPrivacyGroupDoesNotExist() { .thenReturn(Optional.empty()); final String invalidGroupId = Base64.toBase64String("invalid_group_id".getBytes(UTF_8)); final JsonRpcResponse response = method.response(request(invalidGroupId, "latest")); - assertThat(response.getType()).isEqualByComparingTo(JsonRpcResponseType.ERROR); + assertThat(response.getType()).isEqualByComparingTo(RpcResponseType.ERROR); assertThat(((JsonRpcErrorResponse) response).getError().getMessage()) .contains(FIND_PRIVACY_GROUP_ERROR.getMessage()); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/MutableJsonRpcSuccessResponse.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/MutableJsonRpcSuccessResponse.java index 7e61830ce67..a9b9376dc37 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/MutableJsonRpcSuccessResponse.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/MutableJsonRpcSuccessResponse.java @@ -14,6 +14,8 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.response; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; + import java.util.Objects; import com.fasterxml.jackson.annotation.JsonGetter; @@ -74,8 +76,8 @@ public void setVersion(final Object version) { } @JsonIgnore - public JsonRpcResponseType getType() { - return JsonRpcResponseType.SUCCESS; + public RpcResponseType getType() { + return RpcResponseType.SUCCESS; } @Override diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivacyApiGroupJsonRpcMethodsTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivacyApiGroupJsonRpcMethodsTest.java index ab7b90735b5..52a875a4cbd 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivacyApiGroupJsonRpcMethodsTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivacyApiGroupJsonRpcMethodsTest.java @@ -27,7 +27,6 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponseType; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; @@ -35,6 +34,7 @@ import org.hyperledger.besu.ethereum.privacy.MultiTenancyPrivacyController; import org.hyperledger.besu.ethereum.privacy.PrivacyController; import org.hyperledger.besu.plugin.services.privacy.PrivateMarkerTransactionFactory; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; import java.util.Map; import java.util.Optional; @@ -140,7 +140,7 @@ public void rpcMethodsCreatedWhenPrivacyIsNotEnabledAreDisabled() { final JsonRpcRequestContext request = new JsonRpcRequestContext(new JsonRpcRequest("2.0", "priv_method", null)); final JsonRpcResponse response = privMethod.response(request); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.ERROR); + assertThat(response.getType()).isEqualTo(RpcResponseType.ERROR); JsonRpcErrorResponse errorResponse = (JsonRpcErrorResponse) response; assertThat(errorResponse.getErrorType()).isEqualTo(PRIVACY_NOT_ENABLED); diff --git a/ethereum/retesteth/src/test/java/org/hyperledger/besu/ethereum/retesteth/methods/TestImportRawBlockTest.java b/ethereum/retesteth/src/test/java/org/hyperledger/besu/ethereum/retesteth/methods/TestImportRawBlockTest.java index 76496235386..b156f2294df 100644 --- a/ethereum/retesteth/src/test/java/org/hyperledger/besu/ethereum/retesteth/methods/TestImportRawBlockTest.java +++ b/ethereum/retesteth/src/test/java/org/hyperledger/besu/ethereum/retesteth/methods/TestImportRawBlockTest.java @@ -19,10 +19,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.response.JsonRpcErrorResponse; -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.retesteth.RetestethContext; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; import java.io.IOException; @@ -69,7 +69,7 @@ public void testMissingParent() { "2.0", TestImportRawBlock.METHOD_NAME, new Object[] {rawBlockRLPString})); final var response = test_importRawBlock.response(request); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.ERROR); + assertThat(response.getType()).isEqualTo(RpcResponseType.ERROR); assertThat(((JsonRpcErrorResponse) response).getErrorType()) .isEqualTo(RpcErrorType.BLOCK_IMPORT_ERROR); } @@ -84,7 +84,7 @@ public void testBadBlock() { "2.0", TestImportRawBlock.METHOD_NAME, new Object[] {rawBlockRLPString})); final var response = test_importRawBlock.response(request); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.ERROR); + assertThat(response.getType()).isEqualTo(RpcResponseType.ERROR); assertThat(((JsonRpcErrorResponse) response).getErrorType()) .isEqualTo(RpcErrorType.BLOCK_RLP_IMPORT_ERROR); } @@ -100,7 +100,7 @@ public void testGoodBlock() { "2.0", TestImportRawBlock.METHOD_NAME, new Object[] {rawBlockRLPString})); final var response = test_importRawBlock.response(request); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(response.getType()).isEqualTo(RpcResponseType.SUCCESS); } @Test @@ -118,11 +118,11 @@ public void testReimportExistingBlock() { new JsonRpcRequest("2.0", TestRewindToBlock.METHOD_NAME, new Object[] {0L})); final var response = test_importRawBlock.response(request); - assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(response.getType()).isEqualTo(RpcResponseType.SUCCESS); final var rewindResponse = test_rewindToBlock.response(requestRewind); - assertThat(rewindResponse.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(rewindResponse.getType()).isEqualTo(RpcResponseType.SUCCESS); final var reimportResponse = test_importRawBlock.response(request); - assertThat(reimportResponse.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); + assertThat(reimportResponse.getType()).isEqualTo(RpcResponseType.SUCCESS); assertThat(context.getBlockchain().getChainHead().getHeight()).isEqualTo(1L); } diff --git a/plugin-api/build.gradle b/plugin-api/build.gradle index 81e66a06a04..0d593b1105f 100644 --- a/plugin-api/build.gradle +++ b/plugin-api/build.gradle @@ -70,7 +70,7 @@ Calculated : ${currentHash} tasks.register('checkAPIChanges', FileStateChecker) { description = "Checks that the API for the Plugin-API project does not change without deliberate thought" files = sourceSets.main.allJava.files - knownHash = '6L5dNJ975Ka/X7g4lTdpkBvPQrJgJu+vAf/m1dFCneU=' + knownHash = 'oPsVhFhdIkzHqD+jjwRX7dbgeNeKbpCmPjiBWDdMV7o=' } check.dependsOn('checkAPIChanges') diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcResponseType.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/rpc/RpcResponseType.java similarity index 67% rename from ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcResponseType.java rename to plugin-api/src/main/java/org/hyperledger/besu/plugin/services/rpc/RpcResponseType.java index 9d5be9c4306..b02b45c8577 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcResponseType.java +++ b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/rpc/RpcResponseType.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * Copyright contributors to Hyperledger Besu. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -12,12 +12,16 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.api.jsonrpc.internal.response; +package org.hyperledger.besu.plugin.services.rpc; -/** Various types of responses that the JSON-RPC component may produce. */ -public enum JsonRpcResponseType { +/** Various types of responses that the RPC component may produce. */ +public enum RpcResponseType { + /** No response */ NONE, + /** Successful response */ SUCCESS, + /** Error response */ ERROR, + /** Not authorized response */ UNAUTHORIZED }