From 527b8852dffb6d6889551c44cef1dbf5573d0a3a Mon Sep 17 00:00:00 2001 From: superboyiii <573504781@qq.com> Date: Thu, 30 Nov 2023 10:51:04 +0800 Subject: [PATCH 1/6] Fix stack exception name --- src/ApplicationLogs/LogReader.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ApplicationLogs/LogReader.cs b/src/ApplicationLogs/LogReader.cs index 71a9253f0..40a4225cf 100644 --- a/src/ApplicationLogs/LogReader.cs +++ b/src/ApplicationLogs/LogReader.cs @@ -96,7 +96,7 @@ public static JObject TxLogToJson(Blockchain.ApplicationExecuted appExec) } catch (Exception ex) { - trigger["exception"] = ex.Message; + trigger["stackexception"] = ex.Message; } trigger["notifications"] = appExec.Notifications.Select(q => { @@ -139,7 +139,7 @@ public static JObject BlockLogToJson(Block block, IReadOnlyList { From e7e3e8fe38066e4ac2ecd17cbf00eddf08e9d3ef Mon Sep 17 00:00:00 2001 From: superboyiii <573504781@qq.com> Date: Thu, 30 Nov 2023 16:29:33 +0800 Subject: [PATCH 2/6] fix stack --- src/ApplicationLogs/LogReader.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ApplicationLogs/LogReader.cs b/src/ApplicationLogs/LogReader.cs index 40a4225cf..5f0b13860 100644 --- a/src/ApplicationLogs/LogReader.cs +++ b/src/ApplicationLogs/LogReader.cs @@ -94,9 +94,9 @@ public static JObject TxLogToJson(Blockchain.ApplicationExecuted appExec) { trigger["stack"] = appExec.Stack.Select(q => q.ToJson(Settings.Default.MaxStackSize)).ToArray(); } - catch (Exception ex) + catch (InvalidOperationException) { - trigger["stackexception"] = ex.Message; + trigger["stack"] = "error: invalid operation"; } trigger["notifications"] = appExec.Notifications.Select(q => { @@ -137,9 +137,9 @@ public static JObject BlockLogToJson(Block block, IReadOnlyList q.ToJson(Settings.Default.MaxStackSize)).ToArray(); } - catch (Exception ex) + catch (InvalidOperationException) { - trigger["stackexception"] = ex.Message; + trigger["stack"] = "error: invalid operation"; } trigger["notifications"] = appExec.Notifications.Select(q => { From 2ced172aea207807d467bf5a951c0ed706a7b8e5 Mon Sep 17 00:00:00 2001 From: superboyiii <573504781@qq.com> Date: Fri, 1 Dec 2023 17:38:29 +0800 Subject: [PATCH 3/6] show all type and value of stack item --- src/ApplicationLogs/LogReader.cs | 33 ++++++++++++------- .../Neo.Network.RPC.Tests.csproj | 2 +- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/ApplicationLogs/LogReader.cs b/src/ApplicationLogs/LogReader.cs index 5f0b13860..5cab4cb9c 100644 --- a/src/ApplicationLogs/LogReader.cs +++ b/src/ApplicationLogs/LogReader.cs @@ -90,14 +90,19 @@ public static JObject TxLogToJson(Blockchain.ApplicationExecuted appExec) trigger["vmstate"] = appExec.VMState; trigger["exception"] = GetExceptionMessage(appExec.Exception); trigger["gasconsumed"] = appExec.GasConsumed.ToString(); - try + var stack = new JArray(); + foreach (var item in appExec.Stack) { - trigger["stack"] = appExec.Stack.Select(q => q.ToJson(Settings.Default.MaxStackSize)).ToArray(); - } - catch (InvalidOperationException) - { - trigger["stack"] = "error: invalid operation"; + try + { + stack.Add(item.ToJson()); + } + catch (InvalidOperationException) + { + stack.Add("error: invalid operation"); + } } + trigger["stack"] = stack; trigger["notifications"] = appExec.Notifications.Select(q => { JObject notification = new JObject(); @@ -133,13 +138,17 @@ public static JObject BlockLogToJson(Block block, IReadOnlyList q.ToJson(Settings.Default.MaxStackSize)).ToArray(); - } - catch (InvalidOperationException) - { - trigger["stack"] = "error: invalid operation"; + try + { + stack.Add(item.ToJson()); + } + catch (InvalidOperationException) + { + stack.Add("error: invalid operation"); + } } trigger["notifications"] = appExec.Notifications.Select(q => { diff --git a/tests/Neo.Network.RPC.Tests/Neo.Network.RPC.Tests.csproj b/tests/Neo.Network.RPC.Tests/Neo.Network.RPC.Tests.csproj index 9815f51e9..cc278b16a 100644 --- a/tests/Neo.Network.RPC.Tests/Neo.Network.RPC.Tests.csproj +++ b/tests/Neo.Network.RPC.Tests/Neo.Network.RPC.Tests.csproj @@ -24,7 +24,7 @@ - + From 78d62b37a51189cb9a142c8abdb59135b976bed5 Mon Sep 17 00:00:00 2001 From: superboyiii <573504781@qq.com> Date: Mon, 4 Dec 2023 10:45:09 +0800 Subject: [PATCH 4/6] fix for GetInvokeResult --- src/ApplicationLogs/LogReader.cs | 4 ++-- src/RpcServer/RpcServer.SmartContract.cs | 17 +++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/ApplicationLogs/LogReader.cs b/src/ApplicationLogs/LogReader.cs index 5cab4cb9c..a3a233b6f 100644 --- a/src/ApplicationLogs/LogReader.cs +++ b/src/ApplicationLogs/LogReader.cs @@ -95,7 +95,7 @@ public static JObject TxLogToJson(Blockchain.ApplicationExecuted appExec) { try { - stack.Add(item.ToJson()); + stack.Add(item.ToJson(Settings.Default.MaxStackSize)); } catch (InvalidOperationException) { @@ -143,7 +143,7 @@ public static JObject BlockLogToJson(Block block, IReadOnlyList ToJson(p, session))); - } - catch (InvalidOperationException) - { - json["stack"] = "error: invalid operation"; + try + { + stack.Add(ToJson(item, session)); + } + catch (InvalidOperationException) + { + stack.Add("error: invalid operation"); + } } + json["stack"] = stack; if (session.Engine.State != VMState.FAULT) { ProcessInvokeWithWallet(json, signers); From a6bf3a190d2cddb5232251b23e994c0c7ba573c4 Mon Sep 17 00:00:00 2001 From: superboyiii <573504781@qq.com> Date: Mon, 4 Dec 2023 17:22:26 +0800 Subject: [PATCH 5/6] catch all exceptions --- src/ApplicationLogs/LogReader.cs | 9 +++++---- src/RpcServer/RpcServer.SmartContract.cs | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ApplicationLogs/LogReader.cs b/src/ApplicationLogs/LogReader.cs index a3a233b6f..5423a607c 100644 --- a/src/ApplicationLogs/LogReader.cs +++ b/src/ApplicationLogs/LogReader.cs @@ -97,9 +97,9 @@ public static JObject TxLogToJson(Blockchain.ApplicationExecuted appExec) { stack.Add(item.ToJson(Settings.Default.MaxStackSize)); } - catch (InvalidOperationException) + catch (Exception ex) { - stack.Add("error: invalid operation"); + stack.Add("error: " + ex); } } trigger["stack"] = stack; @@ -145,11 +145,12 @@ public static JObject BlockLogToJson(Block block, IReadOnlyList { JObject notification = new JObject(); diff --git a/src/RpcServer/RpcServer.SmartContract.cs b/src/RpcServer/RpcServer.SmartContract.cs index 3bf27293b..89df78fa9 100644 --- a/src/RpcServer/RpcServer.SmartContract.cs +++ b/src/RpcServer/RpcServer.SmartContract.cs @@ -100,9 +100,9 @@ private JObject GetInvokeResult(byte[] script, Signer[] signers = null, Witness[ { stack.Add(ToJson(item, session)); } - catch (InvalidOperationException) + catch (Exception ex) { - stack.Add("error: invalid operation"); + stack.Add("error: " + ex); } } json["stack"] = stack; From b20549651bda36c6672609ce3f21cc7d6ad5bc16 Mon Sep 17 00:00:00 2001 From: superboyiii <573504781@qq.com> Date: Tue, 5 Dec 2023 16:56:50 +0800 Subject: [PATCH 6/6] fix-message --- src/ApplicationLogs/LogReader.cs | 4 ++-- src/RpcServer/RpcServer.SmartContract.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ApplicationLogs/LogReader.cs b/src/ApplicationLogs/LogReader.cs index 5423a607c..4d5c7bbc8 100644 --- a/src/ApplicationLogs/LogReader.cs +++ b/src/ApplicationLogs/LogReader.cs @@ -99,7 +99,7 @@ public static JObject TxLogToJson(Blockchain.ApplicationExecuted appExec) } catch (Exception ex) { - stack.Add("error: " + ex); + stack.Add("error: " + ex.Message); } } trigger["stack"] = stack; @@ -147,7 +147,7 @@ public static JObject BlockLogToJson(Block block, IReadOnlyList