Skip to content

Commit d1b03b6

Browse files
cschuchardt88superboyiii
andauthoredMay 6, 2024··
Fix storage snapshot sync (#898)
* Fixed `MemoryLeak` with `nullable` on `non-nullable` projects * fix fetching --------- Co-authored-by: Owen <38493437+superboyiii@users.noreply.github.com>
1 parent 76e933e commit d1b03b6

11 files changed

+36
-30
lines changed
 

‎neo-modules.sln

+13-6
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,24 @@ 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}"
46+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo", "neo\src\Neo\Neo.csproj", "{A00FC746-1351-4275-B2D9-489477B409C0}"
4747
EndProject
48-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.IO", "neo\src\Neo.IO\Neo.IO.csproj", "{FEC96A32-38AB-426B-A93E-D37583BEE901}"
48+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.IO", "neo\src\Neo.IO\Neo.IO.csproj", "{FEC96A32-38AB-426B-A93E-D37583BEE901}"
4949
EndProject
50-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.Json", "neo\src\Neo.Json\Neo.Json.csproj", "{188D043E-393D-4E5B-A216-4274BF9AFB23}"
50+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.Json", "neo\src\Neo.Json\Neo.Json.csproj", "{188D043E-393D-4E5B-A216-4274BF9AFB23}"
5151
EndProject
52-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.VM", "neo\src\Neo.VM\Neo.VM.csproj", "{EDDE78BC-2064-4517-B9B2-25BA012A93C1}"
52+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.VM", "neo\src\Neo.VM\Neo.VM.csproj", "{EDDE78BC-2064-4517-B9B2-25BA012A93C1}"
5353
EndProject
54-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.Extensions", "neo\src\Neo.Extensions\Neo.Extensions.csproj", "{9FF233D7-84C2-4947-96F6-88EE3594C66A}"
54+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.Extensions", "neo\src\Neo.Extensions\Neo.Extensions.csproj", "{9FF233D7-84C2-4947-96F6-88EE3594C66A}"
5555
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}"
56+
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}"
5757
EndProject
5858
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependency", "Dependency", "{997874E0-C2A7-4EB2-85AA-180AF592DC6D}"
5959
EndProject
6060
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.ConsoleService", "neo\src\Neo.ConsoleService\Neo.ConsoleService.csproj", "{919EC990-C586-4B46-900E-8A7496004030}"
6161
EndProject
62+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.CLI", "neo\src\Neo.CLI\Neo.CLI.csproj", "{F9A412E0-5FAA-438B-9E2A-886EB4AA0C66}"
63+
EndProject
6264
Global
6365
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6466
Debug|Any CPU = Debug|Any CPU
@@ -165,6 +167,10 @@ Global
165167
{919EC990-C586-4B46-900E-8A7496004030}.Debug|Any CPU.Build.0 = Debug|Any CPU
166168
{919EC990-C586-4B46-900E-8A7496004030}.Release|Any CPU.ActiveCfg = Release|Any CPU
167169
{919EC990-C586-4B46-900E-8A7496004030}.Release|Any CPU.Build.0 = Release|Any CPU
170+
{F9A412E0-5FAA-438B-9E2A-886EB4AA0C66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
171+
{F9A412E0-5FAA-438B-9E2A-886EB4AA0C66}.Debug|Any CPU.Build.0 = Debug|Any CPU
172+
{F9A412E0-5FAA-438B-9E2A-886EB4AA0C66}.Release|Any CPU.ActiveCfg = Release|Any CPU
173+
{F9A412E0-5FAA-438B-9E2A-886EB4AA0C66}.Release|Any CPU.Build.0 = Release|Any CPU
168174
EndGlobalSection
169175
GlobalSection(SolutionProperties) = preSolution
170176
HideSolutionNode = FALSE
@@ -195,6 +201,7 @@ Global
195201
{9FF233D7-84C2-4947-96F6-88EE3594C66A} = {997874E0-C2A7-4EB2-85AA-180AF592DC6D}
196202
{7437514A-290D-4F84-B315-32ED95F710C1} = {997874E0-C2A7-4EB2-85AA-180AF592DC6D}
197203
{919EC990-C586-4B46-900E-8A7496004030} = {997874E0-C2A7-4EB2-85AA-180AF592DC6D}
204+
{F9A412E0-5FAA-438B-9E2A-886EB4AA0C66} = {997874E0-C2A7-4EB2-85AA-180AF592DC6D}
198205
EndGlobalSection
199206
GlobalSection(ExtensibilityGlobals) = postSolution
200207
SolutionGuid = {61D3ADE6-BBFC-402D-AB42-1C71C9F9EDE3}

‎src/ApplicationLogs/Store/LogStorageStore.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ public bool TryGetEngineState(Guid engineStateId, out EngineLogState state)
288288
.Add(engineStateId.ToByteArray())
289289
.ToArray();
290290
var data = _snapshot.TryGet(key);
291-
state = data?.AsSerializable<EngineLogState>();
291+
state = data?.AsSerializable<EngineLogState>()!;
292292
return data != null && data.Length > 0;
293293
}
294294

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

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

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

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

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

@@ -388,7 +388,7 @@ public bool TryGetTransactionState(UInt256 hash, out TransactionLogState state)
388388
.Add(hash)
389389
.ToArray();
390390
var data = _snapshot.TryGet(key);
391-
state = data?.AsSerializable<TransactionLogState>();
391+
state = data?.AsSerializable<TransactionLogState>()!;
392392
return data != null && data.Length > 0;
393393
}
394394

‎src/ApplicationLogs/Store/Models/ApplicationEngineLogModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Neo.Plugins.Store.Models
1515
{
1616
public class ApplicationEngineLogModel
1717
{
18-
public UInt160 ScriptHash { get; private init; } = UInt160.Zero;
18+
public UInt160 ScriptHash { get; private init; } = new();
1919
public string Message { get; private init; } = string.Empty;
2020

2121
public static ApplicationEngineLogModel Create(EngineLogState logEventState) =>

‎src/ApplicationLogs/Store/Models/BlockchainEventModel.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@
1212
using ApplicationLogs.Store.States;
1313
using Neo;
1414
using Neo.VM.Types;
15-
using Array = System.Array;
1615

1716
namespace ApplicationLogs.Store.Models
1817
{
1918
public class BlockchainEventModel
2019
{
21-
public UInt160 ScriptHash { get; private init; } = UInt160.Zero;
20+
public UInt160 ScriptHash { get; private init; } = new();
2221
public string EventName { get; private init; } = string.Empty;
23-
public StackItem[] State { get; private init; } = Array.Empty<StackItem>();
22+
public StackItem[] State { get; private init; } = [];
2423

2524
public static BlockchainEventModel Create(UInt160 scriptHash, string eventName, StackItem[] state) =>
2625
new()

‎src/ApplicationLogs/Store/Models/BlockchainExecutionModel.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ public class BlockchainExecutionModel
2323
public VMState VmState { get; private init; } = VMState.NONE;
2424
public string Exception { get; private init; } = string.Empty;
2525
public long GasConsumed { get; private init; } = 0L;
26-
public StackItem[] Stack { get; private init; } = System.Array.Empty<StackItem>();
27-
public BlockchainEventModel[] Notifications { get; set; } = System.Array.Empty<BlockchainEventModel>();
28-
public ApplicationEngineLogModel[] Logs { get; set; } = System.Array.Empty<ApplicationEngineLogModel>();
26+
public StackItem[] Stack { get; private init; } = [];
27+
public BlockchainEventModel[] Notifications { get; set; } = [];
28+
public ApplicationEngineLogModel[] Logs { get; set; } = [];
2929

3030
public static BlockchainExecutionModel Create(TriggerType trigger, ExecutionLogState executionLogState, StackItem[] stack) =>
3131
new()

‎src/ApplicationLogs/Store/States/BlockLogState.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace ApplicationLogs.Store.States
1616
{
1717
public class BlockLogState : ISerializable, IEquatable<BlockLogState>
1818
{
19-
public Guid[] NotifyLogIds { get; private set; } = Array.Empty<Guid>();
19+
public Guid[] NotifyLogIds { get; private set; } = [];
2020

2121
public static BlockLogState Create(Guid[] notifyLogIds) =>
2222
new()

‎src/ApplicationLogs/Store/States/ContractLogState.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace ApplicationLogs.Store.States
1818
{
1919
public class ContractLogState : NotifyLogState, IEquatable<ContractLogState>
2020
{
21-
public UInt256 TransactionHash { get; private set; } = UInt256.Zero;
21+
public UInt256 TransactionHash { get; private set; } = new();
2222
public TriggerType Trigger { get; private set; } = TriggerType.All;
2323

2424
public static ContractLogState Create(Blockchain.ApplicationExecuted applicationExecuted, NotifyEventArgs notifyEventArgs, Guid[] stackItemIds) =>

‎src/ApplicationLogs/Store/States/EngineLogState.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Neo.Plugins.Store.States
1515
{
1616
public class EngineLogState : ISerializable, IEquatable<EngineLogState>
1717
{
18-
public UInt160 ScriptHash { get; private set; } = UInt160.Zero;
18+
public UInt160 ScriptHash { get; private set; } = new();
1919
public string Message { get; private set; } = string.Empty;
2020

2121
public static EngineLogState Create(UInt160 scriptHash, string message) =>

‎src/ApplicationLogs/Store/States/ExecutionLogState.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ public class ExecutionLogState : ISerializable, IEquatable<ExecutionLogState>
2020
public VMState VmState { get; private set; } = VMState.NONE;
2121
public string Exception { get; private set; } = string.Empty;
2222
public long GasConsumed { get; private set; } = 0L;
23-
public Guid[] StackItemIds { get; private set; } = Array.Empty<Guid>();
23+
public Guid[] StackItemIds { get; private set; } = [];
2424

2525
public static ExecutionLogState Create(Blockchain.ApplicationExecuted appExecution, Guid[] stackItemIds) =>
2626
new()
2727
{
2828
VmState = appExecution.VMState,
29-
Exception = appExecution.Exception?.InnerException?.Message ?? appExecution.Exception?.Message,
29+
Exception = appExecution.Exception?.InnerException?.Message ?? appExecution.Exception?.Message!,
3030
GasConsumed = appExecution.GasConsumed,
3131
StackItemIds = stackItemIds,
3232
};

‎src/ApplicationLogs/Store/States/NotifyLogState.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ namespace ApplicationLogs.Store.States
1717
{
1818
public class NotifyLogState : ISerializable, IEquatable<NotifyLogState>
1919
{
20-
public UInt160 ScriptHash { get; protected set; } = UInt160.Zero;
20+
public UInt160 ScriptHash { get; protected set; } = new();
2121
public string EventName { get; protected set; } = string.Empty;
22-
public Guid[] StackItemIds { get; protected set; } = Array.Empty<Guid>();
22+
public Guid[] StackItemIds { get; protected set; } = [];
2323

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

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

5656
writer.Write((uint)StackItemIds.Length);
57-
for (int i = 0; i < StackItemIds.Length; i++)
57+
for (var i = 0; i < StackItemIds.Length; i++)
5858
writer.WriteVarBytes(StackItemIds[i].ToByteArray());
5959
}
6060

0 commit comments

Comments
 (0)
Please sign in to comment.