Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Standardise the Engine JSON-RPC error codes #8695

Merged
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8ef3a38
Standardise the Engine JSON-RPC error codes
Malaydewangan09 Oct 9, 2024
9969d19
Merge branch 'master' into standardise-json-rpc-error-codes
Malaydewangan09 Oct 10, 2024
6612848
Merge branch 'Consensys:master' into standardise-json-rpc-error-codes
Malaydewangan09 Oct 11, 2024
7514da8
Refactor JsonRpcErrorCodes to enum for improved efficiency and structure
lucassaldanha Oct 11, 2024
abfaed5
Merge branch 'standardise-json-rpc-error-codes' of github.com:Malayde…
Malaydewangan09 Oct 11, 2024
4b8711e
Make method parameters final in JsonRpcErrorCodes
Malaydewangan09 Oct 11, 2024
7e468d5
Optimize JsonRpcErrorCodes lookup using Int2ObjectOpenHashMap
Malaydewangan09 Oct 11, 2024
a9f1d80
Standardise the Engine JSON-RPC error codes
Malaydewangan09 Oct 9, 2024
3bad1b8
Refactor JsonRpcErrorCodes to enum for improved efficiency and structure
lucassaldanha Oct 11, 2024
2ddbb0f
Make method parameters final in JsonRpcErrorCodes
Malaydewangan09 Oct 11, 2024
dc68ccc
Optimize JsonRpcErrorCodes lookup using Int2ObjectOpenHashMap
Malaydewangan09 Oct 11, 2024
d4dd83c
Merge branch 'standardise-json-rpc-error-codes' of github.com:Malayde…
Malaydewangan09 Oct 13, 2024
08a2366
change JsonRpcErrorCodes to package private
Malaydewangan09 Oct 13, 2024
4504c04
Merge branch 'master' into standardise-json-rpc-error-codes
Malaydewangan09 Oct 14, 2024
6aa34bc
change method name for getter
Malaydewangan09 Oct 14, 2024
33ba572
Merge branch 'master' into standardise-json-rpc-error-codes
Malaydewangan09 Oct 14, 2024
ed9d033
Improve JSON-RPC error message formatting
Malaydewangan09 Oct 14, 2024
754f99a
Merge branch 'master' into standardise-json-rpc-error-codes
Malaydewangan09 Oct 16, 2024
598cd71
Improve JSON-RPC error handling test coverage
Malaydewangan09 Oct 16, 2024
ad9ece0
Merge branch 'standardise-json-rpc-error-codes' of github.com:Malayde…
Malaydewangan09 Oct 16, 2024
7eb382a
Merge branch 'master' into standardise-json-rpc-error-codes
tbenr Oct 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

package tech.pegasys.teku.ethereum.executionclient.web3j;

import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;

public enum JsonRpcErrorCodes {
tbenr marked this conversation as resolved.
Show resolved Hide resolved
PARSE_ERROR(-32700, "Parse error"),
INVALID_REQUEST(-32600, "Invalid Request"),
Expand All @@ -23,6 +25,14 @@ public enum JsonRpcErrorCodes {

private final int errorCode;
private final String description;
private static final Int2ObjectOpenHashMap<JsonRpcErrorCodes> CODE_TO_ERROR_MAP;

static {
CODE_TO_ERROR_MAP = new Int2ObjectOpenHashMap<>();
for (JsonRpcErrorCodes error : values()) {
tbenr marked this conversation as resolved.
Show resolved Hide resolved
CODE_TO_ERROR_MAP.put(error.getErrorCode(), error);
}
}

JsonRpcErrorCodes(final int errorCode, final String description) {
this.errorCode = errorCode;
Expand All @@ -42,10 +52,9 @@ public static String getErrorMessage(final int errorCode) {
}

public static JsonRpcErrorCodes fromCode(final int errorCode) {
for (JsonRpcErrorCodes error : values()) {
if (error.getErrorCode() == errorCode) {
return error;
}
JsonRpcErrorCodes error = CODE_TO_ERROR_MAP.get(errorCode);
tbenr marked this conversation as resolved.
Show resolved Hide resolved
if (error != null) {
return error;
}
return errorCode >= -32099 && errorCode <= -32000 ? SERVER_ERROR : INTERNAL_ERROR;
}
Expand Down