Commit graph

98 commits

Author SHA1 Message Date
Evgeniy Stratonikov
ec21c14ca9 gomod: upgrade yaml package from v2 to v3
Close #2085.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-05-30 15:26:17 +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
2096ad6e81 *: remove io/ioutil uses
Close #1764.
2022-03-17 19:39:18 +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
ba49209d8a cli: use ioutil instead of os to read/write files
Go 1.15 doesn't have os.ReadFile and os.WiteFile.
2022-02-02 13:48:17 +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
2e452df13a rpc/storage: add storage changes to invoke* diagnostics 2022-01-19 00:02:19 +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
Roman Khimov
33e37e60e5
Merge pull request #2264 from nspcc-dev/fix-win-tests
*: Windows compatibility fixes
2021-11-29 11:25:35 +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
AnnaShaleva
aefb6f9fee *: fix tests failing due to path.Join usage
Solution:
Use `file/filepath` package to construct expected path. This package is OS-aware, see https://github.com/golang/go/issues/30616.
2021-11-29 11:11:09 +03:00
AnnaShaleva
991f1be8e6 cli: fix TestHandleLoggingParams test
Problem:
```
--- FAIL: TestHandleLoggingParams (0.02s)
    --- FAIL: TestHandleLoggingParams/default (0.00s)
        server_test.go:51:
                Error Trace:    server_test.go:51
                Error:          Received unexpected error:
                                couldn't open sink "C:\\Users\\Anna\\AppData\\Local\\Temp\\TestHandleLoggingParams226652490\\001/file.log": no sink found for scheme "c"
                Test:           TestHandleLoggingParams/default
    --- FAIL: TestHandleLoggingParams/debug (0.00s)
        server_test.go:64:
                Error Trace:    server_test.go:64
                Error:          Received unexpected error:
                                couldn't open sink "C:\\Users\\Anna\\AppData\\Local\\Temp\\TestHandleLoggingParams226652490\\001/file.log": no sink found for scheme "c"
                Test:           TestHandleLoggingParams/debug
```

Solution:
Currently no solution is implemented, but we can use relative paths instead of absolute.
2021-11-26 18:26:20 +03:00
Evgeniy Stratonikov
856385b106 dao: use custom storage prefix
We use 2 prefixes for storing items because of state synchronization.
This commit allows to parametrize dao with the default prefix.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-11-24 16:22:07 +03:00
Roman Khimov
6d074a96e9 *: make tests use TempDir(), fix #1319
Simplify things, drop TempFile at the same time (refs. #1764)
2021-08-26 17:29:40 +03:00
Evgeniy Stratonikov
0b681d40e8 cli: fix tests for go1.17
`getPath` returns paths without leading dot.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-08-19 18:16:56 +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
Roman Khimov
e9cefc4bfc *: fix all errcheck warnings in testing code 2021-05-12 21:45:12 +03:00
Anna Shaleva
a04e46f719 cli: reload RPC-server TLS config on SIGHUP 2021-05-04 10:38:02 +03:00
Anna Shaleva
2c81fc8b8e *: upgrade tests to use T.Cleanup() 2021-03-01 17:08:00 +03:00
Roman Khimov
7bef87e2ef cli: use base64 for state dump
See neo-project/neo-modules/#499.
2021-02-07 22:07:30 +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
Roman Khimov
a8bb040558 *: fix ineffassign goreportcard warnings 2020-12-28 17:31:50 +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
cab767dafe cli: add tests to cli packages
Closes #1336
2020-08-26 10:14:55 +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
98888def16 cli/server: drop key mangler from dumper
It's no longer needed (yay!)
2020-08-10 16:58:38 +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
66df805f3b cli/server: update value conversion for Neo 3
Version is no longer being stored for the value, so there is no need for '00'
byte.
2020-06-24 10:21:24 +03:00
Roman Khimov
fb18eda515 cli/server: update toNeoStorageKey key conversion for Neo 3
Follow #1037 changes with contract IDs and update padding, the number of
value bytes is being stored now as 17th byte instead of number of zeroes.
2020-06-24 10:21:24 +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