-
Notifications
You must be signed in to change notification settings - Fork 841
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
add engine_getClientVersionV1 #7512
Merged
pinges
merged 14 commits into
hyperledger:main
from
Matilda-Clerke:6471-add-engine-getClientVersionV1
Aug 27, 2024
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c5f151e
add engine_getClientVersionV1
Matilda-Clerke caebd5a
Apply spotless
Matilda-Clerke 060d6db
5098: Fix integration test compile issue
Matilda-Clerke 93f37de
Merge branch 'main' into 6471-add-engine-getClientVersionV1
Matilda-Clerke 7f53348
Merge branch 'main' into 6471-add-engine-getClientVersionV1
Matilda-Clerke 10ee3ba
5098:Reuse VERSION instead of retrieving BesuInfo class information a…
Matilda-Clerke df8434c
5098: Fix typo in RpcMethod
Matilda-Clerke 7cb6dcc
5098: Fix broken unit test
Matilda-Clerke 24ed389
Merge branch 'main' into 6471-add-engine-getClientVersionV1
Matilda-Clerke 09f97e1
Merge branch 'main' into 6471-add-engine-getClientVersionV1
Matilda-Clerke c3bf4c9
5098: Include shortened git commit hash in all build versions. Update…
Matilda-Clerke c370aae
Merge branch 'main' into 6471-add-engine-getClientVersionV1
Matilda-Clerke 0fd5509
5098: Apply spotless
Matilda-Clerke f83cccf
Merge remote-tracking branch 'origin/6471-add-engine-getClientVersion…
Matilda-Clerke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,9 @@ | |
/** Provides a facade to construct the JSON-RPC component. */ | ||
public class JsonRpcTestMethodsFactory { | ||
|
||
private static final String CLIENT_VERSION = "TestClientVersion/0.1.0"; | ||
private static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Renaming this to better match its source in BesuInfo |
||
private static final String CLIENT_VERSION = "0.1.0"; | ||
private static final String CLIENT_COMMIT = "12345678"; | ||
private static final BigInteger NETWORK_ID = BigInteger.valueOf(123); | ||
|
||
private final BlockchainImporter importer; | ||
|
@@ -175,7 +177,9 @@ public Map<String, JsonRpcMethod> methods() { | |
|
||
return new JsonRpcMethodsFactory() | ||
.methods( | ||
CLIENT_NODE_NAME, | ||
CLIENT_VERSION, | ||
CLIENT_COMMIT, | ||
NETWORK_ID, | ||
new StubGenesisConfigOptions(), | ||
peerDiscovery, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...perledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetClientVersionV1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; | ||
|
||
import org.hyperledger.besu.ethereum.ProtocolContext; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EngineGetClientVersionResultV1; | ||
|
||
import io.vertx.core.Vertx; | ||
|
||
public class EngineGetClientVersionV1 extends ExecutionEngineJsonRpcMethod { | ||
private static final String ENGINE_CLIENT_CODE = "BU"; | ||
private static final String ENGINE_CLIENT_NAME = "Besu"; | ||
|
||
private final String clientVersion; | ||
private final String commit; | ||
|
||
public EngineGetClientVersionV1( | ||
final Vertx vertx, | ||
final ProtocolContext protocolContext, | ||
final EngineCallListener engineCallListener, | ||
final String clientVersion, | ||
final String commit) { | ||
super(vertx, protocolContext, engineCallListener); | ||
this.clientVersion = clientVersion; | ||
this.commit = commit; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return RpcMethod.ENGINE_GET_CLIENT_VERSION_V1.getMethodName(); | ||
} | ||
|
||
@Override | ||
public JsonRpcResponse syncResponse(final JsonRpcRequestContext request) { | ||
return new JsonRpcSuccessResponse( | ||
request.getRequest().getId(), | ||
new EngineGetClientVersionResultV1( | ||
ENGINE_CLIENT_CODE, ENGINE_CLIENT_NAME, clientVersion, commit)); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...yperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetClientVersionResultV1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results; | ||
|
||
import com.fasterxml.jackson.annotation.JsonGetter; | ||
|
||
public class EngineGetClientVersionResultV1 { | ||
private final String code; | ||
private final String name; | ||
private final String version; | ||
private final String commit; | ||
|
||
public EngineGetClientVersionResultV1( | ||
final String code, final String name, final String version, final String commit) { | ||
this.code = code; | ||
this.name = name; | ||
this.version = version; | ||
this.commit = commit; | ||
} | ||
|
||
@JsonGetter(value = "code") | ||
public String getCode() { | ||
return code; | ||
} | ||
|
||
@JsonGetter(value = "name") | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@JsonGetter(value = "version") | ||
public String getVersion() { | ||
return version; | ||
} | ||
|
||
@JsonGetter(value = "commit") | ||
public String getCommit() { | ||
return commit; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of NULL, would it be better to return empty String
""
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, is there a test that covers NULL commit? How would it be reported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, it's difficult to test the value of COMMIT because BesuInfo pulls data from the class' package which isn't typically set outside of a proper build.
As for null vs empty String, philosophically I'd rather it be null. The api doesn't really specify what should be supplied if a value isn't available.