Roman Khimov
aefb26255a
dao: drop DAO interface
...
It's a remnant from the days when we had Simple and Cached DAO
implementations, now it makes zero sense.
2022-02-16 18:24:20 +03:00
Anna Shaleva
0de4c0fc17
compiler: use full paths for debug info files if relative can't be constructed
...
Firstly introduced in 9871dc8f5a
. It's OK
if relative path can't be constructed e.g. for interop dependencies. Otherwice
leads to failing tests on Windows with the following error:
```
2022-02-09T09:39:31.3307626Z panic: Rel: can't make D:\a\neo-go\neo-go\pkg\interop\neogointernal\syscall.go relative to C:\Users\RUNNER~1\AppData\Local\Temp\TestContractInitAndCompile1998984267\001\testcontract [recovered]
2022-02-09T09:39:31.3308830Z panic: Rel: can't make D:\a\neo-go\neo-go\pkg\interop\neogointernal\syscall.go relative to C:\Users\RUNNER~1\AppData\Local\Temp\TestContractInitAndCompile1998984267\001\testcontract
2022-02-09T09:39:31.3309285Z
2022-02-09T09:39:31.3309390Z goroutine 302 [running]:
2022-02-09T09:39:31.3309725Z testing.tRunner.func1.2({0x14dbfe0, 0xc00051bdb0})
2022-02-09T09:39:31.3310187Z C:/hostedtoolcache/windows/go/1.17.6/x64/src/testing/testing.go:1209 +0x36c
2022-02-09T09:39:31.3310538Z testing.tRunner.func1()
2022-02-09T09:39:31.3310937Z C:/hostedtoolcache/windows/go/1.17.6/x64/src/testing/testing.go:1212 +0x3b6
2022-02-09T09:39:31.3311285Z panic({0x14dbfe0, 0xc00051bdb0})
2022-02-09T09:39:31.3311689Z C:/hostedtoolcache/windows/go/1.17.6/x64/src/runtime/panic.go:1047 +0x266
2022-02-09T09:39:31.3312319Z github.com/nspcc-dev/neo-go/pkg/compiler.(*codegen).fillDocumentInfo.func1(0xc0002d0b40)
2022-02-09T09:39:31.3312885Z D:/a/neo-go/neo-go/pkg/compiler/analysis.go:240 +0x34d
2022-02-09T09:39:31.3313397Z go/token.(*FileSet).Iterate(0xc0000a69c0, 0xc0004898b0)
2022-02-09T09:39:31.3313839Z C:/hostedtoolcache/windows/go/1.17.6/x64/src/go/token/position.go:463 +0xde
2022-02-09T09:39:31.3314404Z github.com/nspcc-dev/neo-go/pkg/compiler.(*codegen).fillDocumentInfo(0xc0002e4d20)
2022-02-09T09:39:31.3314947Z D:/a/neo-go/neo-go/pkg/compiler/analysis.go:236 +0x97
2022-02-09T09:39:31.3315530Z github.com/nspcc-dev/neo-go/pkg/compiler.(*codegen).compile(0xc0002e4d20, 0xc00009a690, 0xc000101540)
2022-02-09T09:39:31.3316064Z D:/a/neo-go/neo-go/pkg/compiler/codegen.go:2088 +0x192
2022-02-09T09:39:31.3316563Z github.com/nspcc-dev/neo-go/pkg/compiler.codeGen(0xc00009a690)
2022-02-09T09:39:31.3317066Z D:/a/neo-go/neo-go/pkg/compiler/codegen.go:2167 +0x7cd
2022-02-09T09:39:31.3317679Z github.com/nspcc-dev/neo-go/pkg/compiler.CompileWithOptions({0xc0000435e0, 0x62}, {0x0, 0x0}, 0xc0004bcf70)
2022-02-09T09:39:31.3318233Z D:/a/neo-go/neo-go/pkg/compiler/compiler.go:225 +0xde
2022-02-09T09:39:31.3318804Z github.com/nspcc-dev/neo-go/pkg/compiler.CompileAndSave({0xc0000435e0, 0x62}, 0xc0004bcf70)
2022-02-09T09:39:31.3319353Z D:/a/neo-go/neo-go/pkg/compiler/compiler.go:241 +0x3a5
2022-02-09T09:39:31.3319889Z github.com/nspcc-dev/neo-go/cli/smartcontract.contractCompile(0xc0004e42c0)
2022-02-09T09:39:31.3320456Z D:/a/neo-go/neo-go/cli/smartcontract/smart_contract.go:520 +0xc2d
2022-02-09T09:39:31.3320873Z github.com/urfave/cli.HandleAction({0x14b6fa0, 0x17b8d60}, 0x7)
2022-02-09T09:39:31.3321344Z C:/Users/runneradmin/go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:524 +0xf4
2022-02-09T09:39:31.3321931Z github.com/urfave/cli.Command.Run({{0x16460d2, 0x7}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0x166fe9e, 0x27}, {0x0, ...}, ...}, ...)
2022-02-09T09:39:31.3322443Z C:/Users/runneradmin/go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:173 +0xc09
2022-02-09T09:39:31.3322894Z github.com/urfave/cli.(*App).RunAsSubcommand(0xc0000b7340, 0xc0004e4000)
2022-02-09T09:39:31.3323375Z C:/Users/runneradmin/go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:405 +0x106c
2022-02-09T09:39:31.3323852Z github.com/urfave/cli.Command.startApp({{0x1647536, 0x8}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0x1671070, 0x28}, {0x0, ...}, ...}, ...)
2022-02-09T09:39:31.3324365Z C:/Users/runneradmin/go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:372 +0x108c
2022-02-09T09:39:31.3324838Z github.com/urfave/cli.Command.Run({{0x1647536, 0x8}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0x1671070, 0x28}, {0x0, ...}, ...}, ...)
2022-02-09T09:39:31.3325327Z C:/Users/runneradmin/go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:102 +0xe8c
2022-02-09T09:39:31.3325744Z github.com/urfave/cli.(*App).Run(0xc000323880, {0xc0004237a0, 0xb, 0x12})
2022-02-09T09:39:31.3326198Z C:/Users/runneradmin/go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:277 +0xa8c
2022-02-09T09:39:31.3326770Z github.com/nspcc-dev/neo-go/cli.(*executor).run(0xc0000709c0, {0xc0004237a0, 0xb, 0x12})
2022-02-09T09:39:31.3327275Z D:/a/neo-go/neo-go/cli/executor_test.go:273 +0x3a5
2022-02-09T09:39:31.3327812Z github.com/nspcc-dev/neo-go/cli.(*executor).Run(0x14aa020, 0xc000493950, {0xc0004237a0, 0xb, 0x12})
2022-02-09T09:39:31.3328324Z D:/a/neo-go/neo-go/cli/executor_test.go:263 +0x10f
2022-02-09T09:39:31.3328844Z github.com/nspcc-dev/neo-go/cli.TestContractInitAndCompile(0xc0001d69c0)
2022-02-09T09:39:31.3329377Z D:/a/neo-go/neo-go/cli/contract_test.go:155 +0x147f
2022-02-09T09:39:31.3329694Z testing.tRunner(0xc0001d69c0, 0x17b8be8)
2022-02-09T09:39:31.3330123Z C:/hostedtoolcache/windows/go/1.17.6/x64/src/testing/testing.go:1259 +0x230
2022-02-09T09:39:31.3330470Z created by testing.(*T).Run
2022-02-09T09:39:31.3330862Z C:/hostedtoolcache/windows/go/1.17.6/x64/src/testing/testing.go:1306 +0x727
2022-02-09T09:39:31.3331325Z FAIL github.com/nspcc-dev/neo-go/cli 5.552s
```
2022-02-10 18:58:44 +03:00
Evgeniy Stratonikov
b5afe24090
compiler: properly process defer
in conditional statements
...
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-02-04 11:04:03 +03:00
Evgeniy Stratonikov
ed43b75631
compiler: do not traverse defer
function literals twice
...
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-02-02 16:52:15 +03:00
Anna Shaleva
9c2e92d7d9
compiler: check overloaded methods for safeness one more time
...
It's possible that overloaded method is marked as `safe` in manifest, so
that it must have `save` field set to true after its name was
overwritten.
2022-01-21 18:03:04 +03:00
Evgeniy Stratonikov
ad65d1fa1f
compiler: implement custom logic for go1.15
...
For some reason `foo.go` is interpreted as an http URL, and even if we
replace it with `./foo.go` there is an errors with file missing on disk.
Because `CompileWithOptions` should be able to compile file under any
circumstances, we allocate temporary directory base on version used to
compile a binary.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-01-21 17:43:28 +03:00
Evgeniy Stratonikov
970769e5b2
compiler: allow to use _
in constants
...
When `_` is unused it can be omitted from constant values mapping.
Catched when compiling `netmap` contract from nspcc-dev/neofs-contract.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-01-20 13:52:58 +03:00
Evgeniy Stratonikov
548a6a06f1
compiler: speed up boolean expression short-circuit test
...
The amount of tests done is comparable to all other tests in compiler
package (~2k). After we moved to a new x/tools package this became a
bottleneck. In this commit we reduce the amount of compiled files by
combining multiple tests in a single file.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-01-20 13:21:26 +03:00
Evgeniy Stratonikov
9871dc8f5a
compiler: update x/tools package
...
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-01-20 13:21:26 +03:00
Evgeniy Stratonikov
e7a0ecb349
compiler: provide .go
filename to Compile
...
First argument contains filename, thus we use '.go' suffix to
distinguish between directories and files.
Contract name should be provided in options.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-01-20 13:21:24 +03:00
Evgeniy Stratonikov
8af9c870b1
compiler: remove CompileWithDebugInfo
...
It is a simple wrapper over `CompileWithOptions` which we don't really
need. Custom options can be specified explicitly instead of using some
random default. This default was introduced in 1578904da
, however tests
written there use `CompileWithOptions` and all other tests
pass on that commit even without this default.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-01-20 13:15:48 +03:00
Evgeniy Stratonikov
46f623a48f
compiler/test: use public functions in tests
...
`CompileWithOptions` does exactly the thing we need.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-01-20 13:15:48 +03:00
Roman Khimov
299a7ea614
compiler: use CALLT for native contract calls, fix #2257
2021-12-10 11:58:50 +03:00
Roman Khimov
01d15ff473
Merge pull request #2270 from nspcc-dev/vm-invoked-contracts
...
Add invoked contract tracing
2021-12-01 11:27:27 +03:00
Roman Khimov
dbe184a335
Merge pull request #2280 from nspcc-dev/compiler-struct-cast
...
compiler: allow to slice struct field
2021-11-30 18:14:56 +03:00
Roman Khimov
f12f871432
compiler: use new defer stack for inlined functions, fix #2281
...
Inlined functions shouldn't care about outer scope defer statements, they
can't.
2021-11-30 18:04:02 +03:00
Roman Khimov
cddd5e1f6d
compiler: add a panic on internal lambda inconsistency
...
It's a bit better than behavior observer in #2281 (which is very cryptic).
2021-11-30 18:02:38 +03:00
Evgeniy Stratonikov
66a4245bef
compiler: allow to slice struct field
...
It makes no sense to restrict to identifiers.
2021-11-30 15:48:46 +03:00
AnnaShaleva
aefb6f9fee
*: fix tests failing due to path.Join usage
...
Solution:
Use `file/filepath` package to construct expected path. This package is OS-aware, see https://github.com/golang/go/issues/30616 .
2021-11-29 11:11:09 +03:00
Roman Khimov
b0a8f54776
vm: drop LoadArgs method, it's a Legacy remnant
2021-11-20 21:57:41 +03:00
Roman Khimov
765235eca3
vm: omit context parameter from Call()
...
It's not used and should not be used to switch from contract to contract.
2021-11-20 21:57:41 +03:00
Roman Khimov
a577d40de9
vm: move Jump method to the Context
...
Because it's only relevant for execution context itself.
2021-11-20 21:57:35 +03:00
Roman Khimov
7fa58a4dc8
Merge pull request #2255 from nspcc-dev/compiler-noreturn-defers
...
compiler: correctly handle defer in functions without return values
2021-11-15 10:43:00 +03:00
Roman Khimov
db99368e96
compiler: optimize GAS cost of type conversion
...
CONVERT call base price is 8192. DUP, ISTYPE and JMPIF all cost 2. So we add
0.07% overhead in the worst case and save 99.93% otherwise.
At the same time, old code was just two bytes and new one is seven, but I
think it's tolerable considering how much GAS it can potentially save.
Fix #2250 .
2021-11-12 19:58:21 +03:00
Roman Khimov
a91581fa16
compiler: correctly handle defer in functions without return values
...
Fix #2253 .
2021-11-12 19:36:59 +03:00
Roman Khimov
410aabe7a1
compiler: drop some useless NOPs
...
They're all obsolete and not needed.
2021-11-12 17:19:59 +03:00
Roman Khimov
0d50730382
compiler: optimize map initialization with PACKMAP
2021-11-12 17:19:59 +03:00
Roman Khimov
a8befeea33
compiler: optimize new empty struct creation with PACKSTRUCT
2021-11-12 17:19:59 +03:00
Roman Khimov
909ea477f4
compiler: create arrays/structs more effectively
...
Use PACK/PACKSTRUCT.
2021-11-12 17:19:59 +03:00
Evgeniy Stratonikov
7758378d28
compiler: allow to overload methods in manifest
...
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-10-29 20:15:21 +03:00
Evgeniy Stratonikov
4fe188a60d
compiler: check correctness of emitted bytecode
...
The error here indicates a bug in compiler implementation.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-10-25 13:55:55 +03:00
Evgeniy Stratonikov
a885f84cad
compiler: fail if some functions are missing
...
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-10-25 13:55:55 +03:00
Evgeniy Stratonikov
8a0429036b
compiler: set type information during traversal, fix #2231
...
Set all necessary context before file traversal, not only import
maps. Also, we can skip restoring import maps because all our code is
processed via `For*` iterators which set necessary context.
We can also refactor this a bit to have all context in one place,
this will be done in #2086 .
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-10-25 13:55:55 +03:00
Evgeniy Stratonikov
b91de50e65
compiler: remove convert.To*
from the list of builtins
...
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-10-23 16:16:03 +03:00
Evgeniy Stratonikov
a92bf281c1
compiler: remove custom logic for util
builtins
...
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-10-23 16:12:47 +03:00
Roman Khimov
36295357d8
interop: add Abort() function to ABORT things
...
Related to #2227 .
2021-10-22 14:50:51 +03:00
Evgeniy Stratonikov
0bc81aecf4
compiler: do not emit code for unused imported functions
...
Our current algorithm marks function as used if it is called
at least ones, even if the callee function is itself unused.
This commit implements more clever traversal to collect usage
information more precisely.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-10-13 15:56:07 +03:00
Evgeniy Stratonikov
8d562cef99
compiler: allow to use multiple underscores in func arguments
...
It should still be present in the argument array in VM so just don't
save them in the map.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-10-09 13:23:11 +03:00
Evgeniy Stratonikov
0c01d89827
compiler: check that safe methods exist
...
If a method is missing from the manifest, it is most likely a typo
or regression after refactoring. There is no "turn-off" flag
for this error because we can do this precisely.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-10-06 15:18:58 +03:00
Roman Khimov
42a9d3d7b8
nef: add Source field
...
Follow neo-project/neo#2605 .
2021-09-24 00:19:37 +03:00
Anna Shaleva
4b35a1cf92
core: remove conflicting transactions wrt MaxTraceableBlocks
2021-08-18 13:31:47 +03:00
Evgeniy Stratonikov
dc9287bf5c
compiler: use parameter directly in writeJumps
...
`Next` doesn't longer copy parameter.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-08-13 11:59:04 +03:00
Roman Khimov
d6bd6b6888
native: drop Refuel method from GAS
...
It can be used to attack the network (amplifying DOS), so it's broken
beyond repair. This reverts ac601601c1
.
See also neo-project/neo#2560 and neo-project/neo#2561 .
2021-08-05 10:27:13 +03:00
Roman Khimov
4d1e952be6
go.mod: update go-datastructures to 1.0.53
...
We're only using queue library and it didn't change in any way, but 1.0.53 has
proper go.mod, so it's still an improvement.
It at the same time pulls some new packages also like x/tools.
2021-07-21 23:28:00 +03:00
Roman Khimov
36d486a664
config: add InitialGASSupply, fix #2073
...
We now have 52M by default.
2021-07-20 16:59:54 +03:00
Roman Khimov
f4a9139a05
Merge pull request #2071 from nspcc-dev/fix-more-vm-bugs
...
Fix more VM bugs
2021-07-19 22:00:17 +03:00
Roman Khimov
233307aca5
stackitem: completely drop MaxArraySize
...
Turns out C# VM doesn't have it since preview2, so our limiting of
MaxArraySize in incompatible with it. Removing this limit shouldn't be a
problem with the reference counter we have, both APPEND and SETITEM add things
to reference counter and we can't exceed MaxStackSize. PACK on the other hand
can't get more than MaxStackSize-1 of input elements.
Unify NEWSTRUCT with NEWARRAY* and use better integer checks at the same time.
Multisig limit is still 1024.
2021-07-19 15:42:42 +03:00
Evgeniy Stratonikov
8077f9232d
interop: implement System.Runtime.GetRandom
...
Our murmur3 implementation is architecture independent and optimized in
assembly.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-07-15 16:00:01 +03:00
Evgeniy Stratonikov
96a42cd011
interop: add System.Runtime.GetNetwork
, fix #2038
...
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-07-08 17:02:37 +03:00
Evgeniy Stratonikov
f0100407ee
compiler/test: compile whole directory in examples
...
For `nft-nd-nns` example only `namestate.go` file was compiled which is
certainly not what we want.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-06-28 11:50:40 +03:00