Skip to content

backport: Merge bitcoin#28086, 30265,19833 #6619

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

vijaydasmp
Copy link

BTC Backport

@vijaydasmp vijaydasmp changed the title Apr 2025 01 backport: Apr 1, 2025
@vijaydasmp vijaydasmp changed the title backport: backport: Merge bitcoin#28209 Apr 1, 2025
@vijaydasmp vijaydasmp force-pushed the Apr_2025_01 branch 3 times, most recently from 34d5bc3 to d949961 Compare April 3, 2025 02:21
Copy link

github-actions bot commented Apr 3, 2025

This pull request has conflicts, please rebase.

@vijaydasmp vijaydasmp changed the title backport: Merge bitcoin#28209 backport: Merge bitcoin#28209, 23307, 28086, 30265,19833 Apr 4, 2025
MarcoFalke and others added 2 commits April 4, 2025 19:16
5fabde6 wallet: AddWalletDescriptor requires cs_wallet lock (João Barbosa)
32d036e wallet: GetLabelAddresses requires cs_wallet lock (João Barbosa)

Pull request description:

  This is another small change towards non recursive wallet lock.

ACKs for top commit:
  hebasto:
    ACK 5fabde6, I have reviewed the code and it looks OK, I agree it can be merged.

Tree-SHA512: 00506f0159c56854a171e58a451db8dd9b9f735039697b1cf2ca7f54de61fb51cc1e5eff42265233e041b4b1bfd29c2247496dc4456578e1a23c323bdec2901b
fa36742 fuzz: Bump FuzzedDataProvider.h (MarcoFalke)

Pull request description:

  Also, remove suppression.

ACKs for top commit:
  dergoegge:
    utACK fa36742

Tree-SHA512: 1d960cbedc4f516ef3dcec05b158164eb9673bcb02793c39d4b345be6d767aded1569289175701bc7382afd00ca41a2409831877f100ab9324969de9045ab6fc
@vijaydasmp vijaydasmp force-pushed the Apr_2025_01 branch 4 times, most recently from 16176fc to 69384ba Compare April 10, 2025 15:05
…fault wallets and generated backup files

6b2dcba wallet: List sqlite wallets with empty string name (Ava Chow)
3ddbdd1 wallet: Ignore .bak files when listing wallet files (Ava Chow)

Pull request description:

  When the default wallet is migrated, we do not rename the wallet so we end up having a descriptor wallet with the empty string as its name and the wallet.dat file in the root of the walletdir. This is supposed to be an unsupported configuration and there is no other way to achieve this (other than file copying), but the wallet loading code does not disallow loading such wallets. However `listwalletdir` does not currently list the default wallet if it is sqlite. This is confusing to users, so change `listwalletdir` to include these wallets.

  Additionally, the migration of the default wallet, and of any plain wallet files in the walletdir, produces a backup file in the walletdir itself. Since these backups are a BDB file, `listwalletdir` will detect them as being another wallet that we could open, but this is erroneous and could lead to confusion and potentially funds loss if both the backup and the migrated wallet are in use simultaneously. To reduce the likelihood of this issue, don't list these wallets in `listwalletdir`.

  ***

  Possibly we could have more stringent checks on loading to resolve these issues, but I'm concerned that that will just confuse users and gratuitously break things that already worked.

  Since the original intent was to disallow default wallets for sqlite/descriptors, a possible alternative would be to prevent people from loading such wallets and change migration to rename those wallets. However, given that this behavior with migrating default wallets has existed since default wallet migration was fixed, I think that making such a change would be confusing and break things for no good reason. Although perhaps we should still do the renaming.

  For the backups, we could also change loading to refuse to load any wallet named with `.bak` (or `.legacy.bak`) as such wallets can still be loaded by giving the path to them directly, which some users may do to "restore" the backup. However restricting what can be loaded based on filename seems a little heavyhanded. It wouldn't be funds loss though since the correct way to restore the backup is with `restorewallet`.

ACKs for top commit:
  fjahr:
    Code review ACK 6b2dcba
  furszy:
    Code ACK  6b2dcba
  glozow:
    ACK 6b2dcba

Tree-SHA512: 0b033f6ed55830f8a054afea3fb2cf1fa82a94040053ebfaf123bda36c99f45d3f01a2aec4ed02fed9c61bb3d320b047ed892d7f6644b5a356a7bc5974b10cff
@vijaydasmp vijaydasmp marked this pull request as ready for review April 11, 2025 16:51
@vijaydasmp
Copy link
Author

Copy link

coderabbitai bot commented Apr 11, 2025

Walkthrough

This pull request makes several targeted modifications across different components. In one file related to fuzz testing, type casting in arithmetic operations is adjusted to ensure that both operands use the same unsigned integer type, reducing potential overflow issues. Another change alters the logic for processing database files by excluding those with a ".bak" extension and refining conditions to correctly identify valid files. Updates to wallet functions introduce an assertion that verifies the wallet's mutex is locked before further execution, and the method signature is annotated to require an exclusive lock. Finally, a specific sanitizer suppression entry for implicit integer sign change in the fuzz testing component is removed. All modifications are confined to ensuring type safety, improved file handling, and enhanced thread safety through stricter locking requirements.

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bcd14b0 and acddb7b.

📒 Files selected for processing (5)
  • src/test/fuzz/FuzzedDataProvider.h (3 hunks)
  • src/wallet/db.cpp (1 hunks)
  • src/wallet/wallet.cpp (1 hunks)
  • src/wallet/wallet.h (1 hunks)
  • test/sanitizer_suppressions/ubsan (0 hunks)
💤 Files with no reviewable changes (1)
  • test/sanitizer_suppressions/ubsan
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/wallet/wallet.h (4)
src/wallet/scriptpubkeyman.h (9)
  • desc (594-594)
  • internal (172-172)
  • internal (172-172)
  • internal (189-189)
  • internal (189-189)
  • internal (326-326)
  • internal (352-352)
  • internal (551-551)
  • internal (576-576)
src/interfaces/wallet.h (1)
  • label (109-109)
src/wallet/interfaces.cpp (2)
  • label (158-163)
  • label (158-158)
src/wallet/walletdb.h (1)
  • internal (233-233)
src/wallet/db.cpp (1)
src/wallet/interfaces.cpp (1)
  • paths (621-628)
🔇 Additional comments (7)
src/wallet/wallet.h (1)

1106-1106: Thread safety enhancement: Added locking requirement to AddWalletDescriptor.

The addition of EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) annotation ensures this method can only be called when the wallet's lock is held, preventing potential race conditions when multiple threads attempt to modify wallet descriptors simultaneously.

This is a good practice for maintaining thread safety and preventing data corruption in concurrent environments.

src/wallet/db.cpp (2)

40-41: Improved database file filtering to exclude backup files.

The condition has been modified to exclude files with a .bak extension from being considered as valid databases. This prevents backup files from being mistakenly processed as active database files, which could lead to incorrect behavior or data loading issues.

This change helps improve the robustness of the wallet database handling.


45-51: Refined file identification logic for non-standard wallet files.

The code now checks if a file is a BDB file as a separate condition, executing only when the file is not named wallet.dat. This creates a clearer separation between standard wallet files and other BDB files that might be used for backward compatibility.

This restructuring improves the readability and maintainability of the file processing logic.

src/test/fuzz/FuzzedDataProvider.h (3)

212-212: Fixed potential integer overflow in range calculation.

The code now properly casts both operands to uint64_t before subtraction, ensuring that both values have the same type and preventing potential overflow issues when handling large integer values.

This change enhances the robustness of the fuzzing framework by preventing undefined behavior in arithmetic operations.


233-233: Enhanced type safety in return value calculation.

The modified code explicitly casts min to uint64_t before addition with result, ensuring consistent types throughout the calculation. This prevents potential undefined behavior that could occur with mixed-type arithmetic operations.

This change is particularly important for fuzzing, where edge cases and unusual inputs are common.


393-393: Improved type casting in signed conversion.

The code now correctly casts the result of the subtraction to the target signed type TS rather than using a generic char cast. This ensures proper type conversion, particularly for larger integer types where a char cast would be incorrect.

This change addresses a potential source of bugs when converting between different integer types.

src/wallet/wallet.cpp (1)

4439-4440: Thread safety assertion added.

The addition of AssertLockHeld(cs_wallet) at the beginning of the AddWalletDescriptor method ensures that the wallet's lock is properly held before proceeding, enhancing thread safety. This matches the method signature annotation EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) that was updated in the header file.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@vijaydasmp vijaydasmp changed the title backport: Merge bitcoin#28209, 23307, 28086, 30265,19833 backport: Merge bitcoin#28086, 30265,19833 Apr 11, 2025
@vijaydasmp
Copy link
Author

Hello @UdjinM6 @knst requesting review

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

utACK acddb7b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants