Add a version to fluffy and add web3_clientVersion JSON-RPC (#1531)

This commit is contained in:
Kim De Mey 2023-04-05 16:14:42 +02:00 committed by GitHub
parent fdad9cfd00
commit fb81937708
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 57 additions and 1 deletions

View File

@ -19,7 +19,8 @@ import
beacon_chain/spec/datatypes/altair, beacon_chain/spec/datatypes/altair,
beacon_chain/gossip_processing/light_client_processor, beacon_chain/gossip_processing/light_client_processor,
./conf, ./network_metadata, ./common/common_utils, ./conf, ./network_metadata, ./common/common_utils,
./rpc/[rpc_eth_api, rpc_discovery_api, rpc_portal_api, rpc_portal_debug_api], ./rpc/[rpc_web3_api, rpc_eth_api, rpc_discovery_api, rpc_portal_api,
rpc_portal_debug_api],
./network/state/[state_network, state_content], ./network/state/[state_network, state_content],
./network/history/[history_network, history_content], ./network/history/[history_network, history_content],
./network/beacon_light_client/[ ./network/beacon_light_client/[
@ -246,6 +247,7 @@ proc run(config: PortalConf) {.raises: [CatchableError].} =
let ta = initTAddress(config.rpcAddress, config.rpcPort) let ta = initTAddress(config.rpcAddress, config.rpcPort)
var rpcHttpServerWithProxy = RpcProxy.new([ta], config.proxyUri) var rpcHttpServerWithProxy = RpcProxy.new([ta], config.proxyUri)
rpcHttpServerWithProxy.installDiscoveryApiHandlers(d) rpcHttpServerWithProxy.installDiscoveryApiHandlers(d)
rpcHttpServerWithProxy.installWeb3ApiHandlers()
if stateNetwork.isSome(): if stateNetwork.isSome():
rpcHttpServerWithProxy.installPortalApiHandlers( rpcHttpServerWithProxy.installPortalApiHandlers(
stateNetwork.get().portalProtocol, "state") stateNetwork.get().portalProtocol, "state")

View File

@ -15,3 +15,4 @@ import
export rpcclient, rpc_types, hexstrings, errors export rpcclient, rpc_types, hexstrings, errors
createRpcSigs(RpcClient, currentSourcePath.parentDir / "rpc_calls" / "rpc_eth_calls.nim") createRpcSigs(RpcClient, currentSourcePath.parentDir / "rpc_calls" / "rpc_eth_calls.nim")
createRpcSigs(RpcClient, currentSourcePath.parentDir / "rpc_calls" / "rpc_web3_calls.nim")

View File

@ -0,0 +1 @@
proc web3_clientVersion(): string

View File

@ -0,0 +1,20 @@
# Nimbus fluffy
# Copyright (c) 2023 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
{.push raises: [].}
import
json_rpc/[rpcproxy, rpcserver],
../version
export rpcserver
proc installWeb3ApiHandlers*(rpcServer: RpcServer|RpcProxy)
{.raises: [CatchableError].} =
rpcServer.rpc("web3_clientVersion") do() -> string:
return clientVersion

32
fluffy/version.nim Normal file
View File

@ -0,0 +1,32 @@
# Nimbus fluffy
# Copyright (c) 2023 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
{.push raises: [].}
import strutils
const
versionMajor* = 0
versionMinor* = 1
versionBuild* = 0
gitRevision* = strip(staticExec("git rev-parse --short HEAD"))[0..5]
versionAsStr* =
$versionMajor & "." & $versionMinor & "." & $versionBuild
fullVersionStr* = "v" & versionAsStr & "-" & gitRevision
clientName* = "fluffy"
nimVersion* = staticExec("nim --version | grep -oP '[0-9]+\\.[0-9]+\\.[0-9]+'")
# The web3_clientVersion
clientVersion* = clientName & "/" &
fullVersionStr & "/" &
hostOS & "-" & hostCPU & "/" &
"Nim" & nimVersion