added software version

This commit is contained in:
Pedro Miranda 2024-11-19 10:30:28 +00:00
parent 54007f7dec
commit 4b5834c21e
2 changed files with 68 additions and 12 deletions

View File

@ -13,7 +13,8 @@ import
execution/execution_wrapper,
beacon_chain/[conf, conf_common],
beacon_chain/[beacon_chain_db],
beacon_chain/validators/keystore_management
beacon_chain/validators/keystore_management,
version
## Constants
## TODO: evaluate the proposed timeouts with team
@ -144,29 +145,22 @@ proc startTasks*(
# ------
when isMainModule:
info "Starting Nimbus"
## TODO
## - file limits
## - setup logging
## - read configuration (check nimbus_configs file anottations)
notice "Starting Nimbus"
## - implement config reader for all components
let nimbusConfigs = NimbusConfig()
var tasksList: NimbusTasks = NimbusTasks.new
##TODO: this is an adapted call os the vars required by makeBannerAndConfig
##these values need to be read from some config file
const SPEC_VERSION = "tbd"
const copyrights = "status"
const nimBanner = "nimbus"
const clientId = "nimbus unified"
var beaconNodeConfig = makeBannerAndConfig(
clientId, copyrights, nimBanner, SPEC_VERSION, [], BeaconNodeConf
clientName, copyrightBanner, nimBanner, versionAsStr, [], BeaconNodeConf
).valueOr:
stderr.write error
quit QuitFailure
#TODO: if we don't add the "db" program crashes on
if not(checkAndCreateDataDir(string(beaconNodeConfig.dataDir/"db"))):
if not (checkAndCreateDataDir(string(beaconNodeConfig.dataDir / "db"))):
# We are unable to access/create data folder or data folder's
# permissions are insecure.
quit QuitFailure

View File

@ -0,0 +1,62 @@
# Nimbus
# Copyright (c) 2024 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 std/strutils, stew/byteutils, metrics
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* = "Nimbus"
nimFullBanner = staticExec("nim --version")
nimBanner* = staticExec("nim --version | grep Version")
# The web3_clientVersion
clientVersion* =
clientName & "/" & fullVersionStr & "/" & hostOS & "-" & hostCPU & "/" & "Nim" &
NimVersion
compileYear = CompileDate[0 ..< 4] # YYYY-MM-DD (UTC)
copyrightBanner* =
"Copyright (c) 2021-" & compileYear & " Status Research & Development GmbH"
# Short debugging identifier to be placed in the ENR
enrClientInfoShort* = toBytes("f")
func getNimGitHash*(): string =
const gitPrefix = "git hash: "
let tmp = splitLines(nimFullBanner)
if tmp.len == 0:
return
for line in tmp:
if line.startsWith(gitPrefix) and line.len > 8 + gitPrefix.len:
result = line[gitPrefix.len ..< gitPrefix.len + 8]
# TODO: Currently prefixing these metric names as the non prefixed names give
# a collector already registered conflict at runtime. This is due to the same
# names in nimbus-eth2 nimbus_binary_common.nim even though there are no direct
# imports of that file.
declareGauge versionGauge,
"Nimbus version info (as metric labels)",
["version", "commit"],
name = "nimbus_version"
versionGauge.set(1, labelValues = [fullVersionStr, gitRevision])
declareGauge nimVersionGauge,
"Nim version info", ["version", "nim_commit"], name = "nimbus_nim_version"
nimVersionGauge.set(1, labelValues = [NimVersion, getNimGitHash()])