neo-go/pkg/vm/stackitem
Roman Khimov e34fa2e915 stackitem: limit JSONization nesting level
We can have very deep reference types and attempt to JSONize them can easily
lead to OOM (even though there are no recursive references inside). Therefore
we have to limit them. While regular ToJSON() is buffer size limited to
MaxSize, ToJSONWithTypes is not and limiting it to MaxSize output will require
substantial rewriting effort while not really providing fair result, MaxSize
is more about stack item size while its JSON representation can be much bigger
because of various overheads.

Initial thought was to limit it by element count based on
MaxIteratorResultItems, but the problem here is that we don't always have this
limit in contexts using ToJSONWithTypes (like notification event
marshaling). Thus we need some generic limit which would be fine for all
users.

We at the same time have maxJSONDepth used when deserializing from JSON, so
it can be used for marshaling as well, it's not often that we have deeper
structures in real results.

Inspired by neo-project/neo#2521.
2021-07-06 17:33:16 +03:00
..
item.go *: enable godot linter and fix all its warnings 2021-05-12 23:17:03 +03:00
item_test.go vm: handle very big int creation properly 2020-10-07 11:50:42 +03:00
json.go stackitem: limit JSONization nesting level 2021-07-06 17:33:16 +03:00
json_test.go stackitem: escape control characters in ToJSON() 2021-03-02 10:47:02 +03:00
serialization.go stackitem: properly detect recursive references during serialization 2021-07-06 17:10:31 +03:00
type.go state: allow to encode AppExecResult with recursive items 2020-12-18 13:04:31 +03:00
type_test.go stackitem: allow to convert type from string 2020-07-31 16:07:16 +03:00