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
Evgeniy Stratonikov
aa76383fa7
compiler: extend permission check to runtime hashes
...
If a method is known at compile time we can still check
if it is present in the list of methods of at least one contract.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-06-28 11:49:30 +03:00
Evgeniy Stratonikov
4249674ddc
compiler: check for contract permissions
...
On many occassions we can determine at compile-time if contract config lacks
some properties it needs. This includes all native contract invocations
through stdlib, as both hashes and methods are known at compile-time
there.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-06-28 11:49:29 +03:00
Roman Khimov
352450d25a
Merge pull request #1988 from nspcc-dev/cli-permission
...
cli,compiler: allow to specify manifest permissions
2021-06-07 10:27:29 +03:00
Roman Khimov
efb814a97e
Merge pull request #1995 from nspcc-dev/compiler-verify-notify
...
compiler: disallow `runtime.Notify` in `Verify` function
2021-06-06 11:34:42 +03:00
Evgeniy Stratonikov
1578904da2
compiler: disallow runtime.Notify
in Verify
function
...
Only direct invocations are considered. The check can be disabled
with '--no-events' compiler option.
2021-06-06 09:34:24 +03:00
Evgeniy Stratonikov
4467e2cbfd
cli,compiler: allow to specify manifest permissions
2021-06-04 11:16:22 +03:00
Evgeniy Stratonikov
1d6d7206e9
compiler: inline expressions with type conversions, fix #1879
...
Don't count `string(data)` or `[]byte(data)` as function calls.
2021-06-04 11:08:00 +03:00
Evgeniy Stratonikov
6b3afe9131
compiler: inline all expression with no side-effects, fix #1881
...
This has the drawback of traversing expression each time the argument is
used. However this is not the case in our syscall/native wrappers.
The old behaviour can be restored by explicit local assignment.
2021-06-04 11:07:59 +03:00
Evgeniy Stratonikov
3749f38720
compiler/test: add more tests for inline behaviour
2021-06-04 11:06:09 +03:00
Evgeniy Stratonikov
c538512e60
compiler/test: check Main
locals in inline tests
2021-06-04 11:06:09 +03:00
Evgeniy Stratonikov
5e92a254b2
compiler: check event name length in runtime.Notify
2021-06-03 10:32:56 +03:00
Evgeniy Stratonikov
1a5e656d38
compiler: restore event check warnings
...
It was broken after changes for inlining. Add tests.
2021-06-03 10:32:56 +03:00
Evgeniy Stratonikov
233996eec0
native/neo: add getAccountState
method, close #1975
2021-05-27 10:59:38 +03:00
Evgeniy Stratonikov
e314e55a1b
compiler: add Base58Check*
interop wrappers
...
Missing piece from #1977 .
2021-05-25 18:06:40 +03:00
Evgeniy Stratonikov
60a3e0d778
compiler: count auxiliary locals introduced by inlining
...
During initialization of globals no function scope is present thus
locals number is not saved anywere. Save it in `codegen` directly.
2021-05-19 11:50:07 +03:00
Evgeniy Stratonikov
87a69b13f1
compiler/test: add test for inlining with local alias
...
INITSLOT count should be 1 more than for the same test with global.
2021-05-19 11:50:07 +03:00
Evgeniy Stratonikov
b693d54282
compiler: count local variables on the go
...
Create local variables as they are needed and remove `INITSLOT`
if there were no locals. This helps to eliminate a whole class
of bugs when calculated and real amount mismatched.
2021-05-19 11:50:07 +03:00
Evgeniy Stratonikov
bfa2bafb04
compiler: optimize jumps in tests
...
Jump target shortening affects manifest, so we better be sure.
2021-05-19 09:54:10 +03:00
Evgeniy Stratonikov
2aaaf30db7
compiler: remove finallyProcessIndex
from funcScope
2021-05-19 09:54:10 +03:00
Anna Shaleva
6eee868b4a
interop: remove native NNS API wrappers
2021-05-17 22:08:15 +03:00
Roman Khimov
834743ec88
Merge pull request #1958 from nspcc-dev/linter
...
Linter improvements
2021-05-13 10:52:58 +03:00
Roman Khimov
9d2712573f
*: enable godot linter and fix all its warnings
...
It's important for NeoGo to have clean documentation. No functional changes.
2021-05-12 23:17:03 +03:00
Roman Khimov
4e651eaf83
compiler: simplify increments as suggested by golint
2021-05-12 22:52:07 +03:00
Roman Khimov
c4e084b0d8
*: fix whitespace errors
...
leading/trailing newlines
2021-05-12 22:51:41 +03:00
Roman Khimov
601841ef35
*: drop unused structure fields
...
Found by structcheck:
`good` is unused (structcheck)
and alike.
2021-05-12 19:41:23 +03:00
Roman Khimov
92dbb3c4b9
*: fix all unused
warnings
...
From golangci-lint.
2021-05-12 18:53:12 +03:00
Roman Khimov
ad8ffee0ab
*: remove redundant return
statements
...
Found by gosimple via golangci-lint.
2021-05-12 18:24:16 +03:00
Roman Khimov
73ecbbb7c6
compiler: remove unused testPrintHash from test code
2021-05-12 18:18:49 +03:00
Roman Khimov
cfc067dd24
*: remove dead code
...
Found by deadcode via golangci-lint.
2021-05-12 18:13:14 +03:00
Roman Khimov
fbcb08c5f0
Merge pull request #1957 from nspcc-dev/compiler/static
...
Emit debug info for static variables
2021-05-12 18:12:58 +03:00
Evgeniy Stratonikov
7b638d5489
compiler: emit debug variable info for _deploy()
2021-05-12 16:04:11 +03:00
Evgeniy Stratonikov
b72f6be9e9
compiler: emit debug variable info for init()
2021-05-12 16:04:06 +03:00
Evgeniy Stratonikov
7afca7f8e5
compiler: add support for static-variables
in debug info
2021-05-12 15:05:39 +03:00
Evgeniy Stratonikov
e8ba386e58
compiler: remove offset comparison from debug test
...
We shouldn't test for them anyway plus the error is more
specific now.
2021-05-12 15:04:46 +03:00
Anna Shaleva
4b933f88a7
core: simplify interop functions
...
We now have the only interop table (system interops).
2021-05-12 13:30:01 +03:00
Anna Shaleva
6d59689d9c
core: rename Neo.Crypto.CheckMultisig interop
2021-05-11 18:38:14 +03:00
Anna Shaleva
366e79b9b8
core: rename Neo.Crypto.CheckSig interop
2021-05-11 18:37:55 +03:00
Roman Khimov
3a21d8f44f
Merge pull request #1947 from nspcc-dev/iterator-remove
...
interop: remove `System.Iterator.Create`
2021-05-11 18:29:17 +03:00
Evgeniy Stratonikov
23a4e25436
interop: remove System.Iterator.Create
, fix #1935
...
There are now only storage iterators. Related #1933 .
2021-05-11 12:13:30 +03:00
Evgeniy Stratonikov
40d1dd0e0d
native/std: add stringSplit
method
2021-05-11 12:11:38 +03:00
Evgeniy Stratonikov
dadfe2b9ab
native/std: add memorySearch
method
2021-05-11 12:11:38 +03:00
Evgeniy Stratonikov
978f4dfbc5
native/std: add memoryCompare
method
2021-05-11 12:11:38 +03:00
Evgeniy Stratonikov
e4b34833da
native/std: add overloads for itoa
and atoi
2021-05-11 12:11:38 +03:00
Roman Khimov
ba5273999f
Merge pull request #1950 from nspcc-dev/nep11/data
...
*: add `data` to NEP11 Transfer
2021-05-06 10:39:56 +03:00
Anna Shaleva
d0c64347ab
*: add data
to NEP11 Transfer
2021-05-05 19:44:29 +03:00
Anna Shaleva
50fc9bf766
smartcontract: use permission descriptors for manifest's trusts
2021-05-05 17:40:10 +03:00
Evgeniy Stratonikov
ac601601c1
native: add refuel
method to GAS contract
2021-04-29 18:26:34 +03:00
Evgeniy Stratonikov
0114f9a912
interop: add System.Runtime.BurnGas
2021-04-29 18:23:33 +03:00
Evgeniy Stratonikov
dc393642a2
opcode: fix GTE, LTE string representations
2021-04-29 16:08:48 +03:00
Roman Khimov
555693d8b8
oracle: add MinimumResponseGas to interop
...
It's important for users of oracle contract.
2021-04-06 22:50:42 +03:00
Roman Khimov
090d68f8fa
oracle: add response codes to interop defintions
...
Client should be aware of them.
2021-04-06 22:50:42 +03:00
Roman Khimov
7e9f8e03c2
compiler: add a test for inlined selector statements
...
Selector here is either a struct field access or global package
variable/constant. While technically none of these require an additional
local, inlining actually uses one, so add a test for it.
2021-04-06 10:54:37 +03:00
Roman Khimov
21a7f3d760
compiler: keep traversing after c.countLocalsCall()
...
Some arguments can be inlined functions themselves thus requiring additional
attention. Otherwise we can get less local variables than really used by
STLOCs (and subsequent program crash).
2021-04-05 22:58:07 +03:00
Anna Shaleva
a2a9d7ff05
core: move NNS record types to a separate package
...
We need this to avoid `native` dependency in RPC client.
2021-03-26 20:44:32 +03:00
Roman Khimov
b3f9cd1541
dao: drop network from DAO
...
Not used any more.
2021-03-26 13:45:18 +03:00
Roman Khimov
df12adaa9e
crypto: remove crypto.Verifiable interface
...
We can now verify any hash.Hashable thing.
2021-03-26 13:45:18 +03:00
Roman Khimov
126b83a825
Merge pull request #1854 from nspcc-dev/examples/fix-owner
...
examples: update owner address
2021-03-23 17:43:31 +03:00
Anna Shaleva
0948d53244
examples: add documentation
...
And provide the wallet for examples `my_wallet.json` with the owner
address inside.
2021-03-23 16:46:15 +03:00
Anna Shaleva
681bd89cc7
core: move native node roles to a separate pkg
...
We need this to avoid `native` dependency in the RPC client.
2021-03-23 13:56:34 +03:00
Roman Khimov
83cb5ff07b
roles: add missing NeoFSAlphabet role
2021-03-19 16:18:45 +03:00
Roman Khimov
b56e028733
*: add more package-specific documentation
...
For the most important packages at least.
2021-03-19 16:18:45 +03:00
Anna Shaleva
0d9266d407
core: remove System.Contract.IsStandard
2021-03-16 16:59:23 +03:00
Anna Shaleva
9377751e65
config: add NativeUpdateHistory
2021-03-15 12:35:14 +03:00
Evgeniy Stratonikov
256cd09228
native: allow to set oracle request price
2021-03-11 10:12:30 +03:00
Evgeniy Stratonikov
27fc28bd69
native: allow to set candidate register price
2021-03-11 10:12:30 +03:00
Anna Shaleva
9015e50847
core: refactor Neo.Crypto.CheckMultisigWithECDsaSecpr1
...
Rename it to Neo.Crypto.CheckMultisig and remove `message` parameter.
2021-03-10 21:46:05 +03:00
Anna Shaleva
7126637f73
core: remove Neo.Crypto.CheckMultisigWithECDsaSecp256k1
...
Koblitz RIP.
2021-03-10 21:46:05 +03:00
Anna Shaleva
cdaca7be3e
core: use Neo.Crypto.CheckSig for standard signature verification
2021-03-10 21:45:58 +03:00
Anna Shaleva
4e6c1092b8
core: add Neo.Crypto.CheckSig interop
2021-03-10 19:24:19 +03:00
Anna Shaleva
14ade42101
core: remove System.Binary.[Serialize, Deserialize] syscalls
...
And move their tests to native StdLib.
2021-03-10 19:24:19 +03:00
Anna Shaleva
5c9c168ee5
core: remove System.Binary.[Base64*, Base58*] syscalls
...
And move their tests to native StdLib.
2021-03-10 19:24:19 +03:00
Anna Shaleva
4d2ad4b9e2
core: remove System.Json.[Serialize, Deserialize] interops
...
And move their tests to native StdLib.
2021-03-10 19:24:19 +03:00
Anna Shaleva
f65485b735
core: remove System.Binary.Itoa and System.Binary.Atoi syscalls
...
And move their tests to native StdLib.
2021-03-10 19:24:19 +03:00
Anna Shaleva
2b90d4455f
native: implement StdLib contract
2021-03-10 19:24:19 +03:00
Anna Shaleva
078870fceb
compiler: fix contract.IsStandard syscall test
2021-03-10 19:24:19 +03:00
Evgeniy Stratonikov
100f2db3fb
native: implement CryptoLib contract
2021-03-10 19:24:19 +03:00
Evgeniy Stratonikov
7160675ac1
compiler/interop: improve conversion to bytes interops
...
Allow to convert to both `Buffer` and `ByteString`
and explicitly mention VM types. Rename `ToByteArray` to `ToBytes`
to avoid ambiguity.
2021-03-10 13:38:44 +03:00
Evgeniy Stratonikov
55009153a9
vm/emit: emit Boolean values correctly
...
We should convert both `true` and `false` values.
2021-03-09 13:34:22 +03:00
Evgeniy Stratonikov
fd4174ad31
core/state: remove IsConst
from StorageItem
2021-03-09 11:59:08 +03:00
Evgeniy Stratonikov
7c62df1253
compiler: add tests for syscall handling
2021-03-05 10:17:35 +03:00
Evgeniy Stratonikov
ffd85dd51d
native/policy: remove MaxBlockSize and MaxBlockSystemFee
2021-03-04 16:59:19 +03:00
Evgeniy Stratonikov
7b8533b67c
native/policy: move MaxTransactionsPerBlock to config
2021-03-04 16:59:19 +03:00
Roman Khimov
924de3e090
Merge pull request #1796 from nspcc-dev/compiler/pow
...
Add syscalls for POW and SQRT opcodes
2021-03-04 16:56:15 +03:00
Evgeniy Stratonikov
8f8c7d2839
compiler: fix import alias handling
2021-03-04 14:41:20 +03:00
Evgeniy Stratonikov
d66ce43239
compiler/interop: replace int64
with int
2021-03-04 13:20:43 +03:00