Skip to content

Conversation

@hodlinator
Copy link
Contributor

@hodlinator hodlinator commented Jun 12, 2025

Make wallet DB properly detect and report failure to scan wallet directory. Seems to have been broken since moving from Boost to std::filesystem.

Found while reviewing: #31410 (review)

@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 12, 2025

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

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32736.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK achow101, maflcko, rkrux

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #31410 (qa: Fix wallet_multiwallet.py by hebasto)
  • #29641 (scripted-diff: Use LogInfo over LogPrintf [WIP, NOMERGE, DRAFT] by maflcko)

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.

@fanquake
Copy link
Member

https://cirrus-ci.com/task/6556243914915840?logs=ci#L4845:

[09:50:58.842]                                    AssertionError: [node 0] Expected messages "['Error scanning directory entries under']" does not partially match log:

@hodlinator hodlinator marked this pull request as draft June 12, 2025 15:59
@hodlinator hodlinator force-pushed the 2025/06/wallet_dir_iter branch from ab65c62 to 6ed17c7 Compare June 12, 2025 21:38
@hodlinator hodlinator marked this pull request as ready for review June 12, 2025 21:41
Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

The code looks correct, matches the upstream docs, and passes the tests. I left some nits.

review ACK 6ed17c7dca35ec820dc1c0500ef32a132c641fa5 🤜

Show signature

Signature:

untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: review ACK 6ed17c7dca35ec820dc1c0500ef32a132c641fa5 🤜
8C1jo8YtfwmG7YDw/SkVQcm33apByQ744hTZUTZRr1uCttPMiBfHDSd3YQ0UxkMDHOvAMpU1SIwUm5b4tAV8AQ==

hodlinator and others added 3 commits June 13, 2025 13:41
Seems to have been broken since conversion from Boost in bitcoin#20744. The std::filesystem iteration aborts upon failure while Boost might have allowed skipping over faulty entries.
@hodlinator hodlinator force-pushed the 2025/06/wallet_dir_iter branch from 6ed17c7 to 272cd09 Compare June 13, 2025 12:01
@hodlinator hodlinator changed the title wallet: Warn upon failing to scan directory wallet: Correct dir iteration error handling Jun 13, 2025
@achow101
Copy link
Member

ACK 272cd09

@DrahtBot DrahtBot requested a review from maflcko June 17, 2025 01:04
@maflcko
Copy link
Member

maflcko commented Jun 17, 2025

re-ACK 272cd09 🍽

Show signature

Signature:

untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: re-ACK 272cd09b796a36596b325277bb43cb47b19c8e12 🍽
AEazdGZf0r70TCVJIeQ80JUBY7kWpOCzK+1Ox7cr7sGS7jMMX/Gob+wUeP8QofmQ6VtgMMTCg9yg/xM5jyhyBg==

@maflcko maflcko requested a review from hebasto June 20, 2025 07:54
Copy link
Contributor

@rkrux rkrux left a comment

Choose a reason for hiding this comment

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

tACK 272cd09

assert_equal(result, {'wallets': []})
self.stop_node(0)
# Restore permissions
os.chmod(data_dir('wallets'), stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit:

- os.chmod(data_dir('wallets'), stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
+ os.chmod(data_dir('wallets'), stat.S_IRWXU)

Initially, I thought of fetching the stat modes from os.stat and using those to set them back in chmod here. But RWXU is the most common, so fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Neat! Maybe something that could be done in #31410 now this one merged?

Comment on lines +84 to +85
elif os.geteuid() == 0:
self.log.warning('Skipping test involving chmod as it requires a non-root user.')
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice checking for the effective user ID, was the intention to add it as a safety check?

Copy link
Member

@maflcko maflcko Jun 20, 2025

Choose a reason for hiding this comment

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

Nice checking for the effective user ID, was the intention to add it as a safety check?

no, the test would not pass when this check/skip is removed. See #32736 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To elaborate, we probably run tests under root on CI in some cases to enable tracing:

def skip_if_no_bpf_permissions(self):
"""Skip the running test if we don't have permissions to do BPF syscalls and load BPF maps."""
# check for 'root' permissions
if os.geteuid() != 0:
raise SkipTest("no permissions to use BPF (please review the tests carefully before running them with higher privileges)")

@achow101 achow101 merged commit 482d255 into bitcoin:master Jun 20, 2025
19 checks passed
@hodlinator hodlinator deleted the 2025/06/wallet_dir_iter branch June 22, 2025 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants