Skip to content

Commit

Permalink
Merge branch 'fix/uint160-class' of https://github.com/cschuchardt88/neo
Browse files Browse the repository at this point in the history
 into fix/uint160-class
  • Loading branch information
cschuchardt88 committed Jul 23, 2024
2 parents 950555b + 4be0af1 commit 3c3ff03
Show file tree
Hide file tree
Showing 24 changed files with 75 additions and 66 deletions.
2 changes: 1 addition & 1 deletion src/Neo.CLI/CLI/MainService.Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private void OnShowBlockCommand(string indexOrHash)
ConsoleHelper.Info("", " PrevHash: ", $"{block.PrevHash}");
ConsoleHelper.Info("", " NextConsensus: ", $"{block.NextConsensus}");
ConsoleHelper.Info("", " PrimaryIndex: ", $"{block.PrimaryIndex}");
ConsoleHelper.Info("", " PrimaryPubKey: ", $"{NativeContract.NEO.GetCommittee(NeoSystem.GetSnapshot())[block.PrimaryIndex]}");
ConsoleHelper.Info("", " PrimaryPubKey: ", $"{NativeContract.NEO.GetCommittee(NeoSystem.GetSnapshotCache())[block.PrimaryIndex]}");
ConsoleHelper.Info("", " Version: ", $"{block.Version}");
ConsoleHelper.Info("", " Size: ", $"{block.Size} Byte(s)");
ConsoleHelper.Info();
Expand Down
2 changes: 1 addition & 1 deletion src/Neo.CLI/config.fs.mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"MillisecondsPerBlock": 15000,
"MaxTransactionsPerBlock": 512,
"MemoryPoolMaxTransactions": 50000,
"MaxTraceableBlocks": 2102400,
"MaxTraceableBlocks": 17280,
"InitialGasDistribution": 5200000000000000,
"ValidatorsCount": 7,
"Hardforks": {
Expand Down
2 changes: 1 addition & 1 deletion src/Neo.CLI/config.fs.testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"MillisecondsPerBlock": 15000,
"MaxTransactionsPerBlock": 512,
"MemoryPoolMaxTransactions": 50000,
"MaxTraceableBlocks": 2102400,
"MaxTraceableBlocks": 17280,
"InitialGasDistribution": 5200000000000000,
"ValidatorsCount": 7,
"StandbyCommittee": [
Expand Down
2 changes: 1 addition & 1 deletion src/Neo.Extensions/Neo.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Akka" Version="1.5.20" />
<PackageReference Include="Akka" Version="1.5.26" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Neo/Neo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Akka" Version="1.5.20" />
<PackageReference Include="Akka" Version="1.5.26" />
<PackageReference Include="BouncyCastle.NetCore" Version="2.2.1" />
<PackageReference Include="K4os.Compression.LZ4" Version="1.3.8" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
</ItemGroup>

Expand Down
13 changes: 11 additions & 2 deletions src/Plugins/DBFTPlugin/Consensus/ConsensusContext.MakePayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,20 @@ public ExtensiblePayload MakePrepareResponse()
});
}

// Related to issue https://github.com/neo-project/neo/issues/3431
// Ref. https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.randomnumbergenerator?view=net-8.0
//
//The System.Random class relies on a seed value that can be predictable,
//especially if the seed is based on the system clock or other low-entropy sources.
//RandomNumberGenerator, however, uses sources of entropy provided by the operating
//system, which are designed to be unpredictable.
private static ulong GetNonce()
{
Random _random = new();
Span<byte> buffer = stackalloc byte[8];
_random.NextBytes(buffer);
using (var rng = System.Security.Cryptography.RandomNumberGenerator.Create())
{
rng.GetBytes(buffer);
}
return BinaryPrimitives.ReadUInt64LittleEndian(buffer);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Plugins/OracleService/OracleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public JObject SubmitOracleResponse(JArray _params)

finishedCache.ContainsKey(requestId).False_Or(RpcError.OracleRequestFinished);

using (var snapshot = _system.GetSnapshot())
using (var snapshot = _system.GetSnapshotCache())
{
uint height = NativeContract.Ledger.CurrentIndex(snapshot) + 1;
var oracles = NativeContract.RoleManagement.GetDesignatedByRole(snapshot, Role.Oracle, height);
Expand Down Expand Up @@ -326,7 +326,7 @@ private async void ProcessRequestsAsync()
{
while (!cancelSource.IsCancellationRequested)
{
using (var snapshot = _system.GetSnapshot())
using (var snapshot = _system.GetSnapshotCache())
{
SyncPendingQueue(snapshot);
foreach (var (id, request) in NativeContract.Oracle.GetRequests(snapshot))
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/RocksDBStore/RocksDBStore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="rocksdb" Version="8.11.3.46984" />
<PackageReference Include="rocksdb" Version="9.4.0.50294" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Plugins/RpcServer/RpcServer.Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected virtual JToken GetWalletUnclaimedGas(JArray _params)
CheckWallet();
// Datoshi is the smallest unit of GAS, 1 GAS = 10^8 Datoshi
BigInteger datoshi = BigInteger.Zero;
using (var snapshot = system.GetSnapshot())
using (var snapshot = system.GetSnapshotCache())
{
uint height = NativeContract.Ledger.CurrentIndex(snapshot) + 1;
foreach (UInt160 account in wallet.GetAccounts().Select(p => p.ScriptHash))
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/SQLiteWallet/SQLiteWallet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.7" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Plugins/TokensTracker/Trackers/NEP-11/Nep11Tracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public JToken GetNep11Properties(JArray _params)

using ScriptBuilder sb = new();
sb.EmitDynamicCall(nep11Hash, "properties", CallFlags.ReadOnly, tokenId);
using var snapshot = _neoSystem.GetSnapshot();
using var snapshot = _neoSystem.GetSnapshotCache();

using var engine = ApplicationEngine.Run(sb.ToArray(), snapshot, settings: _neoSystem.Settings);
JObject json = new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions tests/Neo.Extensions.Tests/Neo.Extensions.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions tests/Neo.Json.UnitTests/Neo.Json.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.0" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions tests/Neo.Network.RPC.Tests/Neo.Network.RPC.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

<ItemGroup>
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Akka.TestKit" Version="1.5.20" />
<PackageReference Include="Akka.TestKit.Xunit2" Version="1.5.20" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
<PackageReference Include="Akka.TestKit" Version="1.5.26" />
<PackageReference Include="Akka.TestKit.Xunit2" Version="1.5.26" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public void TestGetCandidates()
var json = new JArray();
var validators = NativeContract.NEO.GetNextBlockValidators(snapshot, _neoSystem.Settings.ValidatorsCount);
snapshot.Commit();
var candidates = NativeContract.NEO.GetCandidates(_neoSystem.GetSnapshot());
var candidates = NativeContract.NEO.GetCandidates(_neoSystem.GetSnapshotCache());

foreach (var candidate in candidates)
{
Expand All @@ -266,7 +266,7 @@ public void TestGetCommittee()
public void TestGetNativeContracts()
{
var result = _rpcServer.GetNativeContracts(new JArray());
var contracts = new JArray(NativeContract.Contracts.Select(p => NativeContract.ContractManagement.GetContract(_neoSystem.GetSnapshot(), p.Hash).ToJson()));
var contracts = new JArray(NativeContract.Contracts.Select(p => NativeContract.ContractManagement.GetContract(_neoSystem.GetSnapshotCache(), p.Hash).ToJson()));
Assert.AreEqual(contracts.ToString(), result.ToString());
}

Expand Down
26 changes: 13 additions & 13 deletions tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void TestGetVersion()
[TestMethod]
public void TestSendRawTransaction_Normal()
{
var snapshot = _neoSystem.GetSnapshot();
var snapshot = _neoSystem.GetSnapshotCache();
var tx = TestUtils.CreateValidTx(snapshot, _wallet, _walletAccount);
var txString = Convert.ToBase64String(tx.ToArray());

Expand All @@ -69,7 +69,7 @@ public void TestSendRawTransaction_InvalidTransactionFormat()
[TestMethod]
public void TestSendRawTransaction_InsufficientBalance()
{
var snapshot = _neoSystem.GetSnapshot();
var snapshot = _neoSystem.GetSnapshotCache();
var tx = TestUtils.CreateInvalidTransaction(snapshot, _wallet, _walletAccount, TestUtils.InvalidTransactionType.InsufficientBalance);
var txString = Convert.ToBase64String(tx.ToArray());

Expand All @@ -82,7 +82,7 @@ public void TestSendRawTransaction_InsufficientBalance()
[TestMethod]
public void TestSendRawTransaction_InvalidSignature()
{
var snapshot = _neoSystem.GetSnapshot();
var snapshot = _neoSystem.GetSnapshotCache();
var tx = TestUtils.CreateInvalidTransaction(snapshot, _wallet, _walletAccount, TestUtils.InvalidTransactionType.InvalidSignature);
var txString = Convert.ToBase64String(tx.ToArray());

Expand All @@ -95,7 +95,7 @@ public void TestSendRawTransaction_InvalidSignature()
[TestMethod]
public void TestSendRawTransaction_InvalidScript()
{
var snapshot = _neoSystem.GetSnapshot();
var snapshot = _neoSystem.GetSnapshotCache();
var tx = TestUtils.CreateInvalidTransaction(snapshot, _wallet, _walletAccount, TestUtils.InvalidTransactionType.InvalidScript);
var txString = Convert.ToBase64String(tx.ToArray());

Expand All @@ -108,7 +108,7 @@ public void TestSendRawTransaction_InvalidScript()
[TestMethod]
public void TestSendRawTransaction_InvalidAttribute()
{
var snapshot = _neoSystem.GetSnapshot();
var snapshot = _neoSystem.GetSnapshotCache();
var tx = TestUtils.CreateInvalidTransaction(snapshot, _wallet, _walletAccount, TestUtils.InvalidTransactionType.InvalidAttribute);
var txString = Convert.ToBase64String(tx.ToArray());

Expand All @@ -123,7 +123,7 @@ public void TestSendRawTransaction_InvalidAttribute()
[TestMethod]
public void TestSendRawTransaction_Oversized()
{
var snapshot = _neoSystem.GetSnapshot();
var snapshot = _neoSystem.GetSnapshotCache();
var tx = TestUtils.CreateInvalidTransaction(snapshot, _wallet, _walletAccount, TestUtils.InvalidTransactionType.Oversized);
var txString = Convert.ToBase64String(tx.ToArray());

Expand All @@ -137,7 +137,7 @@ public void TestSendRawTransaction_Oversized()
[TestMethod]
public void TestSendRawTransaction_Expired()
{
var snapshot = _neoSystem.GetSnapshot();
var snapshot = _neoSystem.GetSnapshotCache();
var tx = TestUtils.CreateInvalidTransaction(snapshot, _wallet, _walletAccount, TestUtils.InvalidTransactionType.Expired);
var txString = Convert.ToBase64String(tx.ToArray());

Expand All @@ -150,7 +150,7 @@ public void TestSendRawTransaction_Expired()
[TestMethod]
public void TestSendRawTransaction_PolicyFailed()
{
var snapshot = _neoSystem.GetSnapshot();
var snapshot = _neoSystem.GetSnapshotCache();
var tx = TestUtils.CreateValidTx(snapshot, _wallet, _walletAccount);
var txString = Convert.ToBase64String(tx.ToArray());
NativeContract.Policy.BlockAccount(snapshot, _walletAccount.ScriptHash);
Expand All @@ -165,7 +165,7 @@ public void TestSendRawTransaction_PolicyFailed()
[TestMethod]
public void TestSendRawTransaction_AlreadyInPool()
{
var snapshot = _neoSystem.GetSnapshot();
var snapshot = _neoSystem.GetSnapshotCache();
var tx = TestUtils.CreateValidTx(snapshot, _wallet, _walletAccount);
_neoSystem.MemPool.TryAdd(tx, snapshot);
var txString = Convert.ToBase64String(tx.ToArray());
Expand All @@ -179,7 +179,7 @@ public void TestSendRawTransaction_AlreadyInPool()
[TestMethod]
public void TestSendRawTransaction_AlreadyInBlockchain()
{
var snapshot = _neoSystem.GetSnapshot();
var snapshot = _neoSystem.GetSnapshotCache();
var tx = TestUtils.CreateValidTx(snapshot, _wallet, _walletAccount);
TestUtils.AddTransactionToBlockchain(snapshot, tx);
snapshot.Commit();
Expand All @@ -195,7 +195,7 @@ public void TestSendRawTransaction_AlreadyInBlockchain()
[TestMethod]
public void TestSubmitBlock_Normal()
{
var snapshot = _neoSystem.GetSnapshot();
var snapshot = _neoSystem.GetSnapshotCache();
var block = TestUtils.CreateBlockWithValidTransactions(snapshot, _wallet, _walletAccount, 1);
var blockString = Convert.ToBase64String(block.ToArray());

Expand All @@ -220,7 +220,7 @@ public void TestSubmitBlock_InvalidBlockFormat()
[TestMethod]
public void TestSubmitBlock_AlreadyExists()
{
var snapshot = _neoSystem.GetSnapshot();
var snapshot = _neoSystem.GetSnapshotCache();
var block = TestUtils.CreateBlockWithValidTransactions(snapshot, _wallet, _walletAccount, 1);
TestUtils.BlocksAdd(snapshot, block.Hash, block);
snapshot.Commit();
Expand All @@ -235,7 +235,7 @@ public void TestSubmitBlock_AlreadyExists()
[TestMethod]
public void TestSubmitBlock_InvalidBlock()
{
var snapshot = _neoSystem.GetSnapshot();
var snapshot = _neoSystem.GetSnapshotCache();
var block = TestUtils.CreateBlockWithValidTransactions(snapshot, _wallet, _walletAccount, 1);
block.Header.Witness = new Witness();
var blockString = Convert.ToBase64String(block.ToArray());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 3c3ff03

Please sign in to comment.