Evgenii Stratonikov
e58616b975
compiler: drop unused call results
...
Close #683 .
2020-08-24 19:34:51 +03:00
Evgenii Stratonikov
f70cb4f34a
compiler: do not use voidCalls
when calculating stack size
...
This was probably a part of some earlier logic.
2020-08-24 19:34:51 +03:00
Roman Khimov
d8badd9a8d
Merge pull request #1351 from nspcc-dev/compiler/jmps
...
Make use of extended JMP* opcodes
2020-08-24 19:22:24 +03:00
Evgenii Stratonikov
4782a94200
native: do not rewrite NextValidators in (*NEO).OnPersist()
...
There is no need in writing the same value again and again.
Closes #1337 .
2020-08-24 16:45:09 +03:00
Roman Khimov
1809076dc6
Merge pull request #1347 from nspcc-dev/vm-updates
...
Post-preview3 VM updates
2020-08-24 16:37:12 +03:00
Roman Khimov
6c27c2c13a
Merge pull request #1350 from nspcc-dev/some-post-preview3-core-changes
...
Some post-preview3 core changes
2020-08-24 16:26:12 +03:00
Roman Khimov
681ae4d5d6
vm: fix TRY offsets check
...
TRY can have an offset != 0 and still it can't have both parameters set to
zero.
2020-08-24 16:20:57 +03:00
Roman Khimov
32112249d5
vm: limit maximum nesting of exception contexts
...
Follow neo-project/neo#365 . neo-vm submodule is updated just to show the
relevant latest commit, nothing really changed there.
2020-08-24 15:37:39 +03:00
Evgenii Stratonikov
9dc3edf351
compiler: make use of extended JMP* opcodes
2020-08-24 11:19:54 +03:00
Evgenii Stratonikov
51f3baf68e
compiler: refactor BinaryExpr handling
...
Reuse code between if conditions and expression context.
2020-08-24 09:46:11 +03:00
Evgenii Stratonikov
4d04c56efb
compiler: make toShortForm
accept an opcode
2020-08-24 09:44:44 +03:00
Evgenii Stratonikov
1be1b8de9e
compiler: merge &&
and ||
processing
2020-08-24 09:44:44 +03:00
Evgenii Stratonikov
59367c96d1
compiler: allow to use +=
on strings
2020-08-24 09:44:44 +03:00
Evgenii Stratonikov
fd7af77895
compiler: refactor convertToken
func
...
Move `getEqualityOpcode` into `convertToken`.
`convertToken` does not need codegen.
2020-08-24 09:44:44 +03:00
Evgenii Stratonikov
ae88c77a8a
compiler: process nil
comparisons separately
2020-08-24 09:44:16 +03:00
Roman Khimov
9c72ea1d64
core/interop: add base58 encoding/decoding syscalls
...
Follow neo-project/neo#1833 .
2020-08-23 17:19:56 +03:00
Roman Khimov
562e7e371f
consensus: switch to uint8 for validator index
...
Follow neo-project/neo#1837 . Tests will need to be updated with real messages.
2020-08-23 16:44:56 +03:00
Roman Khimov
7cba3a0342
core: require AllowStates flag for IsStandard
...
Follow neo-project/neo#1830 .
2020-08-23 15:41:55 +03:00
Evgenii Stratonikov
e4af295080
compiler: process constant first in BinaryExpr handling
2020-08-23 12:24:03 +03:00
Evgenii Stratonikov
7ee1ddff61
transaction: add tests for (*Transaction).isValid()
2020-08-23 09:39:46 +03:00
Evgenii Stratonikov
890c752b3b
mempool: add tests for items ordering
2020-08-23 09:39:46 +03:00
Evgenii Stratonikov
2661ebd295
transaction: add HighPriority attribute
...
HighPriority attributes specifies that transaction was
signed by a committee.
2020-08-23 09:39:46 +03:00
Evgenii Stratonikov
51cebe9e47
smartcontract: support creation of majority multisig scripts
2020-08-23 09:39:46 +03:00
Evgenii Stratonikov
e0104679b5
core/tests: make verityTx test more verbose
2020-08-23 09:39:46 +03:00
Roman Khimov
324f4c265b
stackitem: don't copy existing slices for TryBytes
...
Most often we only need to read them and it doesn't require copying. Make an
explicit copy (and copy only things we need!) where needed.
After the recent neo-vm tests update our vm package testing time jumped to
~12s, with this change it's now more like ~8s.
2020-08-22 23:36:38 +03:00
Roman Khimov
77ea3d361b
vm: update neo-vm tests, simplify parsing
...
We no longer have "*N" notation, see neo-project/neo-vm#326 .
2020-08-22 23:35:29 +03:00
Roman Khimov
74097ae8b0
stackitem: add NewPointerWithHash() to save on hash calculations
...
Inspired by neo-project/neo-vm#352 . We can't directly compare slices, so we're
better optimize things we already have. At the same time this code would
behave a bit different if A is to call B and then B is call A and then some
pointer from the first A invocation is to be compared with a pointer from the
second A invocation. Not sure it really matters.
2020-08-22 22:19:44 +03:00
Roman Khimov
e5813ae8cd
Merge pull request #1346 from nspcc-dev/string-tryboolean
...
Fail converting long strings to boolean
2020-08-22 17:04:11 +03:00
Evgenii Stratonikov
7e34072519
core: implement (*Blockchain).VerifyWitness
...
`ScriptFromWitness` is no longer useful, because we support
contract verification.
2020-08-22 12:45:20 +03:00
Roman Khimov
93f51f922a
stackitem: return error in TryBytes() for big byte strings
...
Follow neo-project/neo-vm#349 .
2020-08-21 21:05:47 +03:00
Roman Khimov
a7670303e8
stackitem: change Bool() to TryBool(), prepare for its failures
2020-08-21 20:55:20 +03:00
Roman Khimov
4e7a1f6c87
Merge pull request #1342 from nspcc-dev/tps
...
Improve TPS, part 1
2020-08-21 14:56:51 +03:00
Evgenii Stratonikov
2b73508561
compiler: emit short jumps while short-circuiting
...
Unless there is some `ast.Walk` between current instruction and jump
target, we can calculate the offset precisely.
2020-08-21 09:43:05 +03:00
Evgenii Stratonikov
984aba3113
compiler: process last instructin in writeJumps
...
It is unlikely that we will emit a script with a JMP in the end,
but `writeJumps` must work correctly even in such case.
2020-08-21 09:43:05 +03:00
Evgenii Stratonikov
cfa62e7051
compiler: emit short jumps where possible
...
Convert long jumps to short ones if the offset
can be represented in a single byte.
Close #805 .
2020-08-21 09:43:05 +03:00
Evgenii Stratonikov
681e81420a
vm: make (*Context).IP() return instruction pointer
...
It is misleading to return +1 in code, and user representation
can always be altered.
2020-08-21 08:44:32 +03:00
Roman Khimov
0e086d61ac
mempool: store feeSum as big.Int
...
Prevent (very) potential overflow.
2020-08-20 19:06:59 +03:00
Roman Khimov
95a80c6922
consensus: add verifyBlock tests
...
Especially the one for #668 .
2020-08-20 18:50:36 +03:00
Roman Khimov
7fedb4f4ba
testchain: move newBlock there from rpc/server
...
Allow its reuse by other components.
2020-08-20 18:50:36 +03:00
Roman Khimov
d9b8704b48
consensus: check for chain's height in verifyBlock
...
We may already be behind and this check could be irrelevant.
2020-08-20 18:50:36 +03:00
Roman Khimov
55b2cbb74d
core: refactor and improve verification and pooling
...
Now we have VerifyTx() and PoolTx() APIs that either verify transaction in
isolation or verify it against the mempool (either the primary one or the one
given) and then add it there. There is no possibility to check against the
mempool, but not add a transaction to it, but I doubt we really need it.
It allows to remove some duplication between old PoolTx and verifyTx where
they both tried to check transaction against mempool (verifying first and then
adding it). It also saves us utility token balance check because it's done by
the mempool anyway and we no longer need to do that explicitly in verifyTx.
It makes AddBlock() and verifyBlock() transaction's checks more correct,
because previously they could miss that even though sender S has enough
balance to pay for A, B or C, he can't pay for all of them.
Caveats:
* consensus is running concurrently to other processes, so things could
change while verifyBlock() is iterating over transactions, this will be
mitigated in subsequent commits
Improves TPS value for single node by at least 11%.
Fixes #667 , fixes #668 .
2020-08-20 18:50:18 +03:00
Roman Khimov
0d8cc437fe
mempool: swap checks in Add, fail fast
...
Checking for duplicates is easier than checking the balance, so it should be
done first.
2020-08-20 18:50:18 +03:00
Roman Khimov
e998c102ca
mempool: rename NewMemPool into New
...
"mempool" is a package name already.
2020-08-20 18:50:18 +03:00
Roman Khimov
0bf2fa915e
consensus: don't decrypt the key again and again, cache it
...
It's cached in dbft for a view anyway, so there is no big difference here
from security POV. Lets us squeeze yet another 4% TPS improvement.
Make the system fail if unable to decrypt the key along the way, which is a
part of #1312 .
2020-08-20 18:50:18 +03:00
Roman Khimov
c7032022f8
core: don't search through the whole DAO in isTxStillRelevant
...
New transactions are added to the chain with blocks. If there is no
transaction X at height N in DAO, it could only be added with block N+1, so
it has to be present there. Therefore we can replace `dao.HasTransaction()`
check with a search through in-block transactions. HasTransaction() is nasty
in that it may add useless load the DB and this code is being run with a big
Blockchain lock held, so we don't want to be delayed here at all.
Improves single-node TPS by ~2%.
2020-08-20 18:50:18 +03:00
Roman Khimov
3a379e4f3e
core: don't reverify mempooled transactions in AddBlock
...
The end effect is almost as if `VerifyTransactions: false` was set in the
config, but without actually compromising the guarantees provided by it.
It almost doubles performance for single-mode benchmarks and makes block
processing smoother (more smaller blocks are being produced).
2020-08-19 15:16:19 +03:00
Roman Khimov
eb8122837e
core: fix failing TestGetTransaction
...
3677cc0e2
ruined it:
TestGetTransaction: blockchain_test.go:413:
Error Trace: blockchain_test.go:413
Error: Not equal:
expected: 467
actual : 399
Test: TestGetTransaction
2020-08-19 13:22:31 +03:00
Roman Khimov
e920b9e572
Merge pull request #1338 from nspcc-dev/fix/interop
...
compiler: allow to alias interop packages
2020-08-19 11:38:14 +03:00
Roman Khimov
6dffd4967a
Merge pull request #1335 from nspcc-dev/tests/binary
...
Update binary test data
2020-08-19 11:33:47 +03:00
Evgenii Stratonikov
181569c2a1
compiler: allow to alias interop packages
...
Fix #397 .
2020-08-19 10:13:36 +03:00
Evgenii Stratonikov
3677cc0e24
core: update GetTransaction test
2020-08-19 09:41:11 +03:00
Evgenii Stratonikov
7eadbcb062
consensus: update binary test data
2020-08-19 09:41:11 +03:00
Roman Khimov
36ce23789a
consensus: fix comment typo
2020-08-18 17:41:22 +03:00
Roman Khimov
6cc61099b6
Merge pull request #1334 from nspcc-dev/fix-recovery-message-payload-decoding
...
consensus: payloads from recovery messages are network-dependent too
2020-08-18 16:32:24 +03:00
Roman Khimov
7db4ac4e2b
consensus: payloads from recovery messages are network-dependent too
...
Fixes wrong hash calculated for prepare request leading to bad prepare
response and inability to run heterogeneous 2+2 Go/C# nodes consensus.
2020-08-18 16:26:20 +03:00
Roman Khimov
9257167af3
Merge pull request #1328 from nspcc-dev/tests/addnetworkfee
...
rpc/client: provide scripts in AddNetworkFee
2020-08-18 15:30:47 +03:00
Evgenii Stratonikov
04bff62d65
transaction: update binary test data
2020-08-18 15:09:30 +03:00
Evgenii Stratonikov
054b77dbde
block: update binary test data
2020-08-18 14:52:30 +03:00
Roman Khimov
b11ee92202
Merge pull request #1333 from nspcc-dev/network/decode_cmdnotfound
...
network: decode CMDNotFound
2020-08-18 14:50:46 +03:00
Anna Shaleva
18691430fd
network: decode CMDNotFound
...
We don't react on this command, but we should be able to decode it.
2020-08-18 14:24:27 +03:00
Roman Khimov
52b002e079
Merge pull request #1332 from nspcc-dev/check-for-excessive-verification-results
...
core: verification script must return exactly one value
2020-08-18 12:15:10 +03:00
Evgenii Stratonikov
a080d24cf5
vm: fix debugger and add tests
...
1. `Run()` must be able to continue execution after a breakpoint.
2. VM must stop right before the breakpoint, not after.
3. Initial vm state is NONE, not HALT.
2020-08-18 11:26:27 +03:00
Evgenii Stratonikov
8659fd79e5
vm: add tests for ByteString enumerator/iterator
2020-08-18 11:24:48 +03:00
Evgenii Stratonikov
6bdaefcfa4
rpc/client: use CreateTxFromScript
where possible
...
There is substantial overlap between `CreateTxFromScript` and
`SignAndPushInvocationTx`. This commit refactors both of them
to reuse common code.
2020-08-18 11:24:48 +03:00
Evgenii Stratonikov
16b10ab918
rpc/client: drop (*Client).wif
...
It isn't used internally and has no value.
2020-08-18 11:24:48 +03:00
Evgenii Stratonikov
316666cc22
rpc/client: add tests for Ping
2020-08-18 11:24:48 +03:00
Evgenii Stratonikov
48f1502167
rpc/client: add tests for SignAndPushInvocationTx
2020-08-18 11:24:48 +03:00
Evgenii Stratonikov
2699508914
wallet: emit proper multisignature
...
In case when a signature needs to be added to multisig
we must first find corresponding signer, not append new witness.
2020-08-18 11:24:48 +03:00
Evgenii Stratonikov
8699a4c1a9
rpc/client: provide scripts in AddNetworkFee
...
To calculate network fee properly we must know type of every
signer (simple, multisig, contract). Providing scripts is the most
simple and flexible way to know this.
2020-08-18 11:24:48 +03:00
Anna Shaleva
591f639ad6
core: fix getOnPersistWrapper for native contracts
...
According to manifest, OnPersist.ReturnType is void, so we shouldn't
return anything from it. It's not so important, as we drop this value at
the end of OnPersist invocation.
2020-08-18 09:52:46 +03:00
Roman Khimov
d0c29f52c9
core: verification script must return exactly one value
...
C# node is quite picky as it expects there to be exactly one value returned,
but our testchain actually adds 4 signatures for multisig cases instead of 3
which makes it technically incompatible with C# node.
2020-08-17 22:02:15 +03:00
Roman Khimov
58af143f25
Merge pull request #1326 from nspcc-dev/fix-block-synchronization
...
Fix block synchronization
2020-08-15 20:19:59 +03:00
Roman Khimov
8e619cc671
Merge pull request #1318 from nspcc-dev/fix/verifytests
...
Add tests for `verifyTx` and `verifyHeader`
2020-08-14 17:24:03 +03:00
Roman Khimov
8d19f0e6f5
network: don't request block we already have
...
GetBlockByIndex handler starts sending blocks right from the start index and
if that index is s.chain.BlockHeight() then we're requesting and receiving a
block we already have.
2020-08-14 16:25:13 +03:00
Roman Khimov
c8cc91eeee
network: request blocks when there is a ping with bigger than ours height
...
Turns out, C# node no longer broadcasts an Inv when it's creating a block,
instead it sends a ping and if we're not paying attention to the height
specified there we're technically missing a new block. Of course we'll get it
later after ping timer expiration and regular ping/pong sequence, but that's
delaying it for no good reason.
2020-08-14 16:22:15 +03:00
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
Roman Khimov
49688de75c
Merge pull request #1260 from nspcc-dev/feature/sendmany
...
cli: allow to transfer multiple tokens in `multitransfer`
2020-08-04 19:35:03 +03:00
Anna Shaleva
6c8accf18c
core, network: request blocks instead of headers
...
Closes #1192
1. We now have CMDGetBlockByIndex, so there's no need to request headers
first when we can just ask for blocks.
2. We don't ask for headers (i.e. we don't send CMDGetHeaders),
consequently, we shouldn't react on CMDHeaders.
3. But we still keep on reacting on CMDGetHeaders command as
there could be a node which needs headers.
2020-08-04 17:52:34 +03:00
Anna Shaleva
f6f3863e0e
network: allow to GetHeaders by index
...
Use GetBlockByIndex payload for GetHeaders command instead of GetBlocks
payload.
2020-08-04 17:52:34 +03:00
Anna Shaleva
7b1c305000
network: fix handleGetBlockByIndexCmd method
...
It returned an error in case if block wasn't found (it might be when our
chain is lower). Fixed. It also should return all requested blocks, not
the first one.
2020-08-04 17:52:34 +03:00
Anna Shaleva
0b0591fc34
network: allow to use -1 to specify GetBlockByIndex.Count
2020-08-04 17:52:34 +03:00
Anna Shaleva
0b856033b0
network: use MaxHeadersAllowed to restrict GetBlockByIndex
2020-08-04 17:52:34 +03:00
Anna Shaleva
737ba700e9
network: rename GetBlockData command
...
GetBlockData -> GetBlockByIndex
2020-08-04 17:52:34 +03:00
Anna Shaleva
7c6cdcbcc9
core: fix bug with policy.MaxVerificationGas
...
In 121c9664b
we should take into account isValid flag of
NativePolicy contract while retrieving MaxVerificationGas native
policy value. Otherwise we won't be able to get MaxVerificationGas
after the node was restarted, because this value is not truly
stored along with the other native policy values.
This commit fixes bug with headers verification after the node
restarting with an existing storage:
```
2020-08-03T12:52:56.158+0300 WARN failed processing headers {"error": "vm failed to execute the script with error: error encountered at instruction 0 (PUSHDATA1): gas limit is exceeded", "errorVerbose": "vm failed to execute the script with error: error encountered at instruction 0 (PUSHDATA1): gas limit is exceeded\ngithub.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).verifyHashAgainstScript\n\t/home/neospcc/Documents/GitProjects/nspcc-dev/neo-go/pkg/core/blockchain.go:1454\ngithub.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).verifyHeaderWitnesses\n\t/home/neospcc/Documents/GitProjects/nspcc-dev/neo-go/pkg/core/blockchain.go:1517\ngithub.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).verifyHeader\n\t/home/neospcc/Documents/GitProjects/nspcc-dev/neo-go/pkg/core/blockchain.go:1175\ngithub.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).addHeaders\n\t/home/neospcc/Documents/GitProjects/nspcc-dev/neo-go/pkg/core/blockchain.go:484\ngithub.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).AddHeaders\n\t/home/neospcc/Documents/GitProjects/nspcc-dev/neo-go/pkg/core/blockchain.go:453\ngithub.com/nspcc-dev/neo-go/pkg/network.(*Server).handleHeadersCmd\n\t/home/neospcc/Documents/GitProjects/nspcc-dev/neo-go/pkg/network/server.go:454\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1373"}
```
2020-08-04 17:52:34 +03:00
Anna Shaleva
ba08a9b6ad
core: move all transaction.Decode checks to separate method
...
We should perform the same checks during UnmarshalJSON.
2020-08-04 17:34:06 +03:00
Anna Shaleva
ead6bdb25e
core: remove unnecessary comment
2020-08-04 17:34:06 +03:00
Anna Shaleva
90825efa16
core: move transaction's sender to cosigners
...
Closes #1184
Ported changes from https://github.com/neo-project/neo/pull/1752
2020-08-04 17:33:50 +03:00
Anna Shaleva
66ceaa6b75
smartcontract: add list of supported standards to manifest
...
Closes #1204
2020-08-04 17:29:44 +03:00
Anna Shaleva
4ff3a9e9a7
rpc: filter subscriptions' notifications by name
...
Closes #1263
2020-08-04 16:29:13 +03:00
Anna Shaleva
8697582b23
core: add FeeOnly witness scope
2020-08-04 15:08:59 +03:00
Anna Shaleva
75f1c2d6f2
core: add scopes check to cosigners in DecodeBinary
2020-08-04 15:08:59 +03:00
Anna Shaleva
7865bc5925
core: fix native policy tests
...
That was a merge problem.
2020-08-04 15:05:31 +03:00
Roman Khimov
62f5aa8eb4
Merge pull request #1254 from nspcc-dev/native/policy/maxblocksystemfee
...
core, consensus: add maxBlockSystemFee to native Policy
2020-08-04 13:13:06 +03:00
Roman Khimov
fa5ff8dd95
Merge pull request #1242 from nspcc-dev/fix/json
...
Implement lossless stackitem to json conversion
2020-08-04 12:59:47 +03:00
Evgenii Stratonikov
d54c60ded3
compiler: support pointer dereferencing for structs
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-08-04 11:14:07 +03:00
Evgenii Stratonikov
eb047b12a7
compiler: support creating pointers to struct
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-08-04 11:14:07 +03:00
Anna Shaleva
db65ed04d9
consensus: apply policy during verifyBlock
...
To follow C# implementation we should also check proposed block on
policy matching.
2020-08-04 10:59:09 +03:00
Anna Shaleva
4a1c8464f9
core: use maxBlockSize to apply policy to tx set
...
We should also take into account maxBlockSize in
(bc *Blockchain).ApplyPolicyToTxSet
2020-08-04 10:59:09 +03:00
Anna Shaleva
c647f8e4ed
core: add maxBlockSystemFee to native Policy
...
Closes #1195
2020-08-04 10:59:00 +03:00
Evgenii Stratonikov
2dd6ef964e
cli: allow to transfer multiple tokens in multitransfer
...
Like this:
./neogo wallet nep5 multitransfer -w wallet1_solo.json
--from NVNvVRW5Q5naSx2k2iZm7xRgtRNGuZppAK -r http://127.0.0.1:30333
neo:NYqxsNMHxDg3T19APYP27mBZFfauC4zngR:2
neo:NVNvVRW5Q5naSx2k2iZm7xRgtRNGuZppAK:3
gas:NYqxsNMHxDg3T19APYP27mBZFfauC4zngR:2
2020-08-04 10:36:06 +03:00
Roman Khimov
3e192b11b2
Merge pull request #1255 from nspcc-dev/p2p-handle-decompression-length-mismatch
...
network: handle length mismatch in decompression routine
2020-08-04 10:24:57 +03:00