Roman Khimov
7589733017
config: add a special Blockchain type to configure Blockchain
...
And include some node-specific configurations there with backwards
compatibility. Note that in the future we'll remove Ledger's
fields from the ProtocolConfiguration and it'll be possible to access them in
Blockchain directly (not via .Ledger).
The other option tried was using two configuration types separately, but that
incurs more changes to the codebase, single structure that behaves almost like
the old one is better for backwards compatibility.
Fixes #2676 .
2022-12-07 17:35:53 +03:00
Roman Khimov
c2adbf768b
config: add TimePerBlock to replace SecondsPerBlock
...
It's more generic and convenient than MillisecondsPerBlock. This setting is
made in backwards-compatible fashion, but it'll override SecondsPerBlock if
both are used. Configurations are specifically not changed here, it's
important to check compatibility.
Fixes #2675 .
2022-12-02 19:52:14 +03:00
Roman Khimov
5979138306
stateroot: fix panic on shutdown
...
Stateroot service is always active, but it might have no wallet.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xc57d41]
goroutine 1 [running]:
github.com/nspcc-dev/neo-go/pkg/wallet.(*Wallet).Close(...)
github.com/nspcc-dev/neo-go/pkg/wallet/wallet.go:175
github.com/nspcc-dev/neo-go/pkg/services/stateroot.(*service).Shutdown(0xc000105880?)
github.com/nspcc-dev/neo-go/pkg/services/stateroot/validators.go:77 +0x81
github.com/nspcc-dev/neo-go/pkg/network.(*Server).Shutdown(0xc000105880)
github.com/nspcc-dev/neo-go/pkg/network/server.go:271 +0x205
github.com/nspcc-dev/neo-go/cli/server.startServer(0xc0002702c0)
github.com/nspcc-dev/neo-go/cli/server/server.go:641 +0x2675
github.com/urfave/cli.HandleAction({0xe456e0?, 0x1155f20?}, 0x4?)
github.com/urfave/cli@v1.22.5/app.go:524 +0x50
github.com/urfave/cli.Command.Run({{0xfca38b, 0x4}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0xfd6a46, 0x10}, {0xffebe3, ...}, ...}, ...)
github.com/urfave/cli@v1.22.5/command.go:173 +0x65b
github.com/urfave/cli.(*App).Run(0xc000272000, {0xc00003e180, 0x3, 0x3})
github.com/urfave/cli@v1.22.5/app.go:277 +0x8a7
main.main()
./main.go:21 +0x33
2022-09-13 13:18:13 +03:00
Roman Khimov
58dc8d0c9b
*: always close the wallet after use
...
Fix #2631 .
2022-09-02 14:44:32 +03:00
Roman Khimov
e164625a7f
wallet: provide (*Account).SignHashable API
...
Make PrivateKey() less used and less useful.
2022-09-02 14:44:01 +03:00
Roman Khimov
e569edc841
wallet: add ScriptHash() to Account
...
It allows to simplify a lot of code and avoid getting a PrivateKey in some
cases.
2022-09-02 14:43:34 +03:00
Roman Khimov
8d33206bb8
*: don't get private key from account if just public one is needed
...
Add PublicKey() API to the Account and use it as appropriate, avoid creating
additional references to the private key.
2022-09-02 14:43:28 +03:00
Roman Khimov
eeeb0f6f0e
core: accept two-side channels for sub/unsub, read on unsub
...
Blockchain's notificationDispatcher sends events to channels and these
channels must be read from. Unfortunately, regular service shutdown procedure
does unsubscription first (outside of the read loop) and only then drains the
channel. While it waits for unsubscription request to be accepted
notificationDispatcher can try pushing more data into the same channel which
will lead to a deadlock. Reading in the same method solves this, any number of
events can be pushed until unsub channel accepts the data.
2022-08-19 22:08:40 +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
9f05009d1a
Merge pull request #2580 from nspcc-dev/service-review
...
Service review
2022-07-05 12:23:25 +03:00
Roman Khimov
3e2eda6752
*: add some comments to service Start/Shutdown methods
2022-07-04 23:03:50 +03:00
Roman Khimov
593f4e8734
Merge pull request #2559 from nspcc-dev/cli/wallet-config
...
cli: allow to specify wallet via configuration file
2022-07-04 19:24:23 +03:00
Anna Shaleva
5f36a7ca0f
*: do not call wallet.Close() explicitly
...
NewWallet and NewWalletFromFile close underlying io.Closer by itself,
no need to close it manually. Introduced in #2184 .
2022-07-04 19:09:48 +03:00
Roman Khimov
36d4c17a15
stateroot: wait for the service to stop un Shutdown
2022-07-04 11:12:17 +03:00
Roman Khimov
58b9ac41e2
stateroot: handle double start/shutdown
2022-07-04 11:12:17 +03:00
Anna Shaleva
8ab422da66
*: properly unsubscribe from Blockchain events
2022-06-28 19:09:25 +03:00
Roman Khimov
ff75e67610
core: move stateroot tests into services/stateroot
...
They test both module and service which is a bit wrong, but separating these
tests will lead to some duplication, so it's OK for now to have them in the
higher-order package (service imports module).
2022-06-08 22:53:09 +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
2593bb0535
network: extend Service with Name, use it to distinguish services
2022-04-26 00:31:48 +03:00
Roman Khimov
ddb23ccf78
core: shrink blockchainer.StateRoot further, leave simple RO methods
2022-01-14 19:57:16 +03:00
Roman Khimov
59b2696849
services/consensus: drop blockchainer.Blockchainer use
...
Simplify testing, avoid monstrous Blockchainer interface.
2022-01-14 19:57:16 +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
Anna Shaleva
50296975e2
crypto: allow to provide non-default scrypt parameters
2021-06-11 15:22:28 +03:00
Roman Khimov
39571745cb
stateroot: fix incompleteRoot leak
...
Drop old incomplete roots from the map.
2021-05-07 14:31:20 +03:00
Roman Khimov
3d49f7d99a
stateroot: only send stateroot message once per validators count
...
Actually fix #1922 .
2021-05-07 14:31:20 +03:00
Roman Khimov
4a45abe3e0
stateroot: make vote/root extensibles live less
...
These are arbitrary numbers, but that's what C# node uses. maxRetries could be
set lower because we have exponential backoff anyway, but this works too.
2021-05-07 14:31:20 +03:00
Roman Khimov
7c902669bf
stateroot: implement exponential vote resends
2021-05-07 14:31:20 +03:00
Roman Khimov
d5c7a40db9
stateroot: try finalizing stateroot when adding our signature
...
And don't add/resend it multiple times.
1. We can be in a setup with one SV only and no AddSignature() called at all.
2. AddSignature() might add M-1 signatures and our signature should be the
last one to complete MPTRoot, but we'll never do that.
2021-05-06 23:29:43 +03:00
Roman Khimov
847927af74
stateroot: s/onValidatedRoot/relayExtensible/
...
Makes more sense because it's not just roots that we're relaying.
2021-05-06 22:32:13 +03:00
Roman Khimov
222b4dc920
stateroot: simplify account locking, deduplicate code
2021-05-06 22:17:09 +03:00
Roman Khimov
fc800dcbc1
stateroot: protect incomplete root manipulations in signAndSend
...
We're modifying it here, so there can be a race between this method and
AddSignature().
2021-05-06 21:53:34 +03:00
Roman Khimov
84b240cc9a
services/consensus: add some logging on start
2021-04-02 13:13:26 +03:00
Roman Khimov
a01636a1b0
stateroot: set networking callback in a more straightforward way
2021-04-02 12:12:36 +03:00
Roman Khimov
4d0cbebb5a
stateroot: make it shutdown properly, not locking up whole system
2021-04-02 11:38:49 +03:00
Roman Khimov
3b4dde05c3
stateroot: handle ErrStateMismatch internally
...
It's a local problem and returning error from here leads to peer disconnect
that isn't solving anything.
2021-03-27 00:33:11 +03:00
Roman Khimov
1fdd406234
stateroot: drop unused function
2021-03-27 00:33:11 +03:00
Roman Khimov
042aef452d
stateroot: Extensible messages must have proper category
2021-03-27 00:33:11 +03:00
Roman Khimov
5569512ce9
stateroot: fix missing verification script
...
Stateroot payload must have it.
2021-03-26 13:45:18 +03:00
Roman Khimov
5f7ec6e784
state: fix MPTRoot JSONization
...
Match C# implementation. It's easier to do this by changing the structure
itself.
2021-03-26 13:45:18 +03:00
Roman Khimov
8c110a6147
state: drop Network from MPTRoot structure
...
It's only needed to verify/sign.
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
04e0ea2c0f
stateroot: sign extensible payloads being sent!
...
Unsigned payloads are considered to be invalid for some reason.
2021-03-26 13:45:18 +03:00
Roman Khimov
0248e2c0d2
state: add network to MPTRoot, change hashing
...
Fix RC1 incompatibility.
2021-03-25 22:37:30 +03:00
Evgeniy Stratonikov
2f3abf95a2
stateroot: broadcast state on new blocks
2021-03-09 13:51:11 +03:00
Evgeniy Stratonikov
3c65ed1507
stateroot: allow to sign new roots
2021-03-09 13:51:11 +03:00
Evgeniy Stratonikov
ac227a80fe
stateroot: use RoleStateValidator for verification
2021-03-09 13:51:10 +03:00