diff --git a/Dockerfile b/Dockerfile
index eeaf6602ab6..ccdea679109 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -9,7 +9,6 @@ ARG CI
ARG COMMIT_HASH
ARG TARGETARCH
-COPY .git .git
COPY src/Nethermind src/Nethermind
RUN arch=$([ "$TARGETARCH" = "amd64" ] && echo "x64" || echo "$TARGETARCH") && \
diff --git a/Dockerfile.chiseled b/Dockerfile.chiseled
index 7d7b570e966..936c78877dc 100644
--- a/Dockerfile.chiseled
+++ b/Dockerfile.chiseled
@@ -9,7 +9,6 @@ ARG CI
ARG COMMIT_HASH
ARG TARGETARCH
-COPY .git .git
COPY src/Nethermind src/Nethermind
RUN arch=$([ "$TARGETARCH" = "amd64" ] && echo "x64" || echo "$TARGETARCH") && \
diff --git a/Dockerfile.diag b/Dockerfile.diag
index a2d952143b9..768e8fa9c2e 100644
--- a/Dockerfile.diag
+++ b/Dockerfile.diag
@@ -9,7 +9,6 @@ ARG CI
ARG COMMIT_HASH
ARG TARGETARCH
-COPY .git .git
COPY src/Nethermind src/Nethermind
RUN arch=$([ "$TARGETARCH" = "amd64" ] && echo "x64" || echo "$TARGETARCH") && \
diff --git a/src/Nethermind/Directory.Build.props b/src/Nethermind/Directory.Build.props
index 44dcc89eb8c..b1ac734da65 100644
--- a/src/Nethermind/Directory.Build.props
+++ b/src/Nethermind/Directory.Build.props
@@ -13,7 +13,7 @@
$([System.DateTimeOffset]::UtcNow.ToUnixTimeSeconds())
Demerzel Solutions Limited
Nethermind
- $(Commit.Substring(0, 8))
+ $(Commit)
1.27.0
unstable
@@ -23,10 +23,6 @@
<_Parameter1>BuildTimestamp
<_Parameter2>$(BuildTimestamp)
-
- <_Parameter1>Commit
- <_Parameter2>$(Commit)
-
diff --git a/src/Nethermind/Directory.Packages.props b/src/Nethermind/Directory.Packages.props
index cb88a1ae0d9..5d784e7530d 100644
--- a/src/Nethermind/Directory.Packages.props
+++ b/src/Nethermind/Directory.Packages.props
@@ -28,6 +28,7 @@
+
@@ -76,4 +77,4 @@
-
+
\ No newline at end of file
diff --git a/src/Nethermind/Nethermind.Core/ProductInfo.cs b/src/Nethermind/Nethermind.Core/ProductInfo.cs
index 9cbf70bb8e9..b23e63c3006 100644
--- a/src/Nethermind/Nethermind.Core/ProductInfo.cs
+++ b/src/Nethermind/Nethermind.Core/ProductInfo.cs
@@ -4,34 +4,37 @@
using System;
using System.Linq;
using System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-[assembly: InternalsVisibleTo("Nethermind.Merge.Plugin.Test")]
namespace Nethermind.Core;
public static class ProductInfo
{
static ProductInfo()
{
- var assembly = Assembly.GetEntryAssembly();
- var infoAttr = assembly?.GetCustomAttribute();
- var metadataAttrs = assembly?.GetCustomAttributes();
- var productAttr = assembly?.GetCustomAttribute();
- var commit = metadataAttrs?.FirstOrDefault(a => a.Key.Equals("Commit", StringComparison.Ordinal))?.Value;
+ var assembly = Assembly.GetEntryAssembly()!;
+ var metadataAttrs = assembly.GetCustomAttributes()!;
+ var productAttr = assembly.GetCustomAttribute()!;
+ var versionAttr = assembly.GetCustomAttribute()!;
var timestamp = metadataAttrs?.FirstOrDefault(a => a.Key.Equals("BuildTimestamp", StringComparison.Ordinal))?.Value;
BuildTimestamp = long.TryParse(timestamp, out var t)
? DateTimeOffset.FromUnixTimeSeconds(t)
: DateTimeOffset.MinValue;
- Commit = commit ?? string.Empty;
Name = productAttr?.Product ?? "Nethermind";
OS = Platform.GetPlatformName();
OSArchitecture = RuntimeInformation.OSArchitecture.ToString().ToLowerInvariant();
Runtime = RuntimeInformation.FrameworkDescription;
- Version = infoAttr?.InformationalVersion ?? string.Empty;
+ Version = versionAttr.InformationalVersion;
+
+ var index = Version.IndexOf('+', StringComparison.Ordinal);
+
+ if (index != -1)
+ {
+ Commit = Version[(index + 1)..];
+ Version = Version[..Math.Min(index + 9, Version.Length - 1)];
+ }
- ClientCode = "NM";
ClientId = $"{Name}/v{Version}/{OS.ToLowerInvariant()}-{OSArchitecture}/dotnet{Runtime[5..]}";
}
@@ -39,9 +42,9 @@ static ProductInfo()
public static string ClientId { get; }
- public static string ClientCode { get; }
+ public static string ClientCode { get; } = "NM";
- public static string Commit { get; internal set; }
+ public static string Commit { get; set; } = string.Empty;
public static string Name { get; }
@@ -53,11 +56,11 @@ static ProductInfo()
public static string Version { get; }
- public static string Network { get; set; } = "";
+ public static string Network { get; set; } = string.Empty;
- public static string Instance { get; set; } = "";
+ public static string Instance { get; set; } = string.Empty;
- public static string SyncType { get; set; } = "";
+ public static string SyncType { get; set; } = string.Empty;
- public static string PruningMode { get; set; } = "";
+ public static string PruningMode { get; set; } = string.Empty;
}
diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V1.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V1.cs
index 43b6793f1d1..bfd1368d636 100644
--- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V1.cs
+++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V1.cs
@@ -1520,7 +1520,6 @@ await rpc.engine_forkchoiceUpdatedV1(forkChoiceState1,
[Test]
public async Task Should_return_ClientVersionV1()
{
- ProductInfo.Commit = "0000000000000000000000000000000000000000000000000000000000000000";
using MergeTestBlockchain chain = await CreateBlockchain();
IEngineRpcModule rpcModule = CreateEngineModule(chain);
ResultWrapper result = rpcModule.engine_getClientVersionV1(new ClientVersionV1());
diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/ClientVersionV1.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/ClientVersionV1.cs
index c6e5a853031..e2108102c3f 100644
--- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ClientVersionV1.cs
+++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ClientVersionV1.cs
@@ -16,7 +16,9 @@ public ClientVersionV1()
Code = ProductInfo.ClientCode;
Name = ProductInfo.Name;
Version = ProductInfo.Version;
- Commit = ProductInfo.Commit[..8];
+ Commit = ProductInfo.Commit.Length < 8
+ ? string.Empty.PadLeft(8, '0')
+ : ProductInfo.Commit[..8];
}
public string Code { get; }
diff --git a/src/Nethermind/Nethermind.Runner/Nethermind.Runner.csproj b/src/Nethermind/Nethermind.Runner/Nethermind.Runner.csproj
index 52b6fa2c85d..e675b2dbd2e 100644
--- a/src/Nethermind/Nethermind.Runner/Nethermind.Runner.csproj
+++ b/src/Nethermind/Nethermind.Runner/Nethermind.Runner.csproj
@@ -21,6 +21,10 @@
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
@@ -106,25 +110,4 @@
-
-
-
-
-
- $(Commit.Substring(0, 8))
-
-
-
- <_Parameter1>Commit
- <_Parameter2>$(Commit)
-
-
-
-
-
-
-
-
-
-