Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
18 changes: 18 additions & 0 deletions src/Neo/Plugins/IPluginSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (C) 2015-2025 The Neo Project.
//
// IPluginSettings.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
// for more details.
//
// Redistribution and use in source and binary forms with or without
// modifications are permitted.

namespace Neo.Plugins
{
public interface IPluginSettings
{
public UnhandledExceptionPolicy ExceptionPolicy { get; }
}
}
38 changes: 0 additions & 38 deletions src/Neo/Plugins/PluginSettings.cs

This file was deleted.

34 changes: 17 additions & 17 deletions src/Plugins/ApplicationLogs/LogReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class LogReader : Plugin, ICommittingHandler, ICommittedHandler, ILogHand

public override string Name => "ApplicationLogs";
public override string Description => "Synchronizes smart contract VM executions and notifications (NotifyLog) on blockchain.";
protected override UnhandledExceptionPolicy ExceptionPolicy => Settings.Default.ExceptionPolicy;
protected override UnhandledExceptionPolicy ExceptionPolicy => ApplicationLogsSettings.Default.ExceptionPolicy;

#region Ctor

Expand All @@ -61,7 +61,7 @@ public override void Dispose()
{
Blockchain.Committing -= ((ICommittingHandler)this).Blockchain_Committing_Handler;
Blockchain.Committed -= ((ICommittedHandler)this).Blockchain_Committed_Handler;
if (Settings.Default.Debug)
if (ApplicationLogsSettings.Default.Debug)
ApplicationEngine.InstanceHandler -= ConfigureAppEngine;
GC.SuppressFinalize(this);
}
Expand All @@ -73,20 +73,20 @@ private void ConfigureAppEngine(ApplicationEngine engine)

protected override void Configure()
{
Settings.Load(GetConfiguration());
ApplicationLogsSettings.Load(GetConfiguration());
}

protected override void OnSystemLoaded(NeoSystem system)
{
if (system.Settings.Network != Settings.Default.Network)
if (system.Settings.Network != ApplicationLogsSettings.Default.Network)
return;
string path = string.Format(Settings.Default.Path, Settings.Default.Network.ToString("X8"));
string path = string.Format(ApplicationLogsSettings.Default.Path, ApplicationLogsSettings.Default.Network.ToString("X8"));
var store = system.LoadStore(GetFullPath(path));
_neostore = new NeoStore(store);
_neosystem = system;
RpcServerPlugin.RegisterMethods(this, Settings.Default.Network);
RpcServerPlugin.RegisterMethods(this, ApplicationLogsSettings.Default.Network);

if (Settings.Default.Debug)
if (ApplicationLogsSettings.Default.Debug)
ApplicationEngine.InstanceHandler += ConfigureAppEngine;
}

Expand Down Expand Up @@ -217,14 +217,14 @@ internal void OnGetContractCommand(UInt160 scripthash, uint page = 1, uint pageS

void ICommittingHandler.Blockchain_Committing_Handler(NeoSystem system, Block block, DataCache snapshot, IReadOnlyList<Blockchain.ApplicationExecuted> applicationExecutedList)
{
if (system.Settings.Network != Settings.Default.Network)
if (system.Settings.Network != ApplicationLogsSettings.Default.Network)
return;

if (_neostore is null)
return;
_neostore.StartBlockLogBatch();
_neostore.PutBlockLog(block, applicationExecutedList);
if (Settings.Default.Debug)
if (ApplicationLogsSettings.Default.Debug)
{
foreach (var appEng in applicationExecutedList.Where(w => w.Transaction != null))
{
Expand All @@ -238,7 +238,7 @@ void ICommittingHandler.Blockchain_Committing_Handler(NeoSystem system, Block bl

void ICommittedHandler.Blockchain_Committed_Handler(NeoSystem system, Block block)
{
if (system.Settings.Network != Settings.Default.Network)
if (system.Settings.Network != ApplicationLogsSettings.Default.Network)
return;
if (_neostore is null)
return;
Expand All @@ -247,10 +247,10 @@ void ICommittedHandler.Blockchain_Committed_Handler(NeoSystem system, Block bloc

void ILogHandler.ApplicationEngine_Log_Handler(ApplicationEngine sender, LogEventArgs e)
{
if (Settings.Default.Debug == false)
if (ApplicationLogsSettings.Default.Debug == false)
return;

if (_neosystem.Settings.Network != Settings.Default.Network)
if (_neosystem.Settings.Network != ApplicationLogsSettings.Default.Network)
return;

if (e.ScriptContainer == null)
Expand Down Expand Up @@ -296,7 +296,7 @@ private void PrintExecutionToConsole(BlockchainExecutionModel model)
ConsoleHelper.Info($" {GetMethodParameterName(notifyItem.ScriptHash, notifyItem.EventName, ncount, i)}: ", $"{notifyItem.State[i].ToJson()}");
}
}
if (Settings.Default.Debug)
if (ApplicationLogsSettings.Default.Debug)
{
if (model.Logs.Length == 0)
ConsoleHelper.Info("Logs: ", "[]");
Expand Down Expand Up @@ -366,7 +366,7 @@ private JObject EventModelToJObject(BlockchainEventModel model)

try
{
trigger["stack"] = appLog.Stack.Select(s => s.ToJson(Settings.Default.MaxStackSize)).ToArray();
trigger["stack"] = appLog.Stack.Select(s => s.ToJson(ApplicationLogsSettings.Default.MaxStackSize)).ToArray();
}
catch (Exception ex)
{
Expand Down Expand Up @@ -399,7 +399,7 @@ private JObject EventModelToJObject(BlockchainEventModel model)
return notification;
}).ToArray();

if (Settings.Default.Debug)
if (ApplicationLogsSettings.Default.Debug)
{
trigger["logs"] = appLog.Logs.Select(s =>
{
Expand Down Expand Up @@ -445,7 +445,7 @@ private JObject BlockItemToJObject(BlockchainExecutionModel blockExecutionModel)
};
try
{
trigger["stack"] = blockExecutionModel.Stack.Select(q => q.ToJson(Settings.Default.MaxStackSize)).ToArray();
trigger["stack"] = blockExecutionModel.Stack.Select(q => q.ToJson(ApplicationLogsSettings.Default.MaxStackSize)).ToArray();
}
catch (Exception ex)
{
Expand Down Expand Up @@ -476,7 +476,7 @@ private JObject BlockItemToJObject(BlockchainExecutionModel blockExecutionModel)
return notification;
}).ToArray();

if (Settings.Default.Debug)
if (ApplicationLogsSettings.Default.Debug)
{
trigger["logs"] = blockExecutionModel.Logs.Select(s =>
{
Expand Down
11 changes: 7 additions & 4 deletions src/Plugins/ApplicationLogs/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,30 @@

namespace Neo.Plugins.ApplicationLogs
{
internal class Settings : PluginSettings
internal class ApplicationLogsSettings : IPluginSettings
{
public string Path { get; }
public uint Network { get; }
public int MaxStackSize { get; }

public bool Debug { get; }

public static Settings Default { get; private set; } = default!;
public static ApplicationLogsSettings Default { get; private set; } = default!;

private Settings(IConfigurationSection section) : base(section)
public UnhandledExceptionPolicy ExceptionPolicy { get; }

private ApplicationLogsSettings(IConfigurationSection section)
{
Path = section.GetValue("Path", "ApplicationLogs_{0}");
Network = section.GetValue("Network", 5195086u);
MaxStackSize = section.GetValue("MaxStackSize", (int)ushort.MaxValue);
Debug = section.GetValue("Debug", false);
ExceptionPolicy = section.GetValue("UnhandledExceptionPolicy", UnhandledExceptionPolicy.Ignore);
}

public static void Load(IConfigurationSection section)
{
Default = new Settings(section);
Default = new ApplicationLogsSettings(section);
}
}
}
4 changes: 2 additions & 2 deletions src/Plugins/ApplicationLogs/Store/LogStorageStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ public Guid PutStackItemState(StackItem stackItem)
{
_snapshot.Put(key, BinarySerializer.Serialize(stackItem, ExecutionEngineLimits.Default with
{
MaxItemSize = (uint)Settings.Default.MaxStackSize
MaxItemSize = (uint)ApplicationLogsSettings.Default.MaxStackSize
}));
}
catch
{
_snapshot.Put(key, BinarySerializer.Serialize(StackItem.Null, ExecutionEngineLimits.Default with
{
MaxItemSize = (uint)Settings.Default.MaxStackSize
MaxItemSize = (uint)ApplicationLogsSettings.Default.MaxStackSize
}));
}
return id;
Expand Down
4 changes: 2 additions & 2 deletions src/Plugins/DBFTPlugin/Consensus/ConsensusContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public partial class ConsensusContext : IDisposable, ISerializable
private ECPoint _myPublicKey;
private int _witnessSize;
private readonly NeoSystem neoSystem;
private readonly Settings dbftSettings;
private readonly DbftSettings dbftSettings;
private readonly ISigner _signer;
private readonly IStore store;
private Dictionary<UInt256, ConsensusMessage> cachedMessages;
Expand Down Expand Up @@ -113,7 +113,7 @@ public bool ValidatorsChanged

public int Size => throw new NotImplementedException();

public ConsensusContext(NeoSystem neoSystem, Settings settings, ISigner signer)
public ConsensusContext(NeoSystem neoSystem, DbftSettings settings, ISigner signer)
{
_signer = signer;
this.neoSystem = neoSystem;
Expand Down
8 changes: 4 additions & 4 deletions src/Plugins/DBFTPlugin/Consensus/ConsensusService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ private class Timer { public uint Height; public byte ViewNumber; }
/// This variable is only true during OnRecoveryMessageReceived
/// </summary>
private bool isRecovering = false;
private readonly Settings dbftSettings;
private readonly DbftSettings dbftSettings;
private readonly NeoSystem neoSystem;

public ConsensusService(NeoSystem neoSystem, Settings settings, ISigner signer)
public ConsensusService(NeoSystem neoSystem, DbftSettings settings, ISigner signer)
: this(neoSystem, settings, new ConsensusContext(neoSystem, settings, signer)) { }

internal ConsensusService(NeoSystem neoSystem, Settings settings, ConsensusContext context)
internal ConsensusService(NeoSystem neoSystem, DbftSettings settings, ConsensusContext context)
{
this.neoSystem = neoSystem;
localNode = neoSystem.LocalNode;
Expand Down Expand Up @@ -336,7 +336,7 @@ protected override void PostStop()
base.PostStop();
}

public static Props Props(NeoSystem neoSystem, Settings dbftSettings, ISigner signer)
public static Props Props(NeoSystem neoSystem, DbftSettings dbftSettings, ISigner signer)
{
return Akka.Actor.Props.Create(() => new ConsensusService(neoSystem, dbftSettings, signer));
}
Expand Down
6 changes: 3 additions & 3 deletions src/Plugins/DBFTPlugin/DBFTPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class DBFTPlugin : Plugin, IServiceAddedHandler, IMessageReceivedHandler,
private IActorRef consensus;
private bool started = false;
private NeoSystem neoSystem;
private Settings settings;
private DbftSettings settings;

public override string Description => "Consensus plugin with dBFT algorithm.";

Expand All @@ -39,7 +39,7 @@ public DBFTPlugin()
RemoteNode.MessageReceived += ((IMessageReceivedHandler)this).RemoteNode_MessageReceived_Handler;
}

public DBFTPlugin(Settings settings) : this()
public DBFTPlugin(DbftSettings settings) : this()
{
this.settings = settings;
}
Expand All @@ -51,7 +51,7 @@ public override void Dispose()

protected override void Configure()
{
settings ??= new Settings(GetConfiguration());
settings ??= new DbftSettings(GetConfiguration());
}

protected override void OnSystemLoaded(NeoSystem system)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2015-2025 The Neo Project.
//
// Settings.cs file belongs to the neo project and is free
// DbftSettings.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
Expand All @@ -13,7 +13,7 @@

namespace Neo.Plugins.DBFTPlugin
{
public class Settings : PluginSettings
public class DbftSettings : IPluginSettings
{
public string RecoveryLogs { get; }
public bool IgnoreRecoveryLogs { get; }
Expand All @@ -22,14 +22,19 @@ public class Settings : PluginSettings
public uint MaxBlockSize { get; }
public long MaxBlockSystemFee { get; }

public Settings(IConfigurationSection section) : base(section)
public UnhandledExceptionPolicy ExceptionPolicy { get; }

public DbftSettings() { }

public DbftSettings(IConfigurationSection section)
{
RecoveryLogs = section.GetValue("RecoveryLogs", "ConsensusState");
IgnoreRecoveryLogs = section.GetValue("IgnoreRecoveryLogs", false);
AutoStart = section.GetValue("AutoStart", false);
Network = section.GetValue("Network", 5195086u);
MaxBlockSize = section.GetValue("MaxBlockSize", 262144u);
MaxBlockSystemFee = section.GetValue("MaxBlockSystemFee", 150000000000L);
ExceptionPolicy = section.GetValue("UnhandledExceptionPolicy", UnhandledExceptionPolicy.StopNode);
}
}
}
Loading
Loading