Skip to content

Commit 853f743

Browse files
authored
Merge branch 'master' into Fix-nep11-check
2 parents 67de03d + 79f0d78 commit 853f743

30 files changed

+712
-327
lines changed

.devcontainer/devcontainer.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet
3+
{
4+
"name": "C# (.NET)",
5+
"image": "mcr.microsoft.com/devcontainers/dotnet:1-7.0-jammy",
6+
"onCreateCommand": "./scripts/load_submodule.sh",
7+
"postCreateCommand": "dotnet restore && dotnet build",
8+
"customizations": {
9+
"vscode": {
10+
"extensions": [
11+
"ms-dotnettools.csdevkit"
12+
]
13+
}
14+
}
15+
}

.github/workflows/codeql.yml

-76
This file was deleted.

.github/workflows/main.yml

+21-17
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
submodules: recursive
1821
- name: Setup .NET Core
19-
uses: actions/setup-dotnet@v1
22+
uses: actions/setup-dotnet@v4
2023
with:
2124
dotnet-version: ${{ env.DOTNET_VERSION }}
2225
- name: Check format
@@ -25,15 +28,18 @@ jobs:
2528
run: |
2629
sudo apt-get --assume-yes install libleveldb-dev libsnappy-dev libc6-dev
2730
find tests -name *.csproj | xargs -I % dotnet add % package coverlet.msbuild
28-
dotnet test tests/Neo.Network.RPC.Tests /p:CollectCoverage=true /p:CoverletOutput=${GITHUB_WORKSPACE}/coverage/
29-
dotnet test tests/Neo.Plugins.RpcServer.Tests /p:CollectCoverage=true /p:CoverletOutput=${GITHUB_WORKSPACE}/coverage/lcov /p:MergeWith=${GITHUB_WORKSPACE}/coverage/coverage.json /p:CoverletOutputFormat=lcov
30-
dotnet test tests/Neo.Plugins.Storage.Tests /p:CollectCoverage=true /p:CoverletOutput=${GITHUB_WORKSPACE}/coverage/lcov /p:MergeWith=${GITHUB_WORKSPACE}/coverage/coverage.json /p:CoverletOutputFormat=lcov
31-
dotnet test tests/Neo.Cryptography.MPTTrie.Tests /p:CollectCoverage=true /p:CoverletOutput=${GITHUB_WORKSPACE}/coverage/lcov /p:MergeWith=${GITHUB_WORKSPACE}/coverage/coverage.json /p:CoverletOutputFormat=lcov
32-
dotnet test tests/Neo.Plugins.OracleService.Tests /p:CollectCoverage=true /p:CoverletOutput=${GITHUB_WORKSPACE}/coverage/lcov /p:MergeWith=${GITHUB_WORKSPACE}/coverage/coverage.json /p:CoverletOutputFormat=lcov
31+
EXCLUDED_TESTS=\"[Neo]*,[Neo.IO]*,[Neo.Json]*,[Neo.VM]*,[Neo.Extensions]*,[Neo.Cryptography.BLS12_381]*\"
32+
dotnet test tests/Neo.Network.RPC.Tests /p:CollectCoverage=true /p:CoverletOutput=${GITHUB_WORKSPACE}/coverage-join/ -p:Exclude=${EXCLUDED_TESTS}
33+
dotnet test tests/Neo.Plugins.RpcServer.Tests /p:CollectCoverage=true /p:CoverletOutput=${GITHUB_WORKSPACE}/coverage-join/ /p:MergeWith=${GITHUB_WORKSPACE}/coverage-join/coverage.json -p:Exclude=${EXCLUDED_TESTS}
34+
dotnet test tests/Neo.Plugins.Storage.Tests /p:CollectCoverage=true /p:CoverletOutput=${GITHUB_WORKSPACE}/coverage-join/ /p:MergeWith=${GITHUB_WORKSPACE}/coverage-join/coverage.json -p:Exclude=${EXCLUDED_TESTS}
35+
dotnet test tests/Neo.Cryptography.MPTTrie.Tests /p:CollectCoverage=true /p:CoverletOutput=${GITHUB_WORKSPACE}/coverage-join/ /p:MergeWith=${GITHUB_WORKSPACE}/coverage-join/coverage.json -p:Exclude=${EXCLUDED_TESTS}
36+
dotnet test tests/Neo.Plugins.OracleService.Tests /p:CollectCoverage=true /p:CoverletOutput=${GITHUB_WORKSPACE}/coverage/lcov /p:MergeWith=${GITHUB_WORKSPACE}/coverage-join/coverage.json /p:CoverletOutputFormat=lcov -p:Exclude=${EXCLUDED_TESTS}
3337
- name: Coveralls
34-
uses: coverallsapp/github-action@master
38+
uses: coverallsapp/github-action@v2.2.3
3539
with:
3640
github-token: ${{ secrets.GITHUB_TOKEN }}
41+
format: lcov
42+
file: ${GITHUB_WORKSPACE}/coverage/lcov.info
3743

3844
Review:
3945
needs: Test
@@ -42,21 +48,16 @@ jobs:
4248
- name: Checkout Repo
4349
uses: actions/checkout@v4
4450

45-
- name: AI Code Reviewer
46-
uses: freeedcom/ai-codereviewer@a9a064dfa1db8c83f40ef63f6e247fa09c935ed6
47-
with:
48-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49-
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
50-
OPENAI_API_MODEL: "gpt-4" # Optional: defaults to "gpt-4"
51-
exclude: "**/*.json, **/*.md" # Optional: exclude patterns separated by commas
52-
5351
Release:
5452
needs: Test
5553
if: github.ref == 'refs/heads/master' && startsWith(github.repository, 'neo-project/')
5654
runs-on: ubuntu-latest
5755
steps:
5856
- name: Checkout
59-
uses: actions/checkout@v2
57+
uses: actions/checkout@v4
58+
with:
59+
fetch-depth: 0
60+
submodules: recursive
6061
- name: Get version
6162
id: get_version
6263
run: |
@@ -69,9 +70,12 @@ jobs:
6970
if: steps.check_tag.outputs.statusCode == '404'
7071
id: create_release
7172
uses: actions/create-release@v1
73+
7274
env:
7375
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7476
with:
77+
fetch-depth: 0
78+
submodules: recursive
7579
tag_name: ${{ steps.get_version.outputs.version }}
7680
release_name: ${{ steps.get_version.outputs.version }}
7781
prerelease: ${{ contains(steps.get_version.outputs.version, '-') }}

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "neo"]
2+
path = neo
3+
url = https://github.com/neo-project/neo.git

Directory.Build.props

+6-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
<RepositoryType>git</RepositoryType>
1212
<RepositoryUrl>https://github.com/neo-project/neo-modules.git</RepositoryUrl>
1313
</PropertyGroup>
14-
<ItemGroup>
15-
<PackageReference Include="Neo" Version="3.6.2" ExcludeAssets="runtime" />
16-
</ItemGroup>
17-
</Project>
14+
15+
<ItemGroup>
16+
<ProjectReference Include="..\..\neo\src\Neo\Neo.csproj" />
17+
</ItemGroup>
18+
19+
</Project>

neo

Submodule neo added at 66ef246

neo-modules.sln

+44
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SQLiteWallet", "src\SQLiteW
4343
EndProject
4444
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StorageDumper", "src\StorageDumper\StorageDumper.csproj", "{938D86EA-0F48-436B-9255-4AD9A8E6B9AC}"
4545
EndProject
46+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo", "neo\src\Neo\Neo.csproj", "{A00FC746-1351-4275-B2D9-489477B409C0}"
47+
EndProject
48+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.IO", "neo\src\Neo.IO\Neo.IO.csproj", "{FEC96A32-38AB-426B-A93E-D37583BEE901}"
49+
EndProject
50+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.Json", "neo\src\Neo.Json\Neo.Json.csproj", "{188D043E-393D-4E5B-A216-4274BF9AFB23}"
51+
EndProject
52+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.VM", "neo\src\Neo.VM\Neo.VM.csproj", "{EDDE78BC-2064-4517-B9B2-25BA012A93C1}"
53+
EndProject
54+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.Extensions", "neo\src\Neo.Extensions\Neo.Extensions.csproj", "{9FF233D7-84C2-4947-96F6-88EE3594C66A}"
55+
EndProject
56+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.Cryptography.BLS12_381", "neo\src\Neo.Cryptography.BLS12_381\Neo.Cryptography.BLS12_381.csproj", "{7437514A-290D-4F84-B315-32ED95F710C1}"
57+
EndProject
58+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependency", "Dependency", "{997874E0-C2A7-4EB2-85AA-180AF592DC6D}"
59+
EndProject
4660
Global
4761
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4862
Debug|Any CPU = Debug|Any CPU
@@ -121,6 +135,30 @@ Global
121135
{938D86EA-0F48-436B-9255-4AD9A8E6B9AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
122136
{938D86EA-0F48-436B-9255-4AD9A8E6B9AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
123137
{938D86EA-0F48-436B-9255-4AD9A8E6B9AC}.Release|Any CPU.Build.0 = Release|Any CPU
138+
{A00FC746-1351-4275-B2D9-489477B409C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
139+
{A00FC746-1351-4275-B2D9-489477B409C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
140+
{A00FC746-1351-4275-B2D9-489477B409C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
141+
{A00FC746-1351-4275-B2D9-489477B409C0}.Release|Any CPU.Build.0 = Release|Any CPU
142+
{FEC96A32-38AB-426B-A93E-D37583BEE901}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
143+
{FEC96A32-38AB-426B-A93E-D37583BEE901}.Debug|Any CPU.Build.0 = Debug|Any CPU
144+
{FEC96A32-38AB-426B-A93E-D37583BEE901}.Release|Any CPU.ActiveCfg = Release|Any CPU
145+
{FEC96A32-38AB-426B-A93E-D37583BEE901}.Release|Any CPU.Build.0 = Release|Any CPU
146+
{188D043E-393D-4E5B-A216-4274BF9AFB23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
147+
{188D043E-393D-4E5B-A216-4274BF9AFB23}.Debug|Any CPU.Build.0 = Debug|Any CPU
148+
{188D043E-393D-4E5B-A216-4274BF9AFB23}.Release|Any CPU.ActiveCfg = Release|Any CPU
149+
{188D043E-393D-4E5B-A216-4274BF9AFB23}.Release|Any CPU.Build.0 = Release|Any CPU
150+
{EDDE78BC-2064-4517-B9B2-25BA012A93C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
151+
{EDDE78BC-2064-4517-B9B2-25BA012A93C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
152+
{EDDE78BC-2064-4517-B9B2-25BA012A93C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
153+
{EDDE78BC-2064-4517-B9B2-25BA012A93C1}.Release|Any CPU.Build.0 = Release|Any CPU
154+
{9FF233D7-84C2-4947-96F6-88EE3594C66A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
155+
{9FF233D7-84C2-4947-96F6-88EE3594C66A}.Debug|Any CPU.Build.0 = Debug|Any CPU
156+
{9FF233D7-84C2-4947-96F6-88EE3594C66A}.Release|Any CPU.ActiveCfg = Release|Any CPU
157+
{9FF233D7-84C2-4947-96F6-88EE3594C66A}.Release|Any CPU.Build.0 = Release|Any CPU
158+
{7437514A-290D-4F84-B315-32ED95F710C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
159+
{7437514A-290D-4F84-B315-32ED95F710C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
160+
{7437514A-290D-4F84-B315-32ED95F710C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
161+
{7437514A-290D-4F84-B315-32ED95F710C1}.Release|Any CPU.Build.0 = Release|Any CPU
124162
EndGlobalSection
125163
GlobalSection(SolutionProperties) = preSolution
126164
HideSolutionNode = FALSE
@@ -144,6 +182,12 @@ Global
144182
{8D2EE375-2E2D-45FE-A4E9-0254D12C7554} = {59D802AB-C552-422A-B9C3-64D329FBCDCC}
145183
{D121D57A-512E-4F74-ADA1-24482BF5C42B} = {97E81C78-1637-481F-9485-DA1225E94C23}
146184
{938D86EA-0F48-436B-9255-4AD9A8E6B9AC} = {97E81C78-1637-481F-9485-DA1225E94C23}
185+
{A00FC746-1351-4275-B2D9-489477B409C0} = {997874E0-C2A7-4EB2-85AA-180AF592DC6D}
186+
{7437514A-290D-4F84-B315-32ED95F710C1} = {997874E0-C2A7-4EB2-85AA-180AF592DC6D}
187+
{9FF233D7-84C2-4947-96F6-88EE3594C66A} = {997874E0-C2A7-4EB2-85AA-180AF592DC6D}
188+
{FEC96A32-38AB-426B-A93E-D37583BEE901} = {997874E0-C2A7-4EB2-85AA-180AF592DC6D}
189+
{188D043E-393D-4E5B-A216-4274BF9AFB23} = {997874E0-C2A7-4EB2-85AA-180AF592DC6D}
190+
{EDDE78BC-2064-4517-B9B2-25BA012A93C1} = {997874E0-C2A7-4EB2-85AA-180AF592DC6D}
147191
EndGlobalSection
148192
GlobalSection(ExtensibilityGlobals) = postSolution
149193
SolutionGuid = {61D3ADE6-BBFC-402D-AB42-1C71C9F9EDE3}

scripts/load_submodule.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# Check if the current directory is a git repository
4+
if [ ! -d ".git" ]; then
5+
echo "Error: This script must be run from the root of a Git repository."
6+
exit 1
7+
fi
8+
9+
# Initialize and update git submodules
10+
git submodule update --init --recursive
11+
12+
echo "Git submodules have been updated."

src/ApplicationLogs/LogReader.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@ protected override void OnSystemLoaded(NeoSystem system)
5959
[RpcMethod]
6060
public JToken GetApplicationLog(JArray _params)
6161
{
62-
UInt256 hash = UInt256.Parse(_params[0].AsString());
63-
byte[] value = _db.TryGet(hash.ToArray());
64-
if (value is null)
65-
throw new RpcException(-100, "Unknown transaction/blockhash");
62+
UInt256 hash = Result.Ok_Or(() => UInt256.Parse(_params[0].AsString()), RpcError.InvalidParams.WithData($"Invalid transaction hash: {_params[0]}"));
63+
byte[] value = _db.TryGet(hash.ToArray()).NotNull_Or(RpcError.UnknownScriptContainer);
6664

6765
JObject raw = (JObject)JToken.Parse(Neo.Utility.StrictUTF8.GetString(value));
6866
//Additional optional "trigger" parameter to getapplicationlog for clients to be able to get just one execution result for a block.

src/DBFTPlugin/Consensus/ConsensusService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private void OnStart()
157157
return;
158158
}
159159
}
160-
InitializeConsensus(0);
160+
InitializeConsensus(context.ViewNumber);
161161
// Issue a recovery request on start-up in order to possibly catch up with other nodes
162162
if (!context.WatchOnly)
163163
RequestRecovery();

src/Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
88
</None>
99
</ItemGroup>
10-
</Project>
10+
</Project>

src/OracleService/OracleService.cs

+9-11
Original file line numberDiff line numberDiff line change
@@ -220,24 +220,22 @@ private async void OnTimer(object state)
220220
[RpcMethod]
221221
public JObject SubmitOracleResponse(JArray _params)
222222
{
223-
if (status != OracleStatus.Running) throw new InvalidOperationException();
223+
status.Equals(OracleStatus.Running).True_Or(RpcError.OracleDisabled);
224224
ECPoint oraclePub = ECPoint.DecodePoint(Convert.FromBase64String(_params[0].AsString()), ECCurve.Secp256r1);
225-
ulong requestId = (ulong)_params[1].AsNumber();
226-
byte[] txSign = Convert.FromBase64String(_params[2].AsString());
227-
byte[] msgSign = Convert.FromBase64String(_params[3].AsString());
225+
ulong requestId = Result.Ok_Or(() => (ulong)_params[1].AsNumber(), RpcError.InvalidParams.WithData($"Invalid requestId: {_params[1]}"));
226+
byte[] txSign = Result.Ok_Or(() => Convert.FromBase64String(_params[2].AsString()), RpcError.InvalidParams.WithData($"Invalid txSign: {_params[2]}"));
227+
byte[] msgSign = Result.Ok_Or(() => Convert.FromBase64String(_params[3].AsString()), RpcError.InvalidParams.WithData($"Invalid msgSign: {_params[3]}"));
228228

229-
if (finishedCache.ContainsKey(requestId)) throw new RpcException(-100, "Request has already finished");
229+
finishedCache.ContainsKey(requestId).False_Or(RpcError.OracleRequestFinished);
230230

231231
using (var snapshot = System.GetSnapshot())
232232
{
233233
uint height = NativeContract.Ledger.CurrentIndex(snapshot) + 1;
234234
var oracles = NativeContract.RoleManagement.GetDesignatedByRole(snapshot, Role.Oracle, height);
235-
if (!oracles.Any(p => p.Equals(oraclePub))) throw new RpcException(-100, $"{oraclePub} isn't an oracle node");
236-
if (NativeContract.Oracle.GetRequest(snapshot, requestId) is null)
237-
throw new RpcException(-100, "Request is not found");
235+
oracles.Any(p => p.Equals(oraclePub)).True_Or(RpcErrorFactory.OracleNotDesignatedNode(oraclePub));
236+
NativeContract.Oracle.GetRequest(snapshot, requestId).NotNull_Or(RpcError.OracleRequestNotFound);
238237
var data = Neo.Helper.Concat(oraclePub.ToArray(), BitConverter.GetBytes(requestId), txSign);
239-
if (!Crypto.VerifySignature(data, msgSign, oraclePub)) throw new RpcException(-100, "Invalid sign");
240-
238+
Crypto.VerifySignature(data, msgSign, oraclePub).True_Or(RpcErrorFactory.InvalidSignature($"Invalid oracle response transaction signature from '{oraclePub}'."));
241239
AddResponseTxSign(snapshot, requestId, oraclePub, txSign);
242240
}
243241
return new JObject();
@@ -497,7 +495,7 @@ private void AddResponseTxSign(DataCache snapshot, ulong requestId, ECPoint orac
497495
else if (Crypto.VerifySignature(task.BackupTx.GetSignData(System.Settings.Network), sign, oraclePub))
498496
task.BackupSigns.TryAdd(oraclePub, sign);
499497
else
500-
throw new RpcException(-100, "Invalid response transaction sign");
498+
throw new RpcException(RpcErrorFactory.InvalidSignature($"Invalid oracle response transaction signature from '{oraclePub}'."));
501499

502500
if (CheckTxSign(snapshot, task.Tx, task.Signs) || CheckTxSign(snapshot, task.BackupTx, task.BackupSigns))
503501
{

0 commit comments

Comments
 (0)