Skip to content
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

Wallet scan optimisation #1474

Merged
merged 10 commits into from
Sep 3, 2024
Merged

Wallet scan optimisation #1474

merged 10 commits into from
Sep 3, 2024

Conversation

levoncrypto
Copy link
Contributor

Аdded functionality that allows users to specify the creation date of their wallet during the recovery process for a more optimal wallet scan. Additionally, when creating a new wallet, the creation date will be displayed so that users can save it for future reference.

Copy link

coderabbitai bot commented Aug 5, 2024

Walkthrough

The recent updates improve the wallet recovery process by allowing users to specify their wallet's birth date through the user interface. New UI components were added to the notifymnemonic and recover forms, alongside backend enhancements for date management, enhancing clarity and streamlining the wallet restoration experience.

Changes

Files Change Summary
src/qt/forms/notifymnemonic.ui, src/qt/forms/recover.ui Added UI elements for wallet birth date selection and restructured layouts for better clarity and accessibility.
src/qt/recover.cpp Updated methods to manage date input state and integrated date handling within recovery logic.
src/wallet/wallet.cpp, src/wallet/wallet.h Introduced parseDate function and GetBlockByDate method to retrieve block information based on specified dates.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant Wallet

    User->>UI: Selects "Enable Date Selection"
    UI->>UI: Enable date input field
    User->>UI: Inputs wallet birth date
    UI->>Wallet: Passes date for recovery
    Wallet->>Wallet: Retrieves block by date
    Wallet->>UI: Displays recovery information
Loading

🐰 In the meadow, bright and wide,
A new date widget joins the ride.
With clicks and taps, the process flows,
To restore the wallet, everyone knows!
So hop along, dear friends of mine,
For recovery's sweet—our wallets will shine! ✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range, codebase verification and nitpick comments (1)
src/wallet/wallet.cpp (1)

2374-2387: Document the rationale behind subtracting 200 from the block height.

The logic of subtracting 200 from the block height should be documented to explain its purpose.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c0ddba2 and ee6456a.

Files selected for processing (7)
  • src/qt/forms/notifymnemonic.ui (1 hunks)
  • src/qt/forms/recover.ui (3 hunks)
  • src/qt/notifymnemonic.cpp (3 hunks)
  • src/qt/recover.cpp (5 hunks)
  • src/qt/recover.h (1 hunks)
  • src/wallet/wallet.cpp (2 hunks)
  • src/wallet/wallet.h (1 hunks)
Additional comments not posted (13)
src/qt/recover.h (1)

25-25: LGTM! The new method declaration is consistent with the class design.

The method updateDateInputState is correctly declared as a private slot, aligning with the Qt framework's signal-slot mechanism.

src/qt/notifymnemonic.cpp (2)

40-42: LGTM! The new function implementation is correct.

The function getCurrentDate correctly retrieves the current date formatted as "dd-MM-yyyy".


52-52: LGTM! The changes in the notify method enhance the user interface.

The wallet creation date is correctly displayed using the getCurrentDate function.

src/qt/recover.cpp (4)

63-68: LGTM! The new method implementation is correct.

The method updateDateInputState correctly enables or disables the dateInput field based on the checkbox state and sets a minimum date if enabled.


52-54: LGTM! The changes in the setCreateNew method are correct.

The dateInput field is correctly disabled and cleared when creating a new recovery instance.


79-81: LGTM! The changes in the on_recoverExisting_clicked method are correct.

The dateInput field is correctly enabled based on the state of the enableDateSelection checkbox.


124-128: LGTM! The changes in the askRecover method are correct.

The date input is correctly handled based on the state of the enableDateSelection checkbox.

src/qt/forms/notifymnemonic.ui (2)

113-120: New QLabel for displaying wallet birth date added.

The QLabel walletBirthDate is correctly added with properties for displaying text and enabling word wrapping.


125-125: Text of QLabel updated to include wallet birth date reference.

The updated text in textLabel2 clearly informs users about the importance of the wallet's birth date during restoration and its role in optimizing the wallet scanning process.

src/qt/forms/recover.ui (3)

44-44: Text of QLabel updated to include wallet birth date information.

The updated text clearly informs users about the option to choose the wallet birth date for a faster and optimized wallet scan.


138-189: New vertical layout added for recovery seed phrase and date selection.

The vertical layout verticalLayout2 is correctly added and includes components for inputting the recovery seed phrase and selecting the wallet's birth date.


169-185: New checkbox and date input field added for wallet birth date selection.

The checkbox enableDateSelection and date input field dateInput are correctly added with properties for enabling date selection and displaying the date in the dd-MM-yyyy format.

src/wallet/wallet.h (1)

932-932: New method GetBlockHeightByDate added to CWallet class.

The method GetBlockHeightByDate is correctly added to the CWallet class. Ensure that the implementation handles edge cases and errors appropriately.

src/wallet/wallet.cpp Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ee6456a and b3412ba.

Files selected for processing (2)
  • src/qt/recover.cpp (4 hunks)
  • src/wallet/wallet.cpp (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • src/qt/recover.cpp
  • src/wallet/wallet.cpp

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b3412ba and 3363b32.

Files selected for processing (2)
  • src/qt/recover.cpp (4 hunks)
  • src/wallet/wallet.cpp (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • src/qt/recover.cpp
  • src/wallet/wallet.cpp

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3363b32 and 31589ba.

Files selected for processing (4)
  • src/qt/forms/recover.ui (3 hunks)
  • src/qt/recover.cpp (4 hunks)
  • src/wallet/wallet.cpp (3 hunks)
  • src/wallet/wallet.h (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • src/qt/forms/recover.ui
  • src/wallet/wallet.cpp
  • src/wallet/wallet.h
Additional comments not posted (5)
src/qt/recover.cpp (5)

35-36: Initialization of dateInput is appropriate.

The dateInput field is correctly configured with a display format and a minimum date, enhancing user guidance.


53-54: Disabling and clearing dateInput is consistent.

The changes ensure dateInput is not used when creating a new wallet, aligning with the intended functionality.


66-67: Setting default date and display format for dateInput.

The changes maintain consistency in the UI for new wallet creation.


74-77: Enabling and configuring dateInput for recovery is appropriate.

These changes align with the goal of allowing users to specify a date during recovery.


120-123: Logic for adjusting date in askRecover is approved, but verify correctness.

Subtracting one day from the selected date before using it is a specific logic that should be verified to ensure it aligns with the intended functionality.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 31589ba and b1b7ebe.

Files selected for processing (1)
  • src/wallet/wallet.cpp (3 hunks)
Additional comments not posted (3)
src/wallet/wallet.cpp (3)

2374-2386: LGTM! Verify the logic in GetBlockByDate.

The function correctly iterates through the blockchain to find the appropriate block index based on the given date.


2426-2429: LGTM!

The logging and initialization for rescanning are straightforward and correctly implemented.


2406-2424: LGTM! Verify edge cases in date handling.

The logic for adjusting the starting block index based on the provided date or mnemonic start block looks correct. Ensure edge cases, such as dates before the mnemonic start block, are handled properly.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b1b7ebe and f9df2a0.

Files selected for processing (1)
  • src/wallet/wallet.cpp (3 hunks)
Additional comments not posted (3)
src/wallet/wallet.cpp (3)

2431-2431: Rescan logging and progress updates look good.

The logging and progress updates provide clear information about the rescan process.


2374-2386: Verify the logic in GetBlockByDate.

The function returns a block index offset by 200 if the block time exceeds the target timestamp. Ensure that this logic aligns with the intended functionality and that the offset is correct.


2411-2429: Verify handling of the -wcdate argument.

Ensure that the logic correctly handles the -wcdate argument and that the block index adjustments are accurate.

Verification successful

Verification successful for handling of the -wcdate argument.

The -wcdate argument is correctly used in src/wallet/wallet.cpp for retrieving the date and adjusting the block index accordingly. Additionally, it is set in src/qt/recover.cpp, indicating its role in date-based operations. The logic appears consistent and appropriate for its intended purpose.

  • src/wallet/wallet.cpp: Retrieves -wcdate using GetArg.
  • src/qt/recover.cpp: Sets -wcdate using SoftSetArg.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the handling of the `-wcdate` argument in the wallet scanning logic.

# Test: Search for the `-wcdate` argument usage. Expect: Correct handling and logic adjustments.
rg --type cpp -A 5 $'-wcdate'

Length of output: 433


Script:

#!/bin/bash
# Description: Verify the handling of the `-wcdate` argument in the wallet scanning logic.

# Test: Search for the `-wcdate` argument usage. Expect: Correct handling and logic adjustments.
rg --type cpp -A 5 "'-wcdate'"

Length of output: 38


Script:

#!/bin/bash
# Description: Verify the handling of the `-wcdate` argument in the wallet scanning logic.

# Test: Search for the `-wcdate` argument usage. Expect: Correct handling and logic adjustments.
rg --type cpp -A 5 "-wcdate"

Length of output: 433


Script:

#!/bin/bash
# Description: Verify the handling of the `-wcdate` argument in the wallet scanning logic.

# Test: Search for the `-wcdate` argument usage. Expect: Correct handling and logic adjustments.
rg --type cpp -- "-wcdate"

Length of output: 207

src/wallet/wallet.cpp Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f9df2a0 and 08ed4d1.

Files selected for processing (1)
  • src/wallet/wallet.cpp (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/wallet/wallet.cpp

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 08ed4d1 and b9da4df.

Files selected for processing (1)
  • src/wallet/wallet.cpp (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/wallet/wallet.cpp

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b9da4df and e19e0f6.

Files selected for processing (1)
  • src/wallet/wallet.cpp (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/wallet/wallet.cpp

Copy link
Contributor

@levonpetrosyan93 levonpetrosyan93 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e19e0f6 and 8486aea.

Files selected for processing (1)
  • src/wallet/wallet.cpp (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/wallet/wallet.cpp

@levonpetrosyan93 levonpetrosyan93 merged commit 30b8595 into master Sep 3, 2024
6 checks passed
@levonpetrosyan93 levonpetrosyan93 deleted the scan_optimisation branch September 3, 2024 14:27
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.

3 participants