Commit graph

84 commits

Author SHA1 Message Date
Roman Khimov
4f3ffe7290 golangci: enable errorlint and fix everything it found 2022-09-02 18:36:23 +03:00
Elizaveta Chichindaeva
28908aa3cf [#2442] English Check
Signed-off-by: Elizaveta Chichindaeva <elizaveta@nspcc.ru>
2022-05-04 19:48:27 +03:00
Anna Shaleva
d67ff30704 core: implement statesync module
And support GetMPTData and MPTData P2P commands.
2021-09-07 19:43:27 +03:00
Evgeniy Stratonikov
c74de9a579 network: preallocate buffer for message
```
name            old time/op    new time/op    delta
MessageBytes-8     740ns ± 0%     684ns ± 2%   -7.58%  (p=0.000 n=10+10)

name            old alloc/op   new alloc/op   delta
MessageBytes-8    1.39kB ± 0%    1.20kB ± 0%  -13.79%  (p=0.000 n=10+10)

name            old allocs/op  new allocs/op  delta
MessageBytes-8      11.0 ± 0%      10.0 ± 0%   -9.09%  (p=0.000 n=10+10)
```

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-08-10 09:33:52 +03:00
Roman Khimov
1b186e046b network: use optimized decoder for transactions
NewTransactionFromBytes() works a bit faster and uses less memory.
2021-08-04 23:49:07 +03:00
Roman Khimov
9d2712573f *: enable godot linter and fix all its warnings
It's important for NeoGo to have clean documentation. No functional changes.
2021-05-12 23:17:03 +03:00
Roman Khimov
0888cf9ed2 network: drop Network from Message
It's not used any more.
2021-03-26 13:45:18 +03:00
Roman Khimov
c789431402 payload: drop Network from P2PNotaryRequest
It's not needed now.
2021-03-26 13:45:18 +03:00
Roman Khimov
f91ff78918 payload: drop Network from Extensible
It's only used to sign/verify it and is not a part of the structure. It's
still neded in consensus.Payload though because that's the way dbft library
is.
2021-03-26 13:45:18 +03:00
Roman Khimov
95c279325a block: drop Network from the Header
It's not network-tied any more, network is only needed to
sign/verify. Unfortunately we still have to keep network in consensus data
structures because of dbft library interface.
2021-03-26 13:45:18 +03:00
Roman Khimov
d314f82db3 transaction: drop Network from Transaction
We only need it when signing/verifying.
2021-03-26 13:45:18 +03:00
Evgeniy Stratonikov
5d83c28bc9 network: replace ConsensusType with ExtensibleType 2021-01-22 10:38:33 +03:00
Evgenii Stratonikov
2cb536a6a1 network: provide NullPayload where necessary 2020-12-25 14:36:53 +03:00
Anna Shaleva
0b5cf78468 network: add notary request payload 2020-12-10 18:17:31 +03:00
Evgenii Stratonikov
2dcd366ef9 network: remove extra error check from Message.Encode()
Buffer write error is returned from `Encode()`.
2020-12-04 15:00:35 +03:00
Evgenii Stratonikov
63aebfeae3 network: fix MerkleBlock serialization
1. It contains `block.Base` thus needs network magic.
2. TxCount should match number of hashes.
2020-12-04 14:59:13 +03:00
Evgenii Stratonikov
1869d6d460 core: allow to use state root in header 2020-11-20 17:16:32 +03:00
Roman Khimov
120c4d4406 network: don't compress Inventory messages
They're not really compressable.
2020-09-09 20:46:31 +03:00
Anna Shaleva
18691430fd network: decode CMDNotFound
We don't react on this command, but we should be able to decode it.
2020-08-18 14:24:27 +03:00
Anna Shaleva
f6f3863e0e network: allow to GetHeaders by index
Use GetBlockByIndex payload for GetHeaders command instead of GetBlocks
payload.
2020-08-04 17:52:34 +03:00
Anna Shaleva
737ba700e9 network: rename GetBlockData command
GetBlockData -> GetBlockByIndex
2020-08-04 17:52:34 +03:00
Anna Shaleva
db5b42b601 network: update CMDUncknown
Closes #1135
2020-07-16 06:58:55 +03:00
Evgenii Stratonikov
857ced8230 consensus: add network magic to hash data
Consensus payload's hash now depends on the network node is operating
in.
2020-06-26 18:41:04 +03:00
Anna Shaleva
08cc04c3d5 core: add native policy contract
part of #904
2020-06-24 07:35:07 +03:00
Roman Khimov
892812d539 message: fix Verack processsing
Recent 9f42108ef completely broke handshaking.
2020-06-20 00:28:51 +03:00
Evgenii Stratonikov
9f42108ef2 network: allow NullPayload only for specific commands
CMDFilterClear, CMDGetAddr, CMDMempool all have empty payloads.
2020-06-19 15:01:30 +03:00
Roman Khimov
b483c38593 block/transaction: add network magic into the hash
We make it explicit in the appropriate Block/Transaction structures, not via a
singleton as C# node does. I think this approach has a bit more potential and
allows better packages reuse for different purposes.
2020-06-18 12:39:50 +03:00
Roman Khimov
8388e509df network: don't allocate memory for messages larger than PayloadMaxSize 2020-06-18 12:12:31 +03:00
Roman Khimov
39fd799992 network: fix Compress flag, it's the first bit (index 0) 2020-06-18 12:12:17 +03:00
Roman Khimov
eec462b00c network: fix Inv types for Neo 3
They actually use the same types as for messages. Fixes
2020-05-29T00:06:17.593+0300    WARN    peer disconnected       {"addr": "168.62.167.190:20333", "reason": "handling CMDInv message: invalid inventory type", "peerCount": 3}
2020-05-29 15:02:20 +03:00
Anna Shaleva
0cbd7823ab protocol: add payload compression
closes #872
2020-05-26 22:19:10 +03:00
Anna Shaleva
8142caaf8b protocol: implement getblockdata p2p command
closes #891
2020-05-22 19:16:49 +03:00
Anna Shaleva
64a2fb63e1 protocol: move magic exchange to version payload
closes #889
2020-05-21 14:23:41 +03:00
Anna Shaleva
3bcc56bdcf protocol: switch to binary MessageCommand
closes #888
2020-05-21 13:57:49 +03:00
Roman Khimov
9a67bfac0b network: drop checksums from messages
Follow neo-project/neo#710 changes.
2020-04-19 23:40:31 +03:00
Anna Shaleva
5a984fdf88 config: move config.go out of config/
closes #423
2020-03-31 17:55:59 +03:00
Roman Khimov
e41d434a49 *: move all packages from CityOfZion to nspcc-dev 2020-03-03 17:21:42 +03:00
Roman Khimov
0ba6b2a754 network: introduce peer sending queues
Two queues for high-priority and ordinary messages. Fixes #590. These queues
are deliberately made small to avoid buffer bloat problem, there is gonna be
another queueing layer above them to compensate for that. The queues are
designed to be synchronous in enqueueing, async capabilities are to be added
layer above later.
2020-01-20 17:23:26 +03:00
Roman Khimov
32213b1454
Merge pull request #601 from nspcc-dev/refactoring/core
core: refactor out Block, BlockBase and Header, closes #597.
2020-01-20 16:19:20 +03:00
Vsevolod Brekelov
4e6ed9021c network: add ping pong processing
add pingInterval same as used in ref C# implementation with the same logic
add pingTimeout which is used to check whether pong received. If not -- drop the peer.
add pingLimit which is hardcoded to 4 in TCPPeer. It's limit for unsuccessful ping/pong calls (where pong wasn't received in pingTimeout interval)
2020-01-17 13:24:14 +03:00
Evgenii Stratonikov
63c56cca5c core: refactor out Block, BlockBase and Header structs
See #597.
2020-01-16 10:16:24 +03:00
Evgenii Stratonikov
9b8b77c9ea network: return error if header message is too big
Big messages can still be processed but only first
2000 headers will be used.
2020-01-10 11:14:29 +03:00
Roman Khimov
54d888ba70 io: add type-specific read/write methods
This seriously improves the serialization/deserialization performance for
several reasons:
 * no time spent in `binary` reflection
 * no memory allocations being made on every read/write
 * uses fast ReadBytes everywhere it's appropriate

It also makes Fixed8 Serializable just for convenience.
2019-12-12 20:19:50 +03:00
Evgenii Stratonikov
fccb008594 io: implement ReadBytes() 2019-12-09 15:00:15 +03:00
Roman Khimov
844491d365 *: use more efficient WriteBytes where appropriate
Before this patch on block import we could easily be spending more than 6
seconds out of 30 in Uint256 encoding for UnspentBalance, now it's completely
off the radar.
2019-12-06 18:22:21 +03:00
Evgenii Stratonikov
085ca7b770 network: implement Consensus payloads 2019-11-13 17:27:25 +03:00
Vsevolod Brekelov
8ee421db14 fix spelling and godoc comments 2019-10-22 17:56:03 +03:00
Roman Khimov
3f6104ef4d network: ignore consensus messages
It's a temporary stub until proper encoding/decoding is implemented. It's
useful for testnet/mainnet connections because without it consensus message
receival leads to peer disconnection.
2019-10-17 11:58:27 +03:00
Roman Khimov
5a0f08f2c0 network: fix SIGSEGV on unknown message acceptance
For example, at the moment our node can't handle `consensus` message, so when
it received it before the patch it just crashed because of uninitialized `p`.
2019-09-22 20:09:55 +03:00
Roman Khimov
d1a4e43c48 io: redo Serializable to return errors in BinReader/BinWriter
Further simplifies error handling.
2019-09-17 13:21:52 +03:00