-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Move-only: Pull wallet code out of libbitcoin_server #15638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c5b3a3f to
89061c8
Compare
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
I split this out for review here: https://github.com/Empact/bitcoin/commits/pr/link-split (you can diff Empact@9d9ad38 for consistency) and came away with 2 proposed changes:
|
|
@Empact, I can use your branch with split up commits if other people think that is easier to review. But I'm not sure that they will. Personally I would rather scan a single commit with The two changes you propose are not good, though. They have some problems conceptually, and I think will break the followup PR #15639, although I didn't test. The point of this PR is to designate a directory ( Both wallet code and qt code should be able to translate error codes into strings. So Similarly, both wallet code and qt code should be able to call |
|
Very strong concept ACK to this and #15639. This is the natural follow-up to #10973. That PR defined a node<->wallet interface and made it so wallet code shouldn't directly access node functions. This PR with #15639 ensures that wallet code can't directly access node functions. My only question is when these should be merged. This conflicts with a lot of PRs (including high-priority #15141) so perhaps it should wait. On the other hand, rebases will be trivial since this is just a code move. |
I think it would be slightly easier to review if this was split into multiple commits, each moving a function with with justification for the move. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK b35ba2c
The dimmed zebra helps with checking the moves. I'm fine with either splitting this into smaller commits that explain which things are are moved and why, or just putting a list in the PR description.
I'm able to compile on macOS 10.14.3 with and without wallet.
For some reason the x64 build in Visual Studio 2017 on Windows breaks:

AppVeyor seems happy though. I did a clean before building. Building the parent commit also breaks, although with different errors. Maybe we recently introduced a problem? cc @ken2812221 & @sipsorcery
|
@Sjors this PR builds correctly for me with VS 2017 x64 Debug and Release. Did you re-run the |
|
@sipsorcery I did not. Can't test it at the moment, but that seems like a plausible explanation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated b35ba2c -> 9742ff8 (pr/link.5 -> pr/link.6, compare) adding suggested comments, removing circular lint warnings.
re: #15638 (review)
The dimmed zebra helps with checking the moves. I'm fine with either splitting this into smaller commits that explain which things are are moved and why, or just putting a list in the PR description
I added a list of moves to the PR description. A few people have requested splitting this PR up, and if someone still thinks this is a good idea, I'd urge them to at least first spend a few minutes looking over the commit with --color-moved=dimmed_zebra.
I don't want to break up this PR into a large number of commits, because we have lots of circular dependencies and lots of different binaries (tests, benchmarks, tools, frontends) that pull object files in with different link orders. We also build on many different platforms, so right now any commit that moves a symbol from one object file to another is basically playing russian roullete with travis and appveyor. I spent hours after I first got this PR working locally to eventually get it working on the various travis platforms and appveyor. I don't want to have to repeat this work again with a bunch of individual commits, or to blindly push a bunch of broken commits. I think splitting the commit up at best would only make it slightly easier to review with --color-moved=dimmed_zebra, and in actuality would just make this more intimidating and more awkward to review and maintain. I think a bitcoin contributor who literally spent 10 minutes looking at the current commit with --color-moved=dimmed_zebra, could fully review the PR, verifying that it is move-only and reading all the new comments.
|
John was asking questions about why different functions were moving to various libraries. I'll describe how I was thinking about this below, but I don't consider the question to be extremely important, because the libraries are already pretty scrambled up, and I'm not trying to unscramble them here. All I am trying to do is split up .cpp files that have functions called by the wallet, so wallet code that links these .cpp files doesn't pull in a bunch of node dependencies. But just to provide reassurance that I am not messing up the libraries in some way here, here is how I am thinking about the organization:
Over time, I think it'd be nice if source code organization reflected library organization . I think it'd be nice if all |
|
I split this PR into smaller commits to help my review: https://github.com/jnewbery/bitcoin/tree/pr15638_8 . I pushed each commit as a separate branch on my fork to be built by travis: https://travis-ci.org/jnewbery/bitcoin/builds. I personally find this easier to review as each move is justified by its commit log.
This is really useful. Would you mind opening an issue with basically the description you've given above. I think it'd be useful to have as a reference for how we think the code organization should be moving, and as a place to solicit feedback from other contributors. |
|
@laanwj has also expressed a desire to reorganize the source code (#15465 (comment)):
|
|
Here are 2 revised proposals, related to the earlier work: Empact@c72764e - Moves TransactionError to its own file, Empact@90293e6 - Now just makes Based on the current |
|
Concept ACK |
* merge 15638: Move CheckTransaction from lib_server to lib_consensus * merge 15638: Move policy settings to new src/policy/settings unit * merge 15638: Move rpc utility methods to rpc/util * merge 15638: Move rpc rawtransaction util functions to rpc/rawtransaction_util.cpp * merge 15638: Move several units into common libraries * merge 15638: Move wallet load functions to wallet/load unit * merge 15638: Document src subdirectories and different libraries * [build] Add several util units (cleanup) * build: resolve missing declarations by re-specifying headers
…ay#4560) * merge 15638: Move CheckTransaction from lib_server to lib_consensus * merge 15638: Move policy settings to new src/policy/settings unit * merge 15638: Move rpc utility methods to rpc/util * merge 15638: Move rpc rawtransaction util functions to rpc/rawtransaction_util.cpp * merge 15638: Move several units into common libraries * merge 15638: Move wallet load functions to wallet/load unit * merge 15638: Document src subdirectories and different libraries * [build] Add several util units (cleanup) * build: resolve missing declarations by re-specifying headers fix build errors fix build errors fix build errors
This is a move-only commit. No code is changing and the moves can be easily verified with:
This commit moves functions and variables that wallet code depends on out of libbitcoin_server.a, so the bitcoin-wallet tool can be built without libbitcoin_server.a in #15639, and attempting to access server state from wallet code will result in link errors instead of silently broken code.
List of moves:
CheckTransactionmoves fromconsensus/tx_verify.cpptoconsensus/tx_check.cppurlDecodemoves fromhttpserver.cpptoutil/url.cppTransactionErrorStringmoves fromnode/transaction.cpptoutil/error.cppStringForFeeReasonandFeeModeFromStringmove frompolicy/fees.cpptoutil/fees.cppincrementalRelayFeedustRelayFeeandnBytesPerSigOpmove frompolicy/policy.cpptopolicy/settings.cppSignalsOptInRBFmoves frompolicy/rbf.cpptoutil/rbf.cppfIsBareMultisigStdmoves fromvalidation.cpptopolicy/settings.cppConstructTransactionTxInErrorToJSONandSignTransactionmove fromrpc/rawtransaction.cpptorpc/rawtransaction_util.cppRPCTypeCheckRPCTypeCheckArgumentRPCTypeCheckObjAmountFromValueParseHashV``ParseHashOParseHexVParseHexOHelpExampleCliandHelpExampleRpcmove fromrpc/server.cpptorpc/util.cppAmountHighWarnandAmountErrMsgmove fromui_interface.cpptoutil/error.cppFormatStateMessageandstrMessageMagicmove fromvalidation.cpptoutil/validation.cppVerifyWalletsLoadWalletsStartWalletsFlushWalletsStopWalletsandUnloadWalletsmove fromwallet/init.cpptowallet/node.cpp