Skip to content

build: Drop bitcoin-tx and bitcoin-wallet dependencies on libevent - #18504

Merged
maflcko merged 2 commits into
bitcoin:masterfrom
ryanofsky:pr/dep-libevent
Apr 10, 2020
Merged

maflcko merged 2 commits into
bitcoin:masterfrom
ryanofsky:pr/dep-libevent

Conversation

@ryanofsky

@ryanofsky ryanofsky commented Apr 2, 2020 •

Copy link
Copy Markdown
Contributor

This fixes compile errors trying to build bitcoin-tx and bitcoin-wallet without libevent, which were reported by Luke Dashjr in #18465

The fix avoiding bitcoin-tx dependency on libevent just adds a conditional build rule. This is implemented in the first commit (more details in commit description).

The fix avoiding bitcoin-wallet dependency on libevent requires minor code changes, because bitcoin-wallet (unlike bitcoin-tx) links against code that calls urlDecode / evhttp_uridecode. This fix is implemented in the second commit (again details in the commit description).

Don't include util/url.cpp to libbitcoin_util.a when libevent isn't available.
This fixes a compile error trying to build bitcoin-tx without libevent reported
by Luke Dashjr in bitcoin#18465

Fixes bitcoin#18465
Don't require urlDecode function in wallet code since urlDecode implementation
currently uses libevent. Just call urlDecode indirectly though URL_DECODE
function pointer constant if available.

In bitcoind and bitcoin-qt, URL_DECODE is implemented and used to interpret RPC
wallet requests. In bitcoin-wallet, URL_DECODE is null to avoid depending on
libevent.
@ryanofsky

Copy link
Copy Markdown
Contributor Author

Updated ddfe373 -> 01a3392 (pr/dep-libevent.1 -> pr/dep-libevent.2, compare) with msvc fix

@DrahtBot

DrahtBot commented Apr 3, 2020

Copy link
Copy Markdown
Contributor

Gitian builds

File commit dce6f3b
(master)
commit 8a62b9f52bdedb31ee9603983b813e9d5c4110bd
(master and this pull)
bitcoin-0.19.99-aarch64-linux-gnu-debug.tar.gz 4fba473976a3a85e... 0d64e50e2d3f59f1...
bitcoin-0.19.99-aarch64-linux-gnu.tar.gz c135739e69c4472d... e30313e60ae497ec...
bitcoin-0.19.99-arm-linux-gnueabihf-debug.tar.gz 06bb06c0f823bf90... 1f32dc21b2b701b5...
bitcoin-0.19.99-arm-linux-gnueabihf.tar.gz 7734e4d5cbcb4825... bc88b45b1e981d67...
bitcoin-0.19.99-osx-unsigned.dmg 0b344910a70199be... a857203c058c0b26...
bitcoin-0.19.99-osx64.tar.gz 46e9c05f70086290... eac6982eb274eebd...
bitcoin-0.19.99-riscv64-linux-gnu-debug.tar.gz 7831492494057bba... 535f6b1abe9bcc58...
bitcoin-0.19.99-riscv64-linux-gnu.tar.gz f83ac254cfddb085... 9461af2417ad155b...
bitcoin-0.19.99-win64-debug.zip 604e4c5e227d50f0... ff4e0bc3d6086b09...
bitcoin-0.19.99-win64-setup-unsigned.exe b7fc22b59cfd6f6d... 69d02bb813f8a712...
bitcoin-0.19.99-win64.zip f2836d8a06e7d42c... 2456958b486469ab...
bitcoin-0.19.99-x86_64-linux-gnu-debug.tar.gz 75df0e07d2339760... 5999775aa35e1fce...
bitcoin-0.19.99-x86_64-linux-gnu.tar.gz f3a6db85e94d7cff... 06b0f9039cfaae4d...
bitcoin-0.19.99.tar.gz b478cb46b9bb5433... a1a382d30fbbb817...
bitcoin-core-linux-0.20-res.yml ccc64b0731859e36... 0de1fdbeba9f53f7...
bitcoin-core-osx-0.20-res.yml af46833e50fab798... d0a755fa1d01a73a...
bitcoin-core-win-0.20-res.yml aa9152d74d049f56... 2e51f6b663bb34e3...
linux-build.log 984685556f83f6c0... fef31aab904b165a...
osx-build.log 1e5a6165090ecbec... 67449ea283c6fb2e...
win-build.log 7472b49c6539ee86... 65255c959c9db8d6...
bitcoin-core-linux-0.20-res.yml.diff 6033300b201259e3...
bitcoin-core-osx-0.20-res.yml.diff 5cb3edb9f1c0ff19...
bitcoin-core-win-0.20-res.yml.diff 8991f12e402dc537...
linux-build.log.diff 1701dfe791eb446e...
osx-build.log.diff f5ecaa77996b17c5...
win-build.log.diff aa1c34d8e895a371...

@jonasschnelli

Copy link
Copy Markdown
Contributor

@maflcko

maflcko commented Apr 8, 2020

Copy link
Copy Markdown
Member

cc @luke-jr

@luke-jr luke-jr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of ugly, but utACK

Nit: URL_DECODE should probably be named g_url_decode_fn or something...

@ryanofsky

Copy link
Copy Markdown
Contributor Author

Nit: URL_DECODE should probably be named g_url_decode_fn or something...

Constant naming is used because it is a constant, not a global variable

@maflcko

maflcko commented Apr 8, 2020

Copy link
Copy Markdown
Member

Constant naming is used because it is a constant, not a global variable

G_URL_DECODE like G_TRANSLATION_FUN 😬 ?

@luke-jr

luke-jr commented Apr 8, 2020

Copy link
Copy Markdown
Contributor

G_URL_DECODE_FUN sounds better in that case...

But it's not really a constant - its value varies between builds.

@maflcko

maflcko commented Apr 8, 2020

Copy link
Copy Markdown
Member

The docs say "compile time constants", not "build time constants"

@maflcko

maflcko commented Apr 8, 2020

Copy link
Copy Markdown
Member

Anyway, I was mostly joking about that style nit. Let's not hold back this pull based on naming guidelines.

@luke-jr

luke-jr commented Apr 8, 2020

Copy link
Copy Markdown
Contributor

It's definitely not a compile time constant! ;)

@ryanofsky

Copy link
Copy Markdown
Contributor Author

It's definitely not a compile time constant! ;)

FWIW, following this up in #18568

@practicalswift

Copy link
Copy Markdown
Contributor

Concept ACK, but wouldn't it be easier to implement std::string urlDecode(const std::string &urlEncoded) without evhttp_uridecode?

It has always seemed weird to me that we depend on third-party code for such a trivial function :)

@DrahtBot

DrahtBot commented Apr 9, 2020

Copy link
Copy Markdown
Contributor

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

Conflicts

Reviewers, 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.

Comment thread src/wallet/rpcwallet.cpp
bool GetWalletNameFromJSONRPCRequest(const JSONRPCRequest& request, std::string& wallet_name)
{
if (request.URI.substr(0, WALLET_ENDPOINT_BASE.size()) == WALLET_ENDPOINT_BASE) {
if (URL_DECODE && request.URI.substr(0, WALLET_ENDPOINT_BASE.size()) == WALLET_ENDPOINT_BASE) {

@sidhujag sidhujag Apr 13, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be #ifdef URL_DECODE, ie: on bitcoin-tx the symbol does not exist if libevent is not used.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The symbol URL_DECODE is always defined

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad, thx

PhotoshiNakamoto added a commit to PhotonicBitcoin/pBTC-core that referenced this pull request Dec 11, 2021
Bitcoin Core PR: bitcoin/bitcoin#18504

Pull request description:

  This fixes compile errors trying to build bitcoin-tx and bitcoin-wallet without libevent, which were reported by Luke Dashjr in bitcoin/bitcoin#18465

  The fix avoiding `bitcoin-tx` dependency on libevent just adds a conditional build rule. This is implemented in the first commit (more details in commit description).

  The fix avoiding `bitcoin-wallet` dependency on libevent requires minor code changes, because `bitcoin-wallet` (unlike `bitcoin-tx`) links against code that calls `urlDecode` / `evhttp_uridecode`. This fix is implemented in the second commit (again details in the commit description).
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants