Skip to content

Commit

Permalink
refactor and bump to 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishqjasoria committed Jun 18, 2024
1 parent a36ff1b commit fdce06e
Show file tree
Hide file tree
Showing 18 changed files with 46 additions and 109 deletions.
1 change: 0 additions & 1 deletion src/Nethermind.Verkle.Bench/BenchMultiScalarMul.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Threading.Tasks.Dataflow;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using Nethermind.RustVerkle;
using Nethermind.Verkle.Curve;
using Nethermind.Verkle.Fields.FrEElement;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2022 Demerzel Solutions Limited
// Licensed under Apache-2.0.For full terms, see LICENSE in the project root.

using Nethermind.RustVerkle;
using Nethermind.Verkle.Curve;
using Nethermind.Verkle.Polynomial;
using Nethermind.Verkle.Proofs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using Nethermind.RustVerkle;
using Nethermind.Verkle.Proofs;

namespace Nethermind.Verkle.Bench.MultiProofs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using Nethermind.RustVerkle;
using Nethermind.Verkle.Proofs;

namespace Nethermind.Verkle.Bench.MultiProofs;
Expand Down
1 change: 0 additions & 1 deletion src/Nethermind.Verkle.Tests/Curve/BanderwagonTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Nethermind.RustVerkle;
using Nethermind.Verkle.Curve;
using Nethermind.Verkle.Fields.FrEElement;

Expand Down
1 change: 0 additions & 1 deletion src/Nethermind.Verkle.Tests/Proofs/MultiProofTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Nethermind.RustVerkle;
using Nethermind.Verkle.Curve;
using Nethermind.Verkle.Fields.FrEElement;
using Nethermind.Verkle.Polynomial;
Expand Down
14 changes: 7 additions & 7 deletions src/Nethermind.Verkle/Nethermind.Verkle.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<PropertyGroup Label="Nethermind">
<Version>0.2.9-alpha</Version>
<Version>0.3.0-alpha</Version>
<Authors>Tanishq Jasoria</Authors>
<Company>Nethermind</Company>
<Copyright>Demerzel Solutions Limited</Copyright>
Expand All @@ -30,22 +30,22 @@
</ItemGroup>

<ItemGroup>
<Content Include="RustVerkle\runtimes\linux-arm64\libc_verkle.so" Pack="true" PackagePath="RustVerkle\runtimes\linux-arm64\libc_verkle.so">
<Content Update="runtimes/linux-arm/native/libc_verkle.so" Pack="true" PackagePath="runtimes/linux-arm/native/libc_verkle.so">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="RustVerkle\runtimes\linux-arm\libc_verkle.so" Pack="true" PackagePath="RustVerkle\runtimes\linux-arm\libc_verkle.so">
<Content Include="runtimes/linux-arm64/native/libc_verkle.so" Pack="true" PackagePath="runtimes/linux-arm64/native/libc_verkle.so">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="RustVerkle\runtimes\linux-x64\libc_verkle.so" Pack="true" PackagePath="RustVerkle\runtimes\linux-x64\libc_verkle.so">
<Content Include="runtimes/linux-x64/native/libc_verkle.so" Pack="true" PackagePath="runtimes/linux-x64/native/libc_verkle.so">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="RustVerkle\runtimes\osx-x64\libc_verkle.dylib" Pack="true" PackagePath="RustVerkle\runtimes\osx-x64\libc_verkle.dylib">
<Content Include="runtimes/osx-x64/native/libc_verkle.dylib" Pack="true" PackagePath="runtimes/osx-x64/native/libc_verkle.dylib">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="RustVerkle\runtimes\osx-arm64\libc_verkle.dylib" Pack="true" PackagePath="RustVerkle\runtimes\osx-arm64\libc_verkle.dylib">
<Content Include="runtimes/osx-arm64/native/libc_verkle.dylib" Pack="true" PackagePath="runtimes/osx-arm64/native/libc_verkle.dylibb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="RustVerkle\runtimes\win-x64\c_verkle.dll" Pack="true" PackagePath="RustVerkle\runtimes\win-x64\c_verkle.dll">
<Content Include="runtimes/win-x64/native/c_verkle.dll" Pack="true" PackagePath="runtimes/win-x64/native/c_verkle.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion src/Nethermind.Verkle/Proofs/MultiProof.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Concurrent;
using Nethermind.RustVerkle;
using Nethermind.Verkle.Curve;
using Nethermind.Verkle.Fields.FpEElement;
using Nethermind.Verkle.Fields.FrEElement;
Expand Down
19 changes: 0 additions & 19 deletions src/Nethermind.Verkle/RustVerkle/LibResolver.cs

This file was deleted.

73 changes: 0 additions & 73 deletions src/Nethermind.Verkle/RustVerkle/NativeLib.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
// Copyright 2022 Demerzel Solutions Limited
// Licensed under Apache-2.0.For full terms, see LICENSE in the project root.

using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Loader;

namespace Nethermind.RustVerkle;
namespace Nethermind.Verkle;

public class RustVerkleLib
public static class RustVerkleLib
{
private const string LibraryName = "c_verkle";
private static string? _libraryFallbackPath;
static RustVerkleLib()
{
LibResolver.Setup();
AssemblyLoadContext.Default.ResolvingUnmanagedDll += OnResolvingUnmanagedDll;
}

[DllImport("c_verkle", EntryPoint = "context_new", CallingConvention = CallingConvention.Cdecl)]
Expand Down Expand Up @@ -49,4 +53,36 @@ static RustVerkleLib()

[DllImport("c_verkle", EntryPoint = "verify_proof_uncompressed", CallingConvention = CallingConvention.Cdecl)]
public static extern bool VerkleVerifyUncompressed(IntPtr ct, byte[] input, UIntPtr length);

private static nint OnResolvingUnmanagedDll(Assembly context, string name)
{
if (_libraryFallbackPath is null)
{
string platform;

if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
name = $"lib{name}.so";
platform = "linux";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
name = $"lib{name}.dylib";
platform = "osx";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
name = $"{name}.dll";
platform = "win";
}
else
throw new PlatformNotSupportedException();

string arch = RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant();

_libraryFallbackPath = Path.Combine("runtimes", $"{platform}-{arch}", "native", name);
}

return NativeLibrary.Load(_libraryFallbackPath, context, default);
}
}
Binary file not shown.

0 comments on commit fdce06e

Please sign in to comment.