From 20edc0dcf5066dd944bf83c5792cace0919e8676 Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Fri, 1 Nov 2024 15:29:38 +0100 Subject: [PATCH] Use common format for clientid (#2810) --- nimbus/config.nim | 24 +++++++----------------- nimbus/version.nim | 8 ++++---- tests/test_rpc.nim | 2 +- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/nimbus/config.nim b/nimbus/config.nim index 44edede5d..6a48dcbcc 100644 --- a/nimbus/config.nim +++ b/nimbus/config.nim @@ -11,6 +11,7 @@ import std/[ options, + strformat, strutils, times, os, @@ -31,17 +32,6 @@ import export net, defs -const - # TODO: fix this agent-string format to match other - # eth clients format - NimbusIdent* = "$# v$# [$#: $#, $#, $#]" % [ - NimbusName, - NimbusVersion, - hostOS, - hostCPU, - VmName, - GitRevision - ] let # e.g.: Copyright (c) 2018-2021 Status Research & Development GmbH @@ -50,16 +40,16 @@ let " Status Research & Development GmbH" # e.g.: - # Nimbus v0.1.0 [windows: amd64, rocksdb, evmc, dda8914f] + # nimbus/v0.1.0-abcdef/os-cpu/nim-a.b.c/emvc # Copyright (c) 2018-2021 Status Research & Development GmbH NimbusBuild* = "$#\p$#" % [ - NimbusIdent, + ClientId, NimbusCopyright, ] - NimbusHeader* = "$#\p\p$#" % [ + NimbusHeader* = "$#\p\pNim version $#" % [ NimbusBuild, - version.NimVersion + NimVersion ] func defaultDataDir*(): string = @@ -357,8 +347,8 @@ type agentString* {. desc: "Node agent string which is used as identifier in network" - defaultValue: NimbusIdent - defaultValueDesc: $NimbusIdent + defaultValue: ClientId + defaultValueDesc: $ClientId name: "agent-string" .}: string beaconChunkSize* {. diff --git a/nimbus/version.nim b/nimbus/version.nim index bc2aaccd3..d4bccb9ca 100644 --- a/nimbus/version.nim +++ b/nimbus/version.nim @@ -7,8 +7,8 @@ # those terms. import - std/[strutils, os, sequtils], - stew/byteutils + std/[strformat, strutils, os, sequtils], + stew/byteutils, ./compile_info const sourcePath = currentSourcePath.rsplit({DirSep, AltSep}, 1)[0] @@ -59,6 +59,6 @@ const GitRevisionBytes* = hexToByteArray[4](GitRevision) - NimVersion* = "Nim version " & $NimMajor & "." & $NimMinor & "." & $NimPatch - FullVersionStr* = "v" & NimbusVersion & "-" & GitRevision + + ClientId* = &"{NimbusName}/{FullVersionStr}/{hostOS}-{hostCPU}/Nim-{NimVersion}/{VmName}" diff --git a/tests/test_rpc.nim b/tests/test_rpc.nim index 14561b700..5f3e83b71 100644 --- a/tests/test_rpc.nim +++ b/tests/test_rpc.nim @@ -252,7 +252,7 @@ proc rpcMain*() = # TODO: add more tests here test "web3_clientVersion": let res = await client.web3_clientVersion() - check res == NimbusIdent + check res == ClientId test "web3_sha3": let data = @(NimbusName.toOpenArrayByte(0, NimbusName.len-1))