Skip to content

Commit 7da4a82

Browse files
authored
Merge branch 'master' into n4-dynamic-block
2 parents 30330bd + 0fbc397 commit 7da4a82

File tree

493 files changed

+51804
-53886
lines changed

Some content is hidden

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

493 files changed

+51804
-53886
lines changed

.editorconfig

Lines changed: 10 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,12 @@ indent_size = 2
5555

5656
# Dotnet code style settings:
5757
[*.{cs,vb}]
58-
# Use block-scoped namespace
59-
csharp_style_namespace_declarations = block_scoped:error
60-
dotnet_diagnostic.IDE0160.severity = error
61-
dotnet_diagnostic.IDE0161.severity = error
58+
# Use file-scoped namespace
59+
csharp_style_namespace_declarations = file_scoped:warning
6260

6361
# Member can be made 'readonly'
6462
csharp_style_prefer_readonly_struct_member = true
6563
dotnet_diagnostic.IDE0251.severity = warning
66-
dotnet_diagnostic.IDE0044.severity = warning
6764

6865
dotnet_diagnostic.CS1591.severity = silent
6966
// Use primary constructor
@@ -89,6 +86,7 @@ dotnet_style_collection_initializer = true:warning
8986
dotnet_style_coalesce_expression = true:suggestion
9087
dotnet_style_null_propagation = true:suggestion
9188
dotnet_style_explicit_tuple_names = true:suggestion
89+
dotnet_style_prefer_collection_expression = never
9290

9391
# Whitespace options
9492
dotnet_style_allow_multiple_blank_lines_experimental = false
@@ -115,46 +113,6 @@ dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly
115113

116114
dotnet_naming_style.non_private_readonly_field_style.capitalization = pascal_case
117115

118-
# Constants are PascalCase
119-
dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion
120-
dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants
121-
dotnet_naming_rule.constants_should_be_pascal_case.style = constant_style
122-
123-
dotnet_naming_symbols.constants.applicable_kinds = field, local
124-
dotnet_naming_symbols.constants.required_modifiers = const
125-
126-
dotnet_naming_style.constant_style.capitalization = pascal_case
127-
128-
# Static fields are camelCase and start with s_
129-
dotnet_naming_rule.static_fields_should_be_camel_case.severity = suggestion
130-
dotnet_naming_rule.static_fields_should_be_camel_case.symbols = static_fields
131-
dotnet_naming_rule.static_fields_should_be_camel_case.style = static_field_style
132-
133-
dotnet_naming_symbols.static_fields.applicable_kinds = field
134-
dotnet_naming_symbols.static_fields.required_modifiers = static
135-
136-
dotnet_naming_style.static_field_style.capitalization = camel_case
137-
dotnet_naming_style.static_field_style.required_prefix = s_
138-
139-
# Instance fields are camelCase and start with _
140-
dotnet_naming_rule.instance_fields_should_be_camel_case.severity = suggestion
141-
dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields
142-
dotnet_naming_rule.instance_fields_should_be_camel_case.style = instance_field_style
143-
144-
dotnet_naming_symbols.instance_fields.applicable_kinds = field
145-
146-
dotnet_naming_style.instance_field_style.capitalization = camel_case
147-
dotnet_naming_style.instance_field_style.required_prefix = _
148-
149-
# Locals and parameters are camelCase
150-
dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion
151-
dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters
152-
dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style
153-
154-
dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local
155-
156-
dotnet_naming_style.camel_case_style.capitalization = camel_case
157-
158116
# Local functions are PascalCase
159117
dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion
160118
dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions
@@ -164,19 +122,10 @@ dotnet_naming_symbols.local_functions.applicable_kinds = local_function
164122

165123
dotnet_naming_style.local_function_style.capitalization = pascal_case
166124

167-
# By default, name items with PascalCase
168-
dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion
169-
dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members
170-
dotnet_naming_rule.members_should_be_pascal_case.style = pascal_case_style
171-
172-
dotnet_naming_symbols.all_members.applicable_kinds = *
173-
174-
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
175-
176125
file_header_template = Copyright (C) 2015-2025 The Neo Project.\n\n{fileName} file belongs to the neo project and is free\nsoftware distributed under the MIT software license, see the\naccompanying file LICENSE in the main directory of the\nrepository or http://www.opensource.org/licenses/mit-license.php\nfor more details.\n\nRedistribution and use in source and binary forms with or without\nmodifications are permitted.
177126

178127
# Require file header
179-
dotnet_diagnostic.IDE0073.severity = error
128+
dotnet_diagnostic.IDE0073.severity = warning
180129

181130
# RS0016: Only enable if API files are present
182131
dotnet_public_api_analyzer.require_api_files = true
@@ -211,11 +160,6 @@ csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimenta
211160
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false
212161
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = false
213162

214-
# Prefer "var" everywhere
215-
csharp_style_var_for_built_in_types = true:suggestion
216-
csharp_style_var_when_type_is_apparent = true:suggestion
217-
csharp_style_var_elsewhere = true:suggestion
218-
219163
# Prefer method-like constructs to have a block body
220164
csharp_style_expression_bodied_methods = false:none
221165
csharp_style_expression_bodied_constructors = false:none
@@ -226,6 +170,9 @@ csharp_style_expression_bodied_properties = true:none
226170
csharp_style_expression_bodied_indexers = true:none
227171
csharp_style_expression_bodied_accessors = true:none
228172

173+
# IDE0230: Use UTF-8 string literal
174+
csharp_style_prefer_utf8_string_literals = true:silent
175+
229176
# Suggest more modern language features when available
230177
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
231178
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
@@ -268,9 +215,6 @@ dotnet_diagnostic.IDE0060.severity = none
268215

269216
[src/{Analyzers,CodeStyle,Features,Workspaces,EditorFeatures,VisualStudio}/**/*.{cs,vb}]
270217

271-
# Use collection expression for array
272-
dotnet_diagnostic.IDE0300.severity = warning
273-
274218
# Avoid "this." and "Me." if not necessary
275219
dotnet_diagnostic.IDE0003.severity = warning
276220
dotnet_diagnostic.IDE0009.severity = warning
@@ -289,18 +233,15 @@ dotnet_diagnostic.IDE0052.severity = warning
289233
# IDE0059: Unnecessary assignment to a value
290234
dotnet_diagnostic.IDE0059.severity = warning
291235

236+
# Use collection expression for array
237+
dotnet_diagnostic.IDE0300.severity = warning
238+
292239
# CA1012: Abstract types should not have public constructors
293240
dotnet_diagnostic.CA1012.severity = warning
294241

295242
# CA1822: Make member static
296243
dotnet_diagnostic.CA1822.severity = warning
297244

298-
# Prefer "var" everywhere
299-
dotnet_diagnostic.IDE0007.severity = warning
300-
csharp_style_var_for_built_in_types = true:warning
301-
csharp_style_var_when_type_is_apparent = true:warning
302-
csharp_style_var_elsewhere = true:warning
303-
304245
# csharp_style_allow_embedded_statements_on_same_line_experimental
305246
dotnet_diagnostic.IDE2001.severity = warning
306247

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
- name: Set Version
8484
run: git rev-list --count HEAD | xargs printf 'CI%05d' | xargs -I{} echo 'VERSION_SUFFIX={}' >> $GITHUB_ENV
8585
- name : Pack (Everything)
86-
run: dotnet pack src/Neo/Neo.csproj -c Debug -o out --include-source --version-suffix ${{ env.VERSION_SUFFIX }}
86+
run: dotnet pack -c Debug -o out --include-source --version-suffix ${{ env.VERSION_SUFFIX }}
8787
- name: Publish to myGet
8888
run: dotnet nuget push out/*.nupkg -s https://www.myget.org/F/neo/api/v2/package -k ${MYGET_TOKEN} -ss https://www.myget.org/F/neo/symbols/api/v2/package -sk ${MYGET_TOKEN}
8989
env:
@@ -123,7 +123,7 @@ jobs:
123123
- name: Publish to NuGet
124124
if: steps.check_tag.outputs.statusCode == '404'
125125
run: |
126-
dotnet pack src/Neo/Neo.csproj -o out -c Release
126+
dotnet pack -o out -c Release
127127
dotnet nuget push out/*.nupkg -s https://api.nuget.org/v3/index.json -k ${NUGET_TOKEN}
128128
env:
129129
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}

benchmarks/Directory.Build.props

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33

44
<PropertyGroup>
5-
<LangVersion>latest</LangVersion>
5+
<OutputType>Exe</OutputType>
6+
<TargetFrameworks>net10.0</TargetFrameworks>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
69
<IsPackable>false</IsPackable>
7-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
8-
<WarningLevel>4</WarningLevel>
9-
<AnalysisLevel>latest</AnalysisLevel>
1010
</PropertyGroup>
11-
11+
12+
<ItemGroup>
13+
<PackageReference Include="BenchmarkDotNet" Version="0.15.6" />
14+
</ItemGroup>
15+
1216
</Project>

benchmarks/Neo.Benchmarks/Benchmarks.Hash.cs

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,47 +11,45 @@
1111

1212
using BenchmarkDotNet.Attributes;
1313
using Neo.Cryptography;
14-
using Neo.Extensions;
1514
using System.Diagnostics;
1615
using System.IO.Hashing;
1716
using System.Text;
1817

19-
namespace Neo.Benchmark
18+
namespace Neo.Benchmarks;
19+
20+
public class Benchmarks_Hash
2021
{
21-
public class Benchmarks_Hash
22+
// 256 KiB
23+
static readonly byte[] data = Encoding.ASCII.GetBytes(string.Concat(Enumerable.Repeat("Hello, World!^_^", 16 * 1024)));
24+
25+
static readonly byte[] hash = "9182abedfbb9b18d81a05d8bcb45489e7daa2858".HexToBytes();
26+
27+
[Benchmark]
28+
public static void XxHash32_HashToUInt32()
29+
{
30+
var result = XxHash32.HashToUInt32(data);
31+
Debug.Assert(result == 682967318u);
32+
}
33+
34+
[Benchmark]
35+
public static void XxHash3_HashToUInt64()
36+
{
37+
var result = (uint)XxHash3.HashToUInt64(data);
38+
Debug.Assert(result == 1389469485u);
39+
}
40+
41+
[Benchmark]
42+
public static void Murmur32_HashToUInt32()
43+
{
44+
var result = data.Murmur32(0);
45+
Debug.Assert(result == 3731881930u);
46+
}
47+
48+
[Benchmark]
49+
public static void Murmur128_ComputeHash()
2250
{
23-
// 256 KiB
24-
static readonly byte[] data = Encoding.ASCII.GetBytes(string.Concat(Enumerable.Repeat("Hello, World!^_^", 16 * 1024)));
25-
26-
static readonly byte[] hash = "9182abedfbb9b18d81a05d8bcb45489e7daa2858".HexToBytes();
27-
28-
[Benchmark]
29-
public void XxHash32_HashToUInt32()
30-
{
31-
var result = XxHash32.HashToUInt32(data);
32-
Debug.Assert(result == 682967318u);
33-
}
34-
35-
[Benchmark]
36-
public void XxHash3_HashToUInt64()
37-
{
38-
var result = (uint)XxHash3.HashToUInt64(data);
39-
Debug.Assert(result == 1389469485u);
40-
}
41-
42-
[Benchmark]
43-
public void Murmur32_HashToUInt32()
44-
{
45-
var result = data.Murmur32(0);
46-
Debug.Assert(result == 3731881930u);
47-
}
48-
49-
[Benchmark]
50-
public void Murmur128_ComputeHash()
51-
{
52-
var result = data.Murmur128(0);
53-
if (result.Length != 16)
54-
throw new InvalidOperationException($"Invalid hash length {result.Length}");
55-
}
51+
var result = data.Murmur128(0);
52+
if (result.Length != 16)
53+
throw new InvalidOperationException($"Invalid hash length {result.Length}");
5654
}
5755
}

benchmarks/Neo.Benchmarks/Benchmarks.POC.cs

Lines changed: 55 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -15,65 +15,64 @@
1515
using Neo.VM;
1616
using System.Diagnostics;
1717

18-
namespace Neo.Benchmark
18+
namespace Neo.Benchmarks;
19+
20+
public class Benchmarks_PoCs
1921
{
20-
public class Benchmarks_PoCs
21-
{
22-
private static readonly ProtocolSettings protocol = ProtocolSettings.Load("config.json");
23-
private static readonly NeoSystem system = new(protocol, (string)null);
22+
private static readonly ProtocolSettings protocol = ProtocolSettings.Load("config.json");
23+
private static readonly NeoSystem system = new(protocol, (string?)null);
2424

25-
[Benchmark]
26-
public void NeoIssue2725()
27-
{
28-
// https://github.com/neo-project/neo/issues/2725
29-
// L00: INITSSLOT 1
30-
// L01: NEWARRAY0
31-
// L02: PUSHDATA1 6161616161 //"aaaaa"
32-
// L03: PUSHINT16 500
33-
// L04: STSFLD0
34-
// L05: OVER
35-
// L06: OVER
36-
// L07: SYSCALL 95016f61 //System.Runtime.Notify
37-
// L08: LDSFLD0
38-
// L09: DEC
39-
// L10: DUP
40-
// L11: STSFLD0
41-
// L12: JMPIF L05
42-
// L13: CLEAR
43-
// L14: SYSCALL dbfea874 //System.Runtime.GetExecutingScriptHash
44-
// L15: PUSHINT16 8000
45-
// L16: STSFLD0
46-
// L17: DUP
47-
// L18: SYSCALL 274335f1 //System.Runtime.GetNotifications
48-
// L19: DROP
49-
// L20: LDSFLD0
50-
// L21: DEC
51-
// L22: DUP
52-
// L23: STSFLD0
53-
// L24: JMPIF L17
54-
Run(nameof(NeoIssue2725), "VgHCDAVhYWFhYQH0AWBLS0GVAW9hWJ1KYCT1SUHb/qh0AUAfYEpBJ0M18UVYnUpgJPU=");
55-
}
25+
[Benchmark]
26+
public void NeoIssue2725()
27+
{
28+
// https://github.com/neo-project/neo/issues/2725
29+
// L00: INITSSLOT 1
30+
// L01: NEWARRAY0
31+
// L02: PUSHDATA1 6161616161 //"aaaaa"
32+
// L03: PUSHINT16 500
33+
// L04: STSFLD0
34+
// L05: OVER
35+
// L06: OVER
36+
// L07: SYSCALL 95016f61 //System.Runtime.Notify
37+
// L08: LDSFLD0
38+
// L09: DEC
39+
// L10: DUP
40+
// L11: STSFLD0
41+
// L12: JMPIF L05
42+
// L13: CLEAR
43+
// L14: SYSCALL dbfea874 //System.Runtime.GetExecutingScriptHash
44+
// L15: PUSHINT16 8000
45+
// L16: STSFLD0
46+
// L17: DUP
47+
// L18: SYSCALL 274335f1 //System.Runtime.GetNotifications
48+
// L19: DROP
49+
// L20: LDSFLD0
50+
// L21: DEC
51+
// L22: DUP
52+
// L23: STSFLD0
53+
// L24: JMPIF L17
54+
Run(nameof(NeoIssue2725), "VgHCDAVhYWFhYQH0AWBLS0GVAW9hWJ1KYCT1SUHb/qh0AUAfYEpBJ0M18UVYnUpgJPU=");
55+
}
5656

57-
private static void Run(string name, string poc)
57+
private static void Run(string name, string poc)
58+
{
59+
Random random = new();
60+
Transaction tx = new()
5861
{
59-
Random random = new();
60-
Transaction tx = new()
61-
{
62-
Version = 0,
63-
Nonce = (uint)random.Next(),
64-
SystemFee = 20_00000000,
65-
NetworkFee = 1_00000000,
66-
ValidUntilBlock = ProtocolSettings.Default.MaxTraceableBlocks,
67-
Signers = Array.Empty<Signer>(),
68-
Attributes = Array.Empty<TransactionAttribute>(),
69-
Script = Convert.FromBase64String(poc),
70-
Witnesses = Array.Empty<Witness>()
71-
};
72-
using var snapshot = system.GetSnapshotCache();
73-
using var engine = ApplicationEngine.Create(TriggerType.Application, tx, snapshot, system.GenesisBlock, protocol, tx.SystemFee);
74-
engine.LoadScript(tx.Script);
75-
engine.Execute();
76-
Debug.Assert(engine.State == VMState.FAULT);
77-
}
62+
Version = 0,
63+
Nonce = (uint)random.Next(),
64+
SystemFee = 20_00000000,
65+
NetworkFee = 1_00000000,
66+
ValidUntilBlock = ProtocolSettings.Default.MaxTraceableBlocks,
67+
Signers = Array.Empty<Signer>(),
68+
Attributes = Array.Empty<TransactionAttribute>(),
69+
Script = Convert.FromBase64String(poc),
70+
Witnesses = Array.Empty<Witness>()
71+
};
72+
using var snapshot = system.GetSnapshotCache();
73+
using var engine = ApplicationEngine.Create(TriggerType.Application, tx, snapshot, system.GenesisBlock, protocol, tx.SystemFee);
74+
engine.LoadScript(tx.Script);
75+
engine.Execute();
76+
Debug.Assert(engine.State == VMState.FAULT);
7877
}
7978
}

0 commit comments

Comments
 (0)