Reintroduce engine get client version v1 with commit in manifest (#7548)

* Include Commit-Hash in manifests
* Add commit method in BesuInfo
* Use 8 character hash in EngineGetClientVersionV1 and revert calculateVersion back to original spec

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
Co-authored-by: garyschulte <garyschulte@gmail.com>
pull/7550/head
Matilda-Clerke 2 months ago committed by GitHub
parent 1ea1d4cede
commit da98fa5541
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 3
      acceptance-tests/test-plugins/build.gradle
  3. 3
      besu/build.gradle
  4. 31
      besu/src/main/java/org/hyperledger/besu/BesuInfo.java
  5. 2
      besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
  6. 2
      build.gradle
  7. 3
      config/build.gradle
  8. 3
      consensus/clique/build.gradle
  9. 3
      consensus/common/build.gradle
  10. 3
      consensus/ibft/build.gradle
  11. 3
      consensus/merge/build.gradle
  12. 3
      consensus/qbft/build.gradle
  13. 1
      crypto/algorithms/build.gradle
  14. 1
      crypto/services/build.gradle
  15. 1
      datatypes/build.gradle
  16. 3
      ethereum/api/build.gradle
  17. 6
      ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcTestMethodsFactory.java
  18. 1
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java
  19. 57
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetClientVersionV1.java
  20. 52
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetClientVersionResultV1.java
  21. 13
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/ExecutionEngineJsonRpcMethods.java
  22. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/JsonRpcMethodsFactory.java
  23. 6
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpServiceTest.java
  24. 6
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AdminJsonRpcHttpServiceTest.java
  25. 6
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostAllowlistTest.java
  26. 6
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java
  27. 8
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceRpcApisTest.java
  28. 26
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTest.java
  29. 6
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTestBase.java
  30. 6
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsClientAuthTest.java
  31. 6
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java
  32. 6
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsTest.java
  33. 72
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetClientVersionV1Test.java
  34. 6
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceLoginTest.java
  35. 3
      ethereum/blockcreation/build.gradle
  36. 3
      ethereum/core/build.gradle
  37. 3
      ethereum/eth/build.gradle
  38. 3
      ethereum/ethstats/build.gradle
  39. 3
      ethereum/evmtool/build.gradle
  40. 3
      ethereum/mock-p2p/build.gradle
  41. 3
      ethereum/p2p/build.gradle
  42. 3
      ethereum/permissioning/build.gradle
  43. 3
      ethereum/retesteth/build.gradle
  44. 1
      ethereum/rlp/build.gradle
  45. 3
      ethereum/stratum/build.gradle
  46. 3
      ethereum/trie/build.gradle
  47. 3
      ethereum/verkletrie/build.gradle
  48. 1
      evm/build.gradle
  49. 3
      metrics/core/build.gradle
  50. 3
      metrics/rocksdb/build.gradle
  51. 3
      nat/build.gradle
  52. 3
      pki/build.gradle
  53. 1
      plugin-api/build.gradle
  54. 3
      plugins/rocksdb/build.gradle
  55. 3
      services/kvstore/build.gradle
  56. 3
      services/pipeline/build.gradle
  57. 3
      services/tasks/build.gradle
  58. 3
      testfuzz/build.gradle
  59. 3
      testutil/build.gradle
  60. 1
      util/build.gradle

@ -11,6 +11,7 @@
- Add 'inbound' field to admin_peers JSON-RPC Call [#7461](https://github.com/hyperledger/besu/pull/7461) - Add 'inbound' field to admin_peers JSON-RPC Call [#7461](https://github.com/hyperledger/besu/pull/7461)
- Add pending block header to `TransactionEvaluationContext` plugin API [#7483](https://github.com/hyperledger/besu/pull/7483) - Add pending block header to `TransactionEvaluationContext` plugin API [#7483](https://github.com/hyperledger/besu/pull/7483)
- Add bootnode to holesky config [#7500](https://github.com/hyperledger/besu/pull/7500) - Add bootnode to holesky config [#7500](https://github.com/hyperledger/besu/pull/7500)
- Implement engine_getClientVersionV1 [#7512](https://github.com/hyperledger/besu/pull/7512)
- Performance optimzation for ECMUL (1 of 2) [#7509](https://github.com/hyperledger/besu/pull/7509) - Performance optimzation for ECMUL (1 of 2) [#7509](https://github.com/hyperledger/besu/pull/7509)
- Performance optimzation for ECMUL (2 of 2) [#7543](https://github.com/hyperledger/besu/pull/7543) - Performance optimzation for ECMUL (2 of 2) [#7543](https://github.com/hyperledger/besu/pull/7543)

@ -25,7 +25,8 @@ task testPluginsJar(type: Jar) {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
from sourceSets.main.output from sourceSets.main.output

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -16,7 +16,11 @@ package org.hyperledger.besu;
import org.hyperledger.besu.util.platform.PlatformDetector; import org.hyperledger.besu.util.platform.PlatformDetector;
import java.net.JarURLConnection;
import java.net.URL;
import java.util.Optional; import java.util.Optional;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
/** /**
* Represent Besu information such as version, OS etc. Used with --version option and during Besu * Represent Besu information such as version, OS etc. Used with --version option and during Besu
@ -27,6 +31,24 @@ public final class BesuInfo {
private static final String VERSION = BesuInfo.class.getPackage().getImplementationVersion(); private static final String VERSION = BesuInfo.class.getPackage().getImplementationVersion();
private static final String OS = PlatformDetector.getOS(); private static final String OS = PlatformDetector.getOS();
private static final String VM = PlatformDetector.getVM(); private static final String VM = PlatformDetector.getVM();
private static final String COMMIT;
static {
String className = BesuInfo.class.getSimpleName() + ".class";
String classPath = BesuInfo.class.getResource(className).toString();
String commit;
try {
URL url = new URL(classPath);
JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
Manifest manifest = jarConnection.getManifest();
Attributes attributes = manifest.getMainAttributes();
commit = attributes.getValue("Commit-Hash");
} catch (Exception e) {
commit = null;
}
COMMIT = commit;
}
private BesuInfo() {} private BesuInfo() {}
@ -60,4 +82,13 @@ public final class BesuInfo {
.map(identity -> String.format("%s/%s/v%s/%s/%s", CLIENT, identity, VERSION, OS, VM)) .map(identity -> String.format("%s/%s/v%s/%s/%s", CLIENT, identity, VERSION, OS, VM))
.orElse(version()); .orElse(version());
} }
/**
* Generate the commit hash for this besu version
*
* @return the commit hash for this besu version
*/
public static String commit() {
return COMMIT;
}
} }

@ -1291,6 +1291,8 @@ public class RunnerBuilder {
new JsonRpcMethodsFactory() new JsonRpcMethodsFactory()
.methods( .methods(
BesuInfo.nodeName(identityString), BesuInfo.nodeName(identityString),
BesuInfo.shortVersion(),
BesuInfo.commit(),
ethNetworkConfig.networkId(), ethNetworkConfig.networkId(),
besuController.getGenesisConfigOptions(), besuController.getGenesisConfigOptions(),
network, network,

@ -823,7 +823,7 @@ task distDocker {
dockerPlatform = "--platform ${project.getProperty('docker-platform')}" dockerPlatform = "--platform ${project.getProperty('docker-platform')}"
println "Building for platform ${project.getProperty('docker-platform')}" println "Building for platform ${project.getProperty('docker-platform')}"
} }
def gitDetails = getGitCommitDetails(7) def gitDetails = getGitCommitDetails()
executable shell executable shell
workingDir dockerBuildDir workingDir dockerBuildDir
args "-c", "docker build ${dockerPlatform} --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${gitDetails.hash} -t ${image} ." args "-c", "docker build ${dockerPlatform} --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${gitDetails.hash} -t ${image} ."

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -23,6 +23,7 @@ jar {
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion(), 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash,
'Automatic-Module-Name': 'org.hyperledger.besu.internal.crypto' 'Automatic-Module-Name': 'org.hyperledger.besu.internal.crypto'
) )
} }

@ -23,6 +23,7 @@ jar {
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion(), 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash,
'Automatic-Module-Name': 'org.hyperledger.besu.internal.crypto' 'Automatic-Module-Name': 'org.hyperledger.besu.internal.crypto'
) )
} }

@ -23,6 +23,7 @@ jar {
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion(), 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash,
'Automatic-Module-Name': 'org.hyperledger.besu.datatypes' 'Automatic-Module-Name': 'org.hyperledger.besu.datatypes'
) )
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -64,7 +64,9 @@ import io.vertx.core.VertxOptions;
/** Provides a facade to construct the JSON-RPC component. */ /** Provides a facade to construct the JSON-RPC component. */
public class JsonRpcTestMethodsFactory { public class JsonRpcTestMethodsFactory {
private static final String CLIENT_VERSION = "TestClientVersion/0.1.0"; private static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
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 static final BigInteger NETWORK_ID = BigInteger.valueOf(123);
private final BlockchainImporter importer; private final BlockchainImporter importer;
@ -175,7 +177,9 @@ public class JsonRpcTestMethodsFactory {
return new JsonRpcMethodsFactory() return new JsonRpcMethodsFactory()
.methods( .methods(
CLIENT_NODE_NAME,
CLIENT_VERSION, CLIENT_VERSION,
CLIENT_COMMIT,
NETWORK_ID, NETWORK_ID,
new StubGenesisConfigOptions(), new StubGenesisConfigOptions(),
peerDiscovery, peerDiscovery,

@ -63,6 +63,7 @@ public enum RpcMethod {
ENGINE_FORKCHOICE_UPDATED_V2("engine_forkchoiceUpdatedV2"), ENGINE_FORKCHOICE_UPDATED_V2("engine_forkchoiceUpdatedV2"),
ENGINE_FORKCHOICE_UPDATED_V3("engine_forkchoiceUpdatedV3"), ENGINE_FORKCHOICE_UPDATED_V3("engine_forkchoiceUpdatedV3"),
ENGINE_EXCHANGE_TRANSITION_CONFIGURATION("engine_exchangeTransitionConfigurationV1"), ENGINE_EXCHANGE_TRANSITION_CONFIGURATION("engine_exchangeTransitionConfigurationV1"),
ENGINE_GET_CLIENT_VERSION_V1("engine_getClientVersionV1"),
ENGINE_GET_PAYLOAD_BODIES_BY_HASH_V1("engine_getPayloadBodiesByHashV1"), ENGINE_GET_PAYLOAD_BODIES_BY_HASH_V1("engine_getPayloadBodiesByHashV1"),
ENGINE_GET_PAYLOAD_BODIES_BY_RANGE_V1("engine_getPayloadBodiesByRangeV1"), ENGINE_GET_PAYLOAD_BODIES_BY_RANGE_V1("engine_getPayloadBodiesByRangeV1"),
ENGINE_EXCHANGE_CAPABILITIES("engine_exchangeCapabilities"), ENGINE_EXCHANGE_CAPABILITIES("engine_exchangeCapabilities"),

@ -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.substring(0, 8)));
}
}

@ -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;
}
}

@ -23,6 +23,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineE
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineForkchoiceUpdatedV1; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineForkchoiceUpdatedV1;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineForkchoiceUpdatedV2; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineForkchoiceUpdatedV2;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineForkchoiceUpdatedV3; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineForkchoiceUpdatedV3;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineGetClientVersionV1;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineGetPayloadBodiesByHashV1; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineGetPayloadBodiesByHashV1;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineGetPayloadBodiesByRangeV1; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineGetPayloadBodiesByRangeV1;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineGetPayloadV1; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineGetPayloadV1;
@ -57,13 +58,17 @@ public class ExecutionEngineJsonRpcMethods extends ApiGroupJsonRpcMethods {
private final ProtocolContext protocolContext; private final ProtocolContext protocolContext;
private final EthPeers ethPeers; private final EthPeers ethPeers;
private final Vertx consensusEngineServer; private final Vertx consensusEngineServer;
private final String clientVersion;
private final String commit;
ExecutionEngineJsonRpcMethods( ExecutionEngineJsonRpcMethods(
final MiningCoordinator miningCoordinator, final MiningCoordinator miningCoordinator,
final ProtocolSchedule protocolSchedule, final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext, final ProtocolContext protocolContext,
final EthPeers ethPeers, final EthPeers ethPeers,
final Vertx consensusEngineServer) { final Vertx consensusEngineServer,
final String clientVersion,
final String commit) {
this.mergeCoordinator = this.mergeCoordinator =
Optional.ofNullable(miningCoordinator) Optional.ofNullable(miningCoordinator)
.filter(mc -> mc.isCompatibleWithEngineApi()) .filter(mc -> mc.isCompatibleWithEngineApi())
@ -72,6 +77,8 @@ public class ExecutionEngineJsonRpcMethods extends ApiGroupJsonRpcMethods {
this.protocolContext = protocolContext; this.protocolContext = protocolContext;
this.ethPeers = ethPeers; this.ethPeers = ethPeers;
this.consensusEngineServer = consensusEngineServer; this.consensusEngineServer = consensusEngineServer;
this.clientVersion = clientVersion;
this.commit = commit;
} }
@Override @Override
@ -147,7 +154,9 @@ public class ExecutionEngineJsonRpcMethods extends ApiGroupJsonRpcMethods {
new EngineExchangeCapabilities( new EngineExchangeCapabilities(
consensusEngineServer, protocolContext, engineQosTimer), consensusEngineServer, protocolContext, engineQosTimer),
new EnginePreparePayloadDebug( new EnginePreparePayloadDebug(
consensusEngineServer, protocolContext, engineQosTimer, mergeCoordinator.get()))); consensusEngineServer, protocolContext, engineQosTimer, mergeCoordinator.get()),
new EngineGetClientVersionV1(
consensusEngineServer, protocolContext, engineQosTimer, clientVersion, commit)));
if (protocolSchedule.anyMatch(p -> p.spec().getName().equalsIgnoreCase("cancun"))) { if (protocolSchedule.anyMatch(p -> p.spec().getName().equalsIgnoreCase("cancun"))) {
executionEngineApisSupported.add( executionEngineApisSupported.add(

@ -54,7 +54,9 @@ import io.vertx.core.Vertx;
public class JsonRpcMethodsFactory { public class JsonRpcMethodsFactory {
public Map<String, JsonRpcMethod> methods( public Map<String, JsonRpcMethod> methods(
final String clientNodeName,
final String clientVersion, final String clientVersion,
final String commit,
final BigInteger networkId, final BigInteger networkId,
final GenesisConfigOptions genesisConfigOptions, final GenesisConfigOptions genesisConfigOptions,
final P2PNetwork p2pNetwork, final P2PNetwork p2pNetwork,
@ -89,7 +91,7 @@ public class JsonRpcMethodsFactory {
final List<JsonRpcMethods> availableApiGroups = final List<JsonRpcMethods> availableApiGroups =
List.of( List.of(
new AdminJsonRpcMethods( new AdminJsonRpcMethods(
clientVersion, clientNodeName,
networkId, networkId,
genesisConfigOptions, genesisConfigOptions,
p2pNetwork, p2pNetwork,
@ -115,7 +117,9 @@ public class JsonRpcMethodsFactory {
protocolSchedule, protocolSchedule,
protocolContext, protocolContext,
ethPeers, ethPeers,
consensusEngineServer), consensusEngineServer,
clientVersion,
commit),
new EthJsonRpcMethods( new EthJsonRpcMethods(
blockchainQueries, blockchainQueries,
synchronizer, synchronizer,
@ -141,7 +145,7 @@ public class JsonRpcMethodsFactory {
filterManager), filterManager),
new PrivxJsonRpcMethods( new PrivxJsonRpcMethods(
blockchainQueries, protocolSchedule, transactionPool, privacyParameters), blockchainQueries, protocolSchedule, transactionPool, privacyParameters),
new Web3JsonRpcMethods(clientVersion), new Web3JsonRpcMethods(clientNodeName),
new TraceJsonRpcMethods( new TraceJsonRpcMethods(
blockchainQueries, protocolSchedule, protocolContext, apiConfiguration), blockchainQueries, protocolSchedule, protocolContext, apiConfiguration),
new TxPoolJsonRpcMethods(transactionPool), new TxPoolJsonRpcMethods(transactionPool),

@ -75,7 +75,9 @@ public abstract class AbstractJsonRpcHttpServiceTest {
protected BlockchainSetupUtil blockchainSetupUtil; protected BlockchainSetupUtil blockchainSetupUtil;
protected static String CLIENT_VERSION = "TestClientVersion/0.1.0"; protected static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
protected static final String CLIENT_VERSION = "0.1.0";
protected static final String CLIENT_COMMIT = "12345678";
protected static final BigInteger NETWORK_ID = BigInteger.valueOf(123); protected static final BigInteger NETWORK_ID = BigInteger.valueOf(123);
protected static final Collection<String> JSON_RPC_APIS = protected static final Collection<String> JSON_RPC_APIS =
Arrays.asList( Arrays.asList(
@ -168,7 +170,9 @@ public abstract class AbstractJsonRpcHttpServiceTest {
return new JsonRpcMethodsFactory() return new JsonRpcMethodsFactory()
.methods( .methods(
CLIENT_NODE_NAME,
CLIENT_VERSION, CLIENT_VERSION,
CLIENT_COMMIT,
NETWORK_ID, NETWORK_ID,
new StubGenesisConfigOptions(), new StubGenesisConfigOptions(),
peerDiscoveryMock, peerDiscoveryMock,

@ -58,13 +58,13 @@ public class AdminJsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
final List<EthPeer> peerList = new ArrayList<>(); final List<EthPeer> peerList = new ArrayList<>();
final PeerInfo info1 = final PeerInfo info1 =
new PeerInfo( new PeerInfo(
4, CLIENT_VERSION, caps, 30302, Bytes.fromHexString(String.format("%0128x", 1))); 4, CLIENT_NODE_NAME, caps, 30302, Bytes.fromHexString(String.format("%0128x", 1)));
final PeerInfo info2 = final PeerInfo info2 =
new PeerInfo( new PeerInfo(
4, CLIENT_VERSION, caps, 60302, Bytes.fromHexString(String.format("%0128x", 2))); 4, CLIENT_NODE_NAME, caps, 60302, Bytes.fromHexString(String.format("%0128x", 2)));
final PeerInfo info3 = final PeerInfo info3 =
new PeerInfo( new PeerInfo(
4, CLIENT_VERSION, caps, 60303, Bytes.fromHexString(String.format("%0128x", 3))); 4, CLIENT_NODE_NAME, caps, 60303, Bytes.fromHexString(String.format("%0128x", 3)));
final InetSocketAddress addr30301 = new InetSocketAddress("localhost", 30301); final InetSocketAddress addr30301 = new InetSocketAddress("localhost", 30301);
final InetSocketAddress addr30302 = new InetSocketAddress("localhost", 30302); final InetSocketAddress addr30302 = new InetSocketAddress("localhost", 30302);
final InetSocketAddress addr60301 = new InetSocketAddress("localhost", 60301); final InetSocketAddress addr60301 = new InetSocketAddress("localhost", 60301);

@ -79,7 +79,9 @@ public class JsonRpcHttpServiceHostAllowlistTest {
private static OkHttpClient client; private static OkHttpClient client;
private static String baseUrl; private static String baseUrl;
private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
private static final String CLIENT_VERSION = "TestClientVersion/0.1.0"; private static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
private static final String CLIENT_VERSION = "0.1.0";
private static final String CLIENT_COMMIT = "12345678";
private static final BigInteger CHAIN_ID = BigInteger.valueOf(123); private static final BigInteger CHAIN_ID = BigInteger.valueOf(123);
private final JsonRpcConfiguration jsonRpcConfig = createJsonRpcConfig(); private final JsonRpcConfiguration jsonRpcConfig = createJsonRpcConfig();
@ -100,7 +102,9 @@ public class JsonRpcHttpServiceHostAllowlistTest {
rpcMethods = rpcMethods =
new JsonRpcMethodsFactory() new JsonRpcMethodsFactory()
.methods( .methods(
CLIENT_NODE_NAME,
CLIENT_VERSION, CLIENT_VERSION,
CLIENT_COMMIT,
CHAIN_ID, CHAIN_ID,
new StubGenesisConfigOptions(), new StubGenesisConfigOptions(),
peerDiscoveryMock, peerDiscoveryMock,

@ -100,7 +100,9 @@ public class JsonRpcHttpServiceLoginTest {
protected static OkHttpClient client; protected static OkHttpClient client;
protected static String baseUrl; protected static String baseUrl;
protected static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); protected static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
protected static final String CLIENT_VERSION = "TestClientVersion/0.1.0"; protected static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
protected static final String CLIENT_VERSION = "0.1.0";
protected static final String CLIENT_COMMIT = "12345678";
protected static final BigInteger CHAIN_ID = BigInteger.valueOf(123); protected static final BigInteger CHAIN_ID = BigInteger.valueOf(123);
protected static P2PNetwork peerDiscoveryMock; protected static P2PNetwork peerDiscoveryMock;
protected static BlockchainQueries blockchainQueries; protected static BlockchainQueries blockchainQueries;
@ -131,7 +133,9 @@ public class JsonRpcHttpServiceLoginTest {
rpcMethods = rpcMethods =
new JsonRpcMethodsFactory() new JsonRpcMethodsFactory()
.methods( .methods(
CLIENT_NODE_NAME,
CLIENT_VERSION, CLIENT_VERSION,
CLIENT_COMMIT,
CHAIN_ID, CHAIN_ID,
genesisConfigOptions, genesisConfigOptions,
peerDiscoveryMock, peerDiscoveryMock,

@ -94,7 +94,9 @@ public class JsonRpcHttpServiceRpcApisTest {
private JsonRpcHttpService service; private JsonRpcHttpService service;
private static String baseUrl; private static String baseUrl;
private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
private static final String CLIENT_VERSION = "TestClientVersion/0.1.0"; private static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
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 static final BigInteger NETWORK_ID = BigInteger.valueOf(123);
private JsonRpcConfiguration configuration; private JsonRpcConfiguration configuration;
private static final List<String> netServices = private static final List<String> netServices =
@ -202,7 +204,9 @@ public class JsonRpcHttpServiceRpcApisTest {
final Map<String, JsonRpcMethod> rpcMethods = final Map<String, JsonRpcMethod> rpcMethods =
new JsonRpcMethodsFactory() new JsonRpcMethodsFactory()
.methods( .methods(
CLIENT_NODE_NAME,
CLIENT_VERSION, CLIENT_VERSION,
CLIENT_COMMIT,
NETWORK_ID, NETWORK_ID,
new StubGenesisConfigOptions(), new StubGenesisConfigOptions(),
mock(P2PNetwork.class), mock(P2PNetwork.class),
@ -310,7 +314,9 @@ public class JsonRpcHttpServiceRpcApisTest {
final Map<String, JsonRpcMethod> rpcMethods = final Map<String, JsonRpcMethod> rpcMethods =
new JsonRpcMethodsFactory() new JsonRpcMethodsFactory()
.methods( .methods(
CLIENT_NODE_NAME,
CLIENT_VERSION, CLIENT_VERSION,
CLIENT_COMMIT,
NETWORK_ID, NETWORK_ID,
new StubGenesisConfigOptions(), new StubGenesisConfigOptions(),
p2pNetwork, p2pNetwork,

@ -202,7 +202,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
testHelper.assertValidJsonRpcResult(json, id); testHelper.assertValidJsonRpcResult(json, id);
// Check result // Check result
final String result = json.getString("result"); final String result = json.getString("result");
assertThat(result).isEqualTo(CLIENT_VERSION); assertThat(result).isEqualTo(CLIENT_NODE_NAME);
} }
} }
@ -1127,7 +1127,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
testHelper.assertValidJsonRpcResult(json, id); testHelper.assertValidJsonRpcResult(json, id);
// Check result // Check result
final String result = json.getString("result"); final String result = json.getString("result");
assertThat(result).isEqualTo(CLIENT_VERSION); assertThat(result).isEqualTo(CLIENT_NODE_NAME);
} }
} }
@ -1143,7 +1143,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
final JsonObject json = new JsonObject(resp.body().string()); final JsonObject json = new JsonObject(resp.body().string());
testHelper.assertValidJsonRpcResult(json, id); testHelper.assertValidJsonRpcResult(json, id);
final String result = json.getString("result"); final String result = json.getString("result");
assertThat(result).isEqualTo(CLIENT_VERSION); assertThat(result).isEqualTo(CLIENT_NODE_NAME);
} }
} }
@ -1175,7 +1175,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
testHelper.assertValidJsonRpcResult(json, null); testHelper.assertValidJsonRpcResult(json, null);
// Check result // Check result
final String result = json.getString("result"); final String result = json.getString("result");
assertThat(result).isEqualTo(CLIENT_VERSION); assertThat(result).isEqualTo(CLIENT_NODE_NAME);
} }
} }
@ -1197,7 +1197,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
testHelper.assertValidJsonRpcResult(json, id); testHelper.assertValidJsonRpcResult(json, id);
// Check result // Check result
final String result = json.getString("result"); final String result = json.getString("result");
assertThat(result).isEqualTo(CLIENT_VERSION); assertThat(result).isEqualTo(CLIENT_NODE_NAME);
} }
} }
@ -1218,7 +1218,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
testHelper.assertValidJsonRpcResult(json, id); testHelper.assertValidJsonRpcResult(json, id);
// Check result // Check result
final String result = json.getString("result"); final String result = json.getString("result");
assertThat(result).isEqualTo(CLIENT_VERSION); assertThat(result).isEqualTo(CLIENT_NODE_NAME);
} }
} }
@ -1242,7 +1242,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
testHelper.assertValidJsonRpcResult(json, id); testHelper.assertValidJsonRpcResult(json, id);
// Check result // Check result
final String result = json.getString("result"); final String result = json.getString("result");
assertThat(result).isEqualTo(CLIENT_VERSION); assertThat(result).isEqualTo(CLIENT_NODE_NAME);
} }
} }
@ -1268,7 +1268,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
testHelper.assertValidJsonRpcResult(json, id); testHelper.assertValidJsonRpcResult(json, id);
// Check result // Check result
final String result = json.getString("result"); final String result = json.getString("result");
assertThat(result).isEqualTo(CLIENT_VERSION); assertThat(result).isEqualTo(CLIENT_NODE_NAME);
} }
} }
@ -1289,7 +1289,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
testHelper.assertValidJsonRpcResult(json, id); testHelper.assertValidJsonRpcResult(json, id);
// Check result // Check result
final String result = json.getString("result"); final String result = json.getString("result");
assertThat(result).isEqualTo(CLIENT_VERSION); assertThat(result).isEqualTo(CLIENT_NODE_NAME);
} }
} }
@ -1353,7 +1353,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
final JsonObject json = new JsonObject(resp.body().string()); final JsonObject json = new JsonObject(resp.body().string());
testHelper.assertValidJsonRpcResult(json, id); testHelper.assertValidJsonRpcResult(json, id);
final String result = json.getString("result"); final String result = json.getString("result");
assertThat(result).isEqualTo(CLIENT_VERSION); assertThat(result).isEqualTo(CLIENT_NODE_NAME);
} }
} }
@ -1485,7 +1485,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
// Check result web3_clientVersion // Check result web3_clientVersion
final JsonObject jsonClientVersion = responses.get(clientVersionRequestId); final JsonObject jsonClientVersion = responses.get(clientVersionRequestId);
testHelper.assertValidJsonRpcResult(jsonClientVersion, clientVersionRequestId); testHelper.assertValidJsonRpcResult(jsonClientVersion, clientVersionRequestId);
assertThat(jsonClientVersion.getString("result")).isEqualTo(CLIENT_VERSION); assertThat(jsonClientVersion.getString("result")).isEqualTo(CLIENT_NODE_NAME);
// Check result unknown method // Check result unknown method
final JsonObject jsonError = responses.get(brokenRequestId); final JsonObject jsonError = responses.get(brokenRequestId);
@ -1540,7 +1540,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
// Check result web3_clientVersion // Check result web3_clientVersion
final JsonObject jsonClientVersion = responses.get(clientVersionRequestId); final JsonObject jsonClientVersion = responses.get(clientVersionRequestId);
testHelper.assertValidJsonRpcResult(jsonClientVersion, clientVersionRequestId); testHelper.assertValidJsonRpcResult(jsonClientVersion, clientVersionRequestId);
assertThat(jsonClientVersion.getString("result")).isEqualTo(CLIENT_VERSION); assertThat(jsonClientVersion.getString("result")).isEqualTo(CLIENT_NODE_NAME);
// Check invalid request // Check invalid request
final JsonObject jsonError = responses.get(invalidId); final JsonObject jsonError = responses.get(invalidId);
@ -1605,7 +1605,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
// Check result web3_clientVersion // Check result web3_clientVersion
final JsonObject jsonClientVersion = responses.get(clientVersionRequestId); final JsonObject jsonClientVersion = responses.get(clientVersionRequestId);
testHelper.assertValidJsonRpcResult(jsonClientVersion, clientVersionRequestId); testHelper.assertValidJsonRpcResult(jsonClientVersion, clientVersionRequestId);
assertThat(jsonClientVersion.getString("result")).isEqualTo(CLIENT_VERSION); assertThat(jsonClientVersion.getString("result")).isEqualTo(CLIENT_NODE_NAME);
// Check result net_version // Check result net_version
final JsonObject jsonNetVersion = responses.get(netVersionRequestId); final JsonObject jsonNetVersion = responses.get(netVersionRequestId);

@ -78,7 +78,9 @@ public class JsonRpcHttpServiceTestBase {
protected static OkHttpClient client; protected static OkHttpClient client;
protected static String baseUrl; protected static String baseUrl;
protected static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); protected static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
protected static final String CLIENT_VERSION = "TestClientVersion/0.1.0"; protected static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
protected static final String CLIENT_VERSION = "0.1.0";
protected static final String CLIENT_COMMIT = "12345678";
protected static final BigInteger CHAIN_ID = BigInteger.valueOf(123); protected static final BigInteger CHAIN_ID = BigInteger.valueOf(123);
protected static P2PNetwork peerDiscoveryMock; protected static P2PNetwork peerDiscoveryMock;
protected static EthPeers ethPeersMock; protected static EthPeers ethPeersMock;
@ -108,7 +110,9 @@ public class JsonRpcHttpServiceTestBase {
rpcMethods = rpcMethods =
new JsonRpcMethodsFactory() new JsonRpcMethodsFactory()
.methods( .methods(
CLIENT_NODE_NAME,
CLIENT_VERSION, CLIENT_VERSION,
CLIENT_COMMIT,
CHAIN_ID, CHAIN_ID,
new StubGenesisConfigOptions(), new StubGenesisConfigOptions(),
peerDiscoveryMock, peerDiscoveryMock,

@ -85,7 +85,9 @@ public class JsonRpcHttpServiceTlsClientAuthTest {
protected static final Vertx vertx = Vertx.vertx(); protected static final Vertx vertx = Vertx.vertx();
private static final String JSON_HEADER = "application/json; charset=utf-8"; private static final String JSON_HEADER = "application/json; charset=utf-8";
private static final String CLIENT_VERSION = "TestClientVersion/0.1.0"; private static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
private static final String CLIENT_VERSION = "0.1.0";
private static final String CLIENT_COMMIT = "12345678";
private static final BigInteger CHAIN_ID = BigInteger.valueOf(123); private static final BigInteger CHAIN_ID = BigInteger.valueOf(123);
private static final NatService natService = new NatService(Optional.empty()); private static final NatService natService = new NatService(Optional.empty());
@ -114,7 +116,9 @@ public class JsonRpcHttpServiceTlsClientAuthTest {
rpcMethods = rpcMethods =
new JsonRpcMethodsFactory() new JsonRpcMethodsFactory()
.methods( .methods(
CLIENT_NODE_NAME,
CLIENT_VERSION, CLIENT_VERSION,
CLIENT_COMMIT,
CHAIN_ID, CHAIN_ID,
new StubGenesisConfigOptions(), new StubGenesisConfigOptions(),
peerDiscoveryMock, peerDiscoveryMock,

@ -75,7 +75,9 @@ class JsonRpcHttpServiceTlsMisconfigurationTest {
protected static final Vertx vertx = Vertx.vertx(); protected static final Vertx vertx = Vertx.vertx();
private static final String CLIENT_VERSION = "TestClientVersion/0.1.0"; private static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
private static final String CLIENT_VERSION = "0.1.0";
private static final String CLIENT_COMMIT = "12345678";
private static final BigInteger CHAIN_ID = BigInteger.valueOf(123); private static final BigInteger CHAIN_ID = BigInteger.valueOf(123);
private static final NatService natService = new NatService(Optional.empty()); private static final NatService natService = new NatService(Optional.empty());
private final SelfSignedP12Certificate besuCertificate = SelfSignedP12Certificate.create(); private final SelfSignedP12Certificate besuCertificate = SelfSignedP12Certificate.create();
@ -102,7 +104,9 @@ class JsonRpcHttpServiceTlsMisconfigurationTest {
rpcMethods = rpcMethods =
new JsonRpcMethodsFactory() new JsonRpcMethodsFactory()
.methods( .methods(
CLIENT_NODE_NAME,
CLIENT_VERSION, CLIENT_VERSION,
CLIENT_COMMIT,
CHAIN_ID, CHAIN_ID,
new StubGenesisConfigOptions(), new StubGenesisConfigOptions(),
peerDiscoveryMock, peerDiscoveryMock,

@ -81,7 +81,9 @@ public class JsonRpcHttpServiceTlsTest {
protected static final Vertx vertx = Vertx.vertx(); protected static final Vertx vertx = Vertx.vertx();
private static final String JSON_HEADER = "application/json; charset=utf-8"; private static final String JSON_HEADER = "application/json; charset=utf-8";
private static final String CLIENT_VERSION = "TestClientVersion/0.1.0"; private static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
private static final String CLIENT_VERSION = "0.1.0";
private static final String CLIENT_COMMIT = "12345678";
private static final BigInteger CHAIN_ID = BigInteger.valueOf(123); private static final BigInteger CHAIN_ID = BigInteger.valueOf(123);
private static final NatService natService = new NatService(Optional.empty()); private static final NatService natService = new NatService(Optional.empty());
private JsonRpcHttpService service; private JsonRpcHttpService service;
@ -103,7 +105,9 @@ public class JsonRpcHttpServiceTlsTest {
rpcMethods = rpcMethods =
new JsonRpcMethodsFactory() new JsonRpcMethodsFactory()
.methods( .methods(
CLIENT_NODE_NAME,
CLIENT_VERSION, CLIENT_VERSION,
CLIENT_COMMIT,
CHAIN_ID, CHAIN_ID,
new StubGenesisConfigOptions(), new StubGenesisConfigOptions(),
peerDiscoveryMock, peerDiscoveryMock,

@ -0,0 +1,72 @@
/*
* 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 static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.ethereum.ProtocolContext;
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.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EngineGetClientVersionResultV1;
import io.vertx.core.Vertx;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
class EngineGetClientVersionV1Test {
private static final String ENGINE_CLIENT_CODE = "BU";
private static final String ENGINE_CLIENT_NAME = "Besu";
private static final String CLIENT_VERSION = "v25.6.7-dev-abcdef12";
private static final String COMMIT = "abcdef12";
private EngineGetClientVersionV1 getClientVersion;
@BeforeEach
void before() {
getClientVersion =
new EngineGetClientVersionV1(
Mockito.mock(Vertx.class),
Mockito.mock(ProtocolContext.class),
Mockito.mock(EngineCallListener.class),
CLIENT_VERSION,
COMMIT);
}
@Test
void testGetName() {
assertThat(getClientVersion.getName()).isEqualTo("engine_getClientVersionV1");
}
@Test
void testSyncResponse() {
JsonRpcRequestContext request = new JsonRpcRequestContext(new JsonRpcRequest("v", "m", null));
JsonRpcResponse actualResult = getClientVersion.syncResponse(request);
assertThat(actualResult).isInstanceOf(JsonRpcSuccessResponse.class);
JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) actualResult;
assertThat(successResponse.getResult()).isInstanceOf(EngineGetClientVersionResultV1.class);
EngineGetClientVersionResultV1 actualEngineGetClientVersionResultV1 =
(EngineGetClientVersionResultV1) successResponse.getResult();
assertThat(actualEngineGetClientVersionResultV1.getName()).isEqualTo(ENGINE_CLIENT_NAME);
assertThat(actualEngineGetClientVersionResultV1.getCode()).isEqualTo(ENGINE_CLIENT_CODE);
assertThat(actualEngineGetClientVersionResultV1.getVersion()).isEqualTo(CLIENT_VERSION);
assertThat(actualEngineGetClientVersionResultV1.getCommit()).isEqualTo(COMMIT);
}
}

@ -115,7 +115,9 @@ public class WebSocketServiceLoginTest {
protected static OkHttpClient client; protected static OkHttpClient client;
protected static String baseUrl; protected static String baseUrl;
protected static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); protected static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
protected static final String CLIENT_VERSION = "TestClientVersion/0.1.0"; protected static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
protected static final String CLIENT_VERSION = "0.1.0";
protected static final String CLIENT_COMMIT = "12345678";
protected static final BigInteger CHAIN_ID = BigInteger.valueOf(123); protected static final BigInteger CHAIN_ID = BigInteger.valueOf(123);
protected static P2PNetwork peerDiscoveryMock; protected static P2PNetwork peerDiscoveryMock;
protected static BlockchainQueries blockchainQueries; protected static BlockchainQueries blockchainQueries;
@ -167,7 +169,9 @@ public class WebSocketServiceLoginTest {
spy( spy(
new JsonRpcMethodsFactory() new JsonRpcMethodsFactory()
.methods( .methods(
CLIENT_NODE_NAME,
CLIENT_VERSION, CLIENT_VERSION,
CLIENT_COMMIT,
CHAIN_ID, CHAIN_ID,
genesisConfigOptions, genesisConfigOptions,
peerDiscoveryMock, peerDiscoveryMock,

@ -7,7 +7,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -29,7 +29,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -20,7 +20,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -23,6 +23,7 @@ jar {
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion(), 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash,
'Automatic-Module-Name': 'org.hyperledger.besu.internal.rlp' 'Automatic-Module-Name': 'org.hyperledger.besu.internal.rlp'
) )
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -25,6 +25,7 @@ jar {
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion(), 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash,
'Automatic-Module-Name': 'org.hyperledger.besu.evm' 'Automatic-Module-Name': 'org.hyperledger.besu.evm'
) )
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,6 +22,7 @@ jar {
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion(), 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash,
'Automatic-Module-Name': 'org.hyperledger.besu.plugin.api' 'Automatic-Module-Name': 'org.hyperledger.besu.plugin.api'
) )
} }

@ -20,7 +20,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -24,7 +24,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -22,7 +22,8 @@ jar {
'Specification-Title': archiveBaseName, 'Specification-Title': archiveBaseName,
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion() 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash
) )
} }
} }

@ -23,6 +23,7 @@ jar {
'Specification-Version': project.version, 'Specification-Version': project.version,
'Implementation-Title': archiveBaseName, 'Implementation-Title': archiveBaseName,
'Implementation-Version': calculateVersion(), 'Implementation-Version': calculateVersion(),
'Commit-Hash': getGitCommitDetails(40).hash,
'Automatic-Module-Name': 'org.hyperledger.besu.internal.util' 'Automatic-Module-Name': 'org.hyperledger.besu.internal.util'
) )
} }

Loading…
Cancel
Save