Skip to content

Commit 1ae79dc

Browse files
authored
NimbusVersion in one place for all version related code (#3609)
* NimbusVersion in one place for all version related code .nimble file, nimbus-eth1 binaries, docker built release files, etc now get the 'NimbusVersion' string from one place: 'version.nim'. This PR also fix nightly build failure due to recent changes that import non nim vm stuff into version.nim * oops * oops again * Fix test_rpc * Add version linter * Fix check_version.sh * Link to specific commit
1 parent 1403470 commit 1ae79dc

File tree

9 files changed

+111
-43
lines changed

9 files changed

+111
-43
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,4 @@ jobs:
124124
if: ${{ !cancelled() }} && github.event_name == 'pull_request'
125125
run: |
126126
bash scripts/check_copyright_year.sh
127+
bash scripts/check_version.sh

execution_chain/common/common.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import
1414
logging,
1515
../db/[core_db, ledger, storage_types, fcu_db],
1616
../utils/[utils],
17-
".."/[constants, errors, version],
17+
".."/[constants, errors, version_info],
1818
"."/[chain_config, evmforks, genesis, hardforks],
1919
taskpools
2020

execution_chain/config.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import
2929
],
3030
eth/[common, net/nat],
3131
./networking/[bootnodes, eth1_enr as enr],
32-
./[constants, compile_info, version],
32+
./[constants, compile_info, version_info],
3333
./common/chain_config,
3434
./db/opts
3535

execution_chain/nimbus_execution_client.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import
1818
metrics/chronicles_support,
1919
stew/byteutils,
2020
./rpc,
21-
./version,
21+
./version_info,
2222
./constants,
2323
./nimbus_desc,
2424
./nimbus_import,
@@ -96,7 +96,7 @@ proc setupP2P(nimbus: NimbusNode, conf: NimbusConf,
9696

9797
func compatibleForkIdProc(id: ForkID): bool {.raises: [].} =
9898
com.compatibleForkId(id)
99-
99+
100100
let forkIdProcs = ForkIdProcs(
101101
forkId: forkIdProc,
102102
compatibleForkId: compatibleForkIdProc,

execution_chain/rpc/engine_api.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import
1313
web3/[conversions, execution_types],
1414
../beacon/api_handler,
1515
../beacon/beacon_engine,
16-
../version
16+
../version_info
1717

1818
from ../beacon/web3_eth_conv import Hash32
1919

execution_chain/version.nim

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,30 @@
1-
# Copyright (c) 2018-2025 Status Research & Development GmbH
2-
# Licensed under either of
3-
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
4-
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
5-
# at your option.
6-
# This file may not be copied, modified, or distributed except according to
7-
# those terms.
8-
9-
{.push raises: [].}
10-
11-
import
12-
std/[strformat],
13-
stew/byteutils, ./compile_info, beacon_chain/buildinfo
14-
15-
const
16-
NimbusName* = "nimbus-eth1"
17-
## project name string
18-
19-
NimbusMajor*: int = 0
20-
## is the major number of Nimbus' version.
21-
22-
NimbusMinor*: int = 1
23-
## is the minor number of Nimbus' version.
24-
25-
NimbusPatch*: int = 0
26-
## is the patch number of Nimbus' version.
27-
28-
NimbusVersion* = $NimbusMajor & "." & $NimbusMinor & "." & $NimbusPatch
29-
## is the version of Nimbus as a string.
30-
31-
GitRevisionBytes* = hexToByteArray[4](GitRevision)
32-
33-
FullVersionStr* = "v" & NimbusVersion & "-" & GitRevision
34-
35-
ClientId* = &"{NimbusName}/{FullVersionStr}/{hostOS}-{hostCPU}/Nim-{NimVersion}"
36-
37-
ShortClientId* = NimbusName & "/" & FullVersionStr
1+
# Copyright (c) 2025 Status Research & Development GmbH
2+
# Licensed under either of
3+
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
4+
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
5+
# at your option.
6+
# This file may not be copied, modified, or distributed except according to
7+
# those terms.
8+
9+
{.push raises: [].}
10+
11+
#------------------------------------------------------------------------------
12+
# The only place where NimbusVersion is declared.
13+
# Please do not put nim vm unfriendly stuff in this file, otherwise it will
14+
# break some scripts. Users of this file:
15+
# - ./version_info.nim > used by compiled binaries.
16+
# - ../scripts/print_version.nims > used by docker files.
17+
#------------------------------------------------------------------------------
18+
19+
const
20+
NimbusMajor* = 0
21+
## is the major number of Nimbus' version.
22+
23+
NimbusMinor* = 1
24+
## is the minor number of Nimbus' version.
25+
26+
NimbusPatch* = 0
27+
## is the patch number of Nimbus' version.
28+
29+
NimbusVersion* = $NimbusMajor & "." & $NimbusMinor & "." & $NimbusPatch
30+
## is the version of Nimbus as a string.

execution_chain/version_info.nim

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright (c) 2018-2025 Status Research & Development GmbH
2+
# Licensed under either of
3+
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
4+
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
5+
# at your option.
6+
# This file may not be copied, modified, or distributed except according to
7+
# those terms.
8+
9+
{.push raises: [].}
10+
11+
import
12+
std/[strformat],
13+
stew/byteutils, ./compile_info, beacon_chain/buildinfo,
14+
./version
15+
16+
export
17+
version
18+
19+
const
20+
NimbusName* = "nimbus-eth1"
21+
## project name string
22+
23+
# Please keep it 4 bytes long, used in `engine_ClientVersionV1`
24+
# https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.4/src/engine/identification.md#clientversionv1
25+
GitRevisionBytes* = hexToByteArray[4](GitRevision)
26+
27+
FullVersionStr* = "v" & NimbusVersion & "-" & GitRevision
28+
29+
ClientId* = &"{NimbusName}/{FullVersionStr}/{hostOS}-{hostCPU}/Nim-{NimVersion}"
30+
31+
ShortClientId* = NimbusName & "/" & FullVersionStr

scripts/check_version.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2025 Status Research & Development GmbH. Licensed under
4+
# either of:
5+
# - Apache License, version 2.0
6+
# - MIT license
7+
# at your option. This file may not be copied, modified, or distributed except
8+
# according to those terms.
9+
10+
remove_quotes_spaces() {
11+
local str="$1"
12+
# Remove any quotes
13+
str="${str//\"/}"
14+
echo "$str" | sed 's/[[:space:]]//g'
15+
}
16+
17+
while read -r line; do
18+
if [[ "$line" == *"NimbusMajor*"* ]]; then
19+
NIMBUS_MAJOR=$(remove_quotes_spaces ${line##*=})
20+
fi
21+
if [[ "$line" == *"NimbusMinor*"* ]]; then
22+
NIMBUS_MINOR=$(remove_quotes_spaces ${line##*=})
23+
fi
24+
if [[ "$line" == *"NimbusPatch*"* ]]; then
25+
NIMBUS_PATCH=$(remove_quotes_spaces ${line##*=})
26+
break
27+
fi
28+
done < execution_chain/version.nim
29+
30+
# Search 'version' from 'nimbus.nimble'
31+
while read -r line; do
32+
if [[ "$line" == "version"* ]]; then
33+
VERSION_IN_NIMBLE_FILE=$(remove_quotes_spaces ${line##*=})
34+
break
35+
fi
36+
done < nimbus.nimble
37+
38+
NIMBUS_VERSION=$NIMBUS_MAJOR.$NIMBUS_MINOR.$NIMBUS_PATCH
39+
40+
if [[ "$NIMBUS_VERSION" != "$VERSION_IN_NIMBLE_FILE" ]]; then
41+
echo "NimbusVersion($NIMBUS_VERSION) doesn't match version in .nimble file($VERSION_IN_NIMBLE_FILE)"
42+
exit 2
43+
fi

tests/test_rpc.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import
1515
eth/rlp,
1616
eth/common/[transaction_utils, addresses],
1717
../hive_integration/nodocker/engine/engine_client,
18-
../execution_chain/[constants, transaction, config, version],
18+
../execution_chain/[constants, transaction, config, version_info],
1919
../execution_chain/db/[ledger, storage_types],
2020
../execution_chain/sync/wire_protocol,
2121
../execution_chain/core/[tx_pool, chain, pow/difficulty],

0 commit comments

Comments
 (0)