Commit graph

1446 commits

Author SHA1 Message Date
Roman Khimov
03977083c0
Merge pull request #1095 from nspcc-dev/update-dbft-neox-2.x
consensus: update dbft library (neox-2.x)
2020-06-24 14:32:06 +03:00
Roman Khimov
86110445a6 consensus: update dbft library
Pick up the following changes:
 * recovery message sending fix
 * tx re-requests on sendRecoveryRequest
 * proposed block checks fix
 * timeout calculation fix for InitializeConsensus
 * removal of TxPerBlock which is irrelevant for neo-go (policying is done by
   the node, not dbft library)
2020-06-24 13:39:12 +03:00
Evgenii Stratonikov
9ee9cb8e39 core: provide key recovery interops only if neox is enabled 2020-06-24 12:37:27 +03:00
Evgenii Stratonikov
b5fb63d091 *: specify first state root index in config 2020-06-24 12:37:27 +03:00
Evgenii Stratonikov
d128b55dbf *: add config flag for enabling state root feature 2020-06-24 12:37:27 +03:00
Evgenii Stratonikov
c06b3b669d io: make maxArraySize public 2020-06-24 12:14:33 +03:00
Evgenii Stratonikov
bc81b56708 consensus: fix decodeData doc-comment 2020-06-24 10:47:44 +03:00
Evgenii Stratonikov
2863343f03 consensus: use a method function for NewPayload() 2020-06-22 17:06:28 +03:00
Roman Khimov
3a6186af54
Merge pull request #1083 from nspcc-dev/fix/stateroot
Request verified state roots
2020-06-22 16:42:41 +03:00
Evgenii Stratonikov
ad0cf146e8 consensus: restrict invocation script size 2020-06-22 15:36:12 +03:00
Evgenii Stratonikov
511d18d409 io: allow to restrict slice size in ReadVarBytes 2020-06-22 15:35:42 +03:00
Evgenii Stratonikov
aebed3826b consensus: fix commitCompact payload
Add state root signature to `commitCompact` in `recoveryMessage`.
2020-06-22 14:30:21 +03:00
Evgenii Stratonikov
caf53740d3 network: do not process state roots below verified height
Implement fast path to skip state root retrieval and decoding.
2020-06-22 12:33:35 +03:00
Evgenii Stratonikov
e2e1bd09ae network: request state roots if needed 2020-06-22 12:33:35 +03:00
Evgenii Stratonikov
f8051da0bd core: extend Blockchainer interface with StateHeight()
Allow to query current verified state root height.
2020-06-22 10:53:13 +03:00
Evgenii Stratonikov
f665843887 core: update verified state root height 2020-06-22 10:53:12 +03:00
Roman Khimov
d5ba2e49a2
Merge pull request #1045 from nspcc-dev/fix/stateroot
consensus: verify state root in PrepareRequest
2020-06-11 11:25:02 +03:00
Evgenii Stratonikov
8614867439 consensus: verify state root in PrepareRequest
Fixes #1042.
2020-06-11 10:18:12 +03:00
Roman Khimov
7d786fac79 core: fix key recovery interops return value
It's uncompressed coordinate, both X and Y, not just X. Fix #1043.
2020-06-10 19:20:57 +03:00
Roman Khimov
a6541c4514 keys: add support for uncompressed serialization in PublicKey 2020-06-10 19:17:08 +03:00
Roman Khimov
edd60e656e consensus: fix processing changeview payloads from recovery message
Using view number from the recovery message is just plain wrong, it's gonna be
higher than our current view and these messages will be treated as coming from
the future, even though they have their original view number included.
2020-06-09 18:17:01 +03:00
Roman Khimov
76f71ab1ef
Merge pull request #1012 from nspcc-dev/feature/mptrpc
rpc: implement MPT-related RPC (2.x)
2020-06-09 17:25:55 +03:00
Evgenii Stratonikov
1fd7938fd8 network: process state roots properly 2020-06-08 17:31:59 +03:00
Evgenii Stratonikov
519a98039c rpc: implement verifyproof RPC
Test getproof and verifyproof together.
2020-06-08 17:31:59 +03:00
Evgenii Stratonikov
8cbbddddaf rpc: implement getproof RPC 2020-06-08 17:31:58 +03:00
Evgenii Stratonikov
fe8038e8b7 rpc/server: implement getstateheight RPC 2020-06-08 16:40:37 +03:00
Evgenii Stratonikov
53dc7f27b6 rpc/server: implement getstateroot RPC 2020-06-08 16:40:37 +03:00
Evgenii Stratonikov
dcaa82b32b rpc: convert null value to a defaultT
Right now we convert it is unmarshaler into a float64(0)
so an error is supressed.
2020-06-08 16:39:02 +03:00
Roman Khimov
6437f4b32e core: respect MaxFreeTransactionsPerBlock setting
Fix #1019.
2020-06-08 12:35:39 +03:00
Anna Shaleva
4f1cf07075 compiler: add public key recovering syscalls
Added Secp256r1Recover and Secp256k1Recover syscalls.
2020-06-05 22:13:17 +03:00
Evgenii Stratonikov
7b1a54c934 rpc/server: unify boolean flag handling
Implement (*Param).GetBoolean() for converting parameter to bool value.
It is used for verbosity flag and is false iff it is either zero number
or empty sting.
2020-06-05 12:51:09 +03:00
Evgenii Stratonikov
44f93c7c69 rpc/server: simplify errors handling during parameter parsing 2020-06-05 12:51:09 +03:00
Roman Khimov
a1c4d7ce26 core: do MPT compaction every once in a while
We need to compact our in-memory MPT from time to time, otherwise it quickly
fills up all available memory. This raises two obvious quesions --- when to do
that and to what level do that.

As for 'when', I think it's quite easy to use our regular persistence interval
as an anchor (and it also frees up some memory), but we can't do that in the
persistence routine itself because of synchronization issues (adding some
synchronization primitives would add some cost that I'd also like to avoid),
so do it indirectly by comparing persisted and current height in `storeBlock`.

Choosing proper level is another problem, but if we're to roughly estimate one
full branch node to use 1K of memory (usually it's way less than that) then we
can easily store 1K of these nodes and that gives us a depth of 10 for our
trie.
2020-06-04 17:25:57 +03:00
Roman Khimov
e3af560d11 dao: optimize storage cache flushing
Items were serialized several times if there were several successful
transactions in a block, prevent that by using State field as a bitfield (as
it almost was intended to) and adding one more bit. It also eliminates useless
duplicate MPT traversions.

Confirmed to not break storage changes up to 3.3M on testnet.
2020-06-04 17:21:58 +03:00
Roman Khimov
69ccca675d core: fix PrevHash calculation for MPTRoot
This was differing from C# notion of PrevHash. It's not a previous root, but
rather a hash of the previous serialized MPTRoot structure (that is to be
signed by CNs).
2020-06-04 17:19:30 +03:00
Roman Khimov
685d3eb870 dao: prevent double serialization of StorageItems
Converting to MPT value serializes the StorageItem, so it makes no sense doing
it again.
2020-06-04 17:18:15 +03:00
Roman Khimov
f77c239296 mpt: fix extension node cache invalidation
It should always be invalidated if something changes in the `next` (below the
extension node).
2020-06-04 17:16:32 +03:00
Evgenii Stratonikov
5794bdb169 state: implement JSON marshaling for MPT* items 2020-06-03 18:09:28 +03:00
Roman Khimov
24785f1f50
Merge pull request #1008 from nspcc-dev/feature/mpt
core: update MPT during block processing
2020-06-03 16:07:04 +03:00
Roman Khimov
baafa30266
Merge pull request #1006 from nspcc-dev/interop/crypto
core: implement key recover interops
2020-06-03 14:39:44 +03:00
Anna Shaleva
6c06bc57cc core: implement key recover interops
Implement secp256k1 and secp256r1 recover interops, closes #1003.

Note:

We have to implement Koblitz-related math to recover keys properly
with Neo.Cryptography.Secp256k1Recover interop as far as standard
go elliptic package supports short-form Weierstrass curve with a=-3
only (see https://github.com/golang/go/issues/26776 for details).
However, it's not the best choise to have a lot of such math in our
project, so it would be better to use ready-made solution for
Koblitz-related cryptography.
2020-06-03 14:36:04 +03:00
Evgenii Stratonikov
10189b6ab3 consensus: extend payloads with StateRoot info
Create and verify witness after block processing.
2020-06-03 13:33:44 +03:00
Evgenii Stratonikov
edcfdb3bde network: add MPT-related P2P payloads 2020-06-03 13:33:44 +03:00
Evgenii Stratonikov
20f190ef69 core: update MPT during block processing 2020-06-03 13:33:44 +03:00
Roman Khimov
029fecbb71 mpt: don't flush nodes already present in the DB
It's just a waste of time.
2020-06-03 00:37:30 +03:00
Roman Khimov
1b6aee42d5 mpt: restructure nodes a bit, implement serialization and hash cache
It drastically reduces the number of allocations and hash calculations.
2020-06-03 00:37:21 +03:00
Roman Khimov
fd73310a1c
Merge pull request #1007 from nspcc-dev/update-dbft-2.x
consensus: update dbft to include CountFailed and RecoveryMessage changes
2020-06-02 22:44:46 +03:00
Roman Khimov
e4f413aa29 consensus: update dbft to include CountFailed and RecoveryMessage changes
dbft interface changed a little also because of Neo 3 changes, but it still is
compatible with Neo 2.
2020-06-02 11:12:47 +03:00
Roman Khimov
2f90a06db3
Merge pull request #990 from nspcc-dev/feature/mpt
Initial MPT implementation (2.x)
2020-06-01 18:58:35 +03:00
Evgenii Stratonikov
314430be1d mpt: implement NEO storage key conversion 2020-06-01 18:15:13 +03:00