Skip to content

Commit

Permalink
Merge branch 'master' into add/plugins-yml
Browse files Browse the repository at this point in the history
  • Loading branch information
cschuchardt88 authored Aug 10, 2024
2 parents 7444e69 + 28043cb commit 86e6fa1
Show file tree
Hide file tree
Showing 178 changed files with 5,164 additions and 1,717 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Publish (docker-image)

on:
release:
types: [published]

env:
DOTNET_VERSION: 8.0.x
DIST_DIR: ./dist

jobs:
neo-cli-build:
runs-on: ubuntu-latest

steps:
- name: Set Application Version (Environment Variable)
run: |
APP_VERSION=$(echo '${{ github.event.release.tag_name }}' | cut -d 'v' -f 2)
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
- name: Checkout (GitHub)
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Build (neo-cli)
run: |
dotnet publish ./src/Neo.CLI \
--framework net8.0 \
--configuration Release \
--runtime linux-x64 \
--self-contained true \
--output ${{ env.DIST_DIR }} \
--verbosity normal \
-p:VersionPrefix=${{ env.APP_VERSION }} \
-p:RuntimeIdentifier=linux-x64 \
-p:SelfContained=true \
-p:IncludeNativeLibrariesForSelfExtract=false \
-p:PublishTrimmed=false \
-p:PublishSingleFile=true \
-p:PublishReadyToRun=true \
-p:EnableCompressionInSingleFile=true \
-p:DebugType=embedded \
-p:ServerGarbageCollection=true
- name: Build (LevelDbStore)
run: |
dotnet build ./src/Plugins/LevelDBStore \
--framework net8.0 \
--configuration Release \
--output ${{ env.DIST_DIR }}/Plugins/LevelDBStore \
--verbosity normal \
-p:VersionPrefix=${{ env.APP_VERSION }}
- name: Remove (junk)
run: |
rm -v ${{ env.DIST_DIR }}/Plugins/LevelDBStore/Neo*
rm -v ${{ env.DIST_DIR }}/Plugins/LevelDBStore/*.pdb
rm -v ${{ env.DIST_DIR }}/Plugins/LevelDBStore/*.xml
rm -v ${{ env.DIST_DIR }}/*.xml
- name: Docker Login
run: |
docker login ghcr.io \
--username ${{ github.repository_owner }} \
--password ${{ secrets.GITHUB_TOKEN }}
- name: Docker Build
run: |
docker build . \
--file ./.neo/docker/neo-cli/Dockerfile \
--tag ghcr.io/${{ github.repository_owner }}/neo-cli:latest \
--tag ghcr.io/${{ github.repository_owner }}/neo-cli:${{ env.APP_VERSION }} \
--push
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ jobs:
dotnet test ./tests/Neo.Plugins.OracleService.Tests --output ./bin/tests/Neo.Plugins.OracleService.Tests
dotnet test ./tests/Neo.Plugins.RpcServer.Tests --output ./bin/tests/Neo.Plugins.RpcServer.Tests
dotnet test ./tests/Neo.Plugins.Storage.Tests --output ./bin/tests/Neo.Plugins.Storage.Tests
dotnet test ./tests/Neo.Plugins.ApplicationLogs.Tests --output ./bin/tests/Neo.Plugins.ApplicationLogs.Tests
- name: Coveralls
if: matrix.os == 'ubuntu-latest'
Expand All @@ -106,6 +107,7 @@ jobs:
${{ github.workspace }}/tests/Neo.Plugins.OracleService.Tests/TestResults/coverage.info
${{ github.workspace }}/tests/Neo.Plugins.RpcServer.Tests/TestResults/coverage.info
${{ github.workspace }}/tests/Neo.Plugins.Storage.Tests/TestResults/coverage.info
${{ github.workspace }}/tests/Neo.Plugins.ApplicationLogs.Tests/TestResults/coverage.info
${{ github.workspace }}/tests/Neo.Extensions.Tests/TestResults/coverage.info

PublishPackage:
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/pkgs-delete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,24 @@ jobs:
delete-only-pre-release-versions: "true"
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Delete Neo Package
- name: Delete Neo Package (nuget)
uses: actions/delete-package-versions@v4
with:
package-name: Neo
package-type: nuget
min-versions-to-keep: 3
delete-only-pre-release-versions: "true"
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Delete Neo Package (docker)
uses: actions/delete-package-versions@v4
with:
package-name: Neo
package-type: docker
min-versions-to-keep: 1
delete-only-pre-release-versions: "true"
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Delete Neo.ConsoleService Package
uses: actions/delete-package-versions@v4
with:
Expand All @@ -118,6 +128,7 @@ jobs:
min-versions-to-keep: 3
delete-only-pre-release-versions: "true"
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Delete Neo.Extensions Package
uses: actions/delete-package-versions@v4
with:
Expand Down
8 changes: 8 additions & 0 deletions .neo/docker/neo-cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM debian:stable-slim

# Install the apt-get packages
RUN apt-get update
RUN apt-get install -y libicu-dev libleveldb-dev screen

COPY ./dist /opt/neo-cli
RUN ln -s /opt/neo-cli/neo-cli /usr/bin
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2015-2024 The Neo Project.
//
// Benchmarks.cs file belongs to the neo project and is free
// Benchmarks.POC.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
Expand All @@ -9,19 +9,21 @@
// Redistribution and use in source and binary forms with or without
// modifications are permitted.

using BenchmarkDotNet.Attributes;
using Neo.Network.P2P.Payloads;
using Neo.SmartContract;
using Neo.VM;
using System.Diagnostics;

namespace Neo;
namespace Neo.Benchmark;

static class Benchmarks
public class Benchmarks_PoCs
{
private static readonly ProtocolSettings protocol = ProtocolSettings.Load("config.json");
private static readonly NeoSystem system = new(protocol, (string)null);

public static void NeoIssue2725()
[Benchmark]
public void NeoIssue2725()
{
// https://github.com/neo-project/neo/issues/2725
// L00: INITSSLOT 1
Expand Down Expand Up @@ -70,10 +72,7 @@ private static void Run(string name, string poc)
using var snapshot = system.GetSnapshotCache();
using var engine = ApplicationEngine.Create(TriggerType.Application, tx, snapshot, system.GenesisBlock, protocol, tx.SystemFee);
engine.LoadScript(tx.Script);
Stopwatch stopwatch = Stopwatch.StartNew();
engine.Execute();
stopwatch.Stop();
Debug.Assert(engine.State == VMState.FAULT);
Console.WriteLine($"Benchmark: {name},\tTime: {stopwatch.Elapsed}");
}
}
1 change: 1 addition & 0 deletions benchmarks/Neo.Benchmarks/Neo.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\Neo\Neo.csproj" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 3 additions & 6 deletions benchmarks/Neo.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
// Redistribution and use in source and binary forms with or without
// modifications are permitted.

using Neo;
using System.Reflection;
using BenchmarkDotNet.Running;
using Neo.Benchmark;

foreach (var method in typeof(Benchmarks).GetMethods(BindingFlags.Public | BindingFlags.Static))
{
method.CreateDelegate<Action>().Invoke();
}
BenchmarkRunner.Run<Benchmarks_PoCs>();
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2015-2024 The Neo Project.
//
// Benchmarks.cs file belongs to the neo project and is free
// Benchmarks.POC.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
Expand All @@ -9,13 +9,15 @@
// Redistribution and use in source and binary forms with or without
// modifications are permitted.

using BenchmarkDotNet.Attributes;
using System.Diagnostics;

namespace Neo.VM
namespace Neo.VM.Benchmark
{
public static class Benchmarks
public class Benchmarks_PoCs
{
public static void NeoIssue2528()
[Benchmark]
public void NeoIssue2528()
{
// https://github.com/neo-project/neo/issues/2528
// L01: INITSLOT 1, 0
Expand Down Expand Up @@ -47,7 +49,8 @@ public static void NeoIssue2528()
Run(nameof(NeoIssue2528), "VwEAwkpKAfsHdwARwG8AnXcAbwAl9////xHAzwJwlAAAdwAQzm8AnXcAbwAl9////0U=");
}

public static void NeoVMIssue418()
[Benchmark]
public void NeoVMIssue418()
{
// https://github.com/neo-project/neo-vm/issues/418
// L00: NEWARRAY0
Expand Down Expand Up @@ -81,7 +84,8 @@ public static void NeoVMIssue418()
Run(nameof(NeoVMIssue418), "whBNEcARTRHAVgEB/gGdYBFNEU0SwFMSwFhKJPNFUUU=");
}

public static void NeoIssue2723()
[Benchmark]
public void NeoIssue2723()
{
// L00: INITSSLOT 1
// L01: PUSHINT32 130000
Expand All @@ -102,11 +106,8 @@ private static void Run(string name, string poc)
byte[] script = Convert.FromBase64String(poc);
using ExecutionEngine engine = new();
engine.LoadScript(script);
Stopwatch stopwatch = Stopwatch.StartNew();
engine.Execute();
stopwatch.Stop();
Debug.Assert(engine.State == VMState.HALT);
Console.WriteLine($"Benchmark: {name},\tTime: {stopwatch.Elapsed}");
}
}
}
122 changes: 122 additions & 0 deletions benchmarks/Neo.VM.Benchmarks/Benchmarks.Types.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// Copyright (C) 2015-2024 The Neo Project.
//
// Benchmarks.Types.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
// for more details.
//
// Redistribution and use in source and binary forms with or without
// modifications are permitted.

using BenchmarkDotNet.Attributes;
using Array = Neo.VM.Types.Array;

namespace Neo.VM.Benchmark;

public class Benchmarks_Types
{
public IEnumerable<(int Depth, int ElementsPerLevel)> ParamSource()
{
int[] depths = [2, 4];
int[] elementsPerLevel = [2, 4, 6];

foreach (var depth in depths)
{
foreach (var elements in elementsPerLevel)
{
if (depth <= 8 || elements <= 2)
{
yield return (depth, elements);
}
}
}
}

[ParamsSource(nameof(ParamSource))]
public (int Depth, int ElementsPerLevel) Params;

[Benchmark]
public void BenchNestedArrayDeepCopy()
{
var root = new Array(new ReferenceCounter());
CreateNestedArray(root, Params.Depth, Params.ElementsPerLevel);
_ = root.DeepCopy();
}

[Benchmark]
public void BenchNestedArrayDeepCopyWithReferenceCounter()
{
var referenceCounter = new ReferenceCounter();
var root = new Array(referenceCounter);
CreateNestedArray(root, Params.Depth, Params.ElementsPerLevel, referenceCounter);
_ = root.DeepCopy();
}

[Benchmark]
public void BenchNestedTestArrayDeepCopy()
{
var root = new TestArray(new ReferenceCounter());
CreateNestedTestArray(root, Params.Depth, Params.ElementsPerLevel);
_ = root.DeepCopy();
}

[Benchmark]
public void BenchNestedTestArrayDeepCopyWithReferenceCounter()
{
var referenceCounter = new ReferenceCounter();
var root = new TestArray(referenceCounter);
CreateNestedTestArray(root, Params.Depth, Params.ElementsPerLevel, referenceCounter);
_ = root.DeepCopy();
}

private static void CreateNestedArray(Array? rootArray, int depth, int elementsPerLevel = 1, ReferenceCounter? referenceCounter = null)
{
if (depth < 0)
{
throw new ArgumentException("Depth must be non-negative", nameof(depth));
}

if (rootArray == null)
{
throw new ArgumentNullException(nameof(rootArray));
}

if (depth == 0)
{
return;
}

for (var i = 0; i < elementsPerLevel; i++)
{
var childArray = new Array(referenceCounter);
rootArray.Add(childArray);
CreateNestedArray(childArray, depth - 1, elementsPerLevel, referenceCounter);
}
}

private static void CreateNestedTestArray(TestArray rootArray, int depth, int elementsPerLevel = 1, ReferenceCounter referenceCounter = null)

Check warning on line 98 in benchmarks/Neo.VM.Benchmarks/Benchmarks.Types.cs

View workflow job for this annotation

GitHub Actions / Test-Everything

Cannot convert null literal to non-nullable reference type.

Check warning on line 98 in benchmarks/Neo.VM.Benchmarks/Benchmarks.Types.cs

View workflow job for this annotation

GitHub Actions / Test-Everything

Cannot convert null literal to non-nullable reference type.

Check warning on line 98 in benchmarks/Neo.VM.Benchmarks/Benchmarks.Types.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 98 in benchmarks/Neo.VM.Benchmarks/Benchmarks.Types.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 98 in benchmarks/Neo.VM.Benchmarks/Benchmarks.Types.cs

View workflow job for this annotation

GitHub Actions / Test (macos-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 98 in benchmarks/Neo.VM.Benchmarks/Benchmarks.Types.cs

View workflow job for this annotation

GitHub Actions / Test (macos-latest)

Cannot convert null literal to non-nullable reference type.
{
if (depth < 0)
{
throw new ArgumentException("Depth must be non-negative", nameof(depth));
}

if (rootArray == null)
{
throw new ArgumentNullException(nameof(rootArray));
}

if (depth == 0)
{
return;
}

for (var i = 0; i < elementsPerLevel; i++)
{
var childArray = new TestArray(referenceCounter);
rootArray.Add(childArray);
CreateNestedTestArray(childArray, depth - 1, elementsPerLevel, referenceCounter);
}
}
}
1 change: 1 addition & 0 deletions benchmarks/Neo.VM.Benchmarks/Neo.VM.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\Neo.VM\Neo.VM.csproj" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
</ItemGroup>

</Project>
Loading

0 comments on commit 86e6fa1

Please sign in to comment.