Skip to content

fix: error loading identities from local DB on token creation screen#364

Merged
QuantumExplorer merged 28 commits into
v0.9-devfrom
fix/cannot-load-identity-from-db
Jun 26, 2025
Merged

fix: error loading identities from local DB on token creation screen#364
QuantumExplorer merged 28 commits into
v0.9-devfrom
fix/cannot-load-identity-from-db

Conversation

@lklimek
Copy link
Copy Markdown
Contributor

@lklimek lklimek commented Jun 12, 2025

Importing an identity from the network causes NULL wallet in database identity table. This causes errors when loading identities.

@lklimek lklimek requested review from QuantumExplorer and Copilot and removed request for Copilot June 12, 2025 13:54
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 12, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this 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.

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.

@lklimek lklimek requested a review from Copilot June 13, 2025 13:48

This comment was marked as outdated.

Comment thread src/backend_task/identity/load_identity.rs Outdated
@lklimek lklimek requested a review from Copilot June 17, 2025 08:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses errors when loading identities with null wallets by ensuring wallet info is properly determined and loaded, standardizes custom_dash_qt_path handling using PathBuf, and streamlines version management.

  • Added error logging and early return in the token creator when local identities fail to load
  • Migrated all custom_dash_qt_path fields and database storage to use PathBuf, with improved UI enable/disable behavior
  • Introduced determine_wallet_info in QualifiedIdentity, replaced build script version include with env!("CARGO_PKG_VERSION"), and enhanced logging

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/ui/tokens/tokens_screen/token_creator.rs Added tracing error log when identities fail to load
src/ui/network_chooser_screen.rs Migrated custom_dash_qt_path to PathBuf and updated Start button UI
src/ui/identities/keys/key_info_screen.rs Updated insert_local_qualified_identity calls to new signature
src/ui/components/top_panel.rs Guarded Dash-Qt startup on presence of custom path
src/model/qualified_identity/mod.rs Added determine_wallet_info for wallet seed index extraction
src/main.rs Replaced version include with env!("CARGO_PKG_VERSION") constant
src/logging.rs Enhanced logger init with structured version and log file info
src/database/settings.rs Changed Dash-Qt path to use PathBuf and added conversion logic
src/database/initialization.rs Improved migration panic message with version details
src/database/identities.rs Updated insert/get local identities to pass wallet info by reference
src/context.rs Refactored load_local_user_identities to load wallets into identities
src/backend_task/identity/register_identity.rs Adapted insert_local_qualified_identity calls to new signature
src/backend_task/identity/load_identity_from_wallet.rs Updated insert_local_qualified_identity signature for wallet info
src/backend_task/identity/load_identity.rs Integrated determine_wallet_info when loading identities
src/backend_task/core/start_dash_qt.rs Simplified Dash-Qt binary resolution to require PathBuf
src/backend_task/core/mod.rs Updated CoreTask variant to accept PathBuf
src/app.rs Introduced detect_dash_qt_path util and use Option<PathBuf> for custom path
build.rs Removed build script (version.rs generation)
Cargo.toml Removed build entry and updated dependencies
Comments suppressed due to low confidence (1)

src/context.rs:334

  • The type WalletSeedHash is used but not imported in this file; add use crate::model::qualified_identity::WalletSeedHash; (or the appropriate path) to avoid compilation errors.
fn load_wallet_for_identity(
    &self,
    identity: &mut QualifiedIdentity,
    wallet_hashes: &[WalletSeedHash],
) -> Result<()> {

Comment thread src/model/qualified_identity/mod.rs
Comment thread src/app.rs Outdated
pauldelucia and others added 20 commits June 17, 2025 10:53
* feat: add token by token id

* fmt

* update cargo toml
Previously, if the content did not fit on the screen there was no way to view it unless the application window could be made larger
* feat: dark mode

* ok

* fmt

* clippy
* fix: identity not found error when refreshing identities

* chore: ui - gray out inactive identities

* chore: minor ui fixes

* chore: identity status creation failed cannot be reliably determined

* fix: det overwrites pending/failed creation status

* chore: copilot's review

* chore: refactor

* Update src/model/qualified_identity/mod.rs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* chore: not needed migration call removed

* chore: clippy

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* feat: enhance input decoding to support multiple formats

* more work

* more work
@lklimek lklimek force-pushed the fix/cannot-load-identity-from-db branch from f630e42 to ffcb001 Compare June 17, 2025 08:54
@lklimek
Copy link
Copy Markdown
Contributor Author

lklimek commented Jun 17, 2025

@coderabbitai review all

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 17, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

@lklimek I'll conduct a comprehensive review of all changes in this PR. Let me first gather information about what files have been modified.


🏁 Script executed:

#!/bin/bash
# Get the list of changed files in this PR
git diff --name-only HEAD~1 HEAD

# Get more detailed information about the changes
git diff --stat HEAD~1 HEAD

# Show which branch we're on
git branch --show-current

Length of output: 481


Let me try a different approach to identify the changes in this PR:


🏁 Script executed:

#!/bin/bash
# Check available branches to identify the base branch
git branch -a

# Check the commit log to see what's in this branch
git log --oneline -10

# Check if there are any uncommitted changes
git status

# Try to find the merge base with common branch names
for branch in main master develop; do
    if git show-ref --verify --quiet refs/remotes/origin/$branch; then
        echo "Comparing against origin/$branch:"
        git diff --name-only origin/$branch HEAD
        echo "--- Detailed diff stats ---"
        git diff --stat origin/$branch HEAD
        break
    fi
done

Length of output: 62801


This is a substantial PR that appears to add comprehensive token functionality to the Dash Evo Tool. Let me examine the key changes to provide a thorough review.


🏁 Script executed:

#!/bin/bash
# Examine the main configuration changes
echo "=== Cargo.toml changes ==="
git diff origin/master HEAD Cargo.toml | head -50

echo "=== .env.example changes ==="
git diff origin/master HEAD .env.example | head -30

echo "=== Main app changes ==="
git diff origin/master HEAD src/app.rs | head -100

Length of output: 13017


🏁 Script executed:

#!/bin/bash
# Let's look at the database changes to understand the new schema
echo "=== Database initialization changes ==="
git diff origin/master HEAD src/database/initialization.rs | head -50

echo "=== New tokens database module ==="
cat src/database/tokens.rs | head -50

echo "=== Context changes ==="
git diff origin/master HEAD src/context.rs | head -50

Length of output: 6853


🏁 Script executed:

#!/bin/bash
# Let's examine the new token backend functionality
echo "=== New token backend modules ==="
find src/backend_task/tokens -name "*.rs" | head -10
echo ""
cat src/backend_task/tokens/mod.rs | head -50

echo "=== Check the main backend task module changes ==="
git diff origin/master HEAD src/backend_task/mod.rs | head -50

echo "=== New UI components structure ==="
find src/ui/tokens -name "*.rs" | head -10

Length of output: 5365


🏁 Script executed:

#!/bin/bash
# Let's examine security aspects and error handling
echo "=== Look at token transfer/mint security ==="
cat src/backend_task/tokens/transfer_tokens.rs | head -80

echo "=== Check database migration safety ==="
grep -A 20 "try_perform_migration" src/database/initialization.rs

echo "=== Examine error handling patterns ==="
grep -r "panic\|unwrap\|expect" src/backend_task/tokens/ | head -10

echo "=== Check font asset sizes ==="
du -h assets/Fonts/ | tail -5

Length of output: 7855


Based on my comprehensive review of this substantial PR, I'll provide feedback on the key areas of concern and improvements needed.

🔍 Overall Assessment

This is a massive PR (486 files, 39K+ additions) that introduces a comprehensive token management system to Dash Evo Tool. While the feature set is impressive, there are several critical concerns that need to be addressed.

⚠️ Critical Issues

1. Database Migration Safety Regression

The migration error handling has become less robust:

// OLD: Graceful fallback
if let Err(e) = self.try_perform_migration(current_version, DEFAULT_DB_VERSION) {
    println!("Migration failed: {:?}", e);
    self.recreate_db(db_file_path)?;  // Graceful recovery
}

// NEW: Hard failure
if let Err(e) = self.try_perform_migration(current_version, DEFAULT_DB_VERSION) {
    panic!("Database migration failed...");  // ❌ Application crash
}

Recommendation: Restore graceful degradation for production stability.

2. Excessive Binary Size

The addition of 374MB of Noto Sans fonts is concerning:

  • Desktop applications should leverage system fonts
  • Consider using font subsets or web fonts
  • This will significantly impact download size and startup time

3. Breaking Configuration Changes

Environment variable naming has changed without backward compatibility:

# OLD
MAINNET_SHOW_IN_UI=true

# NEW  
MAINNET_show_in_ui=true

Recommendation: Provide backward compatibility or clear migration guide.

🔒 Security Review

Positive Aspects:

  • Token transfer operations use proper builder patterns
  • State transition signing is handled correctly
  • Error handling includes proof logging for debugging

Areas for Improvement:

  • Some unwrap() usage in token operations could cause panics
  • Consider adding input validation for token amounts and addresses

🏗️ Architecture & Code Quality

Strengths:

  • Well-structured token backend modules
  • Good separation of concerns between UI and business logic
  • Proper use of async/await patterns

Concerns:

  • PR Size: This should have been split into multiple focused PRs
  • Database Schema: Jump from version 5 to 11 suggests intermediate changes weren't properly tracked
  • Error Handling: Mix of panic-prone and safe error handling patterns

📊 Performance Considerations

  1. Font Loading: 374MB of fonts will impact startup time
  2. Database Complexity: New token tables add query complexity
  3. Memory Usage: Loading multiple font variants simultaneously

🎨 UI/UX

The new theme system and token management screens appear comprehensive, but:

  • Consider lazy loading for complex token screens
  • Ensure responsive design across different screen sizes

📋 Recommendations

High Priority:

  1. Fix database migration safety - restore graceful fallback
  2. Reduce font asset size - use system fonts or minimal subsets
  3. Add backward compatibility for configuration changes
  4. Split this PR into smaller, reviewable chunks for future reference

Medium Priority:

  1. Remove unwrap() calls in favor of proper error handling
  2. Add comprehensive tests for token operations
  3. Document the migration path for existing users
  4. Consider performance impact of extensive font loading

Low Priority:

  1. Optimize database queries for token operations
  2. Add input validation helpers
  3. Consider using enum dispatch for better type safety

Approval Conditional On

This PR introduces valuable functionality but requires the following fixes before merge:

  1. Database migration safety restoration
  2. Font asset size reduction plan
  3. Configuration backward compatibility

The token functionality appears well-implemented from a business logic perspective, but the infrastructure changes need refinement for production readiness.

🐰

     /|   /|  
    ( :-v-: )
     |     |
     ^-----^

Thoroughly reviewing your comprehensive token system - impressive scope but needs some polish!

Comment thread src/ui/identities/keys/key_info_screen.rs
@QuantumExplorer QuantumExplorer merged commit 740a836 into v0.9-dev Jun 26, 2025
3 checks passed
@QuantumExplorer QuantumExplorer deleted the fix/cannot-load-identity-from-db branch June 26, 2025 09:43
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.

6 participants