Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions plugins/ApplicationLogs/LogReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

using Neo.ConsoleService;
using Neo.Extensions.VM;
using Neo.IEventHandlers;
using Neo.Json;
using Neo.Ledger;
using Neo.Network.P2P.Payloads;
Expand Down Expand Up @@ -285,7 +284,7 @@ private void PrintExecutionToConsole(BlockchainExecutionModel model)
ConsoleHelper.Error($"Exception: {model.Exception}");
else
ConsoleHelper.Info("Exception: ", "null");
ConsoleHelper.Info("Gas Consumed: ", $"{new BigDecimal((BigInteger)model.GasConsumed, NativeContract.GAS.Decimals)}");
ConsoleHelper.Info("Gas Consumed: ", $"{new BigDecimal((BigInteger)model.GasConsumed, Governance.GasTokenDecimals)}");
if (model.Stack.Length == 0)
ConsoleHelper.Info("Stack: ", "[]");
else
Expand Down
1 change: 0 additions & 1 deletion plugins/DBFTPlugin/DBFTPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

using Akka.Actor;
using Neo.ConsoleService;
using Neo.IEventHandlers;
using Neo.Network.P2P;
using Neo.Network.P2P.Payloads;
using Neo.Plugins.DBFTPlugin.Consensus;
Expand All @@ -20,7 +19,7 @@

namespace Neo.Plugins.DBFTPlugin;

public sealed class DBFTPlugin : Plugin, IMessageReceivedHandler

Check failure on line 22 in plugins/DBFTPlugin/DBFTPlugin.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

The type or namespace name 'IMessageReceivedHandler' could not be found (are you missing a using directive or an assembly reference?)
{
private IWalletProvider? walletProvider;
private IActorRef consensus = null!;
Expand Down Expand Up @@ -110,7 +109,7 @@
consensus.Tell(new ConsensusService.Start());
}

bool IMessageReceivedHandler.RemoteNode_MessageReceived_Handler(NeoSystem system, Message message)

Check failure on line 112 in plugins/DBFTPlugin/DBFTPlugin.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

'IMessageReceivedHandler' in explicit interface declaration is not an interface

Check failure on line 112 in plugins/DBFTPlugin/DBFTPlugin.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

The type or namespace name 'IMessageReceivedHandler' could not be found (are you missing a using directive or an assembly reference?)
{
if (message.Command == MessageCommand.Transaction)
{
Expand Down
9 changes: 4 additions & 5 deletions plugins/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<Copyright>2015-2025 The Neo Project</Copyright>
<Copyright>2015-2026 The Neo Project</Copyright>
<Authors>The Neo Project</Authors>
<PackageId>Neo.Plugins.$(MSBuildProjectName)</PackageId>
<PackageProjectUrl>https://github.com/neo-project/neo-modules</PackageProjectUrl>
Expand All @@ -18,15 +18,14 @@
<EnableDynamicLoading>true</EnableDynamicLoading>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="4.0.0-CI02011" />
</ItemGroup>

<ItemGroup>
<None Include="config.json" Condition="Exists('config.json')">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="4.0.0-CI02018" />
</ItemGroup>
</Project>
11 changes: 10 additions & 1 deletion plugins/LevelDBStore/IO/Data/LevelDB/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,16 @@ public static class Helper
yield return new(it.Key()!, it.Value()!);
}
}

public static int CompareLex(byte[] a, byte[] b)
{
int n = Math.Min(a.Length, b.Length);
for (int i = 0; i < n; i++)
{
int diff = a[i].CompareTo(b[i]);
if (diff != 0) return diff;
}
return a.Length.CompareTo(b.Length);
}
internal static byte[]? ToByteArray(this IntPtr data, UIntPtr length)
{
if (data == IntPtr.Zero) return null;
Expand Down
51 changes: 51 additions & 0 deletions plugins/LevelDBStore/Plugins/Storage/Snapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,58 @@ public void Dispose()
{
return _db.Seek(_readOptions, keyOrPrefix, direction);
}
public IEnumerable<(byte[] Key, byte[] Value)> FindRange(byte[] start, byte[] end, SeekDirection direction = SeekDirection.Forward)
{
ArgumentNullException.ThrowIfNull(start);
ArgumentNullException.ThrowIfNull(end);

if (Helper.CompareLex(start, end) >= 0)
yield break;

using var iterator = _db.CreateIterator(_readOptions);

if (direction == SeekDirection.Forward)
{
iterator.Seek(start);

while (iterator.Valid())
{
var key = iterator.Key();
if (key is null) break;

if (Helper.CompareLex(key, end) >= 0)
break;

yield return (key, iterator.Value()!);
iterator.Next();
}
}
else
{
iterator.Seek(end);

if (!iterator.Valid())
{
iterator.SeekToLast();
}
else
{
iterator.Prev();
}

while (iterator.Valid())
{
var key = iterator.Key();
if (key is null) break;

if (Helper.CompareLex(key, start) < 0)
break;

yield return (key, iterator.Value()!);
iterator.Prev();
}
}
}
public bool Contains(byte[] key)
{
return _db.Contains(_readOptions, key);
Expand Down
52 changes: 52 additions & 0 deletions plugins/LevelDBStore/Plugins/Storage/Store.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,58 @@ public bool TryGet(byte[] key, [NotNullWhen(true)] out byte[]? value)
public IEnumerable<(byte[], byte[])> Find(byte[]? keyOrPrefix, SeekDirection direction = SeekDirection.Forward) =>
_db.Seek(ReadOptions.Default, keyOrPrefix, direction);

public IEnumerable<(byte[] Key, byte[] Value)> FindRange(byte[] start, byte[] end, SeekDirection direction = SeekDirection.Forward)
{
ArgumentNullException.ThrowIfNull(start);
ArgumentNullException.ThrowIfNull(end);

if (Helper.CompareLex(start, end) >= 0)
yield break;

using var iterator = _db.CreateIterator(ReadOptions.Default);

if (direction == SeekDirection.Forward)
{
iterator.Seek(start);

while (iterator.Valid())
{
var key = iterator.Key();
if (key is null) break;

if (Helper.CompareLex(key, end) >= 0)
break;

yield return (key, iterator.Value()!);
iterator.Next();
}
}
else
{
iterator.Seek(end);

if (!iterator.Valid())
{
iterator.SeekToLast();
}
else
{
iterator.Prev();
}

while (iterator.Valid())
{
var key = iterator.Key();
if (key is null) break;

if (Helper.CompareLex(key, start) < 0)
break;

yield return (key, iterator.Value()!);
iterator.Prev();
}
}
}
public IEnumerator<KeyValuePair<byte[], byte[]>> GetEnumerator() =>
_db.GetEnumerator();

Expand Down
1 change: 0 additions & 1 deletion plugins/OracleService/OracleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using Neo.Extensions;
using Neo.Extensions.Collections;
using Neo.Extensions.IO;
using Neo.IEventHandlers;
using Neo.Json;
using Neo.Ledger;
using Neo.Network.P2P;
Expand Down
2 changes: 1 addition & 1 deletion plugins/RestServer/Controllers/v1/LedgerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public IActionResult ShowGasAccounts(
{
if (skip < 1 || take < 1 || take > RestServerSettings.Current.MaxPageSize)
throw new InvalidParameterRangeException();
var accounts = NativeContract.GAS.ListAccounts(_neoSystem.StoreView, _neoSystem.Settings);
var accounts = NativeContract.Governance.ListAccounts(_neoSystem.StoreView, _neoSystem.Settings);
if (accounts.Any() == false)
return NoContent();
var accountsList = accounts.OrderByDescending(o => o.Balance).Skip((skip - 1) * take).Take(take);
Expand Down
56 changes: 56 additions & 0 deletions plugins/RocksDBStore/Plugins/Storage/Snapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,62 @@ public void Put(byte[] key, byte[] value)
yield return (it.Key(), it.Value());
}

public IEnumerable<(byte[] Key, byte[] Value)> FindRange(byte[] start, byte[] end, SeekDirection direction = SeekDirection.Forward)
{
ArgumentNullException.ThrowIfNull(start);
ArgumentNullException.ThrowIfNull(end);

if (CompareLex(start, end) >= 0)
yield break;

using var it = _db.NewIterator(readOptions: _options);

if (direction == SeekDirection.Forward)
{
for (it.Seek(start); it.Valid(); it.Next())
{
var key = it.Key();
if (CompareLex(key, end) >= 0)
break;

yield return (key, it.Value());
}
}
else
{
it.Seek(end);

if (!it.Valid())
{
it.SeekToLast();
}
else
{
it.Prev();
}

for (; it.Valid(); it.Prev())
{
var key = it.Key();
if (CompareLex(key, start) < 0)
break;

yield return (key, it.Value());
}
}

static int CompareLex(byte[] a, byte[] b)
{
int n = Math.Min(a.Length, b.Length);
for (int i = 0; i < n; i++)
{
int diff = a[i].CompareTo(b[i]);
if (diff != 0) return diff;
}
return a.Length.CompareTo(b.Length);
}
}

public bool Contains(byte[] key)
{
return _db.Get(key, Array.Empty<byte>(), 0, 0, readOptions: _options) >= 0;
Expand Down
55 changes: 55 additions & 0 deletions plugins/RocksDBStore/Plugins/Storage/Store.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,61 @@ public IStoreSnapshot GetSnapshot()
for (it.SeekForPrev(keyOrPrefix); it.Valid(); it.Prev())
yield return (it.Key(), it.Value());
}
public IEnumerable<(byte[] Key, byte[] Value)> FindRange(byte[] start, byte[] end, SeekDirection direction = SeekDirection.Forward)
{
ArgumentNullException.ThrowIfNull(start);
ArgumentNullException.ThrowIfNull(end);

if (CompareLex(start, end) >= 0)
yield break;

using var it = _db.NewIterator();

if (direction == SeekDirection.Forward)
{
for (it.Seek(start); it.Valid(); it.Next())
{
var key = it.Key();
if (CompareLex(key, end) >= 0)
break;

yield return (key, it.Value());
}
}
else
{
it.Seek(end);

if (!it.Valid())
{
it.SeekToLast();
}
else
{
it.Prev();
}

for (; it.Valid(); it.Prev())
{
var key = it.Key();
if (CompareLex(key, start) < 0)
break;

yield return (key, it.Value());
}
}

static int CompareLex(byte[] a, byte[] b)
{
int n = Math.Min(a.Length, b.Length);
for (int i = 0; i < n; i++)
{
int diff = a[i].CompareTo(b[i]);
if (diff != 0) return diff;
}
return a.Length.CompareTo(b.Length);
}
}

public bool Contains(byte[] key)
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/RpcClient/RpcClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ public async Task<BigDecimal> GetWalletBalanceAsync(string assetId)
public async Task<BigDecimal> GetWalletUnclaimedGasAsync()
{
var result = await RpcSendAsync(GetRpcName()).ConfigureAwait(false);
return BigDecimal.Parse(result.AsString(), NativeContract.GAS.Decimals);
return BigDecimal.Parse(result.AsString(), Governance.GasTokenDecimals);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion plugins/RpcClient/TransactionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public async Task<Transaction> SignAsync()
Tx.NetworkFee = await rpcClient.CalculateNetworkFeeAsync(Tx).ConfigureAwait(false);
Tx.Witnesses = null!;

var gasBalance = await new Nep17API(rpcClient).BalanceOfAsync(NativeContract.GAS.Hash, Tx.Sender).ConfigureAwait(false);
var gasBalance = await new Nep17API(rpcClient).BalanceOfAsync(NativeContract.Governance.Hash, Tx.Sender).ConfigureAwait(false);
if (gasBalance < Tx.SystemFee + Tx.NetworkFee)
throw new InvalidOperationException($"Insufficient GAS in address: {Tx.Sender.ToAddress(rpcClient.protocolSettings.AddressVersion)}");

Expand Down
6 changes: 3 additions & 3 deletions plugins/RpcClient/WalletAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public async Task<decimal> GetUnclaimedGasAsync(UInt160 account)
var blockCount = await rpcClient.GetBlockCountAsync().ConfigureAwait(false);
var result = await nep17API.TestInvokeAsync(scriptHash, "unclaimedGas", account, blockCount - 1).ConfigureAwait(false);
BigInteger balance = result.Stack.Single().GetInteger();
return ((decimal)balance) / (long)NativeContract.GAS.Factor;
return ((decimal)balance) / (long)Governance.GasTokenFactor;
}

/// <summary>
Expand All @@ -83,8 +83,8 @@ public async Task<uint> GetNeoBalanceAsync(string account)
/// <returns></returns>
public async Task<decimal> GetGasBalanceAsync(string account)
{
BigInteger balance = await GetTokenBalanceAsync(NativeContract.GAS.Hash.ToString(), account).ConfigureAwait(false);
return ((decimal)balance) / (long)NativeContract.GAS.Factor;
BigInteger balance = await GetTokenBalanceAsync(NativeContract.Governance.Hash.ToString(), account).ConfigureAwait(false);
return ((decimal)balance) / (long)Governance.GasTokenFactor;
}

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions plugins/RpcServer/RcpServerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ public record RpcServersSettings
/// <summary>
/// In the unit of datoshi, 1 GAS = 10^8 datoshi
/// </summary>
public long MaxGasInvoke { get; init; } = (long)new BigDecimal(10M, NativeContract.GAS.Decimals).Value;
public long MaxGasInvoke { get; init; } = (long)new BigDecimal(10M, Governance.GasTokenDecimals).Value;

/// <summary>
/// In the unit of datoshi, 1 GAS = 10^8 datoshi
/// </summary>
public long MaxFee { get; init; } = (long)new BigDecimal(0.1M, NativeContract.GAS.Decimals).Value;
public long MaxFee { get; init; } = (long)new BigDecimal(0.1M, Governance.GasTokenDecimals).Value;
public int MaxIteratorResultItems { get; init; } = 100;
public int MaxStackSize { get; init; } = ushort.MaxValue;
public string[] DisabledMethods { get; init; } = [];
Expand All @@ -88,8 +88,8 @@ public static RpcServersSettings Load(IConfigurationSection section)
AllowOrigins = GetStrings(section, "AllowOrigins"),
KeepAliveTimeout = section.GetValue(nameof(KeepAliveTimeout), @default.KeepAliveTimeout),
RequestHeadersTimeout = section.GetValue(nameof(RequestHeadersTimeout), @default.RequestHeadersTimeout),
MaxGasInvoke = (long)new BigDecimal(section.GetValue<decimal>("MaxGasInvoke", @default.MaxGasInvoke), NativeContract.GAS.Decimals).Value,
MaxFee = (long)new BigDecimal(section.GetValue<decimal>("MaxFee", @default.MaxFee), NativeContract.GAS.Decimals).Value,
MaxGasInvoke = (long)new BigDecimal(section.GetValue<decimal>("MaxGasInvoke", @default.MaxGasInvoke), Governance.GasTokenDecimals).Value,
MaxFee = (long)new BigDecimal(section.GetValue<decimal>("MaxFee", @default.MaxFee), Governance.GasTokenDecimals).Value,
MaxIteratorResultItems = section.GetValue("MaxIteratorResultItems", @default.MaxIteratorResultItems),
MaxStackSize = section.GetValue("MaxStackSize", @default.MaxStackSize),
DisabledMethods = GetStrings(section, "DisabledMethods"),
Expand Down
Loading
Loading