Roman Khimov
f9963cca37
core: short-circuit verifyInputs when there are no inputs
2020-02-06 15:41:56 +03:00
Roman Khimov
70b3839fd0
core/mempool: fix AddBlock and tx pooling concurrency issues
...
Eliminate races between tx checks and adding them to the mempool, ensure the
chain doesn't change while we're working with the new tx. Ensure only one
block addition attempt could be in progress.
2020-02-06 15:41:52 +03:00
Roman Khimov
fca86771e9
Merge pull request #644 from nspcc-dev/fix/array_reverse
...
util: always copy argument in ArrayReverse
2020-02-06 13:14:11 +03:00
Evgenii Stratonikov
24bb66e606
util: fix a bug with not copying slice of len=1 in ArrayReverse
...
ArrayReverse copies it's argument only if it's len is > 1.
It needs to be consistent in all cases.
2020-02-06 12:15:35 +03:00
Evgenii Stratonikov
d07d6f3371
util: refactor tests for ArrayReverse
2020-02-06 12:15:35 +03:00
Evgenii Stratonikov
2a86149c82
vm: leave single CHECKMULTISIG implementation
...
Remove sequential implementation and benchmarks.
They will be still present in commit history.
2020-02-05 17:17:22 +03:00
Roman Khimov
02a5e036fc
vm: deduplicate checkMultisigPar
...
Make its logic more clear.
2020-02-05 17:12:23 +03:00
Evgenii Stratonikov
d93d060010
vm: parallelize CHECKMULTISIG
2020-02-05 17:12:18 +03:00
Roman Khimov
f0bb886be3
mempool: make all methods pointer methods
...
Makes no sense copying the Pool around.
2020-02-04 17:36:11 +03:00
Roman Khimov
70c22ebc7b
Merge pull request #641 from nspcc-dev/consensus-update
...
Consensus update
2020-02-04 15:39:53 +03:00
Roman Khimov
916b54fd60
go.mod: update dbft library, fix #634 and other problems
2020-02-04 13:16:09 +03:00
Roman Khimov
9ceefe17e2
consensus: check current chain height before processing timer
...
The chain may already be more current than our dBFT state (like when the node
has commited something at view 0, but all the other nodes changed view and
accepted something at view 1), so in this case we should reinit dBFT on new
height.
2020-02-04 13:16:09 +03:00
Evgenii Stratonikov
e65b5c9914
consensus: fill preparation hash in recovery message
2020-02-04 13:16:05 +03:00
Evgenii Stratonikov
e441cb1414
consensus: add preparation hash to logger
2020-02-04 13:16:00 +03:00
Evgenii Stratonikov
42dfb52e98
consensus: add more logging in consensus service
2020-02-04 13:15:54 +03:00
Roman Khimov
2e027f3fbd
Merge pull request #640 from nspcc-dev/forbid-encoding-bad-txes
...
Forbid encoding incomplete transactions
2020-02-04 13:03:29 +03:00
Roman Khimov
553b2391a3
consensus: handle encoding errors in Hash()
2020-02-03 16:33:03 +03:00
Roman Khimov
388fed06e5
transaction: forbid serializing invalid transactions
...
Transaction that has no data is invalid and can't be serialized, so throw an
error if someone tries to.
2020-02-03 16:33:03 +03:00
Roman Khimov
9374c5e7c2
Merge pull request #639 from nspcc-dev/networking-improvements
...
Networking improvements
2020-02-03 16:26:04 +03:00
Roman Khimov
f69d317036
Merge pull request #637 from nspcc-dev/feature/optimize_constants
...
compiler: do not store constants as variables
2020-02-03 14:59:06 +03:00
Evgenii Stratonikov
c3094123a1
compiler: do not store constants as variables
...
Because the constants are loaded directly via `emitLoadConst`, there is no need to store
them in an array of locals. It can have a big overhead, because it
is done at the beginning of every function.
2020-02-03 13:29:28 +03:00
Roman Khimov
e5d0125a3f
network: do async broadcast when processing P2P TX
...
It can lead to some goroutine explosion, but supposedly it's better than
stalling other processing and eventually all of these goroutines should finish
their sends. Note that this doesn't change the behavior for RPC-relayed
transactions that are still waiting for the broadcast to finish ensuring
proper transaction distribution before returning the result to the client.
2020-01-30 14:03:52 +03:00
Roman Khimov
0fcbc697ca
network: only tell consensus service about new valid transactions
...
Transactions can be bad and can duplicate each other, consensus service
shouldn't be bothered with that.
2020-01-30 14:03:52 +03:00
Roman Khimov
fdbaac7a30
network: prevent broadcast queue starving, share time with p2p
...
Blocked broadcast queue of one peer may affect broadcasting capabilities of
the server, so prevent total blocking of it by p2p queue.
2020-01-30 14:03:52 +03:00
Roman Khimov
b2c4587dad
network: fix PeerAddr() for not-yet-handshaked case
...
If we have already got Version message, we don't need the rest of handshake to
complete before being able to properly answer the PeerAddr() requests. Fixes
some duplicate connections between machines.
2020-01-30 14:03:52 +03:00
Roman Khimov
49bd7aada5
network: log peerCount on connection registration
...
Symmetrical to disconnects, make it easier to look through the logs.
2020-01-30 14:03:52 +03:00
Roman Khimov
32695b4f40
network: don't unregister connected peers
...
If we drop connection because we're already connected don't unregister this
connected address because it's connected anyway!
2020-01-30 14:03:52 +03:00
Roman Khimov
eb4ec61b8b
network: register connected addr in handleVersionCmd()
...
Prevent useless attempts to connect to this peer if the peer has already made
a connection to us.
2020-01-30 14:03:52 +03:00
Roman Khimov
9eafec0d1d
network: introduce peer-to-peer message queue
...
This one is designed to give more priority to direct nodes communication, that
is that their messaging would have more priority than generic broadcasts. It
should improve consensus process under TX pressure and allow to handle
pings in time (preventing disconnects).
2020-01-30 14:03:52 +03:00
Roman Khimov
72e4eb7172
network: fix wrong NewPing() parameters
...
They have the opposite order, height first and nonce second. It was done wrong
in 4e6ed902
and never fixed since. Fixes sending wrong peer state leading to
useless getheaders messages (and disconnects when the other side is lagging
behind).
2020-01-30 14:03:52 +03:00
Roman Khimov
da09fda575
network: add debug on message receival
2020-01-30 14:03:52 +03:00
Roman Khimov
1c28dd2567
network: add message type to disconnect error message
...
If it was caused by message processing, but only after the handshake to
preserve errIdenticalID and other handshaking errors.
2020-01-30 14:03:52 +03:00
Roman Khimov
b79abd1e27
network: detect duplicate connections before handshake completes
...
We can have more than one connection attempt in progress and not yet completed
the handshake, so if there is a Version already received we should look it.
2020-01-30 14:03:52 +03:00
Roman Khimov
48ca0e1126
Merge pull request #635 from nspcc-dev/feature/dbft
...
consensus: update dbft version
2020-01-30 14:02:51 +03:00
Evgenii Stratonikov
3d99b10d5e
consensus: update dbft version
2020-01-30 13:57:21 +03:00
Roman Khimov
f773ec69fb
Merge pull request #633 from nspcc-dev/fix-rpc-unused-address-handling
...
rpc: fix getaccountstate/getunspents for unknown addresses
2020-01-29 20:14:27 +03:00
Roman Khimov
b1b660c779
rpc: fix getaccountstate/getunspents for unknown addresses
...
Returning error string as a result (not an error) is utterly wrong, but C#
implementation just returns a zero balance for unknown addresses, so we should
follow that.
2020-01-29 19:01:00 +03:00
Roman Khimov
0ccc59628c
Merge pull request #631 from nspcc-dev/fix/return3
...
compiler: fix a bug with assignment to underscore
2020-01-29 18:32:43 +03:00
Roman Khimov
2aaa126462
Merge pull request #632 from nspcc-dev/feature/recoverymsg
...
consensus: use our implementations of Recovery* messages
Fixes EOF errors on consensus message decoding.
2020-01-29 18:31:54 +03:00
Evgenii Stratonikov
390bf58f97
consensus: use our implementations of Recovery* messages
...
While decoding payload, local implementations of Recovery*
messages were used, but when creating RecoveryMessage inside dBFT
library default NewRecoveryMessage was invoked. This lead to parsing
errors.
2020-01-29 17:56:26 +03:00
Evgenii Stratonikov
8b922c057c
compiler: fix a bug with assignment to underscore
...
When using underscore it does not appear in the list
of local variables, so it can't be assigned.
In this commit the value is dropped.
2020-01-29 17:07:55 +03:00
Roman Khimov
d234a1e718
Merge pull request #629 from nspcc-dev/feature/panic
...
compiler: support panic builtin
2020-01-29 15:10:30 +03:00
Evgenii Stratonikov
7053b3b2c0
compiler: optimize append argument processing
...
Append should leave it's result on top of the stack.
Thus we need to transform top of the stack:
(top) a . b --> (top) a . b . b
It can be done with just OVER + SWAP.
2020-01-29 12:28:38 +03:00
Evgenii Stratonikov
b6629fb6bd
compiler: refactor argument handling for builtins
...
It is more convenient to have all unusual logic in one place.
2020-01-29 12:28:38 +03:00
Evgenii Stratonikov
d2326a8b96
compiler: support panic
in source
...
In situations where VM's FAULT state needs to be reached,
panic function can be used. It compiles to THROW instruction.
2020-01-29 12:28:38 +03:00
Roman Khimov
a839efb35e
Merge pull request #626 from nspcc-dev/feature/switch
...
compiler: implement switch statement support
Implements 1 & 2 from #628 .
2020-01-29 10:03:47 +03:00
Evgenii Stratonikov
e0f47decc7
compiler: replace ROLL(2) with equivalent ROT
2020-01-29 09:56:16 +03:00
Evgenii Stratonikov
28571bd3dc
compiler: implement switch statement support
2020-01-29 09:56:16 +03:00
Roman Khimov
0ce0ecb95e
Merge pull request #624 from nspcc-dev/feature/bigint
...
compiler: emit integers correctly
2020-01-28 18:04:32 +03:00
Roman Khimov
ab03aee2cf
Merge pull request #627 from nspcc-dev/fix-getdata-and-pings
...
Fix getdata and pings
2020-01-28 17:43:13 +03:00