From 711e6c69128aa859bce7a9e3cdb360b7e15a7c55 Mon Sep 17 00:00:00 2001 From: Igor Machado Date: Thu, 29 Aug 2019 12:29:42 +0800 Subject: [PATCH 1/3] empty scripthash, all notifications --- neo/SmartContract/InteropService.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/neo/SmartContract/InteropService.cs b/neo/SmartContract/InteropService.cs index 8651dfbc3d..3795c5943d 100644 --- a/neo/SmartContract/InteropService.cs +++ b/neo/SmartContract/InteropService.cs @@ -236,14 +236,16 @@ private static bool Runtime_Serialize(ApplicationEngine engine) private static bool Runtime_GetNotifications(ApplicationEngine engine) { - var data = engine.CurrentContext.EvaluationStack.Pop().GetByteArray(); - if (data.Length != UInt160.Length) return false; + byte[] data = engine.CurrentContext.EvaluationStack.Pop().GetByteArray(); + if ((data.Length != 0) || (data.Length != UInt160.Length)) return false; if (!engine.CheckArraySize(engine.Notifications.Count)) return false; - var hash = new UInt160(data); IEnumerable notifications = engine.Notifications; - if (!hash.Equals(UInt160.Zero)) + if (data.Length == UInt160.Length) // must filter by scriptHash + { + var hash = new UInt160(data); notifications = notifications.Where(p => p.ScriptHash == hash); + } engine.CurrentContext.EvaluationStack.Push(notifications.Select(u => new VM.Types.Array(new StackItem[] { u.ScriptHash.ToArray(), u.State })).ToArray()); return true; From 9683bf0326959c3c7b6766851191396600abf851 Mon Sep 17 00:00:00 2001 From: Igor Machado Date: Thu, 29 Aug 2019 12:32:46 +0800 Subject: [PATCH 2/3] || to && --- neo/SmartContract/InteropService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neo/SmartContract/InteropService.cs b/neo/SmartContract/InteropService.cs index 3795c5943d..82ee91cbe2 100644 --- a/neo/SmartContract/InteropService.cs +++ b/neo/SmartContract/InteropService.cs @@ -237,7 +237,7 @@ private static bool Runtime_Serialize(ApplicationEngine engine) private static bool Runtime_GetNotifications(ApplicationEngine engine) { byte[] data = engine.CurrentContext.EvaluationStack.Pop().GetByteArray(); - if ((data.Length != 0) || (data.Length != UInt160.Length)) return false; + if ((data.Length != 0) && (data.Length != UInt160.Length)) return false; if (!engine.CheckArraySize(engine.Notifications.Count)) return false; IEnumerable notifications = engine.Notifications; From 06a05abdeba5e72c80f3748c77d1cc2954630222 Mon Sep 17 00:00:00 2001 From: Shargon Date: Thu, 29 Aug 2019 11:16:57 +0200 Subject: [PATCH 3/3] Fix ut --- neo.UnitTests/SmartContract/UT_InteropService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neo.UnitTests/SmartContract/UT_InteropService.cs b/neo.UnitTests/SmartContract/UT_InteropService.cs index 39687fd720..6a33a32abc 100644 --- a/neo.UnitTests/SmartContract/UT_InteropService.cs +++ b/neo.UnitTests/SmartContract/UT_InteropService.cs @@ -85,7 +85,7 @@ public void Runtime_GetNotifications_Test() // Receive all notifications - script.EmitPush(UInt160.Zero.ToArray()); + script.EmitPush(new byte[0]); script.EmitSysCall(InteropService.System_Runtime_GetNotifications); // Execute