Skip to content

Commit e0de1a4

Browse files
author
Jimmy
authored
Merge branch 'neo-project:master' into check
2 parents ce2414f + 7fac685 commit e0de1a4

File tree

191 files changed

+4852
-2024
lines changed

Some content is hidden

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

191 files changed

+4852
-2024
lines changed

.github/workflows/nuget.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
env:
1010
DOTNET_VERSION: 9.0.x
1111
CONFIGURATION: Release
12+
NEO_NUGET_DIR: ./pkgs
1213

1314
jobs:
1415
nuget-release:
@@ -34,7 +35,7 @@ jobs:
3435
run: |
3536
dotnet pack ./neo.sln \
3637
--configuration Release \
37-
--output ./sbin \
38+
--output ${{ env.NEO_NUGET_DIR }} \
3839
--verbosity normal \
3940
-p:VersionPrefix=${{ env.APP_VERSION }} \
4041
-p:DebugSymbols=false \
@@ -47,7 +48,7 @@ jobs:
4748
4849
- name: Publish to NuGet.org
4950
run: |
50-
dotnet nuget push ./sbin/*.nupkg \
51+
dotnet nuget push ${{ env.NEO_NUGET_DIR }}/*.nupkg \
5152
--source https://api.nuget.org/v3/index.json \
5253
--api-key ${{ secrets.NUGET_TOKEN }} \
5354
--skip-duplicate

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,14 @@ PublishScripts/
153153

154154
# NuGet Packages
155155
*.nupkg
156+
*.snupkg
157+
156158
# The packages folder can be ignored because of Package Restore
157159
**/packages/*
160+
158161
# except build/, which is used as an MSBuild target.
159162
!**/packages/build/
163+
160164
# Uncomment if necessary however generally it will be regenerated when needed
161165
#!**/packages/repositories.config
162166
# NuGet v3's project.json files produces more ignoreable files
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright (C) 2015-2025 The Neo Project.
2+
//
3+
// Benchmarks.SignData.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+
using Neo.Extensions;
14+
using Neo.Network.P2P;
15+
using Neo.Network.P2P.Payloads;
16+
17+
namespace Neo.Benchmark
18+
{
19+
public class Benchmarks_SignData
20+
{
21+
private static readonly Transaction s_tx = new()
22+
{
23+
Attributes = [],
24+
Script = Array.Empty<byte>(),
25+
Signers = [new Signer() { Account = UInt160.Zero, AllowedContracts = [], AllowedGroups = [], Rules = [], Scopes = WitnessScope.Global }],
26+
Witnesses = []
27+
};
28+
29+
/// <summary>
30+
/// Gets the data of a <see cref="IVerifiable"/> object to be hashed.
31+
/// </summary>
32+
/// <param name="verifiable">The <see cref="IVerifiable"/> object to hash.</param>
33+
/// <param name="network">The magic number of the network.</param>
34+
/// <returns>The data to hash.</returns>
35+
public static byte[] GetSignDataV1(IVerifiable verifiable, uint network)
36+
{
37+
using MemoryStream ms = new();
38+
using BinaryWriter writer = new(ms);
39+
writer.Write(network);
40+
writer.Write(verifiable.Hash);
41+
writer.Flush();
42+
return ms.ToArray();
43+
}
44+
45+
[Benchmark]
46+
public void TestOld()
47+
{
48+
GetSignDataV1(s_tx, 0);
49+
}
50+
51+
[Benchmark]
52+
public void TestNew()
53+
{
54+
s_tx.GetSignData(0);
55+
}
56+
}
57+
}

benchmarks/Neo.Benchmarks/Program.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,14 @@
1010
// modifications are permitted.
1111

1212
using BenchmarkDotNet.Running;
13-
using Neo.Benchmark;
14-
using Neo.Benchmarks.Persistence.Benchmarks;
15-
using Neo.SmartContract.Benchmark;
1613

17-
// List all bencharks:
14+
// List all benchmarks:
1815
// dotnet run -c Release --framework [for example: net9.0] -- --list flat(or tree)
1916
// Run a specific benchmark:
2017
// dotnet run -c Release --framework [for example: net9.0] -- -f [benchmark name]
2118
// Run all benchmarks:
2219
// dotnet run -c Release --framework [for example: net9.0] -- -f *
23-
// Run all bencharks of a class:
20+
// Run all benchmarks of a class:
2421
// dotnet run -c Release --framework [for example: net9.0] -- -f '*Class*'
2522
// More options: https://benchmarkdotnet.org/articles/guides/console-args.html
2623
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);

benchmarks/Neo.Extensions.Benchmarks/Program.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@
1010
// modifications are permitted.
1111

1212
using BenchmarkDotNet.Running;
13-
using Neo.Extensions;
1413

15-
// List all bencharks:
14+
// List all benchmarks:
1615
// dotnet run -c Release --framework [for example: net9.0] -- --list flat(or tree)
1716
// Run a specific benchmark:
1817
// dotnet run -c Release --framework [for example: net9.0] -- -f [benchmark name]
1918
// Run all benchmarks:
2019
// dotnet run -c Release --framework [for example: net9.0] -- -f *
21-
// Run all bencharks of a class:
20+
// Run all benchmarks of a class:
2221
// dotnet run -c Release --framework [for example: net9.0] -- -f '*Class*'
2322
// More options: https://benchmarkdotnet.org/articles/guides/console-args.html
2423
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);

benchmarks/Neo.Json.Benchmarks/Program.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@
1010
// modifications are permitted.
1111

1212
using BenchmarkDotNet.Running;
13-
using Neo.Json.Benchmarks;
1413

15-
// List all bencharks:
14+
// List all benchmarks:
1615
// dotnet run -c Release --framework [for example: net9.0] -- --list flat(or tree)
1716
// Run a specific benchmark:
1817
// dotnet run -c Release --framework [for example: net9.0] -- -f [benchmark name]
1918
// Run all benchmarks:
2019
// dotnet run -c Release --framework [for example: net9.0] -- -f *
21-
// Run all bencharks of a class:
20+
// Run all benchmarks of a class:
2221
// dotnet run -c Release --framework [for example: net9.0] -- -f '*Class*'
2322
// More options: https://benchmarkdotnet.org/articles/guides/console-args.html
2423
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);

benchmarks/Neo.VM.Benchmarks/InstructionBuilder/InstructionBuilder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// Redistribution and use in source and binary forms with or without
1010
// modifications are permitted.
1111

12+
using Neo.Extensions;
1213
using System.Buffers.Binary;
1314
using System.Numerics;
1415

@@ -96,7 +97,7 @@ internal Instruction Push(BigInteger number)
9697

9798
internal Instruction Push(string s)
9899
{
99-
return Push(Utility.StrictUTF8.GetBytes(s));
100+
return Push(s.ToStrictUtf8Bytes());
100101
}
101102

102103
internal Instruction Push(byte[] data)

benchmarks/Neo.VM.Benchmarks/Program.cs

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,56 +14,23 @@
1414
using Neo.VM.Benchmark;
1515
using System.Reflection;
1616

17-
// Flag to determine if running benchmark or running methods
18-
// If `NEO_VM_BENCHMARK` environment variable is set, run benchmark no matter.
19-
var runBenchmark = true;
20-
2117
// Define the benchmark or execute class
22-
var benchmarkType = typeof(Benchmarks_PoCs);
23-
24-
/*
25-
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
26-
| |
27-
| DO NOT MODIFY THE CODE BELOW |
28-
| |
29-
| All configuration should be done above this line |
30-
| |
31-
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
32-
*/
33-
34-
// Explanation:
35-
// Benchmark methods must contain no parameters to be valid.
36-
// This is because we need to be able to invoke these methods repeatedly
37-
// without any external input. All necessary data should be set up in the Setup method
38-
// or as properties of the benchmark class.
39-
40-
// Example:
41-
42-
// [Benchmark]
43-
// public void BenchmarkMethod()
44-
// {
45-
// // Benchmark code here
46-
// }
47-
if (Environment.GetEnvironmentVariable("NEO_VM_BENCHMARK") != null || runBenchmark)
18+
if (Environment.GetEnvironmentVariable("NEO_VM_BENCHMARK") != null)
4819
{
49-
BenchmarkRunner.Run(benchmarkType);
20+
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
5021
}
5122
else
5223
{
24+
var benchmarkType = typeof(Benchmarks_PoCs);
5325
var instance = Activator.CreateInstance(benchmarkType);
54-
var setupMethod = benchmarkType.GetMethods(BindingFlags.Public | BindingFlags.Instance)
55-
.FirstOrDefault(m => m.GetCustomAttribute<GlobalSetupAttribute>() != null);
56-
if (setupMethod != null)
57-
{
58-
setupMethod.Invoke(instance, null);
59-
}
26+
benchmarkType.GetMethods(BindingFlags.Public | BindingFlags.Instance)
27+
.FirstOrDefault(m => m.GetCustomAttribute<GlobalSetupAttribute>() != null)?
28+
.Invoke(instance, null); // setup
6029

61-
var methods = benchmarkType.GetMethods(BindingFlags.Public | BindingFlags.Instance);
30+
var methods = benchmarkType.GetMethods(BindingFlags.Public | BindingFlags.Instance)
31+
.Where(m => m.DeclaringType == benchmarkType && !m.GetCustomAttributes<GlobalSetupAttribute>().Any());
6232
foreach (var method in methods)
6333
{
64-
if (method.DeclaringType == benchmarkType && !method.GetCustomAttributes<GlobalSetupAttribute>().Any())
65-
{
66-
method.Invoke(instance, null);
67-
}
34+
method.Invoke(instance, null);
6835
}
6936
}

nuget.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<packageSources>
44
<clear />
55
<!-- <add key="github" value="https://nuget.pkg.github.com/neo-project/index.json" /> -->
6+
<add key="Local" value="./pkgs/" />
67
<add key="MyGet-neo" value="https://www.myget.org/F/neo/api/v3/index.json" />
78
<add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
89
</packageSources>

pkgs/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)