Skip to content

Commit 8a07f91

Browse files
committed
bump to besu 24.9.1 dependencies, deal with RPC fallout
Signed-off-by: garyschulte <[email protected]>
1 parent 0a685c2 commit 8a07f91

14 files changed

+90
-53
lines changed

gradle/versions.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ dependencyManagement {
2323
dependency 'com.google.guava:guava:32.1.2-jre'
2424

2525
// Hyperledger Besu
26-
dependencySet(group: 'org.hyperledger.besu', version: '23.4.1') {
26+
dependencySet(group: 'org.hyperledger.besu', version: '24.9.1') {
2727
entry 'besu-datatypes'
2828
entry 'evm'
2929
entry 'plugin-api'
3030
}
31-
dependencySet(group: 'org.hyperledger.besu.internal', version: '23.4.1') {
31+
dependencySet(group: 'org.hyperledger.besu.internal', version: '24.9.1') {
3232
entry 'api'
3333
entry 'util'
3434
entry 'algorithms'
@@ -68,7 +68,7 @@ dependencyManagement {
6868
dependency 'org.junit.vintage:junit-vintage-engine:5.8.2'
6969

7070
// Mockito
71-
dependency 'org.mockito:mockito-core:5.2.0'
71+
dependency 'org.mockito:mockito-core:5.14.2'
7272

7373
// OpenTelemetry
7474
dependency 'io.opentelemetry:opentelemetry-api:1.19.0'

services/rpc/server/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ dependencies {
2828

2929
// Hyperledger Besu dependencies
3030
implementation 'org.hyperledger.besu:besu-datatypes'
31+
implementation 'org.hyperledger.besu:plugin-api'
3132
implementation 'org.hyperledger.besu.internal:api'
33+
implementation 'org.hyperledger.besu.internal:core'
3234
implementation 'org.hyperledger.besu.internal:rlp'
3335
implementation 'org.hyperledger.besu.internal:util'
3436
implementation 'org.hyperledger.besu.internal:util'
@@ -68,4 +70,4 @@ dependencies {
6870

6971
test {
7072
useJUnitPlatform()
71-
}
73+
}

services/rpc/server/src/main/java/net/consensys/shomei/rpc/server/JsonRpcExecutorHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
package net.consensys.shomei.rpc.server;
1515

1616
import static net.consensys.shomei.rpc.server.JsonRpcObjectExecutor.handleJsonRpcError;
17+
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INTERNAL_ERROR;
1718

1819
import java.io.IOException;
1920

2021
import io.vertx.core.Handler;
2122
import io.vertx.ext.web.RoutingContext;
2223
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
2324
import org.hyperledger.besu.ethereum.api.jsonrpc.execution.JsonRpcExecutor;
24-
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
2525
import org.slf4j.Logger;
2626
import org.slf4j.LoggerFactory;
2727

@@ -44,7 +44,7 @@ public static Handler<RoutingContext> handler(
4444
throw new RuntimeException(e);
4545
}
4646
} catch (final RuntimeException e) {
47-
handleJsonRpcError(ctx, null, JsonRpcError.INTERNAL_ERROR);
47+
handleJsonRpcError(ctx, null, INTERNAL_ERROR);
4848
}
4949
};
5050
}

services/rpc/server/src/main/java/net/consensys/shomei/rpc/server/JsonRpcObjectExecutor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
import org.hyperledger.besu.ethereum.api.jsonrpc.context.ContextKey;
3737
import org.hyperledger.besu.ethereum.api.jsonrpc.execution.JsonRpcExecutor;
3838
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest;
39-
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
4039
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
4140
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
42-
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponseType;
41+
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
42+
import org.hyperledger.besu.plugin.services.rpc.RpcResponseType;
4343

4444
public class JsonRpcObjectExecutor {
4545
private static final ObjectWriter JSON_OBJECT_WRITER = createObjectWriter();
@@ -86,7 +86,7 @@ String getRpcMethodName(final RoutingContext ctx) {
8686
}
8787

8888
protected static void handleJsonRpcError(
89-
final RoutingContext routingContext, final Object id, final JsonRpcError error) {
89+
final RoutingContext routingContext, final Object id, final RpcErrorType error) {
9090
final HttpServerResponse response = routingContext.response();
9191
if (!response.closed()) {
9292
response
@@ -101,7 +101,7 @@ private static void handleJsonObjectResponse(
101101
final RoutingContext ctx)
102102
throws IOException {
103103
response.setStatusCode(status(jsonRpcResponse).code());
104-
if (jsonRpcResponse.getType() == JsonRpcResponseType.NONE) {
104+
if (jsonRpcResponse.getType() == RpcResponseType.NONE) {
105105
response.end();
106106
} else {
107107
try (final JsonResponseStreamer streamer =
@@ -114,7 +114,7 @@ private static void handleJsonObjectResponse(
114114
private static HttpResponseStatus status(final JsonRpcResponse response) {
115115
return switch (response.getType()) {
116116
case UNAUTHORIZED -> HttpResponseStatus.UNAUTHORIZED;
117-
case ERROR -> statusCodeFromError(((JsonRpcErrorResponse) response).getError());
117+
case ERROR -> statusCodeFromError(((JsonRpcErrorResponse) response).getErrorType());
118118
default -> HttpResponseStatus.OK;
119119
};
120120
}
@@ -129,7 +129,7 @@ private static ObjectWriter createObjectWriter() {
129129
.with(JsonGenerator.Feature.AUTO_CLOSE_TARGET);
130130
}
131131

132-
private static HttpResponseStatus statusCodeFromError(final JsonRpcError error) {
132+
private static HttpResponseStatus statusCodeFromError(final RpcErrorType error) {
133133
return switch (error) {
134134
case INVALID_REQUEST, PARSE_ERROR -> HttpResponseStatus.BAD_REQUEST;
135135
default -> HttpResponseStatus.OK;

services/rpc/server/src/main/java/net/consensys/shomei/rpc/server/error/ShomeiJsonRpcErrorResponse.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,22 @@
2121
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
2222
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
2323
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
24-
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponseType;
24+
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
25+
import org.hyperledger.besu.plugin.services.rpc.RpcResponseType;
2526

2627
@JsonPropertyOrder({"jsonrpc", "id", "code"})
2728
public class ShomeiJsonRpcErrorResponse extends JsonRpcErrorResponse {
2829

2930
private final JsonError jsonError;
3031

3132
public ShomeiJsonRpcErrorResponse(
32-
final Object id, final JsonRpcError error, final String message, Object data) {
33+
final Object id, final RpcErrorType error, final String message, Object data) {
3334
super(id, error);
3435
this.jsonError = new JsonError(error, message, data);
3536
}
3637

3738
public ShomeiJsonRpcErrorResponse(
38-
final Object id, final JsonRpcError error, final String message) {
39+
final Object id, final RpcErrorType error, final String message) {
3940
this(id, error, message, null);
4041
}
4142

@@ -52,13 +53,13 @@ public JsonRpcError getError() {
5253

5354
@Override
5455
@JsonIgnore
55-
public JsonRpcResponseType getType() {
56-
return JsonRpcResponseType.ERROR;
56+
public RpcResponseType getType() {
57+
return RpcResponseType.ERROR;
5758
}
5859

5960
@SuppressWarnings("unused")
6061
private record JsonError(
61-
@JsonIgnore JsonRpcError jsonRpcErrorCode,
62+
@JsonIgnore RpcErrorType jsonRpcErrorCode,
6263
@JsonGetter("message") String message,
6364
@JsonGetter("data") @JsonInclude(JsonInclude.Include.NON_NULL) Object data) {
6465

services/rpc/server/src/main/java/net/consensys/shomei/rpc/server/method/LineaGetProof.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@
3131
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
3232
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
3333
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash;
34-
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
34+
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter;
3535
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
3636
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
37+
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
3738

3839
public class LineaGetProof implements JsonRpcMethod {
3940

@@ -75,24 +76,36 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
7576
} else {
7677
return new ShomeiJsonRpcErrorResponse(
7778
requestContext.getRequest().getId(),
78-
JsonRpcError.INVALID_REQUEST,
79+
RpcErrorType.INVALID_REQUEST,
7980
"BLOCK_MISSING_IN_CHAIN - block is missing");
8081
}
8182
}
8283

8384
private AccountKey getAccountAddress(final JsonRpcRequestContext request) {
84-
return new AccountKey(request.getRequiredParameter(0, Address.class));
85+
try {
86+
return new AccountKey(request.getRequiredParameter(0, Address.class));
87+
} catch (JsonRpcParameter.JsonRpcParameterException e) {
88+
throw new RuntimeException(e);
89+
}
8590
}
8691

8792
private List<StorageSlotKey> getSlotKeys(final JsonRpcRequestContext request) {
88-
return Arrays.stream(request.getRequiredParameter(1, String[].class))
89-
.map(UInt256::fromHexString)
90-
.map(StorageSlotKey::new)
91-
.collect(Collectors.toList());
93+
try {
94+
return Arrays.stream(request.getRequiredParameter(1, String[].class))
95+
.map(UInt256::fromHexString)
96+
.map(StorageSlotKey::new)
97+
.collect(Collectors.toList());
98+
} catch (JsonRpcParameter.JsonRpcParameterException e) {
99+
throw new RuntimeException(e);
100+
}
92101
}
93102

94103
private BlockParameterOrBlockHash getBlockParameterOrBlockHash(
95104
final JsonRpcRequestContext request) {
96-
return request.getRequiredParameter(2, BlockParameterOrBlockHash.class);
105+
try {
106+
return request.getRequiredParameter(2, BlockParameterOrBlockHash.class);
107+
} catch (JsonRpcParameter.JsonRpcParameterException e) {
108+
throw new RuntimeException(e);
109+
}
97110
}
98111
}

services/rpc/server/src/main/java/net/consensys/shomei/rpc/server/method/RollupDeleteZkEVMStateMerkleProofByRange.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
2121
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
22+
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter;
2223
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
2324
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
2425

@@ -37,8 +38,12 @@ public String getName() {
3738

3839
@Override
3940
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
40-
final RollupDeleteZkEvmStateByRangeParameter param =
41-
requestContext.getRequiredParameter(0, RollupDeleteZkEvmStateByRangeParameter.class);
41+
final RollupDeleteZkEvmStateByRangeParameter param;
42+
try {
43+
param = requestContext.getRequiredParameter(0, RollupDeleteZkEvmStateByRangeParameter.class);
44+
} catch (JsonRpcParameter.JsonRpcParameterException e) {
45+
throw new RuntimeException(e);
46+
}
4247

4348
final TraceManager.TraceManagerUpdater updater = traceManager.updater();
4449
for (long i = param.getStartBlockNumber(); i <= param.getEndBlockNumber(); i++) {

services/rpc/server/src/main/java/net/consensys/shomei/rpc/server/method/RollupForkChoiceUpdated.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424

2525
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
2626
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
27-
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
27+
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter;
2828
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
2929
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
30+
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
3031

3132
public class RollupForkChoiceUpdated implements JsonRpcMethod {
3233

@@ -47,20 +48,24 @@ public String getName() {
4748

4849
@Override
4950
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
50-
final RollupForkChoiceUpdatedParameter param =
51-
requestContext.getRequiredParameter(0, RollupForkChoiceUpdatedParameter.class);
51+
final RollupForkChoiceUpdatedParameter param;
52+
try {
53+
param = requestContext.getRequiredParameter(0, RollupForkChoiceUpdatedParameter.class);
54+
} catch (JsonRpcParameter.JsonRpcParameterException e) {
55+
throw new RuntimeException(e);
56+
}
5257
if (param.getFinalizedBlockNumber() < zkWorldStateArchive.getCurrentBlockNumber()) {
5358
return new ShomeiJsonRpcErrorResponse(
5459
requestContext.getRequest().getId(),
55-
JsonRpcError.INVALID_PARAMS,
60+
RpcErrorType.INVALID_PARAMS,
5661
"Cannot set finalized %d lower than the current shomei head %s ."
5762
.formatted(
5863
param.getFinalizedBlockNumber(), zkWorldStateArchive.getCurrentBlockNumber()));
5964
}
6065
if (!fullSyncDownloader.getFullSyncRules().isEnableFinalizedBlockLimit()) {
6166
return new ShomeiJsonRpcErrorResponse(
6267
requestContext.getRequest().getId(),
63-
JsonRpcError.UNAUTHORIZED,
68+
RpcErrorType.UNAUTHORIZED,
6469
"The --enable-finalized-block-limit feature must be activated in order to set the finalized block limit.");
6570
}
6671
// update full sync rules

services/rpc/server/src/main/java/net/consensys/shomei/rpc/server/method/RollupGetZkEVMStateMerkleProofV0.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@
3232
import org.hyperledger.besu.datatypes.Hash;
3333
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
3434
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
35-
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
35+
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter;
3636
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
3737
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
38+
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
3839
import org.hyperledger.besu.ethereum.rlp.RLP;
3940

4041
public class RollupGetZkEVMStateMerkleProofV0 implements JsonRpcMethod {
@@ -52,12 +53,16 @@ public String getName() {
5253

5354
@Override
5455
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
55-
final RollupGetZkEvmStateV0Parameter param =
56-
requestContext.getRequiredParameter(0, RollupGetZkEvmStateV0Parameter.class);
56+
final RollupGetZkEvmStateV0Parameter param;
57+
try {
58+
param = requestContext.getRequiredParameter(0, RollupGetZkEvmStateV0Parameter.class);
59+
} catch (JsonRpcParameter.JsonRpcParameterException e) {
60+
throw new RuntimeException(e);
61+
}
5762
if (!IMPL_VERSION.equals(param.getZkStateManagerVersion())) {
5863
return new ShomeiJsonRpcErrorResponse(
5964
requestContext.getRequest().getId(),
60-
JsonRpcError.INVALID_PARAMS,
65+
RpcErrorType.INVALID_PARAMS,
6166
"UNSUPPORTED_VERSION",
6267
new JsonInvalidVersionMessage(param.getZkStateManagerVersion(), IMPL_VERSION));
6368
}
@@ -69,7 +74,7 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
6974
if (traceRaw.isEmpty()) {
7075
return new ShomeiJsonRpcErrorResponse(
7176
requestContext.getRequest().getId(),
72-
JsonRpcError.INVALID_PARAMS,
77+
RpcErrorType.INVALID_PARAMS,
7378
"BLOCK_MISSING_IN_CHAIN - block %d is missing".formatted(i));
7479
}
7580
}

services/rpc/server/src/main/java/net/consensys/shomei/rpc/server/method/SendRawTrieLog.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@
2424

2525
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
2626
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
27-
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
27+
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter;
2828
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
2929
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
3030
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
31+
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
3132
import org.slf4j.Logger;
3233
import org.slf4j.LoggerFactory;
3334

@@ -55,16 +56,21 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
5556
IntStream.range(0, requestContext.getRequest().getParamLength())
5657
.forEach(
5758
index -> {
58-
TrieLogElement param =
59-
requestContext.getRequest().getRequiredParameter(index, TrieLogElement.class);
59+
TrieLogElement param;
60+
try {
61+
param =
62+
requestContext.getRequest().getRequiredParameter(index, TrieLogElement.class);
63+
} catch (JsonRpcParameter.JsonRpcParameterException e) {
64+
throw new RuntimeException(e);
65+
}
6066
trieLogIdentifiers.add(param.getTrieLogIdentifier());
6167
});
6268
trieLogObserver.onNewBesuHeadReceived(trieLogIdentifiers);
6369
} catch (RuntimeException e) {
6470
LOG.error("failed to handle new TrieLog {}", e.getMessage());
6571
LOG.debug("exception handling TrieLog", e);
6672
return new JsonRpcErrorResponse(
67-
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
73+
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
6874
}
6975
return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
7076
}

0 commit comments

Comments
 (0)