Anna Shaleva
25ed5fcd60
vm: allow custom limit duing Map\Array\Struct deserialization
2023-02-08 10:58:55 +03:00
Anna Shaleva
15fa65d30f
vm: export stackitem's deserContext
2023-02-08 10:58:54 +03:00
Evgeniy Stratonikov
db977ce38d
vm: add fuzz test for ParseMultiSigContract
...
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-12-28 11:50:15 +03:00
Anna Shaleva
2d6db6f5c4
vm: adjust stale comment
2022-12-07 17:30:02 +03:00
Anna Shaleva
82221b0ca7
*: fix Neo and NeoGo misuses
2022-12-07 17:29:09 +03:00
Roman Khimov
f6a9969fa8
Merge pull request #2770 from nspcc-dev/push-bool
...
vm: add PUSHT and PUSHF opcodes
2022-12-02 14:20:11 +07:00
Roman Khimov
389bdfd1b6
Merge pull request #2719 from nspcc-dev/eval
...
runtime: implement System.Runtime.LoadScript, fix #2701
2022-12-02 14:08:40 +07:00
Anna Shaleva
1250e82c2a
vm: add PUSHT and PUSHF opcodes
...
Port https://github.com/neo-project/neo-vm/pull/497 .
2022-12-02 10:02:33 +03:00
Anna Shaleva
0ceae612c6
vm: improve failed SYSCALL logging
...
For better user experience.
2022-11-28 17:16:27 +03:00
Roman Khimov
4e26f4b26e
runtime: implement System.Runtime.LoadScript, fix #2701
2022-11-25 15:11:49 +03:00
Roman Khimov
0039615ae3
Merge pull request #2816 from nspcc-dev/fix-pointer-serialization
...
Fix pointer serialization
2022-11-20 22:59:52 +07:00
Roman Khimov
9ba18b5dfa
stackitem: serialize/deserialize pointers, fix #2815
...
They of course can't be serialized, but in protected mode we still need to
handle them somehow.
2022-11-20 16:02:50 +03:00
Roman Khimov
8e7f65be17
vm: use proper estack for exception handler
...
v.estack might be some inner invoked contract and its stack must not be used
for exception handler set up by higher-order contract.
2022-11-18 11:36:38 +03:00
Roman Khimov
cb64957af5
vm: don't use Stack for istack
...
We don't use all of the Stack functionality for it, so drop useless methods
and avoid some interface conversions. It increases single-node TPS by about
0.9%, so nothing really important there, but not a bad change either. Maybe it
can be reworked again with generics though.
2022-11-18 11:35:29 +03:00
Roman Khimov
aef01bf663
vm: fix istack marshaling, fix #2799
2022-11-16 00:40:12 +03:00
Roman Khimov
90582faacd
vm: save current stack slice when loading new context
...
v.estack is used throughout the code to work with estack, while ctx.sc.estack
is (theoretically) just a reference to it that is saved on script load and
restored to v.estack on context unload. The problem is that v.estack can grow
as we use it and can be reallocated away from its original slice (saved in the
ctx.sc.estack), so either ctx.sc.estack should be a pointer or we need to
ensure that it's correct when loading a new script. The second approach is a
bit safer for now and it fixes #2798 .
2022-11-15 23:48:02 +03:00
Roman Khimov
5d43367082
emit: optimize Bool GAS cost
...
NOT is 1 byte shorter and 2048 times cheaper than CONVERT. Inspired by
neo-project/neo-vm#493 .
2022-10-25 13:08:33 +03:00
Anna Shaleva
7db9258104
vm: make LoadFileWithFlags actually load with flags provided
2022-10-13 16:07:34 +03:00
Anna Shaleva
7eb87afab8
cli: unify parameters parsing
...
Share parameters parsing code between 'contract invokefunction' and
'vm run' commands. It allows VM CLI to parse more complicated parameter
types including arrays and file-backed bytestrings.
2022-10-13 08:20:27 +03:00
Anna Shaleva
f45d8fc08d
vm: remove default syscall handler
...
It's not needed anymore. Close #1075 .
2022-10-07 15:56:34 +03:00
Anna Shaleva
0b717b0c22
vm: move vm CLI to cli/vm package
2022-10-07 15:56:34 +03:00
Anna Shaleva
df802b6fc6
vm: adjust emit.AppCall comment
...
There's no APPCALL anymore.
2022-09-21 17:25:45 +03:00
Roman Khimov
f78a065230
vm/cli: generate Go 1.17 go.mods
2022-09-08 21:18:51 +03:00
Roman Khimov
1e54b422cd
emit: make *util.Uint160 and *util.Uint256 emittable
...
They can be nil or can be regular uint types we're used to.
2022-09-08 14:33:04 +03:00
Roman Khimov
4f3ffe7290
golangci: enable errorlint and fix everything it found
2022-09-02 18:36:23 +03:00
Evgeniy Stratonikov
9712be78fd
vm: optimize refcounter
...
```
name old time/op new time/op delta
RefCounter_Add-8 9.47ns ± 4% 2.75ns ± 1% -70.92% (p=0.000 n=10+9)
RefCounter_AddRemove-8 88.9ns ±20% 5.5ns ± 4% -93.78% (p=0.000 n=10+10)
name old alloc/op new alloc/op delta
RefCounter_Add-8 0.00B 0.00B ~ (all equal)
RefCounter_AddRemove-8 48.0B ± 0% 0.0B -100.00% (p=0.000 n=10+10)
name old allocs/op new allocs/op delta
RefCounter_Add-8 0.00 0.00 ~ (all equal)
RefCounter_AddRemove-8 2.00 ± 0% 0.00 -100.00% (p=0.000 n=10+10)
```
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-08-23 13:18:06 +03:00
Evgeniy Stratonikov
59fbc689e4
vm/bench: extend refcounter benchmarks
...
Adding an array multiple times leads to the fast update via `IncRC`.
This hides the allocation that is there on the first addition. In this
commit add another benchmark which measures Add/Remove together, to
ensure that `switch` in `refCounter.Add` is entered. Benchmark results
are meaningful, because `Add`/`Remove` have almost identical implementation.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-08-23 13:08:42 +03:00
Anna Shaleva
916f2293b8
*: apply go 1.19 formatter heuristics
...
And make manual corrections where needed. See the "Common mistakes
and pitfalls" section of https://tip.golang.org/doc/comment .
2022-08-09 15:37:52 +03:00
Anna Shaleva
bb751535d3
*: bump minimum supported go version
...
Close #2497 .
2022-08-08 13:59:32 +03:00
Roman Khimov
e8d2277fe5
contract/vm: only push NULL after call in dynamic contexts
...
And determine the need for Null dynamically. For some reason the only dynamic
context is Contract.Call. CALLT is not dynamic and neither is a call from
native contract, go figure...
2022-08-05 14:35:00 +03:00
Roman Khimov
99e2681d3a
interop/vm: use more robust CalledByEntry check
...
Directly check contexts.
2022-08-05 14:35:00 +03:00
Roman Khimov
13f5fdbe8a
vm: extract shared parts of the Context
...
Local calls reuse them, cross-contract calls create new ones. This allows to
avoid some allocations and use a little less memory.
2022-08-05 14:26:25 +03:00
Roman Khimov
1e62474514
vm: move InvocationTree into a package of its own
...
result.Invoke shouldn't depend on vm.
2022-07-08 23:30:30 +03:00
Roman Khimov
fab8dfb9f8
vm: move State type into a package of its own
...
It's used a lot in other places that need it, but don't need whole VM at the
same time.
2022-07-08 18:34:52 +03:00
Roman Khimov
926b082d39
Merge pull request #2538 from nspcc-dev/restrict-out-of-bounds
...
core: check methods offsets while contract deploying
2022-07-04 12:54:32 +03:00
Roman Khimov
19ad31dc52
vm: optimize IsSignatureContract
...
We use it a lot in (*Blockchain).IsTxStillRelevant().
name old time/op new time/op delta
IsSignatureContract-8 19.1ns ± 5% 1.2ns ± 4% -93.81% (p=0.000 n=10+10)
name old alloc/op new alloc/op delta
IsSignatureContract-8 0.00B 0.00B ~ (all equal)
name old allocs/op new allocs/op delta
IsSignatureContract-8 0.00 0.00 ~ (all equal)
2022-06-07 10:29:13 +03:00
Roman Khimov
92c94f265c
interop/vm: make VM reusable and use on VM for all in-block execs
...
Avoid allocating again and again. Increases TPS by about 3%.
2022-06-07 10:05:47 +03:00
Anna Shaleva
1005c1f7db
vm: forbid jumping out of the script bounds
2022-06-06 12:18:19 +03:00
Roman Khimov
edb6ca8926
Merge pull request #2531 from nspcc-dev/perf
...
Minor performance improvements
2022-06-03 10:40:56 +03:00
Roman Khimov
c3d989ebda
stackitem: reusable serialization context
...
We serialize items a lot and this allows to avoid a number of allocations.
2022-06-02 15:38:39 +03:00
Roman Khimov
3d4076ca36
vm: microoptimize new estack creation
...
Subslice won't reach element -1, but it can reuse the same buffer space more
effectively.
2022-05-31 18:53:05 +03:00
Roman Khimov
e1607e23c2
Merge pull request #2525 from nspcc-dev/immutable-items
...
vm: implement immutable stackitems
2022-05-31 10:36:56 +03:00
Anna Shaleva
42a051e55a
core: DeepCopy notifiction event args inside System.Runtime.Notify
2022-05-31 08:07:53 +03:00
Anna Shaleva
7296f0c913
vm: support immutable compound types
2022-05-31 08:07:50 +03:00
Anna Shaleva
107f5e0793
vm: adjust refcount operations order
...
Perform add/set/remove operations with VM type firstly, and with
refcounter after that. It is needed to be able to extend add/set/remove
operations with extra checks.
2022-05-31 08:02:13 +03:00
Roman Khimov
502cdd68ab
Merge pull request #2508 from nspcc-dev/snapshot-isolation
...
core, vm: implement snapshot isolation
2022-05-27 12:44:06 +03:00
Anna Shaleva
a79c80cb8d
vm: wrap cross-contract exceptions
2022-05-26 11:44:26 +03:00
Anna Shaleva
a39b7cc3fd
core, vm: move all isolation-related logic out of VM
...
Keep it inside the interop context.
2022-05-26 09:26:31 +03:00
Anna Shaleva
f79f62dab4
vm: use single function instead of committer/discarder
2022-05-26 09:26:31 +03:00
Anna Shaleva
08b68e9b82
vm, core: push Null return value only if no exception occurs
...
Close https://github.com/nspcc-dev/neo-go/issues/2509 .
2022-05-26 09:26:31 +03:00