-
Notifications
You must be signed in to change notification settings - Fork 37.7k
bitcoin-wallet tool: Drop libbitcoin_server.a dependency #15639
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
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. |
cdc621a
to
2d0a984
Compare
Concept ACK Decoupling is good. Somewhat related: #15612 ("Reduce the number of globals used") |
I just left feedback in #15638 pertaining to the newly introduced circular dependencies. I agree with @practicalswift that decoupling is good, but I hope we can do this without introducing new circular dependencies. |
This is a move-only commit. No code is changing and the moves can be easily verified with: git log -p -n1 --color-moved=dimmed_zebra 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 bitcoin#15639, and attempting to access server state from wallet code will result in link errors instead of silently broken code. List of moves: `CheckTransaction` moves from `consensus/tx_verify.cpp` to `consensus/tx_check.cpp` `urlDecode` moves from `httpserver.cpp` to `util/url.cpp` `TransactionErrorString` moves from `node/transaction.cpp` to `util/error.cpp` `StringForFeeReason` and `FeeModeFromString` move from `policy/fees.cpp` to `util/fees.cpp` `incrementalRelayFee` `dustRelayFee` and `nBytesPerSigOp` move from `policy/policy.cpp` to `policy/settings.cpp` `SignalsOptInRBF` moves from `policy/rbf.cpp` to `util/rbf.cpp` `fIsBareMultisigStd` moves from `validation.cpp` to `policy/settings.cpp` `ConstructTransaction` `TxInErrorToJSON` and `SignTransaction` move from `rpc/rawtransaction.cpp` to `rpc/rawtransaction_util.cpp` `RPCTypeCheck` `RPCTypeCheckArgument` `RPCTypeCheckObj` `AmountFromValue` `ParseHashV``ParseHashO` `ParseHexV` `ParseHexO` `HelpExampleCli` and `HelpExampleRpc` move from `rpc/server.cpp` to `rpc/util.cpp` `AmountHighWarn` and `AmountErrMsg` move from `ui_interface.cpp` to `util/error.cpp` `FormatStateMessage` and `strMessageMagic` move from 'validation.cpp` to 'util/validation.cpp` `VerifyWallets` `LoadWallets` `StartWallets` `FlushWallets` `StopWallets` and `UnloadWallets` move from `wallet/init.cpp` to `wallet/node.cpp`
Pass null Chain interface pointer to CWallet. This is needed to drop libbitcoin_server dependency and avoid linking node code.
Remove last few instances of accesses to node global variables from wallet code. Also remove accesses to node globals from code in policy/policy.cpp that isn't actually called by wallet code, but does get linked into wallet code. This is the last change needed to allow bitcoin-wallet tool to be linked without depending on libbitcoin_server.a, to ensure wallet code doesn't access node global state and avoid bugs like bitcoin#15557 (comment)
This ensures wallet code doesn't access node global state, avoiding bugs like bitcoin#15557 (comment)
4d074e8 [build] Move AnalyzePSBT from psbt.cpp to node/psbt.cpp (Russell Yanofsky) fd509bd [docs] Document src subdirectories and different libraries (John Newbery) 9eaeb7f [build] Move wallet load functions to wallet/load unit (John Newbery) 91a25d1 [build] Add several util units (John Newbery) 9951786 [build] Move several units into common libraries (John Newbery) 0509465 [build] Move rpc rawtransaction util functions to rpc/rawtransaction_util.cpp (John Newbery) 1acc61f [build] Move rpc utility methods to rpc/util (John Newbery) 4a75c9d [build] Move policy settings to new src/policy/settings unit (John Newbery) fdf8888 [build] Move CheckTransaction from lib_server to lib_consensus (John Newbery) Pull request description: This is a move-only commit. No code is changing and the moves can be easily verified with: ```sh git log -p -n1 --color-moved=dimmed_zebra ``` 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: - `CheckTransaction` moves from `consensus/tx_verify.cpp` to `consensus/tx_check.cpp` - `urlDecode` moves from `httpserver.cpp` to `util/url.cpp` - `TransactionErrorString` moves from `node/transaction.cpp` to `util/error.cpp` - `StringForFeeReason` and `FeeModeFromString` move from `policy/fees.cpp` to `util/fees.cpp` - `incrementalRelayFee` `dustRelayFee` and `nBytesPerSigOp` move from `policy/policy.cpp` to `policy/settings.cpp` - `SignalsOptInRBF` moves from `policy/rbf.cpp` to `util/rbf.cpp` - `fIsBareMultisigStd` moves from `validation.cpp` to `policy/settings.cpp` - `ConstructTransaction` `TxInErrorToJSON` and `SignTransaction` move from `rpc/rawtransaction.cpp` to `rpc/rawtransaction_util.cpp` - `RPCTypeCheck` `RPCTypeCheckArgument` `RPCTypeCheckObj` `AmountFromValue` `ParseHashV``ParseHashO` `ParseHexV` `ParseHexO` `HelpExampleCli` and `HelpExampleRpc` move from `rpc/server.cpp` to `rpc/util.cpp` - `AmountHighWarn` and `AmountErrMsg` move from `ui_interface.cpp` to `util/error.cpp` - `FormatStateMessage` and `strMessageMagic` move from `validation.cpp` to `util/validation.cpp` - `VerifyWallets` `LoadWallets` `StartWallets` `FlushWallets` `StopWallets` and `UnloadWallets` move from `wallet/init.cpp` to `wallet/node.cpp` ACKs for commit 4d074e: jnewbery: utACK 4d074e8 (checked by doing the rebase myself and verifying no difference between my branch and 4d074e8) Tree-SHA512: 5e1604a9fb06475f2b96da0de0baa8330f4dda834dc20a0183ef11e1e4c27631d1d1bbb9abf0054efc03d56945fdf9920f63366b6a4f200f665b742a479ff75c
Thanks, this was addressed some time ago in the other PR. |
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.
tested ACK.
Cosmetic question/comment: is the proj moving back towards underscores in variables like old school Unix (dust_relay_fee
), or sticking with C++ style lower-cased first letter, and no underscores?
utACK 78a2fb5. Nice work, Russ. |
utACK 78a2fb5 |
utACK 78a2fb5 |
re: #15639 (review)
Pretty much yes. It's documented in the developer notes: https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#coding-style-general |
Summary: Pass null Chain interface pointer to CWallet. This is needed to drop libbitcoin_server dependency and avoid linking node code. bitcoin/bitcoin@fbc6bb8 --- Partial backport of Core [[bitcoin/bitcoin#15639 | PR15639]] Test Plan: ninja check-all ninja src/bench/bitcoin-bench ./src/bench/bitcoin-bench -filter=CoinSelection Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6233
Summary: in D5967 ([[bitcoin/bitcoin@4a75c9d | core commit]]) I've included policy/settings.h in policy/policy.h so that our version of GetVirtualTransactionSize still had access to `::nBytesPerSigOp` recently while working on commit [[bitcoin/bitcoin@b874747 | b874747b51882a613895a100c4210c7f1dddde30]] of [[bitcoin/bitcoin#15639 | PR15639]], I realize, in hindsight, that looks wrong this diff reverts the include I added to policy.h, moves our version of GetVirtualTransactionSize to settings.h ahead of [[bitcoin/bitcoin#15639 | PR15639]] and makes the other necessary changes Test Plan: ninja check-all Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D6253
Summary: Remove last few instances of accesses to node global variables from wallet code. Also remove accesses to node globals from code in policy/policy.cpp that isn't actually called by wallet code, but does get linked into wallet code. This is the last change needed to allow bitcoin-wallet tool to be linked without depending on libbitcoin_server.a, to ensure wallet code doesn't access node global state and avoid bugs like bitcoin/bitcoin#15557 (comment) --- bitcoin/bitcoin@b874747 --- Depends on D6233 Partial backport of Core [[bitcoin/bitcoin#15639 | PR15639]] Test Plan: ninja check-all Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Subscribers: deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6255
…ency Summary: This ensures wallet code doesn't access node global state, avoiding bugs like bitcoin/bitcoin#15557 (comment) --- bitcoin/bitcoin@78a2fb5 --- Depends on D6255 Concludes backport of Core [[bitcoin/bitcoin#15639 | PR15639]] Test Plan: ninja check-all Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6256
Dropping the
bitcoin-wallet
dependency onlibbitcoin_server.a
ensures wallet code can't access node global state, avoiding bugs like #15557 (comment)