Skip to content

Commit

Permalink
Merge branch 'add/plugins/rest-server' of https://github.com/cschucha…
Browse files Browse the repository at this point in the history
…rdt88/neo into add/plugins/rest-server
  • Loading branch information
cschuchardt88 committed Nov 26, 2024
2 parents 5c29eb7 + 845c9ea commit 3921d3f
Show file tree
Hide file tree
Showing 325 changed files with 15,825 additions and 10,857 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ indent_size = 2

# Dotnet code style settings:
[*.{cs,vb}]
# Use block-scoped namespace
csharp_style_namespace_declarations = block_scoped:error
dotnet_diagnostic.IDE0160.severity = error
dotnet_diagnostic.IDE0161.severity = error

# Member can be made 'readonly'
csharp_style_prefer_readonly_struct_member = true
dotnet_diagnostic.IDE0251.severity = warning
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature-or-enhancement-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Feature or enhancement request
about: Suggest an idea for Neo
title: ''
labels: discussion
labels: Discussion
assignees: ''
---

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Questions
about: Questions about Neo Platform
title: ''
labels: question
labels: Question
assignees: ''
---

Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,17 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Test
if: matrix.os != 'ubuntu-latest'

- name: Test (MacOS)
if: matrix.os == 'macos-latest'
run: |
brew install leveldb
dotnet build
cp -vp /opt/homebrew/Cellar/leveldb/1.23_1/lib/libleveldb.dylib ./tests/Neo.Plugins.Storage.Tests/bin/Debug/net8.0/
dotnet test --blame-hang --blame-crash --no-build
- name: Test (windows)
if: matrix.os == 'windows-latest'
run: |
dotnet sln neo.sln remove ./tests/Neo.Plugins.Storage.Tests/Neo.Plugins.Storage.Tests.csproj
dotnet build
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,8 @@ paket-files/
PublishProfiles
/.vscode
launchSettings.json
/coverages
**/.DS_Store

# Benchmarks
**/BenchmarkDotNet.Artifacts/
57 changes: 57 additions & 0 deletions benchmarks/Neo.Benchmarks/Benchmarks.Hash.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (C) 2015-2024 The Neo Project.
//
// Benchmarks.Hash.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 Neo.Cryptography;
using Neo.Extensions;
using System.Diagnostics;
using System.IO.Hashing;
using System.Text;

namespace Neo.Benchmark
{
public class Benchmarks_Hash
{
// 256 KiB
static readonly byte[] data = Encoding.ASCII.GetBytes(string.Concat(Enumerable.Repeat("Hello, World!^_^", 16 * 1024)));

static readonly byte[] hash = "9182abedfbb9b18d81a05d8bcb45489e7daa2858".HexToBytes();

[Benchmark]
public void RIPEMD160_ComputeHash()
{
using var ripemd160 = new RIPEMD160Managed();
var result = ripemd160.ComputeHash(data);
Debug.Assert(result.SequenceEqual(hash));
}

[Benchmark]
public void XxHash32_HashToUInt32()
{
var result = XxHash32.HashToUInt32(data);
Debug.Assert(result == 682967318u);
}

[Benchmark]
public void XxHash3_HashToUInt64()
{
var result = (uint)XxHash3.HashToUInt64(data);
Debug.Assert(result == 1389469485u);
}

[Benchmark]
public void Murmur32_HashToUInt32()
{
var result = data.Murmur32(0);
Debug.Assert(result == 3731881930u);
}
}
}
111 changes: 56 additions & 55 deletions benchmarks/Neo.Benchmarks/Benchmarks.POC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,64 +15,65 @@
using Neo.VM;
using System.Diagnostics;

namespace Neo.Benchmark;

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

[Benchmark]
public void NeoIssue2725()
public class Benchmarks_PoCs
{
// https://github.com/neo-project/neo/issues/2725
// L00: INITSSLOT 1
// L01: NEWARRAY0
// L02: PUSHDATA1 6161616161 //"aaaaa"
// L03: PUSHINT16 500
// L04: STSFLD0
// L05: OVER
// L06: OVER
// L07: SYSCALL 95016f61 //System.Runtime.Notify
// L08: LDSFLD0
// L09: DEC
// L10: DUP
// L11: STSFLD0
// L12: JMPIF L05
// L13: CLEAR
// L14: SYSCALL dbfea874 //System.Runtime.GetExecutingScriptHash
// L15: PUSHINT16 8000
// L16: STSFLD0
// L17: DUP
// L18: SYSCALL 274335f1 //System.Runtime.GetNotifications
// L19: DROP
// L20: LDSFLD0
// L21: DEC
// L22: DUP
// L23: STSFLD0
// L24: JMPIF L17
Run(nameof(NeoIssue2725), "VgHCDAVhYWFhYQH0AWBLS0GVAW9hWJ1KYCT1SUHb/qh0AUAfYEpBJ0M18UVYnUpgJPU=");
}
private static readonly ProtocolSettings protocol = ProtocolSettings.Load("config.json");
private static readonly NeoSystem system = new(protocol, (string)null);

private static void Run(string name, string poc)
{
Random random = new();
Transaction tx = new()
[Benchmark]
public void NeoIssue2725()
{
// https://github.com/neo-project/neo/issues/2725
// L00: INITSSLOT 1
// L01: NEWARRAY0
// L02: PUSHDATA1 6161616161 //"aaaaa"
// L03: PUSHINT16 500
// L04: STSFLD0
// L05: OVER
// L06: OVER
// L07: SYSCALL 95016f61 //System.Runtime.Notify
// L08: LDSFLD0
// L09: DEC
// L10: DUP
// L11: STSFLD0
// L12: JMPIF L05
// L13: CLEAR
// L14: SYSCALL dbfea874 //System.Runtime.GetExecutingScriptHash
// L15: PUSHINT16 8000
// L16: STSFLD0
// L17: DUP
// L18: SYSCALL 274335f1 //System.Runtime.GetNotifications
// L19: DROP
// L20: LDSFLD0
// L21: DEC
// L22: DUP
// L23: STSFLD0
// L24: JMPIF L17
Run(nameof(NeoIssue2725), "VgHCDAVhYWFhYQH0AWBLS0GVAW9hWJ1KYCT1SUHb/qh0AUAfYEpBJ0M18UVYnUpgJPU=");
}

private static void Run(string name, string poc)
{
Version = 0,
Nonce = (uint)random.Next(),
SystemFee = 20_00000000,
NetworkFee = 1_00000000,
ValidUntilBlock = ProtocolSettings.Default.MaxTraceableBlocks,
Signers = Array.Empty<Signer>(),
Attributes = Array.Empty<TransactionAttribute>(),
Script = Convert.FromBase64String(poc),
Witnesses = Array.Empty<Witness>()
};
using var snapshot = system.GetSnapshotCache();
using var engine = ApplicationEngine.Create(TriggerType.Application, tx, snapshot, system.GenesisBlock, protocol, tx.SystemFee);
engine.LoadScript(tx.Script);
engine.Execute();
Debug.Assert(engine.State == VMState.FAULT);
Random random = new();
Transaction tx = new()
{
Version = 0,
Nonce = (uint)random.Next(),
SystemFee = 20_00000000,
NetworkFee = 1_00000000,
ValidUntilBlock = ProtocolSettings.Default.MaxTraceableBlocks,
Signers = Array.Empty<Signer>(),
Attributes = Array.Empty<TransactionAttribute>(),
Script = Convert.FromBase64String(poc),
Witnesses = Array.Empty<Witness>()
};
using var snapshot = system.GetSnapshotCache();
using var engine = ApplicationEngine.Create(TriggerType.Application, tx, snapshot, system.GenesisBlock, protocol, tx.SystemFee);
engine.LoadScript(tx.Script);
engine.Execute();
Debug.Assert(engine.State == VMState.FAULT);
}
}
}
Loading

0 comments on commit 3921d3f

Please sign in to comment.