Commit graph

90 commits

Author SHA1 Message Date
Roman Khimov
9b0ea2c21b network/consensus: always process dBFT messages as high priority
Move category definition from consensus to payload, consensus service is the
one of its kind (HP), so network.Server can be adjusted accordingly.
2022-08-02 13:07:18 +03:00
Roman Khimov
b92896b0c0 cli: fix FTBFS on Windows
It has a stub for SIGHUP, but doesn't have anything for USR1 and USR2:

Error: cli\server\server.go:520:31: undefined: syscall.SIGUSR1
Error: cli\server\server.go:521:31: undefined: syscall.SIGUSR2
Error: cli\server\server.go:565:17: undefined: syscall.SIGUSR1
Error: cli\server\server.go:608:17: undefined: syscall.SIGUSR2
2022-08-02 13:06:08 +03:00
Roman Khimov
94a8784dcb network: allow to drop services and solve concurrency issues
Now that services can come and go we need to protect all of the associated
fields and allow to deregister them.
2022-08-02 13:05:39 +03:00
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
Roman Khimov
bf92966633 cli: reload state root service on USR1
It's a bit special since it's _always_ present to catch stateroots from the
network.
2022-08-02 13:02:36 +03:00
Roman Khimov
9341bb6628 cli: restart notary service on USR1 2022-07-28 19:05:56 +03:00
Roman Khimov
2adcf406d3 cli: reload Oracle service on USR1
Which allows to enable/disable the service, change nodes, keys and other
settings. Unfortunately, atomic.Value doesn't allow Store(nil), so we have to
store a pointer there that can point to nil interface.
2022-07-28 19:05:56 +03:00
Roman Khimov
df24c1268e cli: restart pprof and prometheus on HUP 2022-07-27 12:30:08 +03:00
Roman Khimov
6593b94594 cli: use new configuration for the RPC server
Also fix addresses if needed and store this new configuration.
2022-07-27 12:30:08 +03:00
Roman Khimov
94099de3c3 cli: also check new ApplicationConfiguration for consistency
Most of the settings can't be changed, only services can.
2022-07-27 12:30:08 +03:00
Roman Khimov
3fca3352d8 cli: read new config on signal and check ProtocolConfiguration
ProtocolConfiguration must remain the same, any errors mean that the signal
will be ignored.
2022-07-27 12:30:08 +03:00
Roman Khimov
2e27c3d829 metrics: move package to services
Where it belongs.
2022-07-21 23:38:23 +03:00
Roman Khimov
43a59adbd0 rpc/server: move to services/rpcsrv
`server` is not a good package name and it's an internal service, so it can be
just about anywhere.
2022-07-21 22:14:12 +03:00
Elizaveta Chichindaeva
28908aa3cf [#2442] English Check
Signed-off-by: Elizaveta Chichindaeva <elizaveta@nspcc.ru>
2022-05-04 19:48:27 +03:00
Roman Khimov
887fe0634d rpc: add StartWhenSynchronized option, fix #2433 2022-04-26 00:31:48 +03:00
Roman Khimov
a10b1ad32d rpc/server: make Server conform network.Service interface
With Start() and Shutdown() taking no parameters and returning no values.
2022-04-22 10:49:06 +03:00
Roman Khimov
2c16e042cd cli/server: don't spit out error if notary request already exists
It could be sent by another actor and that's OK.
2022-04-05 17:37:17 +03:00
Anna Shaleva
8ff7cd865d cli: ensure chain is properly stopped after chain-related commands
Blockchain occupies resources (e.g. it opens log files for DB, etc.)
on creation and running. We need to release these resources if something
goes wrong during execution chain-related commands.

This commit solves the following problem on Windows:
```
--- FAIL: TestServerStart (0.32s)
    --- FAIL: TestServerStart/stateroot_service_is_on_&&_StateRootInHeader=true (0.04s)
        testing.go:894: TempDir RemoveAll cleanup: remove C:\Users\Anna\AppData\Local\Temp\TestServerStart_stateroot_service_is_on_&&_StateRootInHeader=true460557297\001\neogotestchain\000001.log: The process cannot access the file because it is being used by another process.
    --- FAIL: TestServerStart/invalid_Oracle_config (0.03s)
        testing.go:894: TempDir RemoveAll cleanup: remove C:\Users\Anna\AppData\Local\Temp\TestServerStart_invalid_Oracle_config810064028\001\neogotestchain\000001.log: The process cannot access the file because it is being used by another process.
    --- FAIL: TestServerStart/invalid_consensus_config (0.04s)
        testing.go:894: TempDir RemoveAll cleanup: remove C:\Users\Anna\AppData\Local\Temp\TestServerStart_invalid_consensus_config217270091\001\neogotestchain\000001.log: The process cannot access the file because it is being used by another process.
    --- FAIL: TestServerStart/invalid_Notary_config (0.07s)
        --- FAIL: TestServerStart/invalid_Notary_config/malformed_config (0.04s)
            testing.go:894: TempDir RemoveAll cleanup: remove C:\Users\Anna\AppData\Local\Temp\TestServerStart_invalid_Notary_config_malformed_config754934830\001\neogotestchain\000001.log: The process cannot access the file because it is being used by another process.
        --- FAIL: TestServerStart/invalid_Notary_config/invalid_wallet (0.03s)
            testing.go:894: TempDir RemoveAll cleanup: remove C:\Users\Anna\AppData\Local\Temp\TestServerStart_invalid_Notary_config_invalid_wallet934249397\001\neogotestchain\000001.log: The process cannot access the file because it is being used by another process.
    --- FAIL: TestServerStart/good (0.11s)
        testing.go:894: TempDir RemoveAll cleanup: remove C:\Users\Anna\AppData\Local\Temp\TestServerStart_good596150160\001\neogotestchain\000001.log: The process cannot access the file because it is being used by another process.
```

This commit also unifies blockchain and services releasing code.
2022-02-10 10:33:36 +03:00
Anna Shaleva
2736d62d47 cli: ensure opened sinks are properly closed
zap never closes open sinks except its own tests. This behaviour
prevents TestHandleLoggingParams from successful cleanup because
temp log output file can't be closed due to the following error:
```
TempDir RemoveAll cleanup: remove C:\\Users\\Anna\\AppData\\Local\\Temp\\TestHandleLoggingParams_debug5796883
33\\001\\file.log: The process cannot access the file because it is being used by another process.
```

So this tremendous cludge is made mosetly for our testing code.
It is not for concurrent usage (we don't have cases of
multithreaded access to logger output sink).
2022-02-10 10:33:34 +03:00
Anna Shaleva
59fdb69b9a cli: add temp workaround to handle absolute log path for Windows
Fix #2269.
2022-02-10 10:33:10 +03:00
Anna Shaleva
9de9bcb17c cli: add tests for server commands
Fixes:
  * Proper exit code should be returned on exit for server-related
commands
2022-02-02 11:28:26 +03:00
Roman Khimov
ddb23ccf78 core: shrink blockchainer.StateRoot further, leave simple RO methods 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
af87cb082f network: decouple Server from the notary service 2022-01-14 19:55:53 +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
0ad3ea5944 network/cli: move Oracle service instantiation out of the network 2022-01-14 19:53:45 +03:00
AnnaShaleva
16da133d61 cli: release resources occupied by chain before dumpDB exit
Problem:
```
--- FAIL: TestDumpDB (0.08s)
--- FAIL: TestDumpDB/too_low_chain
testing.go:894: TempDir RemoveAll cleanup: remove C:\Users\Anna\AppData\Local\Temp\TestDumpDB_too_low_chain357310492\001\chains\privnet\000001.log: The process cannot access the file because it is being used by another process.
```

Solution:
Release resources occupied by the chain even on non-error command exit.
2021-11-29 11:11:09 +03:00
Evgeniy Stratonikov
de15d42861 cli: remove --skip parameter from restore
It isn't really a parameter and it's value can be deduced automatically.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-07-16 13:32:08 +03:00
Evgeniy Stratonikov
df5ee4abdc cli: allow to use incremental dumps in db restore
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-07-16 13:32:08 +03:00
Anna Shaleva
a04e46f719 cli: reload RPC-server TLS config on SIGHUP 2021-05-04 10:38:02 +03:00
Evgenii Stratonikov
43e4d3af88 oracle: integrate module in core and RPC
1. Initialization is performed via `Blockchain` methods.
2. Native Oracle contract updates list of oracle nodes
  and in-fly requests in `PostPersist`.
3. RPC uses Oracle module directly.
2021-01-28 13:00:58 +03:00
Evgenii Stratonikov
66402923b9 cli/server: remove unused readBlock()
It became obsolete after 6f7284906a.
2020-12-04 11:05:49 +03:00
Evgenii Stratonikov
6f7284906a blockchainer: allow to dump/restore chain 2020-11-24 16:43:11 +03:00
Evgenii Stratonikov
1869d6d460 core: allow to use state root in header 2020-11-20 17:16:32 +03:00
Evgenii Stratonikov
758a88a813 rpc: exit from Start after Listener is running
If port is dynamically allocated, `(*Server).Addr` will contain
0 port. This commit executes listener before exiting from `Start()`
and sets Addr to the actual address.
2020-09-18 12:05:31 +03:00
Evgenii Stratonikov
911be78cc7 cli: use Writer from app instead of Stdout
It is useful in tests.
2020-09-18 12:05:31 +03:00
Anna Shaleva
d6e7d9c281 cli: invoke configureAddresses with pointer
Otherwise configuration remains untouched outside of the method scope.
2020-08-25 16:11:54 +03:00
Roman Khimov
0e2784cd2c always wrap errors when creating new ones with fmt.Errorf()
It doesn't really change anything in most of the cases, but it's a useful
habit anyway.

Fix #350.
2020-08-07 12:21:52 +03:00
Roman Khimov
5ef08f60ae remove github.com/pkg/errors from dependencies
It's not needed any more with Go 1.13 as we have wrapping/unwrapping in base
packages. All errors.Wrap calls are replaced with fmt.Errorf, some strings are
improved along the way.
2020-08-07 12:21:52 +03:00
Roman Khimov
176c0e98d6 cli/server: dump genesis block state when restoring
Neo 3 node does it too and it's very useful because now the genesis block also
does some state changes that are important.
2020-06-24 16:09:54 +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
f2c4b9b1d9 cli: move network options to their own package
They will be reused.
2020-06-18 12:10:14 +03:00
Roman Khimov
26f11a52d9 config: move NetMode into its own micropackage
It's going to be used a bit more and pulling whole config just for one type is
a bit wrong.
2020-06-18 12:09:57 +03:00
Evgenii Stratonikov
651976b2ca config: remove AddressVersion from the configuration
It is never used and is the same constant for both mainnet, testnet and
privnet.
2020-06-17 15:55:22 +03:00
Anna Shaleva
5a984fdf88 config: move config.go out of config/
closes #423
2020-03-31 17:55:59 +03:00
Evgenii Stratonikov
c880435c92 cli: persist restored blocks on exit
Add grace context to execute defer's on exit.
2020-03-16 12:48:51 +03:00
Roman Khimov
e41d434a49 *: move all packages from CityOfZion to nspcc-dev 2020-03-03 17:21:42 +03:00
Evgenii Stratonikov
b50704fd3b rpc: move server-related code to a separate package 2020-02-21 15:12:04 +03:00
Evgenii Stratonikov
b1d9e1132d cli: dump storage changes into JSON files 2020-02-12 12:16:31 +03:00