Roman Khimov
5a9efcc654
stackitem: rework error handling
...
Return good named errors everywhere, export appropriate constants, make
errors.Is() work.
2021-07-07 00:18:00 +03:00
Roman Khimov
0de949b575
stackitem: remove Item/StackItem from function names
...
They're useless in a package named 'stackitem', make this package a bit more
user-friendly.
2021-07-06 19:56:23 +03:00
Roman Khimov
b9ff07f32c
stackitem: add limit to serialized items
...
Standard binary serialization/deserialization is mostly used in VM to put/get
elements into/from storage, so they never should exceed MaxSize (otherwise one
won't be able to deserialize these items).
This patch leaves EncodeBinaryStackItem unprotected, but that's a streaming
interface, so it's up to the user of it to ensure its appropriate use (and our
uses are mostly for native contract's data, so they're fine).
2021-07-06 19:34:02 +03:00
Roman Khimov
8472064bbc
stackitem: refactor serialization code, add explicit context
2021-07-06 19:32:52 +03:00
Roman Khimov
1b7b7e4bec
stackitem: don't overwrite error when serializing Item
...
We must get out as quickly as possible.
2021-07-06 17:51:46 +03:00
Roman Khimov
6879cbcdcc
stackitem: properly detect recursive references during serialization
...
If we're done with element it no longer can lead to recursion error, so fix
cases like `[arr, arr]` where we have two copies of `arr` trigger this error
for no good reason (there is no recursion there).
2021-07-06 17:10:31 +03:00
Evgeniy Stratonikov
8d67a03aec
stackitem: fix Buffer
deserialization
...
Fix incorrect application log for transaction in N3 testnet
8eb4076f1f1c07e693eda7e810779488a2d2b50aba9b727fd237cbc3adbec9e9
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-06-29 11:39:55 +03:00
Evgenii Stratonikov
8c22d27acc
state: allow to encode AppExecResult with recursive items
...
1. Encode them to a special type, decode to `nil`.
2. `Interop` can be encoded in JSON, this info should also be preserved.
2020-12-18 13:04:31 +03:00
Roman Khimov
0120a8f239
stackitem: limit buffer/bytearray reads upon deserialization
...
This is not the way it's done in C#, but that's the most sensible approach to
me.
2020-10-07 23:08:20 +03:00
Roman Khimov
64e9775707
vm/stackitem: limit reads for bigint values
...
They can't exceed 33 bytes.
2020-10-07 23:07:10 +03:00
Anna Shaleva
29f1e646ed
vm: fix stackitem serialisation
...
We're able to serialise Buffer stackitem, but can not deserealise it
which leads to errors. Fixed.
2020-07-06 15:04:19 +03:00
Evgenii Stratonikov
a980cac0b3
stackitem: support Null item (de-)serialization
...
It's binary representation contains just type (AnyT).
2020-06-19 11:38:56 +03:00
Anna Shaleva
7ca2807875
vm/encoding: move bigint from vm to encoding package
2020-06-08 13:27:13 +03:00
Anna Shaleva
783f5ecb01
vm: move StackItem to a separate package
...
closes #912
2020-06-08 13:27:08 +03:00