Skip to content

Commit

Permalink
3.2.1 (#705)
Browse files Browse the repository at this point in the history
* add invoked contract (#657)

* add in file copyright (#679)

* witness rule support (#676)

* Prevent SSRF (#692)

* limit free gas (#697)

* add log when exception happens under debug mode (#690)

* dbft: tune MaxBlock* parameters (#688)

* Fix StateAPI.MakeFindStatesParams (#699)

* update Console to ConsoleHelper (#682)

* refac log (#700)

* Make RpcServer.ProcessAsync public to enable better neo express integration (#701)

* Limit result stack (#696)

* fix MaxBlockSystemFee (#703)

* code optimise (#704)

* Add oracle global timeout (#698)
  • Loading branch information
superboyiii authored Apr 21, 2022
1 parent 32aacc4 commit 81eb9b7
Show file tree
Hide file tree
Showing 143 changed files with 1,495 additions and 92 deletions.
3 changes: 2 additions & 1 deletion src/ApplicationLogs/ApplicationLogs/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"PluginConfiguration": {
"Path": "ApplicationLogs_{0}",
"Network": 860833102
"Network": 860833102,
"MaxStackSize": 65535
},
"Dependency": [
"RpcServer"
Expand Down
22 changes: 16 additions & 6 deletions src/ApplicationLogs/LogReader.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright (C) 2015-2021 The Neo Project.
//
// The Neo.Plugins.ApplicationLogs is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project 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.

using Neo.IO;
using Neo.IO.Data.LevelDB;
using Neo.IO.Json;
Expand Down Expand Up @@ -71,11 +81,11 @@ public static JObject TxLogToJson(Blockchain.ApplicationExecuted appExec)
trigger["gasconsumed"] = appExec.GasConsumed.ToString();
try
{
trigger["stack"] = appExec.Stack.Select(q => q.ToJson()).ToArray();
trigger["stack"] = appExec.Stack.Select(q => q.ToJson(Settings.Default.MaxStackSize)).ToArray();
}
catch (InvalidOperationException)
catch (Exception ex)
{
trigger["stack"] = "error: recursive reference";
trigger["exception"] = ex.Message;
}
trigger["notifications"] = appExec.Notifications.Select(q =>
{
Expand Down Expand Up @@ -114,11 +124,11 @@ public static JObject BlockLogToJson(Block block, IReadOnlyList<Blockchain.Appli
trigger["gasconsumed"] = appExec.GasConsumed.ToString();
try
{
trigger["stack"] = appExec.Stack.Select(q => q.ToJson()).ToArray();
trigger["stack"] = appExec.Stack.Select(q => q.ToJson(Settings.Default.MaxStackSize)).ToArray();
}
catch (InvalidOperationException)
catch (Exception ex)
{
trigger["stack"] = "error: recursive reference";
trigger["exception"] = ex.Message;
}
trigger["notifications"] = appExec.Notifications.Select(q =>
{
Expand Down
12 changes: 12 additions & 0 deletions src/ApplicationLogs/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright (C) 2015-2021 The Neo Project.
//
// The Neo.Plugins.ApplicationLogs is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project 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.

using Microsoft.Extensions.Configuration;

namespace Neo.Plugins
Expand All @@ -6,13 +16,15 @@ internal class Settings
{
public string Path { get; }
public uint Network { get; }
public int MaxStackSize { get; }

public static Settings Default { get; private set; }

private Settings(IConfigurationSection section)
{
this.Path = section.GetValue("Path", "ApplicationLogs_{0}");
this.Network = section.GetValue("Network", 5195086u);
this.MaxStackSize = section.GetValue("MaxStackSize", (int)ushort.MaxValue);
}

public static void Load(IConfigurationSection section)
Expand Down
10 changes: 10 additions & 0 deletions src/DBFTPlugin/Consensus/ConsensusContext.Get.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright (C) 2015-2021 The Neo Project.
//
// The Neo.Consensus.DBFT is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project 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.

using Neo.Network.P2P.Payloads;
using Neo.SmartContract;
using Neo.Wallets;
Expand Down
13 changes: 12 additions & 1 deletion src/DBFTPlugin/Consensus/ConsensusContext.MakePayload.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright (C) 2015-2021 The Neo Project.
//
// The Neo.Consensus.DBFT is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project 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.

using Neo.Ledger;
using Neo.Network.P2P.Payloads;
using Neo.SmartContract;
Expand Down Expand Up @@ -47,8 +57,9 @@ private void SignPayload(ExtensiblePayload payload)
sc = new ContractParametersContext(neoSystem.StoreView, payload, dbftSettings.Network);
wallet.Sign(sc);
}
catch (InvalidOperationException)
catch (InvalidOperationException exception)
{
Utility.Log(nameof(ConsensusContext), LogLevel.Debug, exception.ToString());
return;
}
payload.Witness = sc.GetWitnesses()[0];
Expand Down
13 changes: 12 additions & 1 deletion src/DBFTPlugin/Consensus/ConsensusContext.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright (C) 2015-2021 The Neo Project.
//
// The Neo.Consensus.DBFT is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project 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.

using Neo.Cryptography;
using Neo.Cryptography.ECC;
using Neo.IO;
Expand Down Expand Up @@ -160,8 +170,9 @@ public bool Load()
{
Deserialize(reader);
}
catch
catch (Exception exception)
{
Utility.Log(nameof(ConsensusContext), LogLevel.Debug, exception.ToString());
return false;
}
return true;
Expand Down
10 changes: 10 additions & 0 deletions src/DBFTPlugin/Consensus/ConsensusService.Check.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright (C) 2015-2021 The Neo Project.
//
// The Neo.Consensus.DBFT is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project 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.

using Akka.Actor;
using Neo.IO;
using Neo.Network.P2P;
Expand Down
18 changes: 13 additions & 5 deletions src/DBFTPlugin/Consensus/ConsensusService.OnMessage.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright (C) 2015-2021 The Neo Project.
//
// The Neo.Consensus.DBFT is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project 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.

using Akka.Actor;
using Neo.Cryptography;
using Neo.IO;
Expand All @@ -24,14 +34,12 @@ private void OnConsensusPayload(ExtensiblePayload payload)
{
message = context.GetMessage(payload);
}
catch (FormatException)
{
return;
}
catch (IOException)
catch (Exception ex)
{
Utility.Log(nameof(ConsensusService), LogLevel.Debug, ex.ToString());
return;
}

if (!message.Verify(neoSystem.Settings)) return;
if (message.BlockIndex != context.Block.Index)
{
Expand Down
10 changes: 10 additions & 0 deletions src/DBFTPlugin/Consensus/ConsensusService.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright (C) 2015-2021 The Neo Project.
//
// The Neo.Consensus.DBFT is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project 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.

using Akka.Actor;
using Neo.IO;
using Neo.Ledger;
Expand Down
24 changes: 16 additions & 8 deletions src/DBFTPlugin/DBFTPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright (C) 2015-2021 The Neo Project.
//
// The Neo.Consensus.DBFT is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project 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.

using Akka.Actor;
using Neo.ConsoleService;
using Neo.Network.P2P;
Expand Down Expand Up @@ -25,7 +35,7 @@ public DBFTPlugin(Settings settings)

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

protected override void OnSystemLoaded(NeoSystem system)
Expand All @@ -37,14 +47,12 @@ protected override void OnSystemLoaded(NeoSystem system)

private void NeoSystem_ServiceAdded(object sender, object service)
{
if (service is IWalletProvider)
if (service is not IWalletProvider provider) return;
walletProvider = provider;
neoSystem.ServiceAdded -= NeoSystem_ServiceAdded;
if (settings.AutoStart)
{
walletProvider = service as IWalletProvider;
neoSystem.ServiceAdded -= NeoSystem_ServiceAdded;
if (settings.AutoStart)
{
walletProvider.WalletChanged += WalletProvider_WalletChanged;
}
walletProvider.WalletChanged += WalletProvider_WalletChanged;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/DBFTPlugin/DBFTPlugin/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"IgnoreRecoveryLogs": false,
"AutoStart": false,
"Network": 860833102,
"MaxBlockSize": 262144,
"MaxBlockSystemFee": 900000000000
"MaxBlockSize": 2097152,
"MaxBlockSystemFee": 150000000000
}
}
10 changes: 10 additions & 0 deletions src/DBFTPlugin/Messages/ChangeView.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright (C) 2015-2021 The Neo Project.
//
// The Neo.Consensus.DBFT is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project 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.

using System.IO;

namespace Neo.Consensus
Expand Down
10 changes: 10 additions & 0 deletions src/DBFTPlugin/Messages/Commit.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright (C) 2015-2021 The Neo Project.
//
// The Neo.Consensus.DBFT is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project 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.

using Neo.IO;
using System.IO;

Expand Down
10 changes: 10 additions & 0 deletions src/DBFTPlugin/Messages/ConsensusMessage.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright (C) 2015-2021 The Neo Project.
//
// The Neo.Consensus.DBFT is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project 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.

using Neo.IO;
using System;
using System.IO;
Expand Down
10 changes: 10 additions & 0 deletions src/DBFTPlugin/Messages/PrepareRequest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright (C) 2015-2021 The Neo Project.
//
// The Neo.Consensus.DBFT is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project 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.

using Neo.IO;
using System;
using System.IO;
Expand Down
10 changes: 10 additions & 0 deletions src/DBFTPlugin/Messages/PrepareResponse.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright (C) 2015-2021 The Neo Project.
//
// The Neo.Consensus.DBFT is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project 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.

using Neo.IO;
using System.IO;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright (C) 2015-2021 The Neo Project.
//
// The Neo.Consensus.DBFT is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project 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.

using Neo.IO;
using System.IO;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright (C) 2015-2021 The Neo Project.
//
// The Neo.Consensus.DBFT is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project 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.

using Neo.IO;
using System;
using System.IO;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright (C) 2015-2021 The Neo Project.
//
// The Neo.Consensus.DBFT is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project 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.

using Neo.IO;
using System.IO;

Expand Down
10 changes: 10 additions & 0 deletions src/DBFTPlugin/Messages/RecoveryMessage/RecoveryMessage.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright (C) 2015-2021 The Neo Project.
//
// The Neo.Consensus.DBFT is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project 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.

using Neo.IO;
using Neo.Network.P2P.Payloads;
using System;
Expand Down
Loading

0 comments on commit 81eb9b7

Please sign in to comment.