Roman Khimov
5a7fa2d3df
cli: restart consensus service on USR2
...
Fix #1949 . Also drop wallet from the ServerConfig since it's not used in any
meaningful way after this change.
2022-08-02 13:05:07 +03:00
Anna Shaleva
1ae601787d
network: allow to handle GetMPTData with KeepOnlyLatestState on
...
And adjust documentation along the way.
2022-07-14 14:33:20 +03:00
Roman Khimov
2593bb0535
network: extend Service with Name, use it to distinguish services
2022-04-26 00:31:48 +03:00
Anna Shaleva
9bbd94d0fa
network: tune waiting limits in tests
...
Some tests are failing on Windows due to slow runners with errors like the following:
```
2022-02-09T17:11:20.3127016Z --- FAIL: TestGetData/transaction (1.82s)
2022-02-09T17:11:20.3127385Z server_test.go:500:
2022-02-09T17:11:20.3127878Z Error Trace: server_test.go:500
2022-02-09T17:11:20.3128533Z server_test.go:520
2022-02-09T17:11:20.3128978Z Error: Condition never satisfied
2022-02-09T17:11:20.3129479Z Test: TestGetData/transaction
```
2022-02-10 18:58:50 +03:00
Roman Khimov
60d6fa1125
network: keep a copy of the config inside of Server
...
Avoid copying the configuration again and again, make things a bit more
efficient.
2022-01-24 18:43:01 +03:00
Roman Khimov
bc6d6e58bc
network: always pass transactions to consensus process
...
Consensus can require conflicting transactions and it can require more
transactions than mempool can fit, all of this should work. Transactions will
be checked anyway using its secondary mempool. See the scenario from #668 .
2022-01-14 20:08:40 +03:00
Roman Khimov
746644a4eb
network: decouple it from blockchainer.Blockchainer
...
We don't need all of it.
2022-01-14 19:57:16 +03:00
Roman Khimov
bf1604454c
blockchainer/network: move StateSync interface to the user
...
Only network package cares about it.
2022-01-14 19:57:14 +03:00
Roman Khimov
508d36f698
network: drop consensus dependency
2022-01-14 19:55:53 +03:00
Roman Khimov
66aafd868b
network: unplug stateroot service from the Server
...
Notice that it makes the node accept Extensible payloads with any category
which is the same way C# node works. We're trusting Extensible senders,
improper payloads are harmless until they DoS the network, but we have some
protections against that too (and spamming with proper category doesn't differ
a lot).
2022-01-14 19:55:50 +03:00
Roman Khimov
5dd4db2c02
network/services: unify service lifecycle management
...
Run with Start, Stop with Shutdown, make behavior uniform.
2022-01-14 19:53:45 +03:00
Roman Khimov
48de82d902
network: fix data race in TestHandleMPTData, fix #2241
2021-11-15 12:37:01 +03:00
AnnaShaleva
2d196b3f35
rpc: refactor calculatenetworkfee
handler
...
Use (Blockchainer).VerifyWitness() to calculate network fee for
contract-based witnesses.
2021-10-25 19:07:25 +03:00
Evgeniy Stratonikov
4dd3a0d503
network: request headers in parallel, fix #2158
...
Do this similarly to how blocks are requested.
See also 4aa1a37
.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-10-06 15:25:54 +03:00
Anna Shaleva
6357af0bb0
network: fix race in TestHandleGetMPTData
...
Init server config before server start. Fixes the following data race:
```
WARNING: DATA RACE
Write at 0x00c00032ef20 by goroutine 26:
github.com/nspcc-dev/neo-go/pkg/network.TestHandleGetMPTData.func2()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server_test.go:755 +0x10a
testing.tRunner()
/usr/local/go/src/testing/testing.go:1193 +0x202
Previous read at 0x00c00032ef20 by goroutine 24:
github.com/nspcc-dev/neo-go/internal/fakechain.(*FakeChain).GetConfig()
/go/src/github.com/nspcc-dev/neo-go/internal/fakechain/fakechain.go:167 +0x6f
github.com/nspcc-dev/neo-go/pkg/network.(*Server).initStaleMemPools()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server.go:1433 +0x89
github.com/nspcc-dev/neo-go/pkg/network.(*Server).Start()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server.go:284 +0x288
github.com/nspcc-dev/neo-go/pkg/network.startWithChannel.func1()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server_test.go:91 +0x44
Goroutine 26 (running) created at:
testing.(*T).Run()
/usr/local/go/src/testing/testing.go:1238 +0x5d7
github.com/nspcc-dev/neo-go/pkg/network.TestHandleGetMPTData()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server_test.go:752 +0x8c
testing.tRunner()
/usr/local/go/src/testing/testing.go:1193 +0x202
Goroutine 24 (running) created at:
github.com/nspcc-dev/neo-go/pkg/network.startWithChannel()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server_test.go:90 +0x78
github.com/nspcc-dev/neo-go/pkg/network.startTestServer()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server_test.go:384 +0xbd
github.com/nspcc-dev/neo-go/pkg/network.TestHandleGetMPTData.func2()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server_test.go:753 +0x55
testing.tRunner()
/usr/local/go/src/testing/testing.go:1193 +0x202
```
2021-09-13 11:45:48 +03:00
Anna Shaleva
29ef076f4b
network: fix race in TestTryInitStateSync
...
Register peers properly. Fixes the following data race:
```
Read at 0x00c001184ac8 by goroutine 116:
github.com/nspcc-dev/neo-go/pkg/network.(*localPeer).EnqueueHPPacket()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/helper_test.go:127 +0x1f2
github.com/nspcc-dev/neo-go/pkg/network.(*localPeer).EnqueuePacket()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/helper_test.go:114 +0xac
github.com/nspcc-dev/neo-go/pkg/network.(*localPeer).EnqueueMessage()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/helper_test.go:111 +0xc1
github.com/nspcc-dev/neo-go/pkg/network.(*localPeer).SendPing()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/helper_test.go:159 +0x88
github.com/nspcc-dev/neo-go/pkg/network.(*Server).runProto()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server.go:446 +0x409
Previous write at 0x00c001184ac8 by goroutine 102:
github.com/nspcc-dev/neo-go/pkg/network.newLocalPeer()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/helper_test.go:83 +0x476
github.com/nspcc-dev/neo-go/pkg/network.TestTryInitStateSync.func3()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server_test.go:1064 +0x40f
testing.tRunner()
/usr/local/go/src/testing/testing.go:1123 +0x202
Goroutine 116 (running) created at:
github.com/nspcc-dev/neo-go/pkg/network.(*Server).run()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server.go:358 +0x69
github.com/nspcc-dev/neo-go/pkg/network.(*Server).Start()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server.go:292 +0x488
github.com/nspcc-dev/neo-go/pkg/network.startWithChannel.func1()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server_test.go:91 +0x44
Goroutine 102 (running) created at:
testing.(*T).Run()
/usr/local/go/src/testing/testing.go:1168 +0x5bb
github.com/nspcc-dev/neo-go/pkg/network.TestTryInitStateSync()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server_test.go:1056 +0xbb
testing.tRunner()
/usr/local/go/src/testing/testing.go:1123 +0x202
```
2021-09-13 11:45:48 +03:00
Anna Shaleva
0fa48691f7
network: do not duplicate MPT nodes in GetMPTNodes response
...
Also tests are added.
2021-09-08 14:25:54 +03:00
Anna Shaleva
d67ff30704
core: implement statesync module
...
And support GetMPTData and MPTData P2P commands.
2021-09-07 19:43:27 +03:00
Roman Khimov
7fc153ed2a
network: only ask mempool for intersections with received Inv
...
Most of the time on healthy network we see new transactions appearing that are
not present in the mempool. Once they get into mempool we don't ask for them
again when some other peer sends an Inv with them. Then these transactions are
usually added into block, removed from mempool and no one actually sends them
again to us. Some stale nodes can do that, but it's not very likely to
happen.
At the receiving end at the same time it's quite expensive to do full chain
HasTransaction() query, so if we can avoid doing that it's always good. Here
it technically allows resending old transaction that will be re-requested and
an attempt to add it to mempool will be made. But it'll inevitably fail
because the same HasTransaction() check is done there too. One can try to
maliciously flood the node with stale transactions but it doesn't differ from
flooding it with any other invalid transactions, so there is no new attack
vector added.
Baseline, 4 nodes with 10 workers:
RPS 6902.296 6465.662 6856.044 6785.515 6157.024 ≈ 6633 ± 4.26%
TPS 6468.431 6218.867 6610.565 6288.596 5790.556 ≈ 6275 ± 4.44%
CPU % 50.231 42.925 49.481 48.396 42.662 ≈ 46.7 ± 7.01%
Mem MB 2856.841 2684.103 2756.195 2733.485 2422.787 ≈ 2691 ± 5.40%
Patched:
RPS 7176.784 7014.511 6139.663 7191.280 7080.852 ≈ 6921 ± 5.72% ↑ 4.34%
TPS 6945.409 6562.756 5927.050 6681.187 6821.794 ≈ 6588 ± 5.38% ↑ 4.99%
CPU % 44.400 43.842 40.418 49.211 49.370 ≈ 45.4 ± 7.53% ↓ 2.78%
Mem MB 2693.414 2640.602 2472.007 2731.482 2707.879 ≈ 2649 ± 3.53% ↓ 1.56%
2021-08-06 20:53:02 +03:00
Roman Khimov
c4e084b0d8
*: fix whitespace errors
...
leading/trailing newlines
2021-05-12 22:51:41 +03:00
Roman Khimov
0178594850
*: simpilfy make() invocations
...
gosimple: S1019: should use make([]byte, 64) instead
2021-05-12 18:36:45 +03:00
Roman Khimov
690a1db589
network: replace consensusStarted/canHandleExtens with syncReached flag
...
They're essentially the same.
2021-04-02 12:55:56 +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
f83b376181
block: replace Base
with Header
2021-03-10 13:38:44 +03:00
Anna Shaleva
2c81fc8b8e
*: upgrade tests to use T.Cleanup()
2021-03-01 17:08:00 +03:00
Anna Shaleva
a237e34c1f
rpc: add test for submitNotaryRequest
2021-02-11 17:15:59 +03:00
Anna Shaleva
5c2ea2d5bb
network: refactor P2PNotaryRequest decoding
...
We need to provide magic for both main and fallback transactions during
decoding, because transactions hashes depend on it.
2021-02-11 17:11:33 +03:00
Anna Shaleva
4ad9c7929b
internals: move testchain from network to internals
...
It'll be useful for tests outside of the network pkg.
2021-02-02 22:01:32 +03:00
Anna Shaleva
bfbd096fed
core: introduce mempool notifications
2021-02-02 22:01:32 +03:00
Anna Shaleva
19fa0daaa6
core, network: add Notary module
2021-02-02 22:01:20 +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
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
Anna Shaleva
0b5cf78468
network: add notary request payload
2020-12-10 18:17:31 +03:00
Evgenii Stratonikov
27624946d9
network/test: add tests for server commands
2020-12-09 15:23:49 +03:00
Evgenii Stratonikov
4aa1a37f3f
network: fetch blocks in parallel
...
Blockcache size is 2000, while max request size is 500.
Try to fetch blocks in chunks starting from current height.
Lower height has priority.
2020-12-02 10:50:35 +03:00
Anna Shaleva
6c8accf18c
core, network: request blocks instead of headers
...
Closes #1192
1. We now have CMDGetBlockByIndex, so there's no need to request headers
first when we can just ask for blocks.
2. We don't ask for headers (i.e. we don't send CMDGetHeaders),
consequently, we shouldn't react on CMDHeaders.
3. But we still keep on reacting on CMDGetHeaders command as
there could be a node which needs headers.
2020-08-04 17:52:34 +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
c590cc02f4
protocol: add capabilities to version payload
...
closes #871
2020-05-27 19:01:14 +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
Evgenii Stratonikov
c508a36827
core,network: shutdown services in tests properly
2020-04-22 17:53:59 +03:00
Roman Khimov
e41d434a49
*: move all packages from CityOfZion to nspcc-dev
2020-03-03 17:21:42 +03:00
Evgenii Stratonikov
a3dacd3b74
tests: replace t.Fatal with require where possible
...
This makes tests less verbose and unifies the style
they are written in.
2020-03-02 17:22:27 +03:00
Roman Khimov
1f672e0da7
network: move SendVersion() to the Peer
...
Only leave server-specific `getVersionMsg()` in the Server, all the other
logic is peer-related.
2020-01-21 17:26:08 +03:00
Evgenii Stratonikov
aecdf470e7
cli,pkg: use zap.Logger
2020-01-10 11:14:27 +03:00