Remove duplicate files, improve build, change test framework

This commit is contained in:
Alexey Osipov 2022-11-07 19:50:32 +03:00
parent f18f95c395
commit 08d7384465
23 changed files with 111 additions and 12613 deletions

View File

@ -29,6 +29,7 @@ jobs:
native: win-x64
host: windows-latest
steps:
- uses: ilammy/msvc-dev-cmd@v1
- uses: actions/checkout@v3
with:
submodules: recursive
@ -38,7 +39,7 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: ckzg-library-${{ matrix.target.native }}
path: bindings/csharp/Ckzg/runtimes/${{ matrix.target.native }}/native
path: bindings/csharp/Ckzg.Bindings/runtimes/${{ matrix.target.native }}/native
build-ckzg-dotnet:
runs-on: ubuntu-latest
@ -48,15 +49,15 @@ jobs:
- uses: actions/download-artifact@v3
with:
name: ckzg-library-linux-x64
path: bindings/csharp/Ckzg/runtimes/linux-x64/native
path: bindings/csharp/Ckzg.Bindings/runtimes/linux-x64/native
- uses: actions/download-artifact@v3
with:
name: ckzg-library-osx-x64
path: bindings/csharp/Ckzg/runtimes/osx-x64/native
path: bindings/csharp/Ckzg.Bindings/runtimes/osx-x64/native
- uses: actions/download-artifact@v3
with:
name: ckzg-library-win-x64
path: bindings/csharp/Ckzg/runtimes/win-x64/native
path: bindings/csharp/Ckzg.Bindings/runtimes/win-x64/native
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
@ -69,5 +70,5 @@ jobs:
- name: Upload package
uses: actions/upload-artifact@v3
with:
name: Ckzg.nuget
path: bindings/csharp/build/Ckzg.1.0.0.nupkg
name: Ckzg.Bindings.nuget
path: bindings/csharp/build/Ckzg.Bindings.1.0.0.nupkg

View File

@ -4,7 +4,7 @@
.vs
.vscode
Ckzg/runtimes/*/native/*
Ckzg.Bindings/runtimes/*/native/*
!**/.gitkeep
test_ckzg*
*.so

View File

@ -6,6 +6,7 @@
"string.h": "c",
"inttypes.h": "c",
"stdlib.h": "c",
"sha256.h": "c"
"sha256.h": "c",
"ckzg.h": "c"
}
}

View File

@ -7,17 +7,20 @@ public class Ckzg
{
static Ckzg()
{
AssemblyLoadContext.Default.ResolvingUnmanagedDll += (assembly, path) => NativeLibrary.Load($"runtimes/{(
AssemblyLoadContext.Default.ResolvingUnmanagedDll += (assembly, path) =>
{
var a = $"runtimes/{(
RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "linux" :
RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "osx" :
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "win" : "")}-{RuntimeInformation.ProcessArchitecture switch
{
Architecture.X86 => "x86",
Architecture.Arm => "arm",
Architecture.X64 => "x64",
Architecture.Arm64 => "arm64",
_ => ""
}}/native/{path}.{(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "dll" : "so")}");
}}/native/{path}.{(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "dll" : "so")}";
return NativeLibrary.Load(a);
};
}
[DllImport("ckzg", EntryPoint = "blob_to_kzg_commitment_wrap", CallingConvention = CallingConvention.Cdecl)]
@ -32,7 +35,7 @@ public class Ckzg
[DllImport("ckzg", EntryPoint = "verify_kzg_proof_wrap", CallingConvention = CallingConvention.Cdecl)] // returns 0 on success
public static extern int verify_kzg_proof(byte[/*48*/] commitment, byte[/*32*/] x, byte[/*32*/] y, byte[/*48*/] proof, IntPtr ts);
[DllImport("ckzg", EntryPoint = "load_trusted_setup_wrap", CallingConvention = CallingConvention.Cdecl)] // free result with free_trusted_setup()
[DllImport("ckzg", EntryPoint = "load_trusted_setup_wrap")] // free result with free_trusted_setup()
public static extern IntPtr load_trusted_setup(string filename);
[DllImport("ckzg", EntryPoint = "free_trusted_setup_wrap", CallingConvention = CallingConvention.Cdecl)]

View File

@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<None Remove="devnetv2-geth.txt" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Ckzg.Bindings\Ckzg.Bindings.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="..\devnetv2-geth.txt" Link="devnetv2-geth.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="..\..\..\src\trusted_setup.txt" Link="trusted_setup.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
global using NUnit.Framework;

View File

@ -1,42 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Ckzg\Ckzg.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="ckzg.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="devnetv2-geth.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="devnetv2.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -1 +0,0 @@
global using Xunit;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ckzg.Tests", "Ckzg.Tests\Ckzg.Tests.csproj", "{BE6A0DC4-3B28-4957-AE17-F57A26C3B674}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ckzg.Bindings", "Ckzg.Bindings\Ckzg.Bindings.csproj", "{4BE5C759-C998-47AB-A7F3-FA5E115A06DD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ckzg", "Ckzg\Ckzg.csproj", "{4BE5C759-C998-47AB-A7F3-FA5E115A06DD}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ckzg.Test", "Ckzg.Test\Ckzg.Test.csproj", "{B7A7291F-3DBC-4D9C-A5F1-B036C2EAA41C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -17,18 +17,6 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BE6A0DC4-3B28-4957-AE17-F57A26C3B674}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BE6A0DC4-3B28-4957-AE17-F57A26C3B674}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BE6A0DC4-3B28-4957-AE17-F57A26C3B674}.Debug|x64.ActiveCfg = Debug|Any CPU
{BE6A0DC4-3B28-4957-AE17-F57A26C3B674}.Debug|x64.Build.0 = Debug|Any CPU
{BE6A0DC4-3B28-4957-AE17-F57A26C3B674}.Debug|x86.ActiveCfg = Debug|Any CPU
{BE6A0DC4-3B28-4957-AE17-F57A26C3B674}.Debug|x86.Build.0 = Debug|Any CPU
{BE6A0DC4-3B28-4957-AE17-F57A26C3B674}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BE6A0DC4-3B28-4957-AE17-F57A26C3B674}.Release|Any CPU.Build.0 = Release|Any CPU
{BE6A0DC4-3B28-4957-AE17-F57A26C3B674}.Release|x64.ActiveCfg = Release|Any CPU
{BE6A0DC4-3B28-4957-AE17-F57A26C3B674}.Release|x64.Build.0 = Release|Any CPU
{BE6A0DC4-3B28-4957-AE17-F57A26C3B674}.Release|x86.ActiveCfg = Release|Any CPU
{BE6A0DC4-3B28-4957-AE17-F57A26C3B674}.Release|x86.Build.0 = Release|Any CPU
{4BE5C759-C998-47AB-A7F3-FA5E115A06DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4BE5C759-C998-47AB-A7F3-FA5E115A06DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4BE5C759-C998-47AB-A7F3-FA5E115A06DD}.Debug|x64.ActiveCfg = Debug|Any CPU
@ -41,6 +29,18 @@ Global
{4BE5C759-C998-47AB-A7F3-FA5E115A06DD}.Release|x64.Build.0 = Release|Any CPU
{4BE5C759-C998-47AB-A7F3-FA5E115A06DD}.Release|x86.ActiveCfg = Release|Any CPU
{4BE5C759-C998-47AB-A7F3-FA5E115A06DD}.Release|x86.Build.0 = Release|Any CPU
{B7A7291F-3DBC-4D9C-A5F1-B036C2EAA41C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B7A7291F-3DBC-4D9C-A5F1-B036C2EAA41C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B7A7291F-3DBC-4D9C-A5F1-B036C2EAA41C}.Debug|x64.ActiveCfg = Debug|Any CPU
{B7A7291F-3DBC-4D9C-A5F1-B036C2EAA41C}.Debug|x64.Build.0 = Debug|Any CPU
{B7A7291F-3DBC-4D9C-A5F1-B036C2EAA41C}.Debug|x86.ActiveCfg = Debug|Any CPU
{B7A7291F-3DBC-4D9C-A5F1-B036C2EAA41C}.Debug|x86.Build.0 = Debug|Any CPU
{B7A7291F-3DBC-4D9C-A5F1-B036C2EAA41C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B7A7291F-3DBC-4D9C-A5F1-B036C2EAA41C}.Release|Any CPU.Build.0 = Release|Any CPU
{B7A7291F-3DBC-4D9C-A5F1-B036C2EAA41C}.Release|x64.ActiveCfg = Release|Any CPU
{B7A7291F-3DBC-4D9C-A5F1-B036C2EAA41C}.Release|x64.Build.0 = Release|Any CPU
{B7A7291F-3DBC-4D9C-A5F1-B036C2EAA41C}.Release|x86.ActiveCfg = Release|Any CPU
{B7A7291F-3DBC-4D9C-A5F1-B036C2EAA41C}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -1,14 +1,14 @@
INCLUDE_DIRS = ../../src ../../blst/bindings
ifeq ($(OS),Windows_NT)
BLST_BUILDSCRIPT=./build.sh
BLST_OBJ=libblst.a
BLST_BUILDSCRIPT=./build.bat
BLST_OBJ=blst.lib
TESTS_EXECUTABLE=test_ckzg.exe
CSHARP_PLATFORM?=win-x64
CLANG_PLATFROM?=x86_64-win
CLANG_FLAGS=
CLANG_EXECUTABLE=gcc
CKZG_LIBRARY_PATH=Ckzg\runtimes\$(CSHARP_PLATFORM)\native\ckzg.dll
CLANG_EXECUTABLE=clang
CKZG_LIBRARY_PATH=Ckzg.Bindings\runtimes\$(CSHARP_PLATFORM)\native\ckzg.dll
else
BLST_BUILDSCRIPT=./build.sh
BLST_OBJ=libblst.a
@ -17,14 +17,13 @@ else
CLANG_PLATFORM?=x86_64-linux
CLANG_FLAGS=-fPIC
CLANG_EXECUTABLE=cc
CKZG_LIBRARY_PATH=Ckzg/runtimes/$(CSHARP_PLATFORM)/native/ckzg.so
CKZG_LIBRARY_PATH=Ckzg.Bindings/runtimes/$(CSHARP_PLATFORM)/native/ckzg.so
endif
.blst:
cd ../../blst &&\
git apply ../blst_sha.patch &&\
$(BLST_BUILDSCRIPT) &&\
uname -a && ls -a &&\
git apply -R ../blst_sha.patch &&\
cd ../bindings/csharp
@ -39,7 +38,7 @@ ckzg:
# E2e tests as an executable
test: tests.c ckzg.c ../../src/c_kzg_4844.c ../../blst/$(BLST_OBJ)
@make .blst
clang -O -w -Wall $(CLANG_FLAGS) ${addprefix -I,${INCLUDE_DIRS}} -o $(TESTS_EXECUTABLE) $^
$(CLANG_EXECUTABLE) -O -w -Wall $(CLANG_FLAGS) ${addprefix -I,${INCLUDE_DIRS}} -o $(TESTS_EXECUTABLE) $^
# E2e tests are built and run
run-test:

View File

@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "c_kzg_4844.h"
#include "ckzg.h"
KZGSettings* load_trusted_setup_wrap(const char* file) {
KZGSettings* out = malloc(sizeof(KZGSettings));

View File

@ -3,7 +3,7 @@
#include <stdlib.h>
#include "c_kzg_4844.h"
#ifdef WIN32
#ifdef _WIN32
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT

View File

@ -36,7 +36,7 @@ void main() {
TestGeth("devnetv2-geth.txt");
printf("\ntrusted_setup.txt\n");
TestE2e("trusted_setup.txt");
TestE2e("../../src/trusted_setup.txt");
printf("\n");
TestGeth("trusted_setup.txt");
TestGeth("../../src/trusted_setup.txt");
}

File diff suppressed because it is too large Load Diff