Commit graph

2234 commits

Author SHA1 Message Date
Roman Khimov
92f37a5d36
Merge pull request #1324 from nspcc-dev/fix-goreportcard-issues
Fix goreportcard issues
2020-08-14 14:50:35 +03:00
Roman Khimov
40bcd4c0bc
Merge pull request #1231 from nspcc-dev/fix/printops
vm: pretty-print remaining opcodes
2020-08-14 14:43:29 +03:00
Evgenii Stratonikov
b2e53fedac vm: pretty-print SYSCALL opcode 2020-08-14 14:22:46 +03:00
Evgenii Stratonikov
a796f2b61d names: implement FromID
Allow to convert interop id to it's name.
2020-08-14 14:22:45 +03:00
Evgenii Stratonikov
7854dcfd8f core: replace interop names with named constants 2020-08-14 14:21:54 +03:00
Evgenii Stratonikov
f3650e20b0 vm: move InteropNameToID to a separate package 2020-08-14 13:54:11 +03:00
Roman Khimov
e7d13e6db2 *: fix misspellings found in Go Report Card 2020-08-14 12:16:24 +03:00
Roman Khimov
f6a308f7f6 *: fix ineffassign where the value should really be used
Found with GoReportCard.
2020-08-14 12:08:57 +03:00
Roman Khimov
ec2a2f3fb9 transaction: fix ineffassign GoReportCard issue
s is not used purposefuly.
2020-08-14 12:08:16 +03:00
Roman Khimov
70cc8b89e8
Merge pull request #1323 from nspcc-dev/fix/clienttests
rpc: fix (*Client).BalanceOf
2020-08-14 11:54:36 +03:00
Evgenii Stratonikov
a8cda69bc3 rpc: fix (*Client).BalanceOf
Add missing argument and write tests.
2020-08-14 11:19:24 +03:00
Evgenii Stratonikov
cadebdfc19 core: add tests for (*Blockchain).verifyHashAgainstScript 2020-08-14 09:40:36 +03:00
Evgenii Stratonikov
1eb9a4c6c6 core: allow to use verification contracts
In NEO3 we can't just appcall hash, as verification script has no access
to state. Instead we use `verify` method of an arbitrary contract.
2020-08-14 09:40:34 +03:00
Evgenii Stratonikov
7f2a931fb6 core: add tests for (*Blockchain).verifyHeader 2020-08-14 09:37:32 +03:00
Evgenii Stratonikov
e8cf4d96ce core: add tests for (*Blockchain).verifyTx 2020-08-14 09:37:30 +03:00
Roman Khimov
bf090a436b
Merge pull request #1315 from nspcc-dev/debugger-compatibility-fixes
Debugger compatibility fixes, part 2
2020-08-13 18:23:38 +03:00
Anna Shaleva
0834661cac rpc: marshal getapplicationlog stack as []stackitem.Item
Following https://github.com/neo-project/neo-modules/issues/318
2020-08-13 17:16:31 +03:00
Anna Shaleva
9456f729be compiler: generate methods names with lowercased first letter
Methods names from debuginfo should match methods names from manifest.
Original method names are stored in ID field.
2020-08-13 13:28:20 +03:00
Anna Shaleva
3c170271c4 compiler: provide namespace for events names
For proper NEO3 debugger work we should provide namespaces for events
names in .debug.json files. But we don't have namespaces in .yml
configuration files and don't need this information for .manifest.json
generation, so let's just keep namespaces empty. This do not prevents
debugger from accepting our .debug.json files.
2020-08-13 10:44:46 +03:00
Evgenii Stratonikov
9cc6e22365 vm: pretty-print ST*/LD* opcodes 2020-08-13 10:38:13 +03:00
Evgenii Stratonikov
7d08d38cd2 vm: pretty-print PUSHINT* opcodes 2020-08-13 10:38:13 +03:00
Evgenii Stratonikov
92ddc474d8 vm: pretty-print CONVERT and ISTYPE opcodes 2020-08-13 10:38:13 +03:00
Roman Khimov
95d86b67c3
Merge pull request #1311 from nspcc-dev/debugger-compatibility-fixes
Debugger compatibility fixes
2020-08-12 18:42:18 +03:00
Anna Shaleva
44aefe76b4 compiler: add events to debuginfo from .yml config 2020-08-12 17:48:03 +03:00
Anna Shaleva
bcb7b9ba63 smartcontract: rename parameter ByteString to ByteArray
Debugger expects it to be ByteArray. C# compiler also compiles it
as `ByteArray` (in both manifest and debug.json).

The previous commit 6a2161207a changed
this line as C# implementation serializes Blockchain.ApplicationExecuted.Stack
as array of stackitem.Item and deserializes it as array of
smartcontract.Parameter.
2020-08-12 17:48:03 +03:00
Roman Khimov
7bf0ae11db
Merge pull request #1309 from nspcc-dev/fix-yaml-import-path
*: use proper YAML library import path, fix #1306
2020-08-12 17:15:37 +03:00
Roman Khimov
292c186665 *: use proper YAML library import path, fix #1306 2020-08-12 16:31:06 +03:00
Roman Khimov
ca542f11fe core: drop unused secondsPerBlock() method 2020-08-11 21:37:18 +03:00
Roman Khimov
b31e18096f rpc/client: remove obsolete retry from invokeSomething()
All preview3 nodes have proper support for scoped signers in parameters.
2020-08-11 21:21:38 +03:00
Roman Khimov
acc2265169 transaction: attribute type is now type, not usage 2020-08-11 21:10:50 +03:00
Roman Khimov
fb70c82157 transaction: there are no valid attributes defined for preview3 2020-08-11 21:10:12 +03:00
Roman Khimov
b1034d8ed6 state: drop Neo 2 Account and everything related
It's substituted with NEP5Balances now.
2020-08-11 20:42:02 +03:00
Roman Khimov
34156ef78d core: fix (*HeaderHashList).Write comment 2020-08-11 20:33:16 +03:00
Roman Khimov
2354af463a core: drop some unused HeaderHashList functions 2020-08-11 20:33:16 +03:00
Roman Khimov
08fd6180b2 native: drop validators count structure
It's not used since #1252.
2020-08-11 20:19:55 +03:00
Roman Khimov
c3f7a419a0
Merge pull request #1296 from nspcc-dev/smartcontract/examples
examples: update examples
2020-08-11 19:09:13 +03:00
Anna Shaleva
b5494320f9 compiler, cli: support events from .yml config file
We currently can't process events in codegen, so we have to provide
them via .yml config file. Do not delete the rest of the code connected
with conversion of MethodDebugInfo.Event into manifest.Event as we have
issue #1038.
2020-08-11 13:42:06 +03:00
Evgenii Stratonikov
a34ba92d46 compiler: allow to split main package across multiple files 2020-08-11 11:12:55 +03:00
Evgenii Stratonikov
553e57c2c4 compiler: make sequence points on global var/const declarations 2020-08-11 11:12:30 +03:00
Evgenii Stratonikov
128626de5c compiler: save sequence points for init function 2020-08-11 11:12:30 +03:00
Evgenii Stratonikov
40fa7c0f6e compiler: emit all used files in DebugInfo.Documents 2020-08-11 11:12:29 +03:00
Evgenii Stratonikov
057e1c6e3c compiler: provide filename to Compile() 2020-08-11 11:10:45 +03:00
Anna Shaleva
5ef6d4d857 consensus: add test for payload.Verify
Closes #1178
2020-08-10 22:03:33 +03:00
Roman Khimov
25ce154cf8
Merge pull request #1300 from nspcc-dev/various-preview3-fixes
Various preview3 testnet fixes
2020-08-10 21:49:30 +03:00
Roman Khimov
c16040aecc native: sort GetValidators result
As it's returned sorted now. Fixes state change mismatch for
NextValidators. It also partially reverts
2f8e7e4d33 and significantly changes the test
chain as the fees are no longer being sent to the same account.
2020-08-10 19:49:09 +03:00
Roman Khimov
dba248236c smartcontract: add CreateDefaultMultiSigRedeemScript
And use it where appropriate. Some of our code was just plain wrong (like the
one in GAS contract) and unification is always useful here.
2020-08-10 18:58:11 +03:00
Roman Khimov
80302c5c07 consensus: use dbft.M() for new block witness
We're collecting dbft.M() number of signatures in getBlockWitness(), so we
should use the same value for M here.
2020-08-10 18:49:48 +03:00
Evgenii Stratonikov
f2cb1d5f02 compiler: use constants in interops
We now support using exported constants, so there is no
need in declaring functions. All functions from `interop/`
are not to be compiled.

Fix #1298.
2020-08-10 17:52:31 +03:00
Roman Khimov
fb97ea9458 native: don't register standby validators on initialization
C# doesn't do that since neo-project/neo#1762.
2020-08-10 17:51:46 +03:00
Roman Khimov
6e252fbaae rpc: answer with zero-length when there are no registered validators
There is a huge difference between
   "result" : [],
and
   "result" : null,
2020-08-10 17:50:19 +03:00
Roman Khimov
f287681fa7 core/native: fix VotersCount zero value encoding
Empty byte array is enough to be bigint value of zero. Fixes state differences
with C# node.
2020-08-10 17:07:14 +03:00
Roman Khimov
5a42b5c7ae network: correct block addition check
Fixes missing an error on block addition when the header actually went it, but
the block didn't.
2020-08-10 16:51:56 +03:00
Evgenii Stratonikov
bf01599430 vm: check return value on context unload
When calling external contracts we expect exactly 1 value to be on
stack. For methods returning nothing, `Null` value is pushed, otherwise
it is an error.`
2020-08-10 11:52:33 +03:00
Evgenii Stratonikov
bbae7318a5 smartcontract: adjust param types according to NEO3 2020-08-10 11:14:48 +03:00
Evgenii Stratonikov
b65369e111 emit: remove unused functions 2020-08-10 11:14:48 +03:00
Roman Khimov
4aeaf05f90
Merge pull request #1289 from nspcc-dev/fix/nep5
Port `getnep5transfers` changes to master
2020-08-10 11:11:24 +03:00
Evgenii Stratonikov
14aba7fc80 core: fix failing tests after merge
Related f5131491b .
2020-08-10 09:20:34 +03:00
Roman Khimov
f5131491b7
Merge pull request #1271 from nspcc-dev/core/call_from_native
core: contractCall from native contracts
2020-08-07 21:24:50 +03:00
Anna Shaleva
c87e2262c3 core: remove ScriptHashGetter from interop context
We have VM inside the context, so don't need ScriptHashGetter anymore.
2020-08-07 20:31:20 +03:00
Anna Shaleva
42736095a1 core: add test to call contract from native
Closes #1200
2020-08-07 20:31:16 +03:00
Evgenii Stratonikov
412fc53cdd rpc: provide timestamps in getnep5transfers
Set default value for the first timestamp to a week ago.
2020-08-07 18:42:34 +03:00
Evgenii Stratonikov
807338f97e core: do not store NEP5 transfer log in memory
Traversing transfer log instead of accumulating and returning it
is faster and takes less memory.
2020-08-07 18:21:06 +03:00
Anna Shaleva
995053f2eb core: add VM into interop context 2020-08-07 16:15:24 +03:00
Roman Khimov
c3c88a57cd
Merge pull request #1281 from nspcc-dev/drop-go-1.12-and-fix-some-things
Drop go 1.12 and fix some things
2020-08-07 13:34:54 +03:00
Roman Khimov
d5a9d80c12 core: refactor out policy check for transaction
We were checking blocked accounts twice which is obviously excessive. We also
have our accounts sorted, so we can rely on that in CheckPolicy(). It also
doesn't make much sense to check MaxBlockSystemFee in Blockchain code, policy
contract can handle that.
2020-08-07 12:21:52 +03:00
Roman Khimov
90180c6fb6 native: pass DAO to CheckPolicy(), it doesn't need interop context
Simplify things a bit.
2020-08-07 12:21:52 +03:00
Roman Khimov
791c983304 core: drop GetScriptHashesForVerifying
It no longer depends on blockchain state and there can't ever be an error, in
fact we can always iterate over signers, so copying these hashes doesn't make
much sense at all as well as sorting arrays in verifyTxWitnesses (witnesses
order must match signers order).
2020-08-07 12:21:52 +03:00
Roman Khimov
c19838ea67 core: use errors.Is in PoolTx
Just in case.
2020-08-07 12:21:52 +03:00
Roman Khimov
4c38fae54c core: fix mempool error check in PoolTx
ErrAlreadyExists should be returned for ErrDup, not ErrConflict.
2020-08-07 12:21:52 +03:00
Roman Khimov
0e2784cd2c always wrap errors when creating new ones with fmt.Errorf()
It doesn't really change anything in most of the cases, but it's a useful
habit anyway.

Fix #350.
2020-08-07 12:21:52 +03:00
Roman Khimov
205f52c563 core: use error wrapping to provide more details 2020-08-07 12:21:52 +03:00
Roman Khimov
5ef08f60ae remove github.com/pkg/errors from dependencies
It's not needed any more with Go 1.13 as we have wrapping/unwrapping in base
packages. All errors.Wrap calls are replaced with fmt.Errorf, some strings are
improved along the way.
2020-08-07 12:21:52 +03:00
Evgenii Stratonikov
bfda60c683 native: add missing witness checks to NEO.(Un)registerCandidate 2020-08-07 09:17:02 +03:00
Evgenii Stratonikov
8af3f05358 native: implement NEO.UnregisterCandidate method 2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
38a92323c9 native: fill votes when registering unregistered candidate
If a candidate was registered, then unregistered and then again
registered, it's votes must not be lost.
2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
27169d140f core: implement (*Blockchain).GetStandByCommitee() 2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
05c24d9401 cli: support voting
Closes #1206.
2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
a3f419f8df emit: allow to emit Null 2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
e5d973d3a4 config: rename StandbyValidators to StandbyCommittee 2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
b14b047c78 native: add tests for delegated voting 2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
9bc731b3b1 native: implement delegated voting
Close #867.
2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
f0b62cdaa6 native: make *totalSupply accept DAO
There is no need to provide full interop context.
2020-08-06 14:26:24 +03:00
Evgenii Stratonikov
3e39f0f211 native: rename Validator to Candidate 2020-08-06 14:26:24 +03:00
Roman Khimov
e1d3223505
Merge pull request #1247 from nspcc-dev/feature/pointers
Support pointers in compiler
2020-08-06 13:53:08 +03:00
Roman Khimov
5e53aceb0f
Merge pull request #1277 from nspcc-dev/restrict-verification-call-flags
core: restrict verification scripts with CallFlags.None
2020-08-06 13:52:14 +03:00
Roman Khimov
57ee8b80e5
Merge pull request #1246 from nspcc-dev/protocol/getblockbyindex
protocol: request blocks by index
2020-08-05 23:21:07 +03:00
Roman Khimov
f5fbef165a
Merge pull request #1259 from nspcc-dev/fix/notifications
Disallow changing notifications
2020-08-05 19:50:45 +03:00
Roman Khimov
b7f89b0544 core: restrict verification scripts with CallFlags.None
Follow neo-project/neo#1776. Looks very suspicious to me as it severely limits
verification scripts, but we have to be compatible at this point.
2020-08-05 19:17:48 +03:00
Roman Khimov
fced917b71
Merge pull request #1261 from nspcc-dev/feature/init
compiler: allow to use `init` function
2020-08-05 19:04:51 +03:00
Evgenii Stratonikov
f2107bfbc4 compiler: copy structs when passing as arguments
In Go structs must be copied when used as arguments.
To do so we must clone struct on VM level.
This is done by appending this struct to an intermediate array.
2020-08-05 13:14:38 +03:00
Evgenii Stratonikov
4488f61777 compiler: compile init even if there are no globals
`init` can be useful even if no globals are present,
e.g. we can use some syscall inside.
2020-08-05 12:59:53 +03:00
Evgenii Stratonikov
194da64975 core: deepcopy notification in System.Runtime.Notify
Make it impossible to change already emitted notifications via
`System.Runtime.GetNotifications`.
2020-08-05 11:19:41 +03:00
Evgenii Stratonikov
b8cc33d0b2 stackitem: implement DeepCopy 2020-08-05 11:19:41 +03:00
Evgenii Stratonikov
439d9ff94d compiler: initialize packages according to go spec
`init()` functions should be called during package initialization,
after global variables were processed.
2020-08-05 11:15:07 +03:00
Evgenii Stratonikov
6f2759be3a compiler: process packages in deterministic order 2020-08-05 11:00:25 +03:00
Evgenii Stratonikov
b771d2d024 compiler: allow to use init function
Process `init()` functions after global variables has been processed.
It's body is saved into the `_initialize` method where all
initialization is performed.
2020-08-05 11:00:25 +03:00
Roman Khimov
4bbe863904
Merge pull request #1266 from nspcc-dev/notifications/filter_by_name
rpc: filter subscriptions' notifications by name
2020-08-05 10:00:15 +03:00
Evgenii Stratonikov
7e3813a88f cli: use TAB as delimiter in vm parse
Make it simpler to use result in pipes:

neo-go vm parse 123 | rg "Integer to Hex" | cut -f1- | sed -r 's/\t//g'
2020-08-05 09:40:50 +03:00
Evgenii Stratonikov
227c6a2caa cli: allow to use vm parse directly 2020-08-05 09:40:50 +03:00
Roman Khimov
ef53a45e7a
Merge pull request #1264 from nspcc-dev/smartcontract/manifest/supported_standards
smartcontract: add list of supported standards to manifest
2020-08-04 22:17:00 +03:00