Skip to content

Commit

Permalink
Merge branch 'master' into HF_Echidna
Browse files Browse the repository at this point in the history
  • Loading branch information
cschuchardt88 authored Dec 4, 2024
2 parents 74498e5 + 79554f2 commit 577c431
Show file tree
Hide file tree
Showing 200 changed files with 1,863 additions and 974 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
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
4 changes: 2 additions & 2 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 @@ -69,7 +69,7 @@ jobs:
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/
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)
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: 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
6 changes: 3 additions & 3 deletions benchmarks/Neo.Benchmarks/Neo.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net8.0</TargetFrameworks>
<TargetFrameworks>net9.0</TargetFrameworks>
<RootNamespace>Neo</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.IO.Hashing" Version="8.0.0" />
<PackageReference Include="System.IO.Hashing" Version="9.0.0" />
<ProjectReference Include="..\..\src\Neo\Neo.csproj" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions benchmarks/Neo.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

using BenchmarkDotNet.Running;
using Neo.Benchmark;
using Neo.SmartContract.Benchmark;

// BenchmarkRunner.Run<Benchmarks_PoCs>();
BenchmarkRunner.Run<Benchmarks_UInt160>();
BenchmarkRunner.Run<Benchmarks_Hash>();
BenchmarkRunner.Run<Benchmarks_StorageKey>();
75 changes: 75 additions & 0 deletions benchmarks/Neo.Benchmarks/SmartContract/Benchmarks.StorageKey.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright (C) 2015-2024 The Neo Project.
//
// Benchmarks.StorageKey.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 System.Text;

namespace Neo.SmartContract.Benchmark
{
public class Benchmarks_StorageKey
{
// for avoiding overhead of encoding
private static readonly byte[] testBytes = Encoding.ASCII.GetBytes("StorageKey");

private const int prefixSize = sizeof(int) + sizeof(byte);

[Benchmark]
public void KeyBuilder_AddInt()
{
var key = new KeyBuilder(1, 0)
.AddBigEndian(1)
.AddBigEndian(2)
.AddBigEndian(3);

var bytes = key.ToArray();
if (bytes.Length != prefixSize + 3 * sizeof(int))
throw new InvalidOperationException();
}

[Benchmark]
public void KeyBuilder_AddIntWithoutPrealloc()
{
var key = new KeyBuilder(1, 0, 0)
.AddBigEndian(1)
.AddBigEndian(2)
.AddBigEndian(3);

var bytes = key.ToArray();
if (bytes.Length != prefixSize + 3 * sizeof(int))
throw new InvalidOperationException();
}

[Benchmark]
public void KeyBuilder_AddBytes()
{
var key = new KeyBuilder(1, 0)
.Add(testBytes)
.Add(testBytes)
.Add(testBytes);

var bytes = key.ToArray();
if (bytes.Length != prefixSize + 3 * testBytes.Length)
throw new InvalidOperationException();
}

[Benchmark]
public void KeyBuilder_AddUInt160()
{
Span<byte> value = stackalloc byte[UInt160.Length];
var key = new KeyBuilder(1, 0)
.Add(new UInt160(value));

var bytes = key.ToArray();
if (bytes.Length != prefixSize + UInt160.Length)
throw new InvalidOperationException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>Neo.Extensions</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MSTest.TestFramework" Version="3.5.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.3" />
<ProjectReference Include="..\..\src\Neo.Extensions\Neo.Extensions.csproj" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions benchmarks/Neo.VM.Benchmarks/Neo.VM.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net8.0</TargetFrameworks>
<TargetFrameworks>net9.0</TargetFrameworks>
<RootNamespace>Neo.VM</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MSTest.TestFramework" Version="3.5.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.3" />
<ProjectReference Include="..\..\src\Neo.Extensions\Neo.Extensions.csproj" />
<ProjectReference Include="..\..\src\Neo.Json\Neo.Json.csproj" />
<ProjectReference Include="..\..\src\Neo.VM\Neo.VM.csproj" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<ProjectReference Include="..\..\tests\Neo.VM.Tests\Neo.VM.Tests.csproj" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.202",
"version": "9.0.100",
"rollForward": "latestFeature",
"allowPrerelease": false
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/Neo.CLI/test-neo-cli.exp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set timeout 10
exp_internal true

# Start neo-cli
spawn dotnet ./bin/Neo.CLI/net8.0/neo-cli.dll
spawn dotnet ./bin/Neo.CLI/net9.0/neo-cli.dll

# Expect the main input prompt
expect {
Expand Down
4 changes: 2 additions & 2 deletions src/Neo.CLI/CLI/MainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -521,13 +521,13 @@ private void WriteBlocks(uint start, uint count, string path, bool writeStart)
if (writeStart)
{
fs.Seek(sizeof(uint), SeekOrigin.Begin);
fs.Read(buffer, 0, buffer.Length);
fs.ReadExactly(buffer);
start += BitConverter.ToUInt32(buffer, 0);
fs.Seek(sizeof(uint), SeekOrigin.Begin);
}
else
{
fs.Read(buffer, 0, buffer.Length);
fs.ReadExactly(buffer);
start = BitConverter.ToUInt32(buffer, 0);
fs.Seek(0, SeekOrigin.Begin);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Neo.CLI/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS Build
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0 AS Build

# Run this from the repository root folder
COPY src .
COPY NuGet.Config /Neo.CLI

WORKDIR /Neo.CLI
RUN dotnet restore && dotnet publish -f net8.0 -c Release -o /app
RUN dotnet restore && dotnet publish -f net9.0 -c Release -o /app

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0 AS Final
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:9.0 AS Final
RUN apt-get update && apt-get install -y \
screen \
libleveldb-dev \
Expand Down
2 changes: 1 addition & 1 deletion src/Neo.CLI/Neo.CLI.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AssemblyTitle>Neo.CLI</AssemblyTitle>
<AssemblyName>neo-cli</AssemblyName>
<OutputType>Exe</OutputType>
Expand Down
4 changes: 2 additions & 2 deletions src/Neo.ConsoleService/Neo.ConsoleService.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.1;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.1;net9.0</TargetFrameworks>
<PackageId>Neo.ConsoleService</PackageId>
<Nullable>enable</Nullable>
<OutputPath>../../bin/$(PackageId)</OutputPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.0" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="9.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

<PropertyGroup>
<VersionPrefix>0.3.0</VersionPrefix>
<TargetFrameworks>netstandard2.1;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.1;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>Neo.Cryptography.BLS12_381</PackageId>
<OutputPath>../../bin/$(PackageId)</OutputPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 8 additions & 0 deletions src/Neo.Extensions/ByteExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,16 @@ public static int XxHash3_32(this byte[] value, long seed = DefaultXxHash3Seed)
/// </summary>
/// <param name="value">The byte array to convert.</param>
/// <returns>The converted hex <see cref="string"/>.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="value"/> is null.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string ToHexString(this byte[] value)
{
#if NET9_0_OR_GREATER
return Convert.ToHexStringLower(value);
#else
if (value is null)
throw new ArgumentNullException(nameof(value));

return string.Create(value.Length * 2, value, (span, bytes) =>
{
for (var i = 0; i < bytes.Length; i++)
Expand All @@ -74,12 +78,16 @@ public static string ToHexString(this byte[] value)
/// <param name="value">The byte array to convert.</param>
/// <param name="reverse">Indicates whether it should be converted in the reversed byte order.</param>
/// <returns>The converted hex <see cref="string"/>.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="value"/> is null.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string ToHexString(this byte[] value, bool reverse = false)
{
if (!reverse)
return ToHexString(value);

if (value is null)
throw new ArgumentNullException(nameof(value));

return string.Create(value.Length * 2, value, (span, bytes) =>
{
for (var i = 0; i < bytes.Length; i++)
Expand Down
Loading

0 comments on commit 577c431

Please sign in to comment.