Commit graph

1338 commits

Author SHA1 Message Date
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
Roman Khimov
06c3fbe455 network: rework ping sends, fix overpinging
Our node was too pingy because of wrong timer setups (that divided timeout
Duration by time.Second), it also was wrong in its time calculations (using
UTC time to calculate intervals). At the same time missing block is a
server-wide problem, so it's better solved with server-wide protocol loop.
2020-01-28 17:39:52 +03:00
Roman Khimov
39800aecb3 network: fix getdata handling
It was broken by 0ba6b2a7, the peer only responded with one message instead of
full requested set.
2020-01-28 17:39:52 +03:00
Evgenii Stratonikov
d190b3a2e0 compiler: emit integers correctly
A while ago VM serialization format for Integer items was changed
but compiler continued to emit Integers in old format.
This commit changes compiler behaviour to be compatible with VM.
2020-01-28 16:39:19 +03:00
Evgenii Stratonikov
f15ceff592 vm: make IntToBytes, BytesToInt public
VM serialization format should be able to be reused.
2020-01-28 16:39:19 +03:00
Roman Khimov
9037cabe1e
Merge pull request #625 from nspcc-dev/prepare-build-and-publish-images
Prepare build and publish images
2020-01-28 13:41:16 +03:00
Evgeniy Kulikov
2cb2a6d320
Add possibility to import different dump of chains
- import dump only if `node` sub command passed
- ACC env variable default value is `6000-privnet-blocks.acc.gz`
- ACC env variable can be declared in `docker-compose`
- ACC env variable can be one of:
  - `/6000-privnet-blocks.acc.gz`
  - `/1600-privnet-blocks-single.acc.gz`
  - custom path to dump of blockchain
2020-01-28 13:29:13 +03:00
Evgeniy Kulikov
9e92749b05
Add single node chain dump to image 2020-01-28 13:04:13 +03:00
Evgeniy Kulikov
afbbdc5e02
Update command to build and publish images
- Use nspcc-dev docker hub repository
- Add command to publish neo-go images
2020-01-28 13:03:18 +03:00
Roman Khimov
1774b87a86
Merge pull request #622 from nspcc-dev/feature/byteconst
compiler: allow to convert string constants to []byte
2020-01-27 15:56:07 +03:00
Evgenii Stratonikov
77f9a2ee26 compiler: convert AppCall parameter from string properly 2020-01-27 15:34:03 +03:00
Evgenii Stratonikov
d65d6ab08d compiler: allow to convert string constants to []byte
Also load constant directly into stack, not by name.
2020-01-27 15:29:52 +03:00
Roman Khimov
1cfad9ccb8
Merge pull request #621 from nspcc-dev/feature/appcall
compiler: implement AppCall interop
2020-01-27 14:53:48 +03:00
Evgenii Stratonikov
097d35b9d5 compiler: fix a bug with FromAddress handling
Conversion of string to address with FromAddress is performed
at compile time so there is no need to push parameters on stack.
2020-01-27 13:14:40 +03:00
Evgenii Stratonikov
330db36168 compiler: implement engine.AppCall interop 2020-01-27 13:14:36 +03:00
Roman Khimov
ead0b8ff94
Merge pull request #620 from nspcc-dev/feature/map
compiler: support map literals
2020-01-23 19:27:12 +03:00
Evgenii Stratonikov
4fd766fe09 compiler: allow usage of string literals in index expressions 2020-01-23 17:28:35 +03:00
Evgenii Stratonikov
058958729d compiler: support map literals 2020-01-23 17:06:15 +03:00