mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:47:36 +00:00
Convert check-deps.sh to python #35167
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!35167
Loading…
Reference in a new issue
No description provided.
Delete branch "202604-checkdeps"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Converts check-deps.sh to python so that it can use the mermaid graph from doc/design/libraries.md as its source of truth, as well as automatically resolve transitive dependencies and demangle C++ names.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.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.
Not sure if we want to remove all the transitive deps from the md file, but without them it's a fair bit easier to follow, at least compared to master:
Nice, Concept ACK
I feel like this was brought up before - makes it indeed much cleaner.
It's really nice to actually be able to read this now.
Re the additional warning we get now:
libbitcoin_clireally doesn't seem to requirelibbitcoin_util, so maybe we can add an edge forbitcoin-cli->libbitcoin_utiland remove the existinglibbitcoin_cli->libbitcoin_utiledge? Could also use this opportunity to cleanup thecommon/args.hinclude fromrpc/client.cpp.ACK 24b0d4c0496b1d4c1986269e11b9bb2a23c67f2e
Concept ACK 24b0d4c0496b1d4c1986269e11b9bb2a23c67f2e
Brings the script more in line with the programming language used for the other tools.
Found some small Nits.
NIT: there is a slight behavioral difference between nm on linux and on mac:
linux nm: "lib.a:obj.o: " (addr glued to obj:, blank for undefined)
Apple nm: "lib.a:obj.o: " (space after obj:, addr always its own token)
Both, the last two whitespace tokens are <type> <symbol>, NIT is to use that.
nm linux:
nm macos:
script to check behavior:
on macos, before:
After:
NIT: For me it was not clear that the depicted Dependency graph is more a "allow list" than an actual state of dependency usage. If you know you will read this distinction in the rest of the document but I think it would help to be a bit more clear for the casual reader / first time bitcoin dev-er. Text is nothing more than a suggestion.
I have always considered
doc/design/libraries.mdto be a design goal rather than a current reality.I don't think it can be considered the "source of truth" at this stage of development. For example,
bitcoind.cppdirectly uses symbols frombitcoin_common(such asArgsManager::GetBoolArg), andbitcoin_commonheaders are build requirements for thebitcoindtarget. This relationship isn't reflected indoc/design/libraries.mdand is currently out of scope for thecheck-depsscript, which might cause confusion.cc @purpleKarrot
It would have also failed on macos with the shell script, right?
Neither the shell or python check-deps script check binary dependencies -- binaries without all their deps will just fail to run anyway, so there's not much point. Even if they were checked, the transitive resolution in the python script would cover this case -- bitcoind depends on libbitcoin_node which depends on libbitcoin_common. (bitcoind would still need to explicitly link to libbitcoin_common presuming libbitcoin_node doesn't publicly incorporate libbitcoin_common though)
Switched to a regex that should also work on macos
Yes, well even worse it would give a "false" succes report.
Concept ACK
3c0e2f544eBig improvement for MacOs usage, it will no-longer report a false succes :
Master:
New Python based script (--no-build to reuse master build):
Not sure about suppressing build output, this deviates from the shell script variant and it somewhat confusing that "nothing" happens in default mode. (but it's building in the background)
Concept ACK
3c0e2f544emoving the./contrib/devtools/check-deps.shto PythonThe previous
check-deps.shwas transparent about triggering a rebuild, while the new check-deps.py builds silently in the background with no feedback, which feels confusingMaster (before PR)
Running `./contrib/devtools/check-deps.sh`
PR at
3c0e2f544eRunning `./contrib/devtools/check-deps.py`
Re-ACK
3c0e2f544e@ryanofsky you might be interested in reviewing here?
Code review
3c0e2f544eand concept ACK.These are very nice changes. It's a great idea to parse dependencies from libraries.md, and to not require manually listing transitive dependencies.
In theory, there could be cases where we might not want to allow transitive dependencies, but if you look at the list of implicit dependencies which are newly allowed as a result of this PR, they all seem acceptable even if they are unnecessary:
I do think there are some changes that should be made to this PR before it is merged. I left various comments below with suggestions, and also applied all the suggestions in a branch you should feel free to use: https://github.com/ryanofsky/bitcoin/commits/pr/dep2
In commit "ci: Convert check-deps to python and use design doc dependencies directly" (
5d3c53858e)Not important, but would be nice to drop this line so build progress is visible like in the previous script.
Alternately if the goal is actually to suppress build output, maybe don't do it when --verbose is specified, and consider using
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULLinstead of capturing and later discarding.In commit "ci: Convert check-deps to python and use design doc dependencies directly" (
5d3c53858e)Since this is run in CI it doesn't seem good to silently just warn about targets that fail to build.
It also doesn't seem good to try to build targets that don't exist, like this currently does with
bitcoin_kernel.In my suggested branch, I skip building
bitcoin_kernel:github.com/bitcoin/bitcoin@9877c0983d/contrib/devtools/check-deps.py (L37-L41)and change both warnings about missing libraries to errors
github.com/bitcoin/bitcoin@9877c0983d/contrib/devtools/check-deps.py (L194)github.com/bitcoin/bitcoin@9877c0983d/contrib/devtools/check-deps.py (L219)In commit "doc: Update library dependencies" (
8a74832)The dependency doesn't really make sense to add. Consensus library was meant to be a very minimal library and not need things in util.
There is no problem dropping this dependency for release builds, but for debug builds I needed to add a suppression for the
Assumeused inmerkle.cpp, similar to the suppression the PR already adds formuhash.cpp.o:github.com/bitcoin/bitcoin@9877c0983d/contrib/devtools/check-deps.py (L30)In commit "doc: Update library dependencies" (
8a74832314)These dependencies are not great to add, and it would be better to use suppressions instead. GUI code is meant to use
src/interfacesclasses to call node and wallet code. Or, in cases where common functions (like psbt functions) need to be shared by GUI/node/wallet libraries, they should be moved tobitcoin_common.GUI code calling node and wallet functions is a problem because it could indicate improper access to node/wallet internals, and create difficulties for other GUI's like the QML port. Also, the GUI should not depend on
bitcoin_clisince it is not an RPC client.In my branch I suggested keeping check-deps behavior unchanged and not checking
bitcoinqtfor now:github.com/bitcoin/bitcoin@9877c0983d/contrib/devtools/check-deps.py (L43-L47)In commit "refactor: Move init/common.cpp to libbitcoin_node" (
9399bf309a)I don't think it's good to remove
init/common.cppfrom libbitcoin_common and move it to libbitcoin_node, because this prevents binaries other thanbitcoindfrom being able to callStartLoggingand take advantage of logging.Currently, we don't have other command line binaries that use logging, but in #30437
StartLoggingis called to make IPC messages visible in thebitcoin-mineclient, and in #10102 it is called from thebitcoin-walletwallet subprocess to log wallet messages. Both of these PR's use aa78d98d82c67c3eb479e7589525678ac369c308, which basically does the opposite of this commit, moving the depended-on file from libbitcoin_node to libbitcoin_common instead of the other way around.So suggestion here is just to replace this commit with aa78d98d82c67c3eb479e7589525678ac369c308
No strong opinion on the implementation details, but I think devs should be able to use Assume/Assert or other low-level utils in consensus. Also linking to your earlier comment https://github.com/bitcoin/bitcoin/pull/34520#discussion_r3051461827:
😅
Seems fine, if those are meant as temporary suppressions, with the goal of fixing it with a proper dependency in one way or another.
On the earlier comment, just because something isn't harmful doesn't make it a good idea.
To fix the suppression, I'd be most inclined to switch from
Assumeto assert, or maybe just make the consensus code part of kernel if there is no longer a clear distinction between consensus & kernel libraries. Different approaches seem fine though.@ajtowns there's been some pending review here for a while. Can you follow up on the comments and questions? I still think the changes here are basically fine as is, but it might give other reviewers more confidence if the pending questions are answered.
🐙 This pull request conflicts with the target branch and needs rebase.
Concept ACK
@ajtowns this has been in need of a rebase for a while.
🟠 Minor · Failed library builds can still produce a successful dependency check
A failed or impossible target build is only warned about, so the script can report success without inspecting a library; CI is largely protected by its earlier full build.
Location:
contrib/devtools/check-deps.py:152(head).🔵 Suggestion · Dependency graph permissions conflict with the documented library boundaries
The graph permits dependencies that the accompanying rules forbid, so passing the check no longer demonstrates compliance with the documented boundaries.
Location:
doc/design/libraries.md:62(head).Reviewed:
3c0e2f544ecc· Full review report · Previous reportspermalink
Closing as up-for-grabs