Skip to content

Commit

Permalink
Merge branch 'master' into base58-patch
Browse files Browse the repository at this point in the history
  • Loading branch information
shargon authored Dec 5, 2024
2 parents 8840fb3 + cc2ad03 commit bfd9ae1
Show file tree
Hide file tree
Showing 349 changed files with 14,233 additions and 11,796 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM mcr.microsoft.com/devcontainers/dotnet:8.0-jammy
FROM mcr.microsoft.com/devcontainers/dotnet:9.0-jammy
# Install the libleveldb-dev package
RUN apt-get update && apt-get install -y libleveldb-dev
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
6 changes: 3 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
types: [published]

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

jobs:
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Build (neo-cli)
run: |
dotnet publish ./src/Neo.CLI \
--framework net8.0 \
--framework net9.0 \
--configuration Release \
--runtime linux-x64 \
--self-contained true \
Expand All @@ -49,7 +49,7 @@ jobs:
- name: Build (LevelDbStore)
run: |
dotnet build ./src/Plugins/LevelDBStore \
--framework net8.0 \
--framework net9.0 \
--configuration Release \
--output ${{ env.DIST_DIR }}/Plugins/LevelDBStore \
--verbosity normal \
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:

env:
DOTNET_VERSION: 8.0.x
DOTNET_VERSION: 9.0.x

jobs:

Expand Down 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/net9.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
2 changes: 1 addition & 1 deletion .github/workflows/nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

# Define environment variables
env:
DOTNET_VERSION: 8.0.x
DOTNET_VERSION: 9.0.x
CONFIGURATION: Release

jobs:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

# Define environment variables
env:
DOTNET_VERSION: 8.0.x
DOTNET_VERSION: 9.0.x
CONFIGURATION: Release
DIST_PATH: /tmp/dist
OUTPUT_PATH: /tmp/out
Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
run: |
dotnet publish ./src/Neo.CLI \
--version-suffix ${{ matrix.runtime }} \
--framework net8.0 \
--framework net9.0 \
--configuration ${{ env.CONFIGURATION }} \
--runtime ${{ matrix.runtime }} \
--self-contained true \
Expand All @@ -128,7 +128,7 @@ jobs:
run: |
dotnet build ./src/Plugins/LevelDBStore \
--version-suffix ${{ matrix.runtime }} \
--framework net8.0 \
--framework net9.0 \
--configuration ${{ env.CONFIGURATION }} \
--output ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }}/Plugins/LevelDBStore \
--verbosity normal \
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ paket-files/
PublishProfiles
/.vscode
launchSettings.json
/coverages
**/.DS_Store

# Benchmarks
**/BenchmarkDotNet.Artifacts/
**/BenchmarkDotNet.Artifacts/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<p align="center">
A modern distributed network for the Smart Economy.
<br>
<a href="https://developers.neo.org/docs/"><strong>Documentation »</strong></a>
<a href="https://docs.neo.org/"><strong>Documentation »</strong></a>
<br>
<br>
<a href="https://github.com/neo-project/neo"><strong>Neo</strong></a>
Expand Down Expand Up @@ -106,7 +106,7 @@
## Overview
This repository contain main classes of the
[Neo](https://neo.org) blockchain.
Visit the [tutorials](https://developers.neo.org) to get started.
Visit the [tutorials](https://docs.neo.org) to get started.


## Project structure
Expand Down
69 changes: 35 additions & 34 deletions benchmarks/Neo.Benchmarks/Benchmarks.Hash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,42 @@
using System.IO.Hashing;
using System.Text;

namespace Neo.Benchmark;

public class Benchmarks_Hash
namespace Neo.Benchmark
{
// 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()
public class Benchmarks_Hash
{
var result = data.Murmur32(0);
Debug.Assert(result == 3731881930u);
// 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 bfd9ae1

Please sign in to comment.