mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-24 11:11:59 +00:00
Implement engine_getClientVersionV1 (#2233)
* Implement engine_getClientVersionV1 * full git revision string * Limit GitRevisionString to 8 chars * Fixes * Debug windows CI * debug windows ci * produce git revision using -C * try not to delete .git folder in windows ci * Harden GitRevision procuration * Add double quotes to git -C param * Escape sourcePath * Remove double quotes from git -C param
This commit is contained in:
parent
abf1e58ed4
commit
74cc3b6127
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -267,7 +267,7 @@ jobs:
|
|||||||
mingw32-make ${DEFAULT_MAKE_FLAGS}
|
mingw32-make ${DEFAULT_MAKE_FLAGS}
|
||||||
build/nimbus.exe --help
|
build/nimbus.exe --help
|
||||||
# give us more space
|
# give us more space
|
||||||
find . -type d -name ".git" -exec rm -rf {} +
|
# find . -type d -name ".git" -exec rm -rf {} +
|
||||||
find . -type d -name "nimcache" -exec rm -rf {} +
|
find . -type d -name "nimcache" -exec rm -rf {} +
|
||||||
mingw32-make ${DEFAULT_MAKE_FLAGS} test
|
mingw32-make ${DEFAULT_MAKE_FLAGS} test
|
||||||
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
|
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
|
||||||
|
@ -13,7 +13,8 @@ import
|
|||||||
web3/[conversions, execution_types],
|
web3/[conversions, execution_types],
|
||||||
../beacon/api_handler,
|
../beacon/api_handler,
|
||||||
../beacon/beacon_engine,
|
../beacon/beacon_engine,
|
||||||
../beacon/web3_eth_conv
|
../beacon/web3_eth_conv,
|
||||||
|
../version
|
||||||
|
|
||||||
{.push raises: [].}
|
{.push raises: [].}
|
||||||
|
|
||||||
@ -33,6 +34,7 @@ const supportedMethods: HashSet[string] =
|
|||||||
"engine_forkchoiceUpdatedV3",
|
"engine_forkchoiceUpdatedV3",
|
||||||
"engine_getPayloadBodiesByHashV1",
|
"engine_getPayloadBodiesByHashV1",
|
||||||
"engine_getPayloadBodiesByRangeV1",
|
"engine_getPayloadBodiesByRangeV1",
|
||||||
|
"engine_getClientVersionV1",
|
||||||
])
|
])
|
||||||
|
|
||||||
# I'm trying to keep the handlers below very thin, and move the
|
# I'm trying to keep the handlers below very thin, and move the
|
||||||
@ -94,3 +96,13 @@ proc setupEngineAPI*(engine: BeaconEngineRef, server: RpcServer) =
|
|||||||
server.rpc("engine_getPayloadBodiesByRangeV1") do(
|
server.rpc("engine_getPayloadBodiesByRangeV1") do(
|
||||||
start: Quantity, count: Quantity) -> seq[Option[ExecutionPayloadBodyV1]]:
|
start: Quantity, count: Quantity) -> seq[Option[ExecutionPayloadBodyV1]]:
|
||||||
return engine.getPayloadBodiesByRange(start.uint64, count.uint64)
|
return engine.getPayloadBodiesByRange(start.uint64, count.uint64)
|
||||||
|
|
||||||
|
server.rpc("engine_getClientVersionV1") do(version: ClientVersionV1) ->
|
||||||
|
seq[ClientVersionV1]:
|
||||||
|
# TODO: what should we do with the `version` parameter?
|
||||||
|
return @[ClientVersionV1(
|
||||||
|
code: "NB",
|
||||||
|
name: NimbusName,
|
||||||
|
version: NimbusVersion,
|
||||||
|
commit: FixedBytes[4](GitRevisionBytes),
|
||||||
|
)]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2018-2022 Status Research & Development GmbH
|
# Copyright (c) 2018-2024 Status Research & Development GmbH
|
||||||
# Licensed under either of
|
# Licensed under either of
|
||||||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
|
||||||
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
|
||||||
@ -6,7 +6,28 @@
|
|||||||
# This file may not be copied, modified, or distributed except according to
|
# This file may not be copied, modified, or distributed except according to
|
||||||
# those terms.
|
# those terms.
|
||||||
|
|
||||||
import strutils
|
import
|
||||||
|
std/[strutils, os, sequtils],
|
||||||
|
stew/byteutils
|
||||||
|
|
||||||
|
const
|
||||||
|
sourcePath = currentSourcePath.rsplit({DirSep, AltSep}, 1)[0]
|
||||||
|
nimbusRevision {.strdefine.} = "00000000"
|
||||||
|
|
||||||
|
static:
|
||||||
|
doAssert(nimbusRevision.len == 8, "nimbusRevision must consist of 8 characters")
|
||||||
|
doAssert(nimbusRevision.allIt(it in HexDigits), "nimbusRevision should contains only hex chars")
|
||||||
|
|
||||||
|
proc gitFolderExists(path: string): bool {.compileTime.} =
|
||||||
|
# walk up parent folder to find `.git` folder
|
||||||
|
var currPath = sourcePath
|
||||||
|
while true:
|
||||||
|
if dirExists(currPath & "/.git"):
|
||||||
|
return true
|
||||||
|
let parts = splitPath(currPath)
|
||||||
|
if parts.tail.len == 0: break
|
||||||
|
currPath = parts.head
|
||||||
|
false
|
||||||
|
|
||||||
const
|
const
|
||||||
NimbusName* = "nimbus-eth1"
|
NimbusName* = "nimbus-eth1"
|
||||||
@ -24,7 +45,18 @@ const
|
|||||||
NimbusVersion* = $NimbusMajor & "." & $NimbusMinor & "." & $NimbusPatch
|
NimbusVersion* = $NimbusMajor & "." & $NimbusMinor & "." & $NimbusPatch
|
||||||
## is the version of Nimbus as a string.
|
## is the version of Nimbus as a string.
|
||||||
|
|
||||||
GitRevision* = strip(staticExec("git rev-parse --short HEAD"))[0..5]
|
# strip: remove spaces
|
||||||
|
# --short=8: ensure we get 8 chars of commit hash
|
||||||
|
# -C sourcePath: get the correct git hash no matter where the current dir is.
|
||||||
|
GitRevision* = if gitFolderExists(sourcePath):
|
||||||
|
# only using git if the parent dir is a git repo.
|
||||||
|
strip(staticExec("git -C " & strutils.escape(sourcePath) &
|
||||||
|
" rev-parse --short=8 HEAD"))
|
||||||
|
else:
|
||||||
|
# otherwise we use revision number given by build system.
|
||||||
|
# e.g. user download from release tarball, or Github zip download.
|
||||||
|
nimbusRevision
|
||||||
|
|
||||||
NimVersion* = staticExec("nim --version | grep Version")
|
GitRevisionBytes* = hexToByteArray[4](GitRevision)
|
||||||
|
|
||||||
|
NimVersion* = "Nim version " & $NimMajor & "." & $NimMinor & "." & $NimPatch
|
||||||
|
2
vendor/nim-web3
vendored
2
vendor/nim-web3
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 46b4b4c8bc42013196a6290ee53029131f97931a
|
Subproject commit ac93b9a99310fd9f1a63255cfde9df47bd63263f
|
Loading…
x
Reference in New Issue
Block a user