Skip to content

fix: active contest vote tallies were not being updated with refresh button#6

Merged
QuantumExplorer merged 4 commits into
masterfrom
fix/refresh-vote-counts
Oct 19, 2024
Merged

fix: active contest vote tallies were not being updated with refresh button#6
QuantumExplorer merged 4 commits into
masterfrom
fix/refresh-vote-counts

Conversation

@pauldelucia
Copy link
Copy Markdown
Member

@pauldelucia pauldelucia commented Oct 17, 2024

The function insert_name_contests_as_normalized_names was returning only names that have not been updated for over an hour, and these names were being used to update the UI showing the contest states. But on testnet, contests only last one hour. So the votes for those names were not being displayed. So instead, we check the network and if it's testnet, we only update the contests created in the past hour, and on mainnet, created in the past two weeks.

Also, in registering dpns names, display aliases instead of identifiers.

Summary by CodeRabbit

  • New Features

    • Streamlined identity selection process for registering DPNS names, enhancing user experience.
    • Improved handling of contested names in the database, ensuring better data integrity and clarity.
  • Bug Fixes

    • Enhanced logic for updating contested names and contestants, preventing potential data inconsistencies.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 17, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces modifications to the Database struct and the RegisterDpnsNameScreen struct. Key enhancements include improved methods for managing contested names, ensuring data integrity during updates, and refining the identity selection process in the UI. Notably, the get_contested_names method now supports network-specific operations, while the insert_name_contests_as_normalized_names method has been updated to better handle name updates based on network conditions. The UI changes streamline how identities are displayed and selected, maintaining overall control flow.

Changes

File Path Change Summary
src/database/contested_names.rs - Enhanced get_contested_names to handle Network type and populate a hashmap with ContestedName objects.
- Refined insert_or_update_name_contest logic for contested name existence checks.
- Updated insert_or_update_contenders with transaction logic.
- Renamed outdated_names to names_to_be_updated in insert_name_contests_as_normalized_names and expanded update logic based on network type.
- Updated update_ending_time to ensure new value checks.
src/ui/identities/register_dpns_name_screen.rs - Simplified render_identity_id_selection to use QualifiedIdentity alias directly, with fallback to Base58 encoding for identity ID.
- Maintained logic in register_dpns_name_clicked while utilizing the modified identity selection process.

Possibly related PRs

  • feat: register usernames #3: The changes in this PR involve the registration of DPNS usernames, which is directly related to the modifications in the RegisterDpnsNameScreen struct and methods in the main PR, as both involve handling DPNS names and user identity selection processes.

Poem

In the database deep, where names do contest,
New logic emerges, ensuring the best.
With identities clear, and selections so bright,
We streamline the process, making it right.
Hop along, dear friends, let’s celebrate this feat,
For every contested name, we make it complete! 🐇✨


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>, 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 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.

Copy link
Copy Markdown
Contributor

@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

🧹 Outside diff range and nitpick comments (1)
src/ui/identities/register_dpns_name_screen.rs (1)

70-72: LGTM! Consider a minor readability improvement.

The changes simplify the display logic for identity selection, which aligns with the AI summary's description of streamlining the process. The code now correctly uses the alias if available, falling back to the identity ID if not.

For improved readability, consider extracting the display text logic into a separate method:

 ui.selectable_value(
     &mut self.selected_qualified_identity,
     Some(qualified_identity.clone()),
-    qualified_identity.alias.as_ref().unwrap_or(
-        &qualified_identity.identity.id().to_string(Encoding::Base58),
-    ),
+    self.get_identity_display_text(qualified_identity),
 )

+ // Add this method to the impl block
+ fn get_identity_display_text(&self, qualified_identity: &QualifiedIdentity) -> String {
+     qualified_identity.alias.clone().unwrap_or_else(|| 
+         qualified_identity.identity.id().to_string(Encoding::Base58)
+     )
+ }

This change would make the main logic more concise and easier to understand at a glance.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 601d405 and dc23dab.

📒 Files selected for processing (2)
  • src/database/contested_names.rs (4 hunks)
  • src/ui/identities/register_dpns_name_screen.rs (1 hunks)
🧰 Additional context used
🔇 Additional comments (2)
src/ui/identities/register_dpns_name_screen.rs (1)

Line range hint 1-190: Verify alignment with PR objectives

The changes in this file focus on improving the identity selection display logic, which is a positive enhancement. However, these modifications don't appear to address the stated PR objectives of fixing "active contest vote tallies not being updated with refresh button".

To ensure we're not missing any relevant changes, please run the following script:

This script will help us verify if there are any other files in the codebase that might contain the changes related to the PR objectives. If no results are found, we may need to clarify the scope of the PR with the author.

src/database/contested_names.rs (1)

464-464: Verify handling of None timestamps when sorting

When sorting names_to_be_updated, the code uses a.1.unwrap_or(0), assigning a timestamp of 0 to entries where last_updated is None. This causes these entries to be considered the oldest. If this is intentional and you want entries with no last_updated to appear first, please confirm. Otherwise, consider using a more appropriate default value or adjusting the sorting logic to ensure correct ordering.

Comment thread src/database/contested_names.rs
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@QuantumExplorer QuantumExplorer merged commit 924b51d into master Oct 19, 2024
@QuantumExplorer QuantumExplorer deleted the fix/refresh-vote-counts branch October 19, 2024 21:06
@coderabbitai coderabbitai Bot mentioned this pull request Dec 13, 2024
lklimek added a commit that referenced this pull request Feb 24, 2026
- Replace assume_checked() with require_network() for address
  validation (CodeRabbit #2)
- Use styled Frame-with-dismiss error display matching Send dialog
  pattern (CodeRabbit #3)
- Don't open dialog when no wallet selected; show MessageBanner
  instead (CodeRabbit #4)
- Extract shared load_bip44_external_addresses() helper to eliminate
  near-duplicate code between mine and receive dialogs (CodeRabbit #5)
- Add backend-side network guard (Regtest/Devnet) for defense-in-depth
  (CodeRabbit #6)
- Rename shadowed ctx binding to refresh_ctx for clarity (CodeRabbit #7)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
lklimek added a commit that referenced this pull request Feb 24, 2026
- Change MineBlocksSuccess(usize) to MineBlocksSuccess(u64) for
  type consistency with block_count parameter (Claudius #5)
- Align dialog close pattern with Send/Receive: use local `open`
  variable for egui X button, reset state inside closure for
  Cancel/Mine buttons (Claudius #6)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
lklimek added a commit that referenced this pull request Feb 24, 2026
… mode (#638)

* feat(wallet): add Mine Blocks dialog for Regtest/Devnet dev mode

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: add manual test scenarios for mine blocks dialog

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(wallet): close Mine Blocks dialog after Cancel/Mine click

The dialog stayed open (in a broken state) after clicking Mine or Cancel
because the local `open` variable was written back to `is_open` after the
dialog state had already been reset. Pass `is_open` directly to egui's
`.open()` and use a separate `close` flag for button-triggered dismissal.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(wallet): address audit findings for Mine Blocks dialog

- Wrap `generate_to_address` in `spawn_blocking` to avoid blocking
  the async runtime thread (HIGH)
- Replace `.expect()` on core client lock with `.map_err()?` for
  graceful error handling instead of panic (HIGH)
- Cap block count at 1000 to prevent resource exhaustion on the
  Core node (HIGH)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(wallet): filter non-numeric input in Mine Blocks block count field

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(wallet): address review comments on Mine Blocks dialog

- Replace assume_checked() with require_network() for address
  validation (CodeRabbit #2)
- Use styled Frame-with-dismiss error display matching Send dialog
  pattern (CodeRabbit #3)
- Don't open dialog when no wallet selected; show MessageBanner
  instead (CodeRabbit #4)
- Extract shared load_bip44_external_addresses() helper to eliminate
  near-duplicate code between mine and receive dialogs (CodeRabbit #5)
- Add backend-side network guard (Regtest/Devnet) for defense-in-depth
  (CodeRabbit #6)
- Rename shadowed ctx binding to refresh_ctx for clarity (CodeRabbit #7)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(wallet): address remaining review comments on Mine Blocks dialog

- Change MineBlocksSuccess(usize) to MineBlocksSuccess(u64) for
  type consistency with block_count parameter (Claudius #5)
- Align dialog close pattern with Send/Receive: use local `open`
  variable for egui X button, reset state inside closure for
  Cancel/Mine buttons (Claudius #6)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
lklimek added a commit that referenced this pull request Feb 25, 2026
- Remove dead `_is_sync_operation` parameter from `Database::set_platform_address_info`
  and all call sites (Finding #6)
- Add doc comment on `set_platform_sync_info` explaining column name drift:
  `last_platform_sync_checkpoint` now stores SDK sync height (Finding #4)
- Remove trivial `set_platform_address_info_from_sync` delegate and update
  callers to use `set_platform_address_info` directly (Finding #7)
- Combine unnecessary `let provider` + `let mut provider = provider`
  rebinding into single `let mut` block (Finding #10)
- Document UTXO selection race window on `broadcast_and_commit_asset_lock`:
  std::sync::RwLock guard is !Send so it cannot span async broadcast

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
lklimek added a commit that referenced this pull request Feb 25, 2026
…rmSyncMode (#635)

* refactor(wallet): simplify platform sync by removing PlatformSyncMode

Remove the PlatformSyncMode enum (Auto/ForceFull/TerminalOnly) and
terminal sync logic (apply_recent_balance_changes, last_terminal_block,
last_full_sync_balance). The SDK now handles incremental sync internally
via AddressProvider::current_balances() and last_sync_height().

Key changes:
- Remove PlatformSyncMode enum from backend_task::wallet
- Simplify fetch_platform_address_balances to use new SDK API with
  stored state (with_stored_state, current_balances, last_sync_height)
- Change CoreTask::RefreshWalletInfo to use bool instead of
  Option<PlatformSyncMode>
- Remove last_full_sync_balance from PlatformAddressInfo
- Simplify database sync info to 2-tuple (timestamp, height)
- Remove set_last_terminal_block from database
- Simplify RefreshMode enum (remove PlatformFull, PlatformTerminal,
  CoreAndPlatformFull, CoreAndPlatformTerminal variants)

Note: requires updated dash-sdk with new sync_address_balances API.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* chore: update platform SDK to rev 0fa82e6652

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: add manual test scenarios for platform sync simplification

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(wallet): address PR #635 audit findings and extract broadcast helper

- DB schema v28: drop obsolete columns (last_terminal_block,
  last_full_sync_balance), rename last_platform_sync_checkpoint →
  last_platform_sync_height, with SQLite ≥3.35 runtime check
- Store asset lock TX before broadcast to prevent SPV InstantSend race
- Defer UTXO removal until after successful broadcast
- Replace .unwrap() on RwLock with .map_err() to avoid panics
- Remove unused _is_sync_operation param and set_platform_address_info_from_sync wrapper
- Fix redundant let-mut rebinding in fetch_platform_address_balances
- Extract broadcast_and_commit_asset_lock() on AppContext to consolidate
  the store→broadcast→cleanup→UTXO-removal pattern from 5 code paths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor(db): schema v28 — drop obsolete sync columns and clean up DB interface (#653)

- Bump DEFAULT_DB_VERSION 27 → 28
- Drop last_terminal_block from wallet table (unused after sync simplification)
- Drop last_full_sync_balance from platform_address_balances table
- Rename last_platform_sync_checkpoint → last_platform_sync_height
- Add runtime SQLite ≥3.35 check (required for DROP COLUMN)
- Idempotent migration: checks column existence before each ALTER
- Remove unused _is_sync_operation param from set_platform_address_info()
- Remove set_platform_address_info_from_sync() wrapper
- Fix redundant let-mut rebinding in fetch_platform_address_balances

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

* revert(db): remove schema v28 migration from this branch

The v28 schema changes (drop obsolete sync columns, rename
last_platform_sync_checkpoint → last_platform_sync_height) will be
applied separately and should not ship on this branch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: address PR review comments — remove dead code and document risks

- Remove dead `_is_sync_operation` parameter from `Database::set_platform_address_info`
  and all call sites (Finding #6)
- Add doc comment on `set_platform_sync_info` explaining column name drift:
  `last_platform_sync_checkpoint` now stores SDK sync height (Finding #4)
- Remove trivial `set_platform_address_info_from_sync` delegate and update
  callers to use `set_platform_address_info` directly (Finding #7)
- Combine unnecessary `let provider` + `let mut provider = provider`
  rebinding into single `let mut` block (Finding #10)
- Document UTXO selection race window on `broadcast_and_commit_asset_lock`:
  std::sync::RwLock guard is !Send so it cannot span async broadcast

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* style: apply nightly fmt

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
shumkov added a commit that referenced this pull request Apr 12, 2026
Addresses all critical and important findings from the M2 code review.

Critical #1: write_core SPV height
  Changed `WHERE seed_hash = ?2` to `WHERE wallet_id = ?2` in the
  wallet.last_terminal_block UPDATE. The persister passes wallet_id
  bytes; the old SQL matched against the seed_hash column which holds
  different bytes — 0 rows matched, sync height was silently lost on
  every restart.

Critical #2: handle_wallet_unlocked shielded init
  After register_with_platform_wallet_manager (which may re-key the
  map), use wallet_id from the Wallet struct for subsequent lookups
  (initialize_shielded_wallet, queue_shielded_sync) instead of the
  stale seed_hash variable.

Critical #3: WalletDerivationPath stores wrong key
  Changed qualified_identity_public_key.rs to populate
  wallet_seed_hash with wallet.wallet_id() instead of
  wallet.seed_hash(). Post-v40, determine_wallet_info() returns
  wallet_id bytes, matching the map key.

Important #4/#5: wallet selection + UI validation
  wallets_screen uses wallet_id for persist_selected_wallet_hash
  and the arc-matches validation check.

Finding #6: shielded_wallet_meta in v40 DELETE sweep
  Added to the cache nuke table list.

Wallet.wallet_id is now non-optional (WalletId, not Option<WalletId>).
The wallet migration screen (to be implemented) ensures every wallet
has wallet_id before the main UI loads. WalletArcRef.seed_hash
renamed to wallet_id. No more map_key() fallback — wallet_id is
always the canonical key.

get_wallets() uses [0u8; 32] as sentinel for NULL wallet_id rows
(password wallets pre-migration). The migration screen detects this
sentinel and prompts for unlock.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
shumkov added a commit that referenced this pull request Apr 13, 2026
HIGH #6: Add tracing::warn to 7 silent identity_id decode continues.
  All `Err(_) => continue` in load() now log before skipping. Matches
  the existing pattern for account_type/txid decode failures.

HIGH #7: payment_type/status catch-all masks corruption.
  Unknown payment_type no longer defaults to Received — skips row
  with tracing::warn. Unknown status no longer defaults to Pending —
  same treatment. Explicitly matches "pending"/"sent"/"received"/
  "confirmed"/"failed".

HIGH #8: created_at type mismatch (write i64, load u64).
  Load now reads as Option<i64> (matching the write cast), clamps
  negative values to 0 via .max(0), converts explicitly to u64.

HIGH #9: Proof decode failure silently degrades asset lock status.
  When proof_data was present but decode failed AND no legacy
  fallback columns (islock_data, chain_height) exist, skip the
  entire row with tracing::error instead of loading a degraded
  entry with Broadcast status.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants