Skip to content

Commit cebbdb8

Browse files
cschuchardt88Wi1l-B0tajara87shargonNGDAdmin
authored
[Rebase] dev into neo-build.dev Branch (#4024)
* Fix: P/Invokes should not be visible (#4003) * [Optimization] - Optimize key method (#4001) * [Optimization] - Optimize Key method * Update src/Neo.Cryptography.MPTTrie/Cache.cs --------- Co-authored-by: Shargon <[email protected]> * Fix Threading hanging with `NeoSystem` (#4005) * Fix threading hanging with `NeoSystem` * Fixed for deadlocks --------- Co-authored-by: Christopher R. Schuchardt <[email protected]> Co-authored-by: Shargon <[email protected]> Co-authored-by: NGD Admin <[email protected]> * Style: unify json init style (#4004) Co-authored-by: Jimmy <[email protected]> Co-authored-by: Shargon <[email protected]> * Update packages (#4006) * Update packages * more * clean --------- Co-authored-by: Jimmy <[email protected]> * Restore DBFTPlugin Unit Tests (ConsensusService and Consensus Context) (#3473) * Initial comit * Fix paths * Added `Neo.Plugins.DBFTPlugin.Tests` to `Neo` internals * Added tests to github workflow * Akka deps * Advancing * TestWallet is mocked * Adding more steps * Fixed Test mocking * Timestamp testing * Header and TestProbe * format * Huge advance! Test probe is now working. Now we go * dotnet format * Header looks like to be correct now * Workaround for dbft settings * build the mock system for solenode * update to 7 nodes network mock system * Comment original tests of the PR * [`ut`] 100% Coverage Trie.Get (#3952) * 100% Coverage Trie.Get * fix ut * feat: Add comprehensive DBFT consensus unit tests - Add 34 comprehensive unit tests covering all DBFT scenarios - Test normal consensus flows, abnormal scenarios, and recovery mechanisms - Include Byzantine fault tolerance testing (f=1 and f=2 failures) - Add network partition and message loss simulation - Implement stress testing with multiple rounds and large transaction sets - Create professional test infrastructure with TestWallet and ConsensusTestHelper - Add comprehensive README documentation - Ensure 100% test pass rate with robust error handling - Cover complete DBFT protocol: PrepareRequest → PrepareResponse → Commit flow - Validate view changes, recovery requests, and state synchronization Test Coverage: - UT_ConsensusService.cs (7 tests): Service lifecycle and message handling - UT_DBFT.cs (6 tests): Basic consensus scenarios - UT_DBFT_Integration.cs (4 tests): Integration scenarios - UT_DBFT_NormalFlow.cs (3 tests): Complete normal consensus flows - UT_DBFT_AbnormalScenarios.cs (4 tests): Failure and attack scenarios - UT_DBFT_Recovery.cs (6 tests): Recovery mechanisms - UT_DBFT_Robustness.cs (4 tests): Stress and edge case testing All tests pass: 34/34 ✅ * chore: Update .NET SDK version to 9.0.203 - Update global.json to use .NET SDK 9.0.203 (from 9.0.102) - Ensures compatibility with latest .NET 9 features and fixes * fix: Revert .NET SDK version to 9.0.102 - Revert global.json to use .NET SDK 9.0.102 (available on build system) - Ensures compatibility with current development environment - Previous version 9.0.203 was not available on the build system * style: Update copyright year to 2025 - Run dotnet format to apply code formatting standards - Update copyright year in RecoveryMessageExtensions.cs from 2024 to 2025 - Maintain consistent code formatting across the project * chore: Update .NET SDK version to 9.0.300 - Update global.json to use .NET SDK 9.0.300 (from 9.0.102) - Ensures compatibility with latest .NET 9 features and improvements - Maintains project build consistency with updated SDK * fix: Resolve RpcServer test compilation errors - Add Neo.IO using statement for ToHexString extension method - Comment out problematic ToHexString calls in test setup - Ensure RpcServer tests can compile alongside DBFT tests - Maintain DBFT test functionality (34/34 tests passing) * fix: Complete RpcServer test compilation fix - Ensure all ToHexString extension method issues are resolved - Maintain compatibility with DBFT tests (34/34 passing) - Fix build errors in RpcServer test suite * Revert changes except DBFT plugin tests - Reverted all source files to match dev branch - Reverted test files in Neo.UnitTests and Neo.Plugins.RpcServer.Tests - Preserved all DBFT plugin test files and functionality - Removed RecoveryMessageExtensions.cs (not in dev branch) * Fix DBFT plugin tests API compatibility and accessibility - Made ConsensusService class internal for test accessibility - Added InternalsVisibleTo attributes for Neo core and DBFT plugin - Updated test constructors to use current dev branch API: - Fixed NeoSystem constructor (2-parameter instead of 6-parameter) - Fixed Settings constructor to use IConfigurationSection - Added Microsoft.Extensions.Configuration packages - Created TestBlockchain.CreateDefaultSettings() helper method - Updated all test files to use compatible API calls - All 1,401 tests passing including 34 DBFT plugin tests - Code formatted with dotnet format * Add comprehensive DBFT consensus message flow tests - Implement proper consensus message flow monitoring as requested in GitHub comment - Add UT_DBFT_ProperMessageFlow.cs with professional, working tests - Update ConsensusTestHelper with async methods for natural message flow - Clean up comments and code formatting with dotnet format - All 38 DBFT plugin tests passing Tests now properly: - Send PrepareRequest and wait for natural PrepareResponse - Monitor actual consensus message flow instead of forcing it - Handle message validation, service resilience, and lifecycle testing - Use simplified but effective message capture mechanism * Update src/Plugins/DBFTPlugin/DBFTPlugin.csproj Co-authored-by: Christopher Schuchardt <[email protected]> * Update src/Plugins/DBFTPlugin/DBFTPlugin.csproj * refactor: Enhance DBFT consensus unit tests to professional standards - Consistent UT_xxx naming convention for all test files - Mock* pattern for all helper/utility classes - Enhanced assertions (7→19, +171% improvement) - Removed duplicate test methods (~140 lines eliminated) - Professional documentation aligned with implementation - Fixed project file syntax (InternalsVisibleTo) - 100% test pass rate maintained (34/34 tests) - Ready for production deployment * Convert DBFT unit tests from xUnit to MSTest framework - Remove xUnit package references (xunit, xunit.runner.visualstudio, Akka.TestKit.Xunit2) - Add Akka.TestKit.MsTest package reference - Update all test files to use MSTest TestKit instead of xUnit - Fix test runner configuration to resolve "Zero tests ran" issue - All 34 tests now pass successfully with MSTest framework - Maintain existing test structure and TestKit inheritance * Update DBFT unit tests README for MSTest framework - Document MSTest framework usage instead of xUnit - Update prerequisites to include MSTest and Akka.NET TestKit (MSTest version) - Add note about Visual Studio Test Explorer integration - Update performance timing to reflect current test execution (~33s) - Emphasize production-ready testing capabilities * Fix copyright header filenames in DBFT tests - Correct UT_DBFT_Performance.cs header (was UT_DBFT_Robustness.cs) - Correct UT_DBFT_Failures.cs header (was UT_DBFT_AbnormalScenarios.cs) - Fix other copyright headers to match actual filenames - Applied via dotnet format to ensure consistency * Update tests/Neo.Plugins.DBFTPlugin.Tests/Neo.Plugins.DBFTPlugin.Tests.csproj * Update tests/Neo.Plugins.DBFTPlugin.Tests/UT_DBFT_Core.cs * Update tests/Neo.Plugins.DBFTPlugin.Tests/UT_DBFT_MessageFlow.cs * Update tests/Neo.Plugins.DBFTPlugin.Tests/UT_DBFT_MessageFlow.cs * Add coverage --------- Co-authored-by: Christopher Schuchardt <[email protected]> Co-authored-by: Jimmy <[email protected]> Co-authored-by: Shargon <[email protected]> Co-authored-by: Will <[email protected]> Co-authored-by: Jimmy <[email protected]> * Style: move MPT Benchamrk Project to benchmarks/ (#4011) * [`improve`] nullable app logs (#4008) * nullable app logs * Update src/Plugins/ApplicationLogs/LogReader.cs Co-authored-by: Christopher Schuchardt <[email protected]> * Apply suggestions from code review Co-authored-by: Christopher Schuchardt <[email protected]> * Update src/Plugins/ApplicationLogs/Settings.cs Co-authored-by: Christopher Schuchardt <[email protected]> --------- Co-authored-by: Christopher Schuchardt <[email protected]> * Fix: remove FluentAssertions in notary tests (#4014) * Add: SignClient Vsock support (#4002) * Add: SignClient vsock support * optimize: add const string * optimize: use Uri parse endpoint --------- Co-authored-by: Shargon <[email protected]> Co-authored-by: NGD Admin <[email protected]> Co-authored-by: Christopher Schuchardt <[email protected]> * Comments: add Exception info for numeric ops (#4021) --------- Co-authored-by: Will <[email protected]> Co-authored-by: Alvaro <[email protected]> Co-authored-by: Shargon <[email protected]> Co-authored-by: Christopher R. Schuchardt <[email protected]> Co-authored-by: NGD Admin <[email protected]> Co-authored-by: Jimmy <[email protected]> Co-authored-by: Vitor Nazário Coelho <[email protected]> Co-authored-by: Jimmy <[email protected]>
1 parent fc4467d commit cebbdb8

File tree

83 files changed

+4412
-609
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+4412
-609
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ jobs:
109109
${{ github.workspace }}/TestResults/Neo.Json.UnitTests/coverage.info
110110
${{ github.workspace }}/TestResults/Neo.Cryptography.MPTTrie.Tests/coverage.info
111111
${{ github.workspace }}/TestResults/Neo.Network.RPC.Tests/coverage.info
112+
${{ github.workspace }}/TestResults/Neo.Plugins.DBFTPlugin.Tests/coverage.info
112113
${{ github.workspace }}/TestResults/Neo.Plugins.OracleService.Tests/coverage.info
113114
${{ github.workspace }}/TestResults/Neo.Plugins.RpcServer.Tests/coverage.info
114115
${{ github.workspace }}/TestResults/Neo.Plugins.Storage.Tests/coverage.info

benchmarks/Neo.Benchmarks/Neo.Benchmarks.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="System.IO.Hashing" Version="9.0.1" />
12+
<PackageReference Include="System.IO.Hashing" Version="9.0.6" />
1313
<ProjectReference Include="..\..\src\Neo\Neo.csproj" />
1414
<ProjectReference Include="..\..\src\Plugins\LevelDBStore\LevelDBStore.csproj" />
15-
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
15+
<PackageReference Include="BenchmarkDotNet" Version="0.15.2" />
1616
</ItemGroup>
1717

1818
<ItemGroup>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright (C) 2015-2025 The Neo Project.
2+
//
3+
// Benchmarks.Cache.cs file belongs to the neo project and is free
4+
// software distributed under the MIT software license, see the
5+
// accompanying file LICENSE in the main directory of the
6+
// repository or http://www.opensource.org/licenses/mit-license.php
7+
// for more details.
8+
//
9+
// Redistribution and use in source and binary forms with or without
10+
// modifications are permitted.
11+
12+
using BenchmarkDotNet.Attributes;
13+
14+
namespace Neo.Cryptography.MPTTrie.Benchmarks
15+
{
16+
public class Benchmarks_Cache
17+
{
18+
private readonly byte _prefix = 0x01;
19+
private readonly UInt256 _hash;
20+
21+
public Benchmarks_Cache()
22+
{
23+
var randomBytes = new byte[UInt256.Length];
24+
new Random(42).NextBytes(randomBytes);
25+
_hash = new UInt256(randomBytes);
26+
}
27+
28+
[Benchmark]
29+
public byte[] Key_Original()
30+
{
31+
var buffer = new byte[UInt256.Length + 1];
32+
using (var ms = new MemoryStream(buffer, true))
33+
using (var writer = new BinaryWriter(ms))
34+
{
35+
writer.Write(_prefix);
36+
_hash.Serialize(writer);
37+
}
38+
return buffer;
39+
}
40+
41+
[Benchmark]
42+
public byte[] Key_Optimized()
43+
{
44+
var buffer = new byte[UInt256.Length + 1];
45+
buffer[0] = _prefix;
46+
_hash.GetSpan().CopyTo(buffer.AsSpan(1));
47+
return buffer;
48+
}
49+
}
50+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="BenchmarkDotNet" Version="0.15.2" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<ProjectReference Include="..\..\src\Neo\Neo.csproj" />
16+
</ItemGroup>
17+
18+
</Project>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (C) 2015-2025 The Neo Project.
2+
//
3+
// Program.cs file belongs to the neo project and is free
4+
// software distributed under the MIT software license, see the
5+
// accompanying file LICENSE in the main directory of the
6+
// repository or http://www.opensource.org/licenses/mit-license.php
7+
// for more details.
8+
//
9+
// Redistribution and use in source and binary forms with or without
10+
// modifications are permitted.
11+
12+
using BenchmarkDotNet.Running;
13+
14+
// List all benchmarks:
15+
// dotnet run -c Release --framework [for example: net9.0] -- --list flat(or tree)
16+
// Run a specific benchmark:
17+
// dotnet run -c Release --framework [for example: net9.0] -- -f [benchmark name]
18+
// Run all benchmarks:
19+
// dotnet run -c Release --framework [for example: net9.0] -- -f *
20+
// Run all benchmarks of a class:
21+
// dotnet run -c Release --framework [for example: net9.0] -- -f '*Class*'
22+
// More options: https://benchmarkdotnet.org/articles/guides/console-args.html
23+
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);

benchmarks/Neo.Extensions.Benchmarks/Neo.Extensions.Benchmarks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<ItemGroup>
1212
<ProjectReference Include="..\..\src\Neo.Extensions\Neo.Extensions.csproj" />
13-
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
13+
<PackageReference Include="BenchmarkDotNet" Version="0.15.2" />
1414
</ItemGroup>
1515

1616
</Project>

benchmarks/Neo.Json.Benchmarks/Neo.Json.Benchmarks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
11+
<PackageReference Include="BenchmarkDotNet" Version="0.15.2" />
1212
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
1313
</ItemGroup>
1414

benchmarks/Neo.VM.Benchmarks/Neo.VM.Benchmarks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<ProjectReference Include="..\..\src\Neo.Extensions\Neo.Extensions.csproj" />
1313
<ProjectReference Include="..\..\src\Neo.Json\Neo.Json.csproj" />
1414
<ProjectReference Include="..\..\src\Neo.VM\Neo.VM.csproj" />
15-
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
15+
<PackageReference Include="BenchmarkDotNet" Version="0.15.2" />
1616
</ItemGroup>
1717

1818
</Project>

neo.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SignClient", "src\Plugins\S
9393
EndProject
9494
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.Plugins.SignClient.Tests", "tests\Neo.Plugins.SignClient.Tests\Neo.Plugins.SignClient.Tests.csproj", "{E2CFEAA1-45F2-4075-94ED-866862C6863F}"
9595
EndProject
96+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.Cryptography.MPTTrie.Benchmarks", "benchmarks\Neo.Cryptography.MPTTrie.Benchmarks\Neo.Cryptography.MPTTrie.Benchmarks.csproj", "{69B0D53B-D97A-4315-B205-CCEBB7289EA9}"
97+
EndProject
9698
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sdk", "sdk", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
9799
EndProject
98100
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{86DC563B-443D-418A-A65E-B7E38EB3EF21}"
@@ -269,6 +271,10 @@ Global
269271
{E2CFEAA1-45F2-4075-94ED-866862C6863F}.Debug|Any CPU.Build.0 = Debug|Any CPU
270272
{E2CFEAA1-45F2-4075-94ED-866862C6863F}.Release|Any CPU.ActiveCfg = Release|Any CPU
271273
{E2CFEAA1-45F2-4075-94ED-866862C6863F}.Release|Any CPU.Build.0 = Release|Any CPU
274+
{69B0D53B-D97A-4315-B205-CCEBB7289EA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
275+
{69B0D53B-D97A-4315-B205-CCEBB7289EA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
276+
{69B0D53B-D97A-4315-B205-CCEBB7289EA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
277+
{69B0D53B-D97A-4315-B205-CCEBB7289EA9}.Release|Any CPU.Build.0 = Release|Any CPU
272278
{6C1B4D3D-FFB4-F470-7670-DE33EAD41127}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
273279
{6C1B4D3D-FFB4-F470-7670-DE33EAD41127}.Debug|Any CPU.Build.0 = Debug|Any CPU
274280
{6C1B4D3D-FFB4-F470-7670-DE33EAD41127}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -327,6 +333,7 @@ Global
327333
{19B1CF1A-17F4-4E04-AB9C-55CE74952E11} = {EDE05FA8-8E73-4924-BC63-DD117127EEE1}
328334
{CAD55942-48A3-4526-979D-7519FADF19FE} = {C2DC830A-327A-42A7-807D-295216D30DBB}
329335
{E2CFEAA1-45F2-4075-94ED-866862C6863F} = {7F257712-D033-47FF-B439-9D4320D06599}
336+
{69B0D53B-D97A-4315-B205-CCEBB7289EA9} = {C25EB0B0-0CAC-4CC1-8F36-F9229EFB99EC}
330337
{86DC563B-443D-418A-A65E-B7E38EB3EF21} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
331338
{6C1B4D3D-FFB4-F470-7670-DE33EAD41127} = {86DC563B-443D-418A-A65E-B7E38EB3EF21}
332339
{9169B1AF-1445-3029-4C82-3C1D5B55C8F5} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}

src/Neo.ConsoleService/Neo.ConsoleService.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<ItemGroup>
99
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
10-
<PackageReference Include="System.ServiceProcess.ServiceController" Version="9.0.1" />
10+
<PackageReference Include="System.ServiceProcess.ServiceController" Version="9.0.6" />
1111
</ItemGroup>
1212

1313
</Project>

0 commit comments

Comments
 (0)