neo-go/pkg
Anna Shaleva effba1fa47 core: ensure System.Runtime.GetNotifications can't break MaxStackSize
This test ensures that NeoGo node doesn't have the DeepCopy problem
described in https://github.com/neo-project/neo/issues/3300 and fixed in
https://github.com/neo-project/neo/pull/3301. This problem leads to the
fact that Notifications items are not being properly refcounted by C#
node which leads to possibility to build an enormously large object on
stack. Go node doesn't have this problem.

The reason (at least, as I understand it) is in the fact that C# node
performs objects refcounting inside the DeepCopy even if the object
itself is not yet on stack. I.e. System.Runtime.Notify handler
immediately adds references to the notification argumetns inside
DeepCopy:
b1d27f0189/src/Neo.VM/Types/Array.cs (L108)
b1d27f0189/src/Neo.VM/Types/Array.cs (L75)

Whereas Go node just performs the honest DeepCopy without references counting:
b66cea5ccc/pkg/vm/stackitem/item.go (L1223)

Going further, C# node clears refs for notification arguments (for array
and underlying array items). System.Runtime.GetNotifications pushes the
notificaiton args array back on stack and increments counter only for
the external array, not for its arguments. Which results in negative
refcounter once notificaiton is removed from the stack. The fix itself
(f471c0542d/src/Neo/SmartContract/NotifyEventArgs.cs (L84))
doesn't need to be ported to NeoGo because Go node adds object to the
refcounter only at the moment when it's being pushed to stack by
System.Runtime.GetNotifications handler. This object is treated as new
object since it was deepcopied earlier by System.Runtime.Notify handler:
b66cea5ccc/pkg/vm/stack.go (L178).

Thus, no functoinal changes from the NeoGo side. And we won't
intentionally break our node to follow C# pre-Domovoi invalid behaviour.

Close #3484, close #3482.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-06-11 17:51:41 +03:00
..
compiler native: autogenerate nativehashes package 2024-05-14 09:39:53 +03:00
config config, native: introduce Cockatrice hard-fork 2024-04-25 13:26:54 +03:00
consensus consensus: use better dbFT 2024-03-25 19:21:51 +03:00
core core: ensure System.Runtime.GetNotifications can't break MaxStackSize 2024-06-11 17:51:41 +03:00
crypto crypto: export GetSignedData function 2024-05-13 09:33:42 +03:00
encoding *: drop go 1.18 support in doc and build targets 2023-10-12 17:59:42 +03:00
interop core: move P2PNotary node role out of P2PSigExtensions 2024-05-21 12:10:47 +03:00
io *: replace interface{} with any keyword 2023-04-04 13:22:42 +03:00
neorpc rpcsrv: add SessionEnabled, MaxIteratorResultItems to getversion 2024-04-03 22:42:14 +03:00
neotest crypto: add StringCompressed() for PublicKey 2024-04-11 15:24:46 +03:00
network network: extend errInvalidInvType error 2024-06-05 15:32:43 +03:00
rpcclient Merge pull request #3438 from nspcc-dev/unwrap-fault-exception 2024-05-17 10:24:26 +03:00
services oracle: add length check o.MainCfg.NeoFS.Nodes 2024-06-05 11:53:52 +03:00
smartcontract smartcontract: ensure nil ParameterContext Item's script is marshallable 2024-04-18 13:55:05 +03:00
util *: replace slice.Copy with bytes.Clone 2024-03-05 13:54:10 +03:00
vm stackitem: extend Make() with []string 2024-06-11 17:50:53 +03:00
wallet wallet: do not store deployed contract script inside Contract account 2024-06-05 15:27:20 +03:00