Skip to content

Commit

Permalink
Include Nethermind build
Browse files Browse the repository at this point in the history
  • Loading branch information
emlautarom1 committed Oct 31, 2024
1 parent 1d618e0 commit 9bb9486
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/Nethermind/Nethermind.Core/ProductInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;

namespace Nethermind.Core;

Expand All @@ -22,6 +23,11 @@ static ProductInfo()
? DateTimeOffset.FromUnixTimeSeconds(t)
: DateTimeOffset.MinValue;
Name = productAttr?.Product ?? "Nethermind";

ShortName = new byte[8];
var nameBytes = Encoding.ASCII.GetBytes(Name);
Array.Copy(nameBytes, ShortName, Math.Min(nameBytes.Length, 8));

OS = Platform.GetPlatformName();
OSArchitecture = RuntimeInformation.OSArchitecture.ToString().ToLowerInvariant();
Runtime = RuntimeInformation.FrameworkDescription;
Expand All @@ -48,6 +54,8 @@ static ProductInfo()

public static string Name { get; }

public static byte[] ShortName { get; }

public static string OS { get; }

public static string OSArchitecture { get; }
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Optimism/OptimismPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public async Task InitRpcModules()
: new NoSyncGcRegionStrategy(_api.SyncModeSelector, _mergeConfig), _api.LogManager),
_api.LogManager);

OptimismProtocolVersion currentVersion = new OptimismProtocolVersion.V0(ProductInfo.Version);
OptimismProtocolVersion currentVersion = new OptimismProtocolVersion.V0(ProductInfo.ShortName, ProductInfo.Version);
IOptimismSignalSuperchainV1Handler signalHandler = new LoggingOptimismSignalSuperchainV1Handler(currentVersion, _api.LogManager);

IOptimismEngineRpcModule opEngine = new OptimismEngineRpcModule(engineRpcModule, signalHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,22 @@ public V0(ReadOnlySpan<byte> build, uint major, uint minor, uint patch, uint pre
PreRelease = preRelease;
}

public V0(string version)
public V0(ReadOnlySpan<byte> build, string version)
{
if (build.Length != 8) throw new ArgumentException($"Expected build identifier to be 8 bytes long, got {build.Length}", nameof(build));

var parts = version.Split('.').Select(uint.Parse).ToList();
if (parts.Count != 4) throw new ParseException($"Invalid version format: {version}");
if (parts.Count != 4) throw new ArgumentException($"Invalid version format '{version}'", nameof(version));

Build = new byte[8];
Build = build.ToArray();
Major = parts[0];
Minor = parts[1];
Patch = parts[2];
PreRelease = parts[3];
}

public V0(string version) : this(new byte[8], version) { }

public new static V0 Read(ReadOnlySpan<byte> span)
{
var version = span[0];
Expand Down

0 comments on commit 9bb9486

Please sign in to comment.