Skip to content

Conversation

ryanofsky
Copy link
Contributor

@ryanofsky ryanofsky commented Mar 22, 2019

Dropping the bitcoin-wallet dependency on libbitcoin_server.a ensures wallet code can't access node global state, avoiding bugs like #15557 (comment)

@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 22, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #15750 ([rpc] Remove the addresses field from the getaddressinfo return object by jnewbery)
  • #15719 (Drop Chain::requestMempoolTransactions method by ryanofsky)
  • #15557 (Enhance bumpfee to include inputs when targeting a feerate by instagibbs)

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.

@ryanofsky ryanofsky force-pushed the pr/link2 branch 2 times, most recently from cdc621a to 2d0a984 Compare March 22, 2019 08:22
@practicalswift
Copy link
Contributor

Concept ACK

Decoupling is good.

Somewhat related: #15612 ("Reduce the number of globals used")

@l2a5b1
Copy link
Contributor

l2a5b1 commented Mar 25, 2019

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.

ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Mar 30, 2019
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)
laanwj added a commit that referenced this pull request Apr 10, 2019
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
@ryanofsky
Copy link
Contributor Author

I just left feedback in #15638 pertaining to the newly introduced circular dependencies

Thanks, this was addressed some time ago in the other PR.

Copy link
Contributor

@jgarzik jgarzik left a 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?

@jnewbery
Copy link
Contributor

utACK 78a2fb5. Nice work, Russ.

@maflcko
Copy link
Member

maflcko commented Apr 10, 2019

utACK 78a2fb5

@meshcollider
Copy link
Contributor

utACK 78a2fb5

@meshcollider meshcollider merged commit 78a2fb5 into bitcoin:master Apr 11, 2019
@ryanofsky
Copy link
Contributor Author

re: #15639 (review)

Cosmetic question/comment: is the proj moving back towards underscores in variables like old school Unix

Pretty much yes. It's documented in the developer notes: https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#coding-style-general

deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 22, 2020
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
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 26, 2020
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
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 27, 2020
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
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 27, 2020
…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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants