Skip to content

Commit

Permalink
Merge branch 'master' into dbft3.0-doublespeakers
Browse files Browse the repository at this point in the history
  • Loading branch information
vncoelho authored May 11, 2024
2 parents fc82203 + 0c58069 commit 653c615
Show file tree
Hide file tree
Showing 24 changed files with 72 additions and 119 deletions.
12 changes: 6 additions & 6 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.202
DOTNET_VERSION: 8.0.x

jobs:

Expand All @@ -29,16 +29,16 @@ jobs:
sudo apt-get --assume-yes install libleveldb-dev
EXCLUDED_TESTS=\"[Neo]*,[Neo.IO]*,[Neo.Json]*,[Neo.VM]*,[Neo.Extensions]*,[Neo.Cryptography.BLS12_381]*\"
dotnet test ./tests/Neo.Cryptography.MPTTrie.Tests /p:CollectCoverage=true /p:CoverletOutput='${{ github.workspace }}/TestResults/coverage/' /p:Exclude=${EXCLUDED_TESTS}
dotnet test ./tests/Neo.Network.RPC.Tests /p:CollectCoverage=true /p:CoverletOutput='${{ github.workspace }}/TestResults/coverage/' /p:MergeWith='${{ github.workspace }}/TestResults/coverage/coverage.net8.0.json' /p:Exclude=${EXCLUDED_TESTS}
dotnet test ./tests/Neo.Plugins.OracleService.Tests /p:CollectCoverage=true /p:CoverletOutput='${{ github.workspace }}/TestResults/coverage/' /p:MergeWith='${{ github.workspace }}/TestResults/coverage/coverage.net8.0.json' /p:Exclude=${EXCLUDED_TESTS}
dotnet test ./tests/Neo.Plugins.RpcServer.Tests /p:CollectCoverage=true /p:CoverletOutput='${{ github.workspace }}/TestResults/coverage/' /p:MergeWith='${{ github.workspace }}/TestResults/coverage/coverage.net8.0.json' /p:Exclude=${EXCLUDED_TESTS}
dotnet test ./tests/Neo.Plugins.Storage.Tests /p:CollectCoverage=true /p:CoverletOutput='${{ github.workspace }}/TestResults/coverage/' /p:MergeWith='${{ github.workspace }}/TestResults/coverage/coverage.net8.0.json' /p:CoverletOutputFormat='lcov' /p:Exclude=${EXCLUDED_TESTS}
dotnet test ./tests/Neo.Network.RPC.Tests /p:CollectCoverage=true /p:CoverletOutput='${{ github.workspace }}/TestResults/coverage/' /p:MergeWith='${{ github.workspace }}/TestResults/coverage/coverage.json' /p:Exclude=${EXCLUDED_TESTS}
dotnet test ./tests/Neo.Plugins.OracleService.Tests /p:CollectCoverage=true /p:CoverletOutput='${{ github.workspace }}/TestResults/coverage/' /p:MergeWith='${{ github.workspace }}/TestResults/coverage/coverage.json' /p:Exclude=${EXCLUDED_TESTS}
dotnet test ./tests/Neo.Plugins.RpcServer.Tests /p:CollectCoverage=true /p:CoverletOutput='${{ github.workspace }}/TestResults/coverage/' /p:MergeWith='${{ github.workspace }}/TestResults/coverage/coverage.json' /p:Exclude=${EXCLUDED_TESTS}
dotnet test ./tests/Neo.Plugins.Storage.Tests /p:CollectCoverage=true /p:CoverletOutput='${{ github.workspace }}/TestResults/coverage/' /p:MergeWith='${{ github.workspace }}/TestResults/coverage/coverage.json' /p:CoverletOutputFormat='lcov' /p:Exclude=${EXCLUDED_TESTS}
- name: Coveralls
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
format: lcov
file: ${{ github.workspace }}/TestResults/coverage/coverage.net8.0.info
file: ${{ github.workspace }}/TestResults/coverage/coverage.info

Review:
needs: Test
Expand Down
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VersionPrefix>3.6.3</VersionPrefix>
<TargetFrameworks>net8.0</TargetFrameworks>
<VersionPrefix>3.7.1</VersionPrefix>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Neo.Plugins</RootNamespace>
<Authors>The Neo Project</Authors>
<PackageTags>NEO;Blockchain</PackageTags>
Expand Down
2 changes: 1 addition & 1 deletion neo
Submodule neo updated 136 files
19 changes: 13 additions & 6 deletions neo-modules.sln
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,24 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SQLiteWallet", "src\SQLiteW
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StorageDumper", "src\StorageDumper\StorageDumper.csproj", "{938D86EA-0F48-436B-9255-4AD9A8E6B9AC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo", "neo\src\Neo\Neo.csproj", "{A00FC746-1351-4275-B2D9-489477B409C0}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo", "neo\src\Neo\Neo.csproj", "{A00FC746-1351-4275-B2D9-489477B409C0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.IO", "neo\src\Neo.IO\Neo.IO.csproj", "{FEC96A32-38AB-426B-A93E-D37583BEE901}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.IO", "neo\src\Neo.IO\Neo.IO.csproj", "{FEC96A32-38AB-426B-A93E-D37583BEE901}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.Json", "neo\src\Neo.Json\Neo.Json.csproj", "{188D043E-393D-4E5B-A216-4274BF9AFB23}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.Json", "neo\src\Neo.Json\Neo.Json.csproj", "{188D043E-393D-4E5B-A216-4274BF9AFB23}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.VM", "neo\src\Neo.VM\Neo.VM.csproj", "{EDDE78BC-2064-4517-B9B2-25BA012A93C1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.VM", "neo\src\Neo.VM\Neo.VM.csproj", "{EDDE78BC-2064-4517-B9B2-25BA012A93C1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.Extensions", "neo\src\Neo.Extensions\Neo.Extensions.csproj", "{9FF233D7-84C2-4947-96F6-88EE3594C66A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.Extensions", "neo\src\Neo.Extensions\Neo.Extensions.csproj", "{9FF233D7-84C2-4947-96F6-88EE3594C66A}"
EndProject
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}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.Cryptography.BLS12_381", "neo\src\Neo.Cryptography.BLS12_381\Neo.Cryptography.BLS12_381.csproj", "{7437514A-290D-4F84-B315-32ED95F710C1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependency", "Dependency", "{997874E0-C2A7-4EB2-85AA-180AF592DC6D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.ConsoleService", "neo\src\Neo.ConsoleService\Neo.ConsoleService.csproj", "{919EC990-C586-4B46-900E-8A7496004030}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.CLI", "neo\src\Neo.CLI\Neo.CLI.csproj", "{F9A412E0-5FAA-438B-9E2A-886EB4AA0C66}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -165,6 +167,10 @@ Global
{919EC990-C586-4B46-900E-8A7496004030}.Debug|Any CPU.Build.0 = Debug|Any CPU
{919EC990-C586-4B46-900E-8A7496004030}.Release|Any CPU.ActiveCfg = Release|Any CPU
{919EC990-C586-4B46-900E-8A7496004030}.Release|Any CPU.Build.0 = Release|Any CPU
{F9A412E0-5FAA-438B-9E2A-886EB4AA0C66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F9A412E0-5FAA-438B-9E2A-886EB4AA0C66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F9A412E0-5FAA-438B-9E2A-886EB4AA0C66}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F9A412E0-5FAA-438B-9E2A-886EB4AA0C66}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -195,6 +201,7 @@ Global
{9FF233D7-84C2-4947-96F6-88EE3594C66A} = {997874E0-C2A7-4EB2-85AA-180AF592DC6D}
{7437514A-290D-4F84-B315-32ED95F710C1} = {997874E0-C2A7-4EB2-85AA-180AF592DC6D}
{919EC990-C586-4B46-900E-8A7496004030} = {997874E0-C2A7-4EB2-85AA-180AF592DC6D}
{F9A412E0-5FAA-438B-9E2A-886EB4AA0C66} = {997874E0-C2A7-4EB2-85AA-180AF592DC6D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {61D3ADE6-BBFC-402D-AB42-1C71C9F9EDE3}
Expand Down
14 changes: 7 additions & 7 deletions src/ApplicationLogs/Store/LogStorageStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public bool TryGetEngineState(Guid engineStateId, out EngineLogState state)
.Add(engineStateId.ToByteArray())
.ToArray();
var data = _snapshot.TryGet(key);
state = data?.AsSerializable<EngineLogState>();
state = data?.AsSerializable<EngineLogState>()!;
return data != null && data.Length > 0;
}

Expand All @@ -298,7 +298,7 @@ public bool TryGetTransactionEngineState(UInt256 hash, out TransactionEngineLogS
.Add(hash)
.ToArray();
var data = _snapshot.TryGet(key);
state = data?.AsSerializable<TransactionEngineLogState>();
state = data?.AsSerializable<TransactionEngineLogState>()!;
return data != null && data.Length > 0;
}

Expand All @@ -309,7 +309,7 @@ public bool TryGetBlockState(UInt256 hash, TriggerType trigger, out BlockLogStat
.Add((byte)trigger)
.ToArray();
var data = _snapshot.TryGet(key);
state = data?.AsSerializable<BlockLogState>();
state = data?.AsSerializable<BlockLogState>()!;
return data != null && data.Length > 0;
}

Expand All @@ -319,7 +319,7 @@ public bool TryGetNotifyState(Guid notifyStateId, out NotifyLogState state)
.Add(notifyStateId.ToByteArray())
.ToArray();
var data = _snapshot.TryGet(key);
state = data?.AsSerializable<NotifyLogState>();
state = data?.AsSerializable<NotifyLogState>()!;
return data != null && data.Length > 0;
}

Expand All @@ -331,7 +331,7 @@ public bool TryGetContractState(UInt160 scriptHash, ulong timestamp, uint iterIn
.AddBigEndian(iterIndex)
.ToArray();
var data = _snapshot.TryGet(key);
state = data?.AsSerializable<ContractLogState>();
state = data?.AsSerializable<ContractLogState>()!;
return data != null && data.Length > 0;
}

Expand All @@ -341,7 +341,7 @@ public bool TryGetExecutionState(Guid executionStateId, out ExecutionLogState st
.Add(executionStateId.ToByteArray())
.ToArray();
var data = _snapshot.TryGet(key);
state = data?.AsSerializable<ExecutionLogState>();
state = data?.AsSerializable<ExecutionLogState>()!;
return data != null && data.Length > 0;
}

Expand Down Expand Up @@ -388,7 +388,7 @@ public bool TryGetTransactionState(UInt256 hash, out TransactionLogState state)
.Add(hash)
.ToArray();
var data = _snapshot.TryGet(key);
state = data?.AsSerializable<TransactionLogState>();
state = data?.AsSerializable<TransactionLogState>()!;
return data != null && data.Length > 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Neo.Plugins.Store.Models
{
public class ApplicationEngineLogModel
{
public UInt160 ScriptHash { get; private init; } = UInt160.Zero;
public UInt160 ScriptHash { get; private init; } = new();
public string Message { get; private init; } = string.Empty;

public static ApplicationEngineLogModel Create(EngineLogState logEventState) =>
Expand Down
5 changes: 2 additions & 3 deletions src/ApplicationLogs/Store/Models/BlockchainEventModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
using ApplicationLogs.Store.States;
using Neo;
using Neo.VM.Types;
using Array = System.Array;

namespace ApplicationLogs.Store.Models
{
public class BlockchainEventModel
{
public UInt160 ScriptHash { get; private init; } = UInt160.Zero;
public UInt160 ScriptHash { get; private init; } = new();
public string EventName { get; private init; } = string.Empty;
public StackItem[] State { get; private init; } = Array.Empty<StackItem>();
public StackItem[] State { get; private init; } = [];

public static BlockchainEventModel Create(UInt160 scriptHash, string eventName, StackItem[] state) =>
new()
Expand Down
6 changes: 3 additions & 3 deletions src/ApplicationLogs/Store/Models/BlockchainExecutionModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public class BlockchainExecutionModel
public VMState VmState { get; private init; } = VMState.NONE;
public string Exception { get; private init; } = string.Empty;
public long GasConsumed { get; private init; } = 0L;
public StackItem[] Stack { get; private init; } = System.Array.Empty<StackItem>();
public BlockchainEventModel[] Notifications { get; set; } = System.Array.Empty<BlockchainEventModel>();
public ApplicationEngineLogModel[] Logs { get; set; } = System.Array.Empty<ApplicationEngineLogModel>();
public StackItem[] Stack { get; private init; } = [];
public BlockchainEventModel[] Notifications { get; set; } = [];
public ApplicationEngineLogModel[] Logs { get; set; } = [];

public static BlockchainExecutionModel Create(TriggerType trigger, ExecutionLogState executionLogState, StackItem[] stack) =>
new()
Expand Down
2 changes: 1 addition & 1 deletion src/ApplicationLogs/Store/States/BlockLogState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace ApplicationLogs.Store.States
{
public class BlockLogState : ISerializable, IEquatable<BlockLogState>
{
public Guid[] NotifyLogIds { get; private set; } = Array.Empty<Guid>();
public Guid[] NotifyLogIds { get; private set; } = [];

public static BlockLogState Create(Guid[] notifyLogIds) =>
new()
Expand Down
2 changes: 1 addition & 1 deletion src/ApplicationLogs/Store/States/ContractLogState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace ApplicationLogs.Store.States
{
public class ContractLogState : NotifyLogState, IEquatable<ContractLogState>
{
public UInt256 TransactionHash { get; private set; } = UInt256.Zero;
public UInt256 TransactionHash { get; private set; } = new();
public TriggerType Trigger { get; private set; } = TriggerType.All;

public static ContractLogState Create(Blockchain.ApplicationExecuted applicationExecuted, NotifyEventArgs notifyEventArgs, Guid[] stackItemIds) =>
Expand Down
2 changes: 1 addition & 1 deletion src/ApplicationLogs/Store/States/EngineLogState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Neo.Plugins.Store.States
{
public class EngineLogState : ISerializable, IEquatable<EngineLogState>
{
public UInt160 ScriptHash { get; private set; } = UInt160.Zero;
public UInt160 ScriptHash { get; private set; } = new();
public string Message { get; private set; } = string.Empty;

public static EngineLogState Create(UInt160 scriptHash, string message) =>
Expand Down
4 changes: 2 additions & 2 deletions src/ApplicationLogs/Store/States/ExecutionLogState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ public class ExecutionLogState : ISerializable, IEquatable<ExecutionLogState>
public VMState VmState { get; private set; } = VMState.NONE;
public string Exception { get; private set; } = string.Empty;
public long GasConsumed { get; private set; } = 0L;
public Guid[] StackItemIds { get; private set; } = Array.Empty<Guid>();
public Guid[] StackItemIds { get; private set; } = [];

public static ExecutionLogState Create(Blockchain.ApplicationExecuted appExecution, Guid[] stackItemIds) =>
new()
{
VmState = appExecution.VMState,
Exception = appExecution.Exception?.InnerException?.Message ?? appExecution.Exception?.Message,
Exception = appExecution.Exception?.InnerException?.Message ?? appExecution.Exception?.Message!,
GasConsumed = appExecution.GasConsumed,
StackItemIds = stackItemIds,
};
Expand Down
8 changes: 4 additions & 4 deletions src/ApplicationLogs/Store/States/NotifyLogState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ namespace ApplicationLogs.Store.States
{
public class NotifyLogState : ISerializable, IEquatable<NotifyLogState>
{
public UInt160 ScriptHash { get; protected set; } = UInt160.Zero;
public UInt160 ScriptHash { get; protected set; } = new();
public string EventName { get; protected set; } = string.Empty;
public Guid[] StackItemIds { get; protected set; } = Array.Empty<Guid>();
public Guid[] StackItemIds { get; protected set; } = [];

public static NotifyLogState Create(NotifyEventArgs notifyItem, Guid[] stackItemsIds) =>
new()
Expand All @@ -44,7 +44,7 @@ public virtual void Deserialize(ref MemoryReader reader)
// It should be safe because it filled from a transaction's notifications.
uint aLen = reader.ReadUInt32();
StackItemIds = new Guid[aLen];
for (int i = 0; i < aLen; i++)
for (var i = 0; i < aLen; i++)
StackItemIds[i] = new Guid(reader.ReadVarMemory().Span);
}

Expand All @@ -54,7 +54,7 @@ public virtual void Serialize(BinaryWriter writer)
writer.WriteVarString(EventName ?? string.Empty);

writer.Write((uint)StackItemIds.Length);
for (int i = 0; i < StackItemIds.Length; i++)
for (var i = 0; i < StackItemIds.Length; i++)
writer.WriteVarBytes(StackItemIds[i].ToByteArray());
}

Expand Down
47 changes: 0 additions & 47 deletions src/RpcClient/Models/RpcNativeContract.cs

This file was deleted.

6 changes: 3 additions & 3 deletions src/RpcClient/RpcClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public static ContractState ContractStateFromJson(JObject json)
return new ContractState
{
Id = (int)json["id"].AsNumber(),
UpdateCounter = (ushort)json["updatecounter"].AsNumber(),
UpdateCounter = (ushort)(json["updatecounter"]?.AsNumber() ?? 0),
Hash = UInt160.Parse(json["hash"].AsString()),
Nef = RpcNefFile.FromJson((JObject)json["nef"]),
Manifest = ContractManifest.FromJson((JObject)json["manifest"])
Expand All @@ -270,10 +270,10 @@ public static ContractState ContractStateFromJson(JObject json)
/// <summary>
/// Get all native contracts.
/// </summary>
public async Task<RpcNativeContract[]> GetNativeContractsAsync()
public async Task<ContractState[]> GetNativeContractsAsync()
{
var result = await RpcSendAsync(GetRpcName()).ConfigureAwait(false);
return ((JArray)result).Select(p => RpcNativeContract.FromJson((JObject)p)).ToArray();
return ((JArray)result).Select(p => ContractStateFromJson((JObject)p)).ToArray();
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/RpcServer/RpcServer.Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ protected virtual JToken GetCommittee(JArray _params)
[RpcMethod]
protected virtual JToken GetNativeContracts(JArray _params)
{
return new JArray(NativeContract.Contracts.Select(p => p.NativeContractToJson(system)));
return new JArray(NativeContract.Contracts.Select(p => NativeContract.ContractManagement.GetContract(system.StoreView, p.Hash).ToJson()));
}
}
}
2 changes: 1 addition & 1 deletion src/RpcServer/RpcServer.Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected virtual JToken CalculateNetworkFee(JArray _params)
JObject account = new();
var networkfee = Wallets.Helper.CalculateNetworkFee(
tx.AsSerializable<Transaction>(), system.StoreView, system.Settings,
wallet is not null ? a => wallet.GetAccount(a).Contract.Script : null);
wallet is not null ? a => wallet.GetAccount(a).Contract.Script : _ => null);
account["networkfee"] = networkfee.ToString();
return account;
}
Expand Down
Loading

0 comments on commit 653c615

Please sign in to comment.