From fb8c95c2be4476c801536bf3bf32020d3a12e142 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Mon, 29 May 2023 13:45:59 +1000 Subject: [PATCH 1/7] default internal error Signed-off-by: Sally MacFarlane --- .../besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java index 1d1b69f9ce7..64c11a0b650 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java @@ -68,7 +68,7 @@ public static JsonRpcError convertTransactionInvalidReason( case TOTAL_DATA_GAS_TOO_HIGH: return JsonRpcError.TOTAL_DATA_GAS_TOO_HIGH; default: - return JsonRpcError.INVALID_PARAMS; + return JsonRpcError.INTERNAL_ERROR; } } } From cb3b95fbf6a2170a0d33f6132effc862119828cf Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Wed, 14 Jun 2023 19:21:47 +1000 Subject: [PATCH 2/7] fixed one test; added new error code Signed-off-by: Sally MacFarlane --- .../besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java | 2 ++ .../ethereum/api/jsonrpc/internal/response/JsonRpcError.java | 1 + .../internal/privacy/methods/eea/EeaSendRawTransactionTest.java | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java index 64c11a0b650..15af4404ea0 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java @@ -45,6 +45,8 @@ public static JsonRpcError convertTransactionInvalidReason( case TX_SENDER_NOT_AUTHORIZED: return JsonRpcError.TX_SENDER_NOT_AUTHORIZED; // Private Transaction Invalid Reasons + case PRIVATE_TRANSACTION_FAILED: + return JsonRpcError.PRIVATE_TRANSACTION_FAILED; case CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE: return JsonRpcError.CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE; case GAS_PRICE_TOO_LOW: diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java index bc633fdeff2..16202e76ab9 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java @@ -160,6 +160,7 @@ public enum JsonRpcError { PRIVATE_FROM_DOES_NOT_MATCH_ENCLAVE_PUBLIC_KEY( -50100, "Private from does not match enclave public key"), VALUE_NOT_ZERO(-50100, "We cannot transfer ether in a private transaction yet."), + PRIVATE_TRANSACTION_FAILED(-50100,"Private transaction failed"), CANT_CONNECT_TO_LOCAL_PEER(-32100, "Cannot add local node as peer."), diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransactionTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransactionTest.java index cd903cf4acc..ad22df0a022 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransactionTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransactionTest.java @@ -143,7 +143,7 @@ public void invalidTransactionIsNotSentToEnclaveAndIsNotAddedToTransactionPool() final JsonRpcResponse expectedResponse = new JsonRpcErrorResponse( - validPrivateForTransactionRequest.getRequest().getId(), JsonRpcError.INVALID_PARAMS); + validPrivateForTransactionRequest.getRequest().getId(), JsonRpcError.PRIVATE_TRANSACTION_FAILED); final JsonRpcResponse actualResponse = method.response(validPrivateForTransactionRequest); From 5ef3c3d76ca7025fe0a3313ee316a40a8c36bce3 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Wed, 14 Jun 2023 19:33:59 +1000 Subject: [PATCH 3/7] fixed remaining privacy unit tests; added new error code Signed-off-by: Sally MacFarlane --- .../besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java | 2 ++ .../api/jsonrpc/internal/response/JsonRpcError.java | 2 +- .../privacy/methods/eea/EeaSendRawTransactionTest.java | 3 ++- .../eea/RestrictedFlexibleEeaSendRawTransactionTest.java | 6 ++++-- .../eea/RestrictedOffchainEeaSendRawTransactionTest.java | 6 ++++-- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java index 15af4404ea0..d454ba1ab38 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java @@ -47,6 +47,8 @@ public static JsonRpcError convertTransactionInvalidReason( // Private Transaction Invalid Reasons case PRIVATE_TRANSACTION_FAILED: return JsonRpcError.PRIVATE_TRANSACTION_FAILED; + case PRIVATE_UNIMPLEMENTED_TRANSACTION_TYPE: + return JsonRpcError.UNIMPLEMENTED_PRIVATE_TRANSACTION_TYPE; case CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE: return JsonRpcError.CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE; case GAS_PRICE_TOO_LOW: diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java index 16202e76ab9..2dee4f5f6d7 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java @@ -160,7 +160,7 @@ public enum JsonRpcError { PRIVATE_FROM_DOES_NOT_MATCH_ENCLAVE_PUBLIC_KEY( -50100, "Private from does not match enclave public key"), VALUE_NOT_ZERO(-50100, "We cannot transfer ether in a private transaction yet."), - PRIVATE_TRANSACTION_FAILED(-50100,"Private transaction failed"), + PRIVATE_TRANSACTION_FAILED(-50100, "Private transaction failed"), CANT_CONNECT_TO_LOCAL_PEER(-32100, "Cannot add local node as peer."), diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransactionTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransactionTest.java index ad22df0a022..0ec49b227aa 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransactionTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransactionTest.java @@ -143,7 +143,8 @@ public void invalidTransactionIsNotSentToEnclaveAndIsNotAddedToTransactionPool() final JsonRpcResponse expectedResponse = new JsonRpcErrorResponse( - validPrivateForTransactionRequest.getRequest().getId(), JsonRpcError.PRIVATE_TRANSACTION_FAILED); + validPrivateForTransactionRequest.getRequest().getId(), + JsonRpcError.PRIVATE_TRANSACTION_FAILED); final JsonRpcResponse actualResponse = method.response(validPrivateForTransactionRequest); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedFlexibleEeaSendRawTransactionTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedFlexibleEeaSendRawTransactionTest.java index 76fe542f4f8..bd6cf52fa08 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedFlexibleEeaSendRawTransactionTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedFlexibleEeaSendRawTransactionTest.java @@ -139,7 +139,8 @@ public void flexiblePrivacyGroupTransactionFailsWhenGroupDoesNotExist() { final JsonRpcResponse expectedResponse = new JsonRpcErrorResponse( - validPrivacyGroupTransactionRequest.getRequest().getId(), JsonRpcError.INVALID_PARAMS); + validPrivacyGroupTransactionRequest.getRequest().getId(), + JsonRpcError.UNIMPLEMENTED_PRIVATE_TRANSACTION_TYPE); assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse); } @@ -152,7 +153,8 @@ public void flexiblePrivacyGroupTransactionFailsWhenGroupDoesNotExist() { final JsonRpcResponse expectedResponse = new JsonRpcErrorResponse( - validPrivacyGroupTransactionRequest.getRequest().getId(), JsonRpcError.INVALID_PARAMS); + validPrivacyGroupTransactionRequest.getRequest().getId(), + JsonRpcError.UNIMPLEMENTED_PRIVATE_TRANSACTION_TYPE); assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOffchainEeaSendRawTransactionTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOffchainEeaSendRawTransactionTest.java index 5d6bdd8e0ce..305f35d7084 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOffchainEeaSendRawTransactionTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOffchainEeaSendRawTransactionTest.java @@ -107,7 +107,8 @@ public void validPantheonPrivacyGroupTransactionIsSentToTransactionPool() { final JsonRpcResponse expectedResponse = new JsonRpcErrorResponse( - validPrivacyGroupTransactionRequest.getRequest().getId(), JsonRpcError.INVALID_PARAMS); + validPrivacyGroupTransactionRequest.getRequest().getId(), + JsonRpcError.UNIMPLEMENTED_PRIVATE_TRANSACTION_TYPE); assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse); } @@ -120,7 +121,8 @@ public void validPantheonPrivacyGroupTransactionIsSentToTransactionPool() { final JsonRpcResponse expectedResponse = new JsonRpcErrorResponse( - validPrivacyGroupTransactionRequest.getRequest().getId(), JsonRpcError.INVALID_PARAMS); + validPrivacyGroupTransactionRequest.getRequest().getId(), + JsonRpcError.UNIMPLEMENTED_PRIVATE_TRANSACTION_TYPE); assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse); } From 508dd1dfb0aa0f4539f3c6075f226d6b8e966086 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Wed, 14 Jun 2023 19:39:03 +1000 Subject: [PATCH 4/7] internal error not invalid params Signed-off-by: Sally MacFarlane --- .../besu/tests/acceptance/privacy/PrivCallAcceptanceTest.java | 2 +- .../api/jsonrpc/methods/fork/london/EthCallIntegrationTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivCallAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivCallAcceptanceTest.java index e037a801ed6..b98744def44 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivCallAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivCallAcceptanceTest.java @@ -200,7 +200,7 @@ public void mustNotSucceedWithWronglyEncodedFunction() throws IOException { privCall(privacyGroupId, eventEmitter, true, false, false); final String errorMessage = priv_call.send().getError().getMessage(); - assertThat(errorMessage).isEqualTo("Invalid params"); + assertThat(errorMessage).isEqualTo("Internal error"); } @Test diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthCallIntegrationTest.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthCallIntegrationTest.java index bae0ef6b639..9c920be7a7e 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthCallIntegrationTest.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthCallIntegrationTest.java @@ -148,7 +148,7 @@ public void shouldReturnErrorWithGasPriceLessThanCurrentBaseFee() { null); final JsonRpcRequestContext request = requestWithParams(callParameter, "latest"); final JsonRpcResponse expectedResponse = - new JsonRpcErrorResponse(null, JsonRpcError.INVALID_PARAMS); + new JsonRpcErrorResponse(null, JsonRpcError.INTERNAL_ERROR); final JsonRpcResponse response = method.response(request); From 25b7270a0c41687c7c49a85b06b33bbc8c7c941c Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Wed, 14 Jun 2023 19:48:52 +1000 Subject: [PATCH 5/7] internal error not invalid params Signed-off-by: Sally MacFarlane --- .../api/jsonrpc/methods/fork/london/EthCallIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthCallIntegrationTest.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthCallIntegrationTest.java index 9c920be7a7e..c70bc6fb975 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthCallIntegrationTest.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthCallIntegrationTest.java @@ -219,7 +219,7 @@ public void shouldReturnErrorWithValidMaxFeePerGasLessThanCurrentBaseFee() { null); final JsonRpcRequestContext request = requestWithParams(callParameter, "latest"); final JsonRpcResponse expectedResponse = - new JsonRpcErrorResponse(null, JsonRpcError.INVALID_PARAMS); + new JsonRpcErrorResponse(null, JsonRpcError.INTERNAL_ERROR); final JsonRpcResponse response = method.response(request); From eb920e4addf2ea7b52d52417edfcf616c3700daf Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Wed, 14 Jun 2023 20:10:42 +1000 Subject: [PATCH 6/7] Private transaction failed Signed-off-by: Sally MacFarlane --- .../besu/tests/acceptance/privacy/PrivCallAcceptanceTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivCallAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivCallAcceptanceTest.java index b98744def44..c42075d48d2 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivCallAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivCallAcceptanceTest.java @@ -200,7 +200,7 @@ public void mustNotSucceedWithWronglyEncodedFunction() throws IOException { privCall(privacyGroupId, eventEmitter, true, false, false); final String errorMessage = priv_call.send().getError().getMessage(); - assertThat(errorMessage).isEqualTo("Internal error"); + assertThat(errorMessage).isEqualTo("Private transaction failed"); } @Test From b8cfd631991ed08126b2061a8113aa6dfef1c96d Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Fri, 16 Jun 2023 17:33:17 +1000 Subject: [PATCH 7/7] tuning error codes Signed-off-by: Sally MacFarlane --- .../jsonrpc/methods/fork/london/EthCallIntegrationTest.java | 4 ++-- .../besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java | 6 +++++- .../api/jsonrpc/internal/response/JsonRpcError.java | 4 +++- .../privacy/methods/eea/EeaSendRawTransactionTest.java | 6 +++--- .../eea/RestrictedFlexibleEeaSendRawTransactionTest.java | 4 ++-- .../eea/RestrictedOffchainEeaSendRawTransactionTest.java | 4 ++-- .../besu/ethereum/transaction/TransactionInvalidReason.java | 2 ++ 7 files changed, 19 insertions(+), 11 deletions(-) diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthCallIntegrationTest.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthCallIntegrationTest.java index c70bc6fb975..05698c199f6 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthCallIntegrationTest.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthCallIntegrationTest.java @@ -148,7 +148,7 @@ public void shouldReturnErrorWithGasPriceLessThanCurrentBaseFee() { null); final JsonRpcRequestContext request = requestWithParams(callParameter, "latest"); final JsonRpcResponse expectedResponse = - new JsonRpcErrorResponse(null, JsonRpcError.INTERNAL_ERROR); + new JsonRpcErrorResponse(null, JsonRpcError.GAS_PRICE_BELOW_CURRENT_BASE_FEE); final JsonRpcResponse response = method.response(request); @@ -219,7 +219,7 @@ public void shouldReturnErrorWithValidMaxFeePerGasLessThanCurrentBaseFee() { null); final JsonRpcRequestContext request = requestWithParams(callParameter, "latest"); final JsonRpcResponse expectedResponse = - new JsonRpcErrorResponse(null, JsonRpcError.INTERNAL_ERROR); + new JsonRpcErrorResponse(null, JsonRpcError.GAS_PRICE_BELOW_CURRENT_BASE_FEE); final JsonRpcResponse response = method.response(request); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java index d454ba1ab38..15bb5196fd9 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java @@ -45,14 +45,18 @@ public static JsonRpcError convertTransactionInvalidReason( case TX_SENDER_NOT_AUTHORIZED: return JsonRpcError.TX_SENDER_NOT_AUTHORIZED; // Private Transaction Invalid Reasons + case PRIVATE_TRANSACTION_INVALID: + return JsonRpcError.PRIVATE_TRANSACTION_INVALID; case PRIVATE_TRANSACTION_FAILED: return JsonRpcError.PRIVATE_TRANSACTION_FAILED; case PRIVATE_UNIMPLEMENTED_TRANSACTION_TYPE: - return JsonRpcError.UNIMPLEMENTED_PRIVATE_TRANSACTION_TYPE; + return JsonRpcError.UNSUPPORTED_PRIVATE_TRANSACTION_TYPE; case CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE: return JsonRpcError.CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE; case GAS_PRICE_TOO_LOW: return JsonRpcError.GAS_PRICE_TOO_LOW; + case GAS_PRICE_BELOW_CURRENT_BASE_FEE: + return JsonRpcError.GAS_PRICE_BELOW_CURRENT_BASE_FEE; case TX_FEECAP_EXCEEDED: return JsonRpcError.TX_FEECAP_EXCEEDED; case MAX_PRIORITY_FEE_PER_GAS_EXCEEDS_MAX_FEE_PER_GAS: diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java index 2dee4f5f6d7..a49b35be458 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java @@ -65,6 +65,7 @@ public enum JsonRpcError { TX_SENDER_NOT_AUTHORIZED(-32007, "Sender account not authorized to send transactions"), CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE(-32008, "Initial sync is still in progress"), GAS_PRICE_TOO_LOW(-32009, "Gas price below configured minimum gas price"), + GAS_PRICE_BELOW_CURRENT_BASE_FEE(-32009, "Gas price below current base fee"), WRONG_CHAIN_ID(-32000, "Wrong chainId"), REPLAY_PROTECTED_SIGNATURES_NOT_SUPPORTED(-32000, "ChainId not supported"), REPLAY_PROTECTED_SIGNATURE_REQUIRED(-32000, "ChainId is required"), @@ -139,7 +140,7 @@ public enum JsonRpcError { // Private transaction errors ENCLAVE_ERROR(-50100, "Error communicating with enclave"), - UNIMPLEMENTED_PRIVATE_TRANSACTION_TYPE(-50100, "Unimplemented private transaction type"), + UNSUPPORTED_PRIVATE_TRANSACTION_TYPE(-50100, "Unsupported private transaction type"), PRIVACY_NOT_ENABLED(-50100, "Privacy is not enabled"), CREATE_PRIVACY_GROUP_ERROR(-50100, "Error creating privacy group"), DECODE_ERROR(-50100, "Unable to decode the private signed raw transaction"), @@ -160,6 +161,7 @@ public enum JsonRpcError { PRIVATE_FROM_DOES_NOT_MATCH_ENCLAVE_PUBLIC_KEY( -50100, "Private from does not match enclave public key"), VALUE_NOT_ZERO(-50100, "We cannot transfer ether in a private transaction yet."), + PRIVATE_TRANSACTION_INVALID(-50100, "Private transaction invalid"), PRIVATE_TRANSACTION_FAILED(-50100, "Private transaction failed"), CANT_CONNECT_TO_LOCAL_PEER(-32100, "Cannot add local node as peer."), diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransactionTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransactionTest.java index 0ec49b227aa..4ad29c1931c 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransactionTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransactionTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.PRIVATE_TRANSACTION_FAILED; +import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.PRIVATE_TRANSACTION_INVALID; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.never; @@ -139,12 +139,12 @@ public void invalidTransactionWithoutPrivateFromFieldFailsWithDecodeError() { @Test public void invalidTransactionIsNotSentToEnclaveAndIsNotAddedToTransactionPool() { when(privacyController.validatePrivateTransaction(any(), anyString())) - .thenReturn(ValidationResult.invalid(PRIVATE_TRANSACTION_FAILED)); + .thenReturn(ValidationResult.invalid(PRIVATE_TRANSACTION_INVALID)); final JsonRpcResponse expectedResponse = new JsonRpcErrorResponse( validPrivateForTransactionRequest.getRequest().getId(), - JsonRpcError.PRIVATE_TRANSACTION_FAILED); + JsonRpcError.PRIVATE_TRANSACTION_INVALID); final JsonRpcResponse actualResponse = method.response(validPrivateForTransactionRequest); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedFlexibleEeaSendRawTransactionTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedFlexibleEeaSendRawTransactionTest.java index bd6cf52fa08..7d11084308e 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedFlexibleEeaSendRawTransactionTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedFlexibleEeaSendRawTransactionTest.java @@ -140,7 +140,7 @@ public void flexiblePrivacyGroupTransactionFailsWhenGroupDoesNotExist() { final JsonRpcResponse expectedResponse = new JsonRpcErrorResponse( validPrivacyGroupTransactionRequest.getRequest().getId(), - JsonRpcError.UNIMPLEMENTED_PRIVATE_TRANSACTION_TYPE); + JsonRpcError.UNSUPPORTED_PRIVATE_TRANSACTION_TYPE); assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse); } @@ -154,7 +154,7 @@ public void flexiblePrivacyGroupTransactionFailsWhenGroupDoesNotExist() { final JsonRpcResponse expectedResponse = new JsonRpcErrorResponse( validPrivacyGroupTransactionRequest.getRequest().getId(), - JsonRpcError.UNIMPLEMENTED_PRIVATE_TRANSACTION_TYPE); + JsonRpcError.UNSUPPORTED_PRIVATE_TRANSACTION_TYPE); assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOffchainEeaSendRawTransactionTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOffchainEeaSendRawTransactionTest.java index 305f35d7084..897346620f4 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOffchainEeaSendRawTransactionTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOffchainEeaSendRawTransactionTest.java @@ -108,7 +108,7 @@ public void validPantheonPrivacyGroupTransactionIsSentToTransactionPool() { final JsonRpcResponse expectedResponse = new JsonRpcErrorResponse( validPrivacyGroupTransactionRequest.getRequest().getId(), - JsonRpcError.UNIMPLEMENTED_PRIVATE_TRANSACTION_TYPE); + JsonRpcError.UNSUPPORTED_PRIVATE_TRANSACTION_TYPE); assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse); } @@ -122,7 +122,7 @@ public void validPantheonPrivacyGroupTransactionIsSentToTransactionPool() { final JsonRpcResponse expectedResponse = new JsonRpcErrorResponse( validPrivacyGroupTransactionRequest.getRequest().getId(), - JsonRpcError.UNIMPLEMENTED_PRIVATE_TRANSACTION_TYPE); + JsonRpcError.UNSUPPORTED_PRIVATE_TRANSACTION_TYPE); assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionInvalidReason.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionInvalidReason.java index 84487d6bfb4..d62e0e87ac4 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionInvalidReason.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionInvalidReason.java @@ -43,10 +43,12 @@ public enum TransactionInvalidReason { TOTAL_DATA_GAS_TOO_HIGH, GAS_PRICE_TOO_LOW, GAS_PRICE_BELOW_CURRENT_BASE_FEE, + MAX_FEE_PER_GAS_BELOW_CURRENT_BASE_FEE, TX_FEECAP_EXCEEDED, INTERNAL_ERROR, // Private Transaction Invalid Reasons + PRIVATE_TRANSACTION_INVALID, PRIVATE_TRANSACTION_FAILED, PRIVATE_NONCE_TOO_LOW, OFFCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST,