Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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") && \
Expand Down
1 change: 0 additions & 1 deletion Dockerfile.chiseled
Original file line number Diff line number Diff line change
Expand Up @@ -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") && \
Expand Down
1 change: 0 additions & 1 deletion Dockerfile.diag
Original file line number Diff line number Diff line change
Expand Up @@ -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") && \
Expand Down
6 changes: 1 addition & 5 deletions src/Nethermind/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<BuildTimestamp Condition="'$(BuildTimestamp)' == ''">$([System.DateTimeOffset]::UtcNow.ToUnixTimeSeconds())</BuildTimestamp>
<Copyright>Demerzel Solutions Limited</Copyright>
<Product>Nethermind</Product>
<SourceRevisionId Condition="'$(Commit)' != ''">$(Commit.Substring(0, 8))</SourceRevisionId>
<SourceRevisionId Condition="'$(Commit)' != ''">$(Commit)</SourceRevisionId>
<VersionPrefix>1.27.0</VersionPrefix>
<VersionSuffix>unstable</VersionSuffix>
</PropertyGroup>
Expand All @@ -23,10 +23,6 @@
<_Parameter1>BuildTimestamp</_Parameter1>
<_Parameter2>$(BuildTimestamp)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(Commit)' != ''">
<_Parameter1>Commit</_Parameter1>
<_Parameter2>$(Commit)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>

</Project>
3 changes: 2 additions & 1 deletion src/Nethermind/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<PackageVersion Include="MathNet.Numerics.FSharp" Version="5.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.DataProtection" Version="8.0.6" />
<PackageVersion Include="Microsoft.AspNetCore.DataProtection.Extensions" Version="8.0.6" />
<PackageVersion Include="Microsoft.Build.Tasks.Git" Version="8.0.0" />
<PackageVersion Include="Microsoft.ClearScript.V8" Version="7.4.5" />
<PackageVersion Include="Microsoft.ClearScript.V8.Native.linux-arm64" Version="7.4.5" />
<PackageVersion Include="Microsoft.ClearScript.V8.Native.linux-x64" Version="7.4.5" />
Expand Down Expand Up @@ -76,4 +77,4 @@
<PackageVersion Include="TestableIO.System.IO.Abstractions.Wrappers" Version="21.0.2" />
<PackageVersion Include="Websocket.Client" Version="5.1.1" />
</ItemGroup>
</Project>
</Project>
35 changes: 19 additions & 16 deletions src/Nethermind/Nethermind.Core/ProductInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,47 @@
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<AssemblyInformationalVersionAttribute>();
var metadataAttrs = assembly?.GetCustomAttributes<AssemblyMetadataAttribute>();
var productAttr = assembly?.GetCustomAttribute<AssemblyProductAttribute>();
var commit = metadataAttrs?.FirstOrDefault(a => a.Key.Equals("Commit", StringComparison.Ordinal))?.Value;
var assembly = Assembly.GetEntryAssembly()!;
var metadataAttrs = assembly.GetCustomAttributes<AssemblyMetadataAttribute>()!;
var productAttr = assembly.GetCustomAttribute<AssemblyProductAttribute>()!;
var versionAttr = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()!;
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..]}";
}

public static DateTimeOffset BuildTimestamp { get; }

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; }

Expand All @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<ClientVersionV1[]> result = rpcModule.engine_getClientVersionV1(new ClientVersionV1());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
25 changes: 4 additions & 21 deletions src/Nethermind/Nethermind.Runner/Nethermind.Runner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@

<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" />
<PackageReference Include="Microsoft.Build.Tasks.Git">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.CommandLineUtils" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" />
<PackageReference Include="NLog.Targets.Seq" />
Expand Down Expand Up @@ -106,25 +110,4 @@
<Copy SourceFiles="@(PluginsForPublish)" DestinationFolder="$(PublishDir)\plugins" />
</Target>

<Target Name="CommitFallback" AfterTargets="BeforeBuild" Condition="'$(Commit)' == ''">
<Exec Command="git describe --always --exclude=* --abbrev=40" ConsoleToMSBuild="True" IgnoreExitCode="False" StandardOutputImportance="low">
<Output PropertyName="Commit" TaskParameter="ConsoleOutput" />
</Exec>
<PropertyGroup>
<SourceRevisionId>$(Commit.Substring(0, 8))</SourceRevisionId>
</PropertyGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>Commit</_Parameter1>
<_Parameter2>$(Commit)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
</Target>

<Target Name="CheckBranchName" AfterTargets="BeforeBuild">
<Exec Command="git branch --show-current" ConsoleToMSBuild="True" StandardOutputImportance="low">
<Output PropertyName="BranchName" TaskParameter="ConsoleOutput" />
</Exec>
<Error Text="The current branch '$(BranchName)' should be named in lower case." Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($(BranchName), '^.*[A-Z].*$'))" />
</Target>
</Project>