Commit graph

198 commits

Author SHA1 Message Date
Anna Shaleva
8f06bf21d7 config: add MaxBlockSize setting 2021-03-16 12:08:47 +03:00
Anna Shaleva
38103dcc7a consensus: check transactions count during PrepareRequest verification 2021-03-15 16:58:37 +03:00
Anna Shaleva
23a3514cc0 consensus: store ProtocolConfiguration in consensus config 2021-03-15 16:58:27 +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
cdaca7be3e core: use Neo.Crypto.CheckSig for standard signature verification 2021-03-10 21:45:58 +03:00
Evgeniy Stratonikov
f83b376181 block: replace Base with Header 2021-03-10 13:38:44 +03:00
Evgeniy Stratonikov
2f490a3403 block: remove ConsensusData field 2021-03-10 13:38:44 +03:00
Evgeniy Stratonikov
bf20db09e0 stateroot: move state-root related logic to core/stateroot 2021-03-09 13:48:29 +03:00
Evgeniy Stratonikov
ffd85dd51d native/policy: remove MaxBlockSize and MaxBlockSystemFee 2021-03-04 16:59:19 +03:00
Evgeniy Stratonikov
798ae6c63c consensus/test: add missing t.Cleanup() 2021-03-03 13:14:25 +03:00
Anna Shaleva
2c81fc8b8e *: upgrade tests to use T.Cleanup() 2021-03-01 17:08:00 +03:00
Evgeniy Stratonikov
91db164519 consensus/test: update binary payload data 2021-02-11 18:26:01 +03:00
Roman Khimov
43bfc909eb consensus: flush previous proposal on new block
Reusing proposals from previous blocks doesn't make sense. And reduce some
code duplication along the way.
2021-02-04 18:54:01 +03:00
Roman Khimov
8c0a7225e5 consensus: only use previous proposal if it has something in it
It might just be uninitialized it doesn't really make sense using zero-length
previous proposal anyway.
2021-02-04 18:48:09 +03:00
Roman Khimov
f081e63674 consensus: fix extensible message category name
Fix this in 2+2 setup:
2021-02-04T13:50:23.923Z        WARN    peer disconnected       {"addr": "172.30.0.5:20334", "reason": "handling CMDExtensible message: invalid category", "peerCount": 3}
2021-02-04T13:50:26.968Z        WARN    peer disconnected       {"addr": "172.30.0.2:42586", "reason": "handling CMDExtensible message: invalid category", "peerCount": 2}
2021-02-04 16:55:46 +03:00
Anna Shaleva
bfbd096fed core: introduce mempool notifications 2021-02-02 22:01:32 +03:00
Evgeniy Stratonikov
9592f3e052 network: implement pool for Extensible payloads 2021-01-28 17:09:06 +03:00
Evgeniy Stratonikov
5d83c28bc9 network: replace ConsensusType with ExtensibleType 2021-01-22 10:38:33 +03:00
Evgeniy Stratonikov
b918ec3abc consensus: refactor payloads structure
1. `Version` and `PrevHash` are now in `PrepareRequest`.
2. Serialization is done via `Extensible` payload.
3. Update dbft version.
2021-01-22 10:38:32 +03:00
Roman Khimov
476cbbebdc native: make registering as a candidate cost more
Follow neo-project/neo#2252.
2021-01-21 23:02:59 +03:00
Evgenii Stratonikov
1c0c331e25 core: update System.Contract.Call syscall
1. Remove `System.Contract.CallEx`.
2. Extend number of parameters.
3. Add return value count to `VM.Context`.
2021-01-14 18:23:36 +03:00
Anna Shaleva
766f66c5ca consensus: update binary payload tests 2020-12-21 12:51:07 +03:00
Evgenii Stratonikov
c5f9f6a3fd consensus: validate timestamp in `verifyBlock()
Not doing this can possibly lead to the same node being validator
again and again.
2020-12-16 17:41:44 +03:00
Evgenii Stratonikov
1840c1c80d core: redefine opcode prices
Prices are defined in as a coefficients to `BaseExecFee` which
is defined by Policy contract (TBD later).
Native method prices are defined without need to multiply.
2020-12-16 13:55:39 +03:00
Evgenii Stratonikov
5310c7f3ce native: fix NEP17.Transfer cost
It was increased with the introducion of `postTransfer`.
2020-12-15 12:04:10 +03:00
Anna Shaleva
0b5cf78468 network: add notary request payload 2020-12-10 18:17:31 +03:00
Roman Khimov
7044e9be40
Merge pull request #1549 from nspcc-dev/core/fix_committee_update
core: update committee every [committee length] blocks
2020-11-27 11:04:40 +03:00
Evgenii Stratonikov
7d91a3a89e pkg: move internal/ package to the root directory
This way we can use it in scripts and cli.
2020-11-24 16:39:56 +03:00
Evgenii Stratonikov
b97dfae8d8 native: replace NEP-5 with NEP-17 2020-11-24 13:08:23 +03:00
Evgenii Stratonikov
1869d6d460 core: allow to use state root in header 2020-11-20 17:16:32 +03:00
Evgenii Stratonikov
3025b42c65 consensus: assume non-nil message in decodeData
`nil` message is occuring only in tests to check that
no unnecessary decoding is done on errors.
2020-11-20 17:14:19 +03:00
Anna Shaleva
933bb4ca75 core: update committee every [committee length] blocks
Was changed in https://github.com/neo-project/neo/pull/1848. Affects
storage dumps.
2020-11-17 11:22:32 +03:00
Evgenii Stratonikov
c30d891aa9 consensus: update NextConsensus only when committee is recalculated 2020-11-09 17:35:32 +03:00
Evgenii Stratonikov
9733a6f394 core: move CalculateNetworkFee to a separate package 2020-10-07 10:04:19 +03:00
Anna Shaleva
e1e586f18b core: restrict the muximum number of contents per block 2020-10-05 18:08:33 +03:00
Evgenii Stratonikov
fc77f8b5b2 consensus: exit if wrong password is provided in configuration 2020-09-21 17:56:25 +03:00
Roman Khimov
15b621f0f3 consensus: wait goroutine to finish on Shutdown
Fixes:
panic: assignment to entry in nil map

goroutine 227 [running]:
github.com/nspcc-dev/neo-go/pkg/core/storage.(*MemoryStore).put(...)
        /home/rik/dev/neo-go/pkg/core/storage/memory_store.go:53
github.com/nspcc-dev/neo-go/pkg/core/storage.(*MemoryStore).PutBatch(0xc00035f580, 0x110a680, 0xc000336750, 0x0, 0x0)
        /home/rik/dev/neo-go/pkg/core/storage/memory_store.go:93 +0x286
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).addHeaders(0xc0000a2340, 0xc0001be301, 0xc00036d428, 0x1, 0x1, 0x0, 0x0)
        /home/rik/dev/neo-go/pkg/core/blockchain.go:516 +0xd5a
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).AddBlock(0xc0000a2340, 0xc0000bc2c0, 0x0, 0x0)
        /home/rik/dev/neo-go/pkg/core/blockchain.go:407 +0x9ca
github.com/nspcc-dev/neo-go/pkg/consensus.(*service).processBlock(0xc000152160, 0x1122320, 0xc0000bc2c0)
        /home/rik/dev/neo-go/pkg/consensus/consensus.go:440 +0xbf
github.com/nspcc-dev/dbft.(*DBFT).checkCommit(0xc0000d3400)
        /home/rik/go/pkg/mod/github.com/nspcc-dev/dbft@v0.0.0-20200911152629-be965ee4d449/check.go:71 +0x918
github.com/nspcc-dev/dbft.(*DBFT).checkPrepare(0xc0000d3400)
        /home/rik/go/pkg/mod/github.com/nspcc-dev/dbft@v0.0.0-20200911152629-be965ee4d449/check.go:36 +0x465
github.com/nspcc-dev/dbft.(*DBFT).sendPrepareRequest(0xc0000d3400)
        /home/rik/go/pkg/mod/github.com/nspcc-dev/dbft@v0.0.0-20200911152629-be965ee4d449/send.go:42 +0x2f8
github.com/nspcc-dev/dbft.(*DBFT).start(0xc0000d3400)
        /home/rik/go/pkg/mod/github.com/nspcc-dev/dbft@v0.0.0-20200911152629-be965ee4d449/dbft.go:269 +0x26f
github.com/nspcc-dev/dbft.(*DBFT).Start(0xc0000d3400)
        /home/rik/go/pkg/mod/github.com/nspcc-dev/dbft@v0.0.0-20200911152629-be965ee4d449/dbft.go:82 +0x59
github.com/nspcc-dev/neo-go/pkg/consensus.(*service).Start(0xc000152160)
        /home/rik/dev/neo-go/pkg/consensus/consensus.go:191 +0x56
github.com/nspcc-dev/neo-go/pkg/network.(*Server).tryStartConsensus(0xc000235040)
        /home/rik/dev/neo-go/pkg/network/server.go:311 +0xda
github.com/nspcc-dev/neo-go/pkg/network.(*Server).Start(0xc000235040, 0xc0000faba0)
        /home/rik/dev/neo-go/pkg/network/server.go:173 +0x202
created by github.com/nspcc-dev/neo-go/cli.newTestChain
        /home/rik/dev/neo-go/cli/executor_test.go:77 +0x47d
FAIL    github.com/nspcc-dev/neo-go/cli 14.479s
2020-09-19 21:49:05 +03:00
Roman Khimov
1608fbff87
Merge pull request #1378 from nspcc-dev/tests/cli
Implement tests for CLI
2020-09-19 17:02:34 +03:00
Evgenii Stratonikov
282b55494b consensus: allow to shutdown service 2020-09-18 12:07:01 +03:00
Roman Khimov
af6a6f5f30 consensus: fix potential system deadlock
There is a notification pushed into the channel when block is being added,
that notification is read by special goroutine that then forwards it to all
subscribers to that particular event. Consensus goroutine is one of that
subscribers, so for the system to properly function it has to read these
events, but at the same time it can generate new blocks inside, so in some
cases it can generate two blocks without ever reading from the subscription
channel and this will lead to a deadlock.

To avoid that we need to check subscription channel for events on every loop.
2020-09-18 10:21:47 +03:00
Roman Khimov
d52e79668b hash: introduce memory-optimized merkle root hash calculation routine
NewMerkleTree is a memory hog, we can do better than that:

BenchmarkMerkle/NewMerkleTree-8                       13          88434670 ns/op        20828207 B/op     300035 allocs/op
BenchmarkMerkle/CalcMerkleRoot-8                      15          69264150 ns/op               0 B/op          0 allocs/op
2020-09-15 18:38:15 +03:00
Roman Khimov
a6a1df4e0d consensus: update dbft, use new timer 2020-09-11 18:55:07 +03:00
Roman Khimov
9c5ef8d234 dbft: rev up, pick performance improvements 2020-09-09 20:46:31 +03:00
Roman Khimov
53c014a0bb crypto/consensus: sign hashes and cache them for consensus payloads
Avoid serializing payload again and again for various purposes. To sign it, we
only need a hash.

Some 2.4% gain in TPS could be achieved with this.
2020-09-09 20:46:31 +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
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
95a80c6922 consensus: add verifyBlock tests
Especially the one for #668.
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
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