Closed scravy closed 5 years ago
In case you are wondering about 94357bde7c484e8466f8e5b6906c908f9c8e49c6: I organized some includes in order for this PR to not introduce any further circular dependencies. Here's a report:
4c4
< Circular dependency: blockchain/blockchain_rpc -> rpc/util -> injector -> blockchain/blockchain_rpc
---
> Circular dependency: blockdb -> validation -> injector -> blockdb
11,14d10
< Circular dependency: consensus/tx_verify -> finalization/vote_recorder -> injector -> p2p/finalizer_commits_handler -> p2p/finalizer_commits_handler_impl -> consensus/tx_verify
< Circular dependency: consensus/tx_verify -> finalization/vote_recorder -> injector -> proposer/multiwallet -> wallet/wallet -> wallet/walletdb -> consensus/tx_verify
< Circular dependency: consensus/tx_verify -> finalization/vote_recorder -> injector -> staking/transactionpicker -> miner -> consensus/tx_verify
< Circular dependency: consensus/tx_verify -> finalization/vote_recorder -> injector -> staking/transactionpicker -> miner -> txmempool -> consensus/tx_verify
16,18d11
< Circular dependency: esperanza/checks -> finalization/vote_recorder -> injector -> p2p/finalizer_commits_handler -> p2p/finalizer_commits_handler_impl -> esperanza/checks
< Circular dependency: esperanza/checks -> finalization/vote_recorder -> injector -> proposer/multiwallet -> wallet/wallet -> esperanza/checks
< Circular dependency: esperanza/checks -> finalization/vote_recorder -> injector -> staking/transactionpicker -> miner -> esperanza/checks
21a15
> Circular dependency: esperanza/finalizationstate -> validation -> finalization/vote_recorder -> esperanza/finalizationstate
22a17
> Circular dependency: esperanza/vote -> keystore -> script/sign -> policy/policy -> validation -> finalization/vote_recorder -> esperanza/vote
23a19
> Circular dependency: finalization/state_db -> validation -> injector -> finalization/state_db
25,26c21
< Circular dependency: finalization/state_processor -> snapshot/creator -> snapshot/p2p_processing -> injector -> finalization/state_processor
< Circular dependency: finalization/vote_recorder -> injector -> p2p/finalizer_commits_handler -> p2p/finalizer_commits_handler_impl -> finalization/vote_recorder
---
> Circular dependency: finalization/state_repository -> validation -> injector -> finalization/state_repository
30d24
< Circular dependency: init -> injector -> settings -> init
38c32
< Circular dependency: injector -> p2p/finalizer_commits_handler -> p2p/finalizer_commits_handler_impl -> snapshot/p2p_processing -> injector
---
> Circular dependency: injector -> staking/active_chain -> validation -> injector
41d34
< Circular dependency: injector -> validation -> injector
Irrelevant to this commit, but what do you think if we replace includes with forward declarations in the injector.h? This file becomes a point which triggers recompilation of ~20 .cpp files when only one component is changed or added.
I was thinking about that, tried it, and does not work; the injector needs to have access to the full declaration as it does type resolution doing typeid(...)
which does not work with a forward declaration.
With this change walletextention will segfault when configured with no injector. This case must be at least properly asserted in functions who uses this dep. Alternatively we can use stub here.
The wallet extension is a bit of a nightmare, because the wallet is a bit of a nightmare. There is the walletdependencies class to inject stuff into the wallet extension which makes it semi-dependency-injected (it's not managed by the injector yet it's sort of dependency injected as it is created by the wallet using the injector, but there are possibly many instances of a wallet).
The wallet dependencies constructor which does not take the injector is not meant to be used in production. I will add a comment to it. It is there purely because CWallet
has a mode (which is for tests only) in which you can create it without a wallet db (without any dependencies at all). This only happens in the unit tests, none of which segfault.
I will add a comment and an assert.
@frolosofsky I hope I can alleviate your concerns with the changes in b154fc347165dc3bf5c2241b77691b567b590501
Rebased, fixed conflicts, force pushed.
I wonder why PR that lands new RPCs, is surrounded by tons of code style refactoring instead of functional tests for new RPC commands.
I haven't check tracestake in details as it is quite complicated (I don't say it must be rewritten or something, just a fact). I will play with this closer locally later.
Some of these changes are because I'm polishing RPC all together. Thank you for bearing with me and doing the effort of reviewing it nevertheless. It should be the same as a bunch of smaller PRs ;-)
Please extract src/rpc/net.cpp code style changes to another PR. It's alsmost impossible to review actual changes in that file.
@frolosofsky That file was accidentally formatted and committed. Undone. I removed it form the commits and force-pushed.
We discussed this a bit and decided to merge despite the concerns. I for one do share these concerns, but I do have to admit that at the same time I'm torn:
Action Items:
::
in injector.h
where we can continue that discussion, which is the only unresolved item here. I think any conclusion should go to the developer guide and I am leaning in favor of removing ::
altogether (in my mind classes, even though in different namespaces but in the same project, should have different names anyway or be used within the namespace only, but that's a different issue/story which is mostly just a personal preference)
As this PR has a couple of approvals and no actual request for changes I hope this is sort of okay. We need to integrate #808, this, that upcoming pull request and it is saving a lot of time and effort to do it via master.
In any case thanks for the good reviews, I think the code is now much more aligned and less alien. There's a couple of things, also refactorings (when already touched then also do), which I'll push in another pull request, which I guess is what we lean to anyway.
Everything RPC!
This adds three new RPC commands
tracechain
,tracestake
, andgetstakeablecoins
. It also cleans up a lot of RPC stuff which has been missed in the past:check-rpc-mappings.py
check-rpc-mappings.py
check-rpc-mappings.py
proposer*
rpcsRPC_*
error messages, e.g. when still in warmup*RPC
components usingGetComponent
The new commands do the following:
tracechain
Starting from
start
(defaults to the current tip of the active chain) forlength
number of blocks: Print coinbase information like stake, reward, combined stake, returned stake. For genesis block: Show initial funds.tracestake
This one allows you to inspect the chain and whether all the stakes refer to the right utxo's.
getstakeablecoins
Enumerates explicitly the coins which are available for staking. Very useful in functional tests and to debug.
How to test / How to use
getstakeablecoins
tracestake