Commit graph

3033 commits

Author SHA1 Message Date
Evgenii Stratonikov
931dc6c64f compiler: remove debug PrintOps() from tests 2020-08-25 08:53:29 +03:00
Evgenii Stratonikov
0f11116040 compiler: support make() 2020-08-25 08:53:28 +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
Roman Khimov
35edc26193
Merge pull request #1345 from nspcc-dev/feature/nextvalidator
native: do not rewrite NextValidators in (*NEO).OnPersist()
2020-08-24 16:50:26 +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
Roman Khimov
860e7f12ad
Merge pull request #1341 from nspcc-dev/feature/highprio
Support high-priority transactions from committee
2020-08-23 13:25:42 +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
Roman Khimov
37cb30c82a
Merge pull request #1344 from nspcc-dev/fix/signatures
core: implement (*Blockchain).VerifyWitness
2020-08-22 13:22:27 +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
Roman Khimov
790693fc6d
Merge pull request #1340 from nspcc-dev/compiler/shortjumps
Emit short jumps where possible
2020-08-21 10:20:22 +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