Repository navigation
fix(wallet): copy the dashj wallet's exchange rates to the metadata table once - #1768
HashEngineering wants to merge 8 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review: 2
Please check the settings in the CodeRabbit UI or the
|
|
✅ Final review complete — no blockers (commit c681167) · triage: normal |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Changes requested: 6 blockers
- A rescan can discard migrated rates before Platform receives them —
wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:135-147(new)
Impact: Users who rescan after the migration queues rates but before publication can retain the rates locally while losing them from Platform and future restores, with no later automatic retry. - Startup migration can upload historical metadata outside the user's Future-only scope —
wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:135-139(new)
Impact: A user who enabled automatic saves only for future transactions can have pre-upgrade rates, memos, or other metadata uploaded without selecting Past, including fields they disabled such as fiat prices. - Startup rate migration can write private memos into support logs —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:194-198(new)
Impact: A user with a private memo on a legacy transaction that lacks a metadata row can disclose that memo when sharing application logs with support. - A legacy literal null rate can abort the entire Past metadata upload —
wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt:2282-2284(new)
Impact: A user saving past metadata can fail to upload any batch when one eligible row still contains the legacy literal"null"rate. - Copying a missing rate can restore a memo the user deleted —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:653-657(new)
Impact: A user who cleared a private memo can see the old dashj memo reappear and become queued for Platform when the migration fills that transaction's missing rate. - A memo-only Platform import can make the migration skip an unqueued rate —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:155-197(new)
Impact: If a Platform memo import creates a row using the dashj rate, the migration can mark completion without queuing that rate, leaving it unavailable after a restore.
This change adds a one-time migration of dashj exchange rates into transaction metadata, process-wide row-write coordination, and null-rate normalization. The supplied build and check CI jobs passed for the reviewed head; the PastaClaw review check is still in progress.
🔴 6 blocking | 🟡 1 suggestion(s) | 💬 1 nitpick(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🟡 Suggestion: Targeted metadata writes can be lost to concurrent whole-row replacement
Impact: A gift-card icon or other metadata value can disappear when its asynchronous update races with a Platform merge or another whole-row metadata write.
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:932-946
The new process-wide lock does not cover every writer of transaction_metadata. The icon callback calls updateIconId() on syncScope without rowWrites; a whole-row merge can read the row, let the icon update land, and then write its stale snapshot back over customIconId. setTransactionMetadata() also calls the whole-row insert() directly outside the lock. Make the icon update and direct whole-row setter participate in the same process-wide lock, or use column-specific updates that cannot overwrite unrelated fields.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.2-sol (phase2-reviewer: general, security-auditor)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.2-sol(effort low) — This is a substantial cross-cutting change to metadata migration, persistence, synchronization, locking, lifecycle cancellation, and recovery behavior, but it does not directly change funds movement, consensus, cryptography, key handling, or a storage schema migration. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Second Phase-2 pass: on this first full review every Phase-2 reviewer also ran a second, independent time, and the verifier weighed both sets
- Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— security-auditor (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt`:
- [SUGGESTION] wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:932-946: Targeted metadata writes can be lost to concurrent whole-row replacement
Impact: A gift-card icon or other metadata value can disappear when its asynchronous update races with a Platform merge or another whole-row metadata write.
The new process-wide lock does not cover every writer of `transaction_metadata`. The icon callback calls `updateIconId()` on `syncScope` without `rowWrites`; a whole-row merge can read the row, let the icon update land, and then write its stale snapshot back over `customIconId`. `setTransactionMetadata()` also calls the whole-row `insert()` directly outside the lock. Make the icon update and direct whole-row setter participate in the same process-wide lock, or use column-specific updates that cannot overwrite unrelated fields.
- [BLOCKING] wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:194-198: Startup rate migration can write private memos into support logs
Impact: A user with a private memo on a legacy transaction that lacks a metadata row can disclose that memo when sharing application logs with support.
The migration reaches `insertTransactionMetadata()` for missing rows, which copies the dashj transaction's memo into `TransactionMetadata` and then logs the entire object at INFO. That object includes the plaintext memo, and `wallet.log` is attached by `ContactSupportViewModel` when the user includes application logs. Use a rate-only migration path that does not import unrelated private fields, and replace the full-row insertion log with content-free diagnostics.
- [BLOCKING] wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:653-657: Copying a missing rate can restore a memo the user deleted
Impact: A user who cleared a private memo can see the old dashj memo reappear and become queued for Platform when the migration fills that transaction's missing rate.
The rate migration calls `syncTransaction()` for a dashj transaction whose metadata row has no usable rate. `syncRateOrInsert()` fills the rate but returns the pre-update row, whose memo may correctly be an empty string after the user deleted it. The following branch sees `tx.memo` still populated in the legacy wallet and calls `setTransactionMemo()`, restoring and queueing the old private text. Provide a migration-specific rate-only operation that does not reconcile memo or service fields.
- [BLOCKING] wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:155-197: A memo-only Platform import can make the migration skip an unqueued rate
Impact: If a Platform memo import creates a row using the dashj rate, the migration can mark completion without queuing that rate, leaving it unavailable after a restore.
When a Platform document creates a missing row, `insertTransactionMetadata()` falls back to the dashj transaction's exchange rate, but `isSyncingPlatform = true` suppresses the change-cache insert. The migration's missing-rate query then either sees that locally populated rate and skips the transaction, or loads the row after the import and treats the pair as already complete. The completion flag consequently records local presence rather than pending-queue or Platform coverage. Track local copying separately from authorized publication and ensure the rate is queued when no equivalent pending or published Platform value exists.
- [NITPICK] wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:1017-1033: The stored-rate unit documentation is attached to the wrong declaration
Impact: Readers looking for the exchange-rate column's unit find the decimal-format documentation separated from `storedRateString()`, while `hasStoredRate()` appears to own two KDoc blocks.
Two consecutive KDoc blocks appear before `hasStoredRate()`, so the decimal storage-unit documentation is not attached to `storedRateString()`, which remains undocumented. Move the first KDoc block immediately above `storedRateString()` and leave the predicate contract above `hasStoredRate()`.
In `wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:135-147: A rescan can discard migrated rates before Platform receives them
Impact: Users who rescan after the migration queues rates but before publication can retain the rates locally while losing them from Platform and future restores, with no later automatic retry.
The migration sets `DASHJ_RATES_COPIED_TO_METADATA` after `syncTransaction()` has locally queued and stored every rate, but that flag does not mean Platform accepted the upload. A rescan calls `clearDatabases()`, which best-effort publishes and then unconditionally clears `transaction_metadata_cache`; a failed, timed-out, or not-yet-started publication therefore drops the queued rates. Because the completion flag remains set, subsequent launches skip the migration and cannot reconstruct the queue. Preserve or replay authorized pending rate changes across non-wipe rescans, or maintain durable migration debt that is cleared only after publication is covered.
- [BLOCKING] wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:135-139: Startup migration can upload historical metadata outside the user's Future-only scope
Impact: A user who enabled automatic saves only for future transactions can have pre-upgrade rates, memos, or other metadata uploaded without selecting Past, including fields they disabled such as fiat prices.
The migration invokes `syncTransaction()` for every legacy transaction whose rate is absent from the table. For a missing row, that path builds a full `TransactionMetadata` object and queues it; `shouldSaveToCache()` currently always returns true. The automatic publisher checks only `saveToNetwork`, does not enforce `saveAfterTimestamp`, and assigns the first cache item for a transaction directly to `itemsToPublish`, so the field filters are applied only when later cache items are merged. A historical migration item can therefore reach Platform unchanged even when the transaction predates the Future start date or exchange-rate saving is disabled. Keep the local rate copy separate from upload authorization, and route historical uploads through the explicit Past flow or enforce date and field filters for the first published item as well.
In `wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt:2282-2284: A legacy literal null rate can abort the entire Past metadata upload
Impact: A user saving past metadata can fail to upload any batch when one eligible row still contains the legacy literal `"null"` rate.
The changed merge now represents a missing document rate as Kotlin `null`, while old local rows may still contain the literal string `"null"`. During `publishPastTxMetadata()`, the diff therefore treats that legacy value as a change and queues it. `publishTransactionMetadata()` then executes `it.rate?.toDouble()` on `"null"` before publishing, throws, and leaves the whole cache batch pending, preventing unrelated memos, categories, and valid rates from being sent. Normalize legacy missing-rate values on both sides of the diff and omit invalid rate pairs without aborting the other metadata fields or transactions.
| try { | ||
| // Creates the metadata row when there is none, or fills in the rate | ||
| // of one that has none, and queues it for Platform, as the dashj | ||
| // engine did when it handled the transaction. | ||
| metadataProvider.syncTransaction(tx) | ||
| } catch (e: CancellationException) { | ||
| throw e | ||
| } catch (e: Exception) { | ||
| failed++ | ||
| log.warn("could not copy the exchange rate of tx {}", tx.txId, e) | ||
| } | ||
| } | ||
| if (failed == 0) dashPayConfig.set(DashPayConfig.DASHJ_RATES_COPIED_TO_METADATA, true) |
There was a problem hiding this comment.
✅ Resolved at
d51d3725; see the replies below.
🔴 Blocking: A rescan can discard migrated rates before Platform receives them
Impact: Users who rescan after the migration queues rates but before publication can retain the rates locally while losing them from Platform and future restores, with no later automatic retry.
The migration sets DASHJ_RATES_COPIED_TO_METADATA after syncTransaction() has locally queued and stored every rate, but that flag does not mean Platform accepted the upload. A rescan calls clearDatabases(), which best-effort publishes and then unconditionally clears transaction_metadata_cache; a failed, timed-out, or not-yet-started publication therefore drops the queued rates. Because the completion flag remains set, subsequent launches skip the migration and cannot reconstruct the queue. Preserve or replay authorized pending rate changes across non-wipe rescans, or maintain durable migration debt that is cleared only after publication is covered.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.2-sol (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Needs a tracking issue (re-reviewed at 1c77e1e2): Deferring this needs a tracking issue for the follow-up, and none is linked in this thread, the PR description or the PR comments. Link one, or ask here and I'll file it; until then the finding stands.
There was a problem hiding this comment.
Fixed in 124ea3a: the copy no longer queues anything for Platform, so there is no pending upload of its own for a rescan to drop. The rates are written to the local table only; uploading them is the Past save, which reads that table (9a29085 clears the last-Past-save mark when rates were copied, so those transactions are not skipped).
There was a problem hiding this comment.
Resolved (re-reviewed at d51d3725): Your local copy no longer creates a pending cache entry that a rescan can discard. The non-wipe rescan preserves transaction_metadata, which the Past save reads to build its diff.
| try { | ||
| // Creates the metadata row when there is none, or fills in the rate | ||
| // of one that has none, and queues it for Platform, as the dashj | ||
| // engine did when it handled the transaction. | ||
| metadataProvider.syncTransaction(tx) |
There was a problem hiding this comment.
✅ Resolved at
d51d3725; see the replies below.
🔴 Blocking: Startup migration can upload historical metadata outside the user's Future-only scope
Impact: A user who enabled automatic saves only for future transactions can have pre-upgrade rates, memos, or other metadata uploaded without selecting Past, including fields they disabled such as fiat prices.
The migration invokes syncTransaction() for every legacy transaction whose rate is absent from the table. For a missing row, that path builds a full TransactionMetadata object and queues it; shouldSaveToCache() currently always returns true. The automatic publisher checks only saveToNetwork, does not enforce saveAfterTimestamp, and assigns the first cache item for a transaction directly to itemsToPublish, so the field filters are applied only when later cache items are merged. A historical migration item can therefore reach Platform unchanged even when the transaction predates the Future start date or exchange-rate saving is disabled. Keep the local rate copy separate from upload authorization, and route historical uploads through the explicit Past flow or enforce date and field filters for the first published item as well.
source: gpt-6.2-sol (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Fixed in 124ea3a: the copy is local. copyRateIfMissing writes the rate columns and queues nothing, so no past metadata reaches the automatic publisher. Past rates are uploaded only by the Past save the user starts.
There was a problem hiding this comment.
Resolved (re-reviewed at d51d3725): Your copy updates an existing row directly or inserts with isSyncingPlatform = true; neither branch adds a cache item for the automatic publisher. Resetting the cutoff does not enqueue a Past save.
| if (!isCoinJoinTx && metadata.isNotEmpty() && !isSyncingPlatform && hasChanges && shouldSaveToCache()) { | ||
| transactionMetadataChangeCacheDao.insert(TransactionMetadataCacheItem(metadata)) | ||
| } | ||
| transactionMetadataDao.insert(metadata) | ||
| log.info("txmetadata: inserting $metadata") |
There was a problem hiding this comment.
✅ Resolved at
d51d3725; see the replies below.
🔴 Blocking: Startup rate migration can write private memos into support logs
Impact: A user with a private memo on a legacy transaction that lacks a metadata row can disclose that memo when sharing application logs with support.
The migration reaches insertTransactionMetadata() for missing rows, which copies the dashj transaction's memo into TransactionMetadata and then logs the entire object at INFO. That object includes the plaintext memo, and wallet.log is attached by ContactSupportViewModel when the user includes application logs. Use a rate-only migration path that does not import unrelated private fields, and replace the full-row insertion log with content-free diagnostics.
source: gpt-6.2-sol (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Resolved (re-reviewed at d51d3725): Your insertion log reports the transaction ID and memo length, not the memo text, and the rate-parse diagnostic no longer serializes the row.
| currencyCode = docs.lastOrNull { it.currencyCode != null }?.currencyCode, | ||
| rate = docs.lastOrNull { it.rate != null }?.rate.toString(), | ||
| // `?.` on toString too: a missing rate is null, never the text "null". | ||
| rate = docs.lastOrNull { it.rate != null }?.rate?.toString(), |
There was a problem hiding this comment.
✅ Resolved at
d51d3725; see the replies below.
🔴 Blocking: A legacy literal null rate can abort the entire Past metadata upload
Impact: A user saving past metadata can fail to upload any batch when one eligible row still contains the legacy literal "null" rate.
The changed merge now represents a missing document rate as Kotlin null, while old local rows may still contain the literal string "null". During publishPastTxMetadata(), the diff therefore treats that legacy value as a change and queues it. publishTransactionMetadata() then executes it.rate?.toDouble() on "null" before publishing, throws, and leaves the whole cache batch pending, preventing unrelated memos, categories, and valid rates from being sent. Normalize legacy missing-rate values on both sides of the diff and omit invalid rate pairs without aborting the other metadata fields or transactions.
source: gpt-6.2-sol (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Still applies (re-reviewed at cd202da8): The safe call prevents new sentinel values from being written by re-merge, but the Past diff can still enqueue a sentinel already in the table. The inherited decimal helper leaves that string unchanged before .toDouble().
There was a problem hiding this comment.
Fixed in 124ea3a: the Past save treats a stored "null" (or a rate without a currency) as no rate before the diff, and the publish step uses toDoubleOrNull, so a rate that is not a number is left out of that item and the batch still goes out.
There was a problem hiding this comment.
Resolved (re-reviewed at d51d3725): Your Past diff treats the legacy "null" value as absent, and toDoubleOrNull() prevents a sentinel already in the cache from aborting publication of other items.
| } else if (metadata.memo.isNotBlank() && tx.memo != null) { | ||
| log.info("metadata memo SKIPPED for tx {} — transaction already has one", tx.txId) | ||
| } else if (metadata.memo.isBlank() && tx.memo != null) { | ||
| setTransactionMemo(tx.txId.toTxId(), tx.memo!!) | ||
| } |
There was a problem hiding this comment.
✅ Resolved at
d51d3725; see the replies below.
🔴 Blocking: Copying a missing rate can restore a memo the user deleted
Impact: A user who cleared a private memo can see the old dashj memo reappear and become queued for Platform when the migration fills that transaction's missing rate.
The rate migration calls syncTransaction() for a dashj transaction whose metadata row has no usable rate. syncRateOrInsert() fills the rate but returns the pre-update row, whose memo may correctly be an empty string after the user deleted it. The following branch sees tx.memo still populated in the legacy wallet and calls setTransactionMemo(), restoring and queueing the old private text. Provide a migration-specific rate-only operation that does not reconcile memo or service fields.
source: gpt-6.2-sol (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Fixed in 124ea3a: the copy calls copyRateIfMissing, which sets only the two rate columns of an existing row. It does not reconcile the memo or the service, so a cleared memo stays cleared.
There was a problem hiding this comment.
Resolved (re-reviewed at d51d3725): Your new copy method updates only the rate pair on an existing row and never enters syncTransaction()'s memo reconciliation, so it leaves a cleared memo intact.
| memo = myMemo, | ||
| service = platformService | ||
| ) | ||
| transactionMetadataDao.insert(metadata) | ||
| // only add to the change cache if some metadata exists and this is not a CoinJoin tx | ||
| val isCoinJoinTx = when (CoinJoinTransactionType.fromTx(this, walletData.wallet!!)) { | ||
| CoinJoinTransactionType.None, CoinJoinTransactionType.Send -> false | ||
| else -> true | ||
| } | ||
|
|
||
| // only save Transaction metadata to | ||
| // Queue for Platform BEFORE the row is written. A caller that retries | ||
| // what the table lacks (DashjRateMigration) reads the row as "done": a | ||
| // process death between the two writes must leave the row missing, to | ||
| // be redone, never the row present and its upload never queued. A | ||
| // second queue entry from the retry carries the same values. | ||
| if (!isCoinJoinTx && metadata.isNotEmpty() && !isSyncingPlatform && hasChanges && shouldSaveToCache()) { | ||
| transactionMetadataChangeCacheDao.insert(TransactionMetadataCacheItem(metadata)) | ||
| } | ||
| transactionMetadataDao.insert(metadata) |
There was a problem hiding this comment.
✅ Resolved at
d51d3725; see the replies below.
🔴 Blocking: A memo-only Platform import can make the migration skip an unqueued rate
Impact: If a Platform memo import creates a row using the dashj rate, the migration can mark completion without queuing that rate, leaving it unavailable after a restore.
When a Platform document creates a missing row, insertTransactionMetadata() falls back to the dashj transaction's exchange rate, but isSyncingPlatform = true suppresses the change-cache insert. The migration's missing-rate query then either sees that locally populated rate and skips the transaction, or loads the row after the import and treats the pair as already complete. The completion flag consequently records local presence rather than pending-queue or Platform coverage. Track local copying separately from authorized publication and ensure the rate is queued when no equivalent pending or published Platform value exists.
source: gpt-6.2-sol (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Fixed in 124ea3a and 9a29085: the copy no longer promises a queued upload, so a row that already holds the dashj rate is complete for it. Publication is the Past save, which diffs every stored row against the Platform documents; a pass that copies rates clears the last-Past-save mark so those transactions are included.
There was a problem hiding this comment.
Resolved (re-reviewed at d51d3725): You separated local copy completion from publication, so a memo-only import that already filled the local rate now satisfies the copy contract. The Past worker's cutoff race is a separate issue in the new publication path.
| * never the smallest-unit integer. Single-sourced so the writers of that column | ||
| * cannot disagree on its unit. Pure. | ||
| */ | ||
| /** | ||
| * Whether a metadata row's [currencyCode] and [rate] are a rate at all: both | ||
| * present, and the rate not the "null" text an older Platform merge stored when | ||
| * the documents carried none. Mirrors [TransactionMetadataDao.loadHistoricalRates]. | ||
| * Pure. | ||
| */ | ||
| internal fun hasStoredRate(currencyCode: String?, rate: String?): Boolean = | ||
| currencyCode != null && rate != null && rate != "null" | ||
|
|
||
| internal fun storedRateString(fiat: Fiat): String = | ||
| MonetaryFormat.FIAT.noCode().format(fiat.toNeutralFiat()).toString() |
There was a problem hiding this comment.
✅ Resolved at
d51d3725; see the replies below.
💬 Nitpick: The stored-rate unit documentation is attached to the wrong declaration
Impact: Readers looking for the exchange-rate column's unit find the decimal-format documentation separated from storedRateString(), while hasStoredRate() appears to own two KDoc blocks.
Two consecutive KDoc blocks appear before hasStoredRate(), so the decimal storage-unit documentation is not attached to storedRateString(), which remains undocumented. Move the first KDoc block immediately above storedRateString() and leave the predicate contract above hasStoredRate().
source: muse-spark-1.3-contributor (phase1-reviewer: general)
There was a problem hiding this comment.
Still applies (re-reviewed at cd202da8): The rebase adds the decimal parser's own KDoc below the formatter, but the formatter's unit contract still sits above the predicate's KDoc.
There was a problem hiding this comment.
Still applies (re-reviewed at a6c4dd2c): The rate-format KDoc was expanded to mention eight-decimal precision, but it is still separated from storedRateString by the hasStoredRate declaration. The documentation contract therefore remains attached to the wrong declaration.
There was a problem hiding this comment.
Fixed in 124ea3a: the unit documentation is back on storedRateString and the predicate contract is on hasStoredRate.
There was a problem hiding this comment.
Resolved (re-reviewed at d51d3725): Your KDoc change puts the unit and precision contract directly on storedRateString() and leaves the predicate contract on hasStoredRate().
00f885c to
cd202da
Compare
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Changes requested: 6 blockers
- A memo-only Platform import can make the migration skip an unqueued rate —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:155-197(thread, carried)
Impact: When a memo-only Platform import creates the row for a rated dashj transaction, the rate can remain available only on the original device even when the user wants historical metadata backed up. - Copying a missing rate can restore a memo the user deleted —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:653-657(thread, carried)
Impact: A user who clears a private memo on a legacy transaction that still needs a rate backfill can see that memo return and become eligible for upload. - A legacy literal null rate can abort the entire Past metadata upload —
wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt:2231-2239(thread, carried)
Impact: A user saving Past metadata after upgrading can have the whole batch fail repeatedly because one eligible transaction retains a legacy"null"rate. - Startup rate migration can write private memos into support logs —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:172-198(thread, carried)
Impact: A user whose rated legacy transaction has a private memo but no metadata row can have that memo included in a subsequently shared support log. - Startup migration can upload historical metadata outside the user's Future-only scope —
wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:135-139(thread, carried)
Impact: Users who enabled only Future saving can have older transaction rates and, for newly inserted rows, private memos published without choosing Past saving. - A rescan can discard migrated rates before Platform receives them —
wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:135-147(thread, carried)
Impact: A user who rescans a cutover wallet before its migrated rates are uploaded can keep seeing the rates locally but lose them on a later restore.
New on this head: The rebased PR still copies missing dashj exchange rates into the metadata table once at startup. Compared with the previous review, its historical-rate query now retains the base branch’s timestamp projection, and the publish path inherits the base’s decimal-rate conversion. On the reviewed head, build and check passed; PastaClaw review is pending.
🔴 6 blocking | 🟡 1 suggestion(s) | 💬 1 nitpick(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🟡 Suggestion: Targeted metadata writes can be lost to concurrent whole-row replacement
Impact: A downloaded transaction icon can fail to appear if a whole-row metadata update for the same transaction overlaps the icon callback.
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:932-946
The icon bitmap can be saved while its row reference is lost. syncPlatformMetadata reads the row under the process-wide rowWrites mutex, but an already running icon download can finish and call updateIconId without that mutex between the read and transactionMetadataDao.update(updated). The whole-row update then restores the old customIconId. Take rowWrites for the final icon column write, or make the other operation update only the columns it owns.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.2-sol (phase2-reviewer: security-auditor)
Still open from earlier rounds (7)
- 🔴 Blocking: A memo-only Platform import can make the migration skip an unqueued rate —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:155-197(thread) - 🔴 Blocking: Copying a missing rate can restore a memo the user deleted —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:653-657(thread) - 🔴 Blocking: A legacy literal null rate can abort the entire Past metadata upload —
wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt:2231-2239(thread) - 🔴 Blocking: Startup rate migration can write private memos into support logs —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:172-198(thread) - 🔴 Blocking: Startup migration can upload historical metadata outside the user's Future-only scope —
wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:135-139(thread) - 🔴 Blocking: A rescan can discard migrated rates before Platform receives them —
wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:135-147(thread) - 💬 Nitpick: The stored-rate unit documentation is attached to the wrong declaration —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:1017-1033(thread)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.2-sol(effort low) — This is a substantial cross-cutting metadata migration and concurrency change, but it does not directly alter funds movement, consensus, cryptography, key handling, peer-facing deserialization, or a storage schema migration. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt`:
- [SUGGESTION] wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:932-946: Targeted metadata writes can be lost to concurrent whole-row replacement
Impact: A downloaded transaction icon can fail to appear if a whole-row metadata update for the same transaction overlaps the icon callback.
The icon bitmap can be saved while its row reference is lost. `syncPlatformMetadata` reads the row under the process-wide `rowWrites` mutex, but an already running icon download can finish and call `updateIconId` without that mutex between the read and `transactionMetadataDao.update(updated)`. The whole-row update then restores the old `customIconId`. Take `rowWrites` for the final icon column write, or make the other operation update only the columns it owns.
- [BLOCKING] wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:155-197: A memo-only Platform import can make the migration skip an unqueued rate
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085414)
- [BLOCKING] wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:653-657: Copying a missing rate can restore a memo the user deleted
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085405)
- [BLOCKING] wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:172-198: Startup rate migration can write private memos into support logs
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085389)
- [NITPICK] wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:1017-1033: The stored-rate unit documentation is attached to the wrong declaration
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085425)
In `wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt:2231-2239: A legacy literal null rate can abort the entire Past metadata upload
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085397)
In `wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:135-139: Startup migration can upload historical metadata outside the user's Future-only scope
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085379)
- [BLOCKING] wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:135-147: A rescan can discard migrated rates before Platform receives them
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085365)
| currencyCode = docs.lastOrNull { it.currencyCode != null }?.currencyCode, | ||
| rate = docs.lastOrNull { it.rate != null }?.rate.toString(), | ||
| // `?.` on toString too: a missing rate is null, never the text "null". | ||
| rate = docs.lastOrNull { it.rate != null }?.rate?.toString(), |
There was a problem hiding this comment.
Still applies (re-reviewed at cd202da8): The safe call prevents new sentinel values from being written by re-merge, but the Past diff can still enqueue a sentinel already in the table. The inherited decimal helper leaves that string unchanged before .toDouble().
| * never the smallest-unit integer. Single-sourced so the writers of that column | ||
| * cannot disagree on its unit. Pure. | ||
| */ | ||
| /** | ||
| * Whether a metadata row's [currencyCode] and [rate] are a rate at all: both | ||
| * present, and the rate not the "null" text an older Platform merge stored when | ||
| * the documents carried none. Mirrors [TransactionMetadataDao.loadHistoricalRates]. | ||
| * Pure. | ||
| */ | ||
| internal fun hasStoredRate(currencyCode: String?, rate: String?): Boolean = | ||
| currencyCode != null && rate != null && rate != "null" | ||
|
|
||
| internal fun storedRateString(fiat: Fiat): String = | ||
| MonetaryFormat.FIAT.noCode().format(fiat.toNeutralFiat()).toString() |
There was a problem hiding this comment.
Still applies (re-reviewed at cd202da8): The rebase adds the decimal parser's own KDoc below the formatter, but the formatter's unit contract still sits above the predicate's KDoc.
QA run 56 — PASS, and the only way to test it was to build the state by handWhy an ordinary test can't reach this code
Confirmed on two devices. A wallet restored from a phrase has 3,306 metadata rows, 0 with a rate, every history row renders "Not available", and the pass correctly reports: So any run that tests this PR by restoring a wallet will get a false pass. Worth knowing for whoever tests it next. What was actually runA wallet that had genuinely been used pre-cutover — 7,459 metadata rows, 391 of them carrying a dashj-sourced rate. On 11.9.3, with the app stopped: update transaction_metadata set rate=null, currencyCode=null where rate is not null; -- 391
pragma wal_checkpoint(TRUNCATE);The dashj wallet file was not touched, so it still held those 391 rates. State before the upgrade: 7,459 rows, 0 with a rate. Then 12000305 installed in place. ResultVerified by diffing the rows rather than trusting that line:
One cosmetic noteRestored values carry more trailing zeros than the originals — QA run 56, 2026-11-30. Build 12000305 (12.0.3-qa05), branch |
cd202da to
1c77e1e
Compare
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Changes requested: 6 blockers
- Startup migration can upload historical metadata outside the user's Future-only scope —
wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:135-139(thread, carried)
Impact: A user who enabled Future but not Past can have pre-opt-in rates and, for newly created metadata rows, private memos published to Platform after upgrading. - A memo-only Platform import can make the migration skip an unqueued rate —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:189-197(thread, carried)
Impact: An upgrader whose memo-only Platform metadata is imported before the backfill can see a correct local rate that is still missing on restore. - Copying a missing rate can restore a memo the user deleted —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:653-657(thread, carried)
Impact: An upgrader who cleared a private memo on a transaction with a missing local rate can see the memo reappear and be queued for upload. - Startup rate migration can write private memos into support logs —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:197-198(thread, carried)
Impact: An upgrader with a memo on a rated transaction that has no metadata row can disclose the memo when sharing application logs with support. - A legacy literal null rate can abort the entire Past metadata upload —
wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt:2284-2286(thread, carried)
Impact: A user who selects Past can fail to back up every transaction in the batch because one eligible local row still contains the literal rate string"null". - A rescan can discard migrated rates before Platform receives them —
wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:135-147(thread, carried; accepted as a deferral; lifts when a tracking issue is linked on its thread)
Impact: Users who rescan after the migration queues rates but before publication can retain the rates locally while losing them from Platform and future restores, with no later automatic retry.
New on this head: This PR adds a one-time startup backfill for historical exchange rates held by the legacy dashj wallet. The rebase retains the shared metadata row lock and preserves legacy smallest-unit conversion when applying a stored rate to a dashj transaction. The build and check jobs passed on this head; the review check is pending.
🔴 6 blocking | 🟡 1 suggestion(s) | 💬 1 nitpick(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🟡 Suggestion: Targeted metadata writes can be lost to concurrent whole-row replacement
Impact: A transaction can lose its newly downloaded icon when the download completes during a Platform merge or gift-card update for the same row.
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:946-947
The bitmap can be saved successfully while its link from the transaction is overwritten. A whole-row writer can load the old customIconId under rowWrites, then the download callback can update that column outside the lock. The whole-row @Update then puts the old ID back. Use the same mutex for the column update; the download, image processing and bitmap insert can stay outside it.
iconBitmapDao.addBitmap(IconBitmap(imageHash, resizedImageData, iconUrl, icon.height, icon.width))
rowWrites.withLock { transactionMetadataDao.updateIconId(txId, imageHash) }
source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)
Still open from earlier rounds (6)
- 🔴 Blocking: Startup migration can upload historical metadata outside the user's Future-only scope —
wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:135-139(thread) - 🔴 Blocking: A memo-only Platform import can make the migration skip an unqueued rate —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:189-197(thread) - 🔴 Blocking: Copying a missing rate can restore a memo the user deleted —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:653-657(thread) - 🔴 Blocking: Startup rate migration can write private memos into support logs —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:197-198(thread) - 🔴 Blocking: A legacy literal null rate can abort the entire Past metadata upload —
wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt:2284-2286(thread) - 💬 Nitpick: The stored-rate unit documentation is attached to the wrong declaration —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:1019-1035(thread)
⏸️ Awaiting tracking link (1): A rescan can discard migrated rates before Platform receives them (thread). Link an issue on its thread, or ask there and PastaClaw files it.
Review provenance
Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — This is a large, intricate persistent-data migration that changes transaction metadata durability, Platform synchronization, crash recovery, and process-wide concurrency behavior in DashjRateMigration and WalletTransactionMetadataProvider. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt`:
- [SUGGESTION] wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:946-947: Targeted metadata writes can be lost to concurrent whole-row replacement
Impact: A transaction can lose its newly downloaded icon when the download completes during a Platform merge or gift-card update for the same row.
The bitmap can be saved successfully while its link from the transaction is overwritten. A whole-row writer can load the old `customIconId` under `rowWrites`, then the download callback can update that column outside the lock. The whole-row `@Update` then puts the old ID back. Use the same mutex for the column update; the download, image processing and bitmap insert can stay outside it.
- [BLOCKING] wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:189-197: A memo-only Platform import can make the migration skip an unqueued rate
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085414)
- [BLOCKING] wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:653-657: Copying a missing rate can restore a memo the user deleted
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085405)
- [BLOCKING] wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:197-198: Startup rate migration can write private memos into support logs
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085389)
- [NITPICK] wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:1019-1035: The stored-rate unit documentation is attached to the wrong declaration
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085425)
In `wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:135-139: Startup migration can upload historical metadata outside the user's Future-only scope
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085379)
- [BLOCKING] wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:135-147: A rescan can discard migrated rates before Platform receives them
(awaiting a tracking link: link an issue on its thread, or ask there and PastaClaw files it; no code change needed; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085365)
In `wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt:2284-2286: A legacy literal null rate can abort the entire Past metadata upload
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085397)
| try { | ||
| // Creates the metadata row when there is none, or fills in the rate | ||
| // of one that has none, and queues it for Platform, as the dashj | ||
| // engine did when it handled the transaction. | ||
| metadataProvider.syncTransaction(tx) | ||
| } catch (e: CancellationException) { | ||
| throw e | ||
| } catch (e: Exception) { | ||
| failed++ | ||
| log.warn("could not copy the exchange rate of tx {}", tx.txId, e) | ||
| } | ||
| } | ||
| if (failed == 0) dashPayConfig.set(DashPayConfig.DASHJ_RATES_COPIED_TO_METADATA, true) |
There was a problem hiding this comment.
Needs a tracking issue (re-reviewed at 1c77e1e2): Deferring this needs a tracking issue for the follow-up, and none is linked in this thread, the PR description or the PR comments. Link one, or ask here and I'll file it; until then the finding stands.
…able once A transaction's historical rate reached transaction_metadata only as a side effect of the dashj engine handling the transaction. That engine is held after the cutover, so a rate it never copied stayed in the dashj wallet file alone: not synced to Platform and lost on a restore. DashjRateMigration copies every rate the table lacks, through the same syncTransaction the engine used, and never changes one the table already has. It is requested on every launch and stops at a stored flag, so it runs on the launch that commits the cutover, or on the first launch with this code for an install that cut over in 12.0.2. The flag is set only when every missing rate was written; an unreadable flag means no pass that launch. Co-Authored-By: Claude Fable 5.2 <[email protected]>
… and concurrent writers Pre-review findings on the rate copy: - The metadata provider queued a rate for Platform after writing it to the table. A process death in between left the rate stored and never published, and the retry skipped it. The queue entry is now written first. - Reset Wallet did not stop the pass, which could write a row of the wiped wallet or set the done-flag after the clear. The wipe now cancels the pass and waits for it, and refuses a new one until it has finished. - The Platform re-merge stored the text "null" for a missing rate, which counted as a rate and could replace a real one. It is no longer written, and a stored "null" or a rate without a currency is treated as no rate. - Platform sync reads a metadata row and writes the whole row back; a rate written in between was erased. Every read-then-write of a metadata row in the provider now runs under one lock. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…der instance WalletTransactionMetadataProvider is injected unscoped, so Platform sync, the one-time rate copy and the UI each hold their own instance. A lock per instance did not keep Platform sync's whole-row write from erasing a rate another instance had just written. The lock now lives in the companion object. Co-Authored-By: Claude Fable 5.2 <[email protected]>
1c77e1e to
a6c4dd2
Compare
The copy went through syncTransaction, which also reconciles the memo and service, logs the row and queues it for Platform. For past transactions that restored a memo the user had cleared, wrote the memo to the log and queued uploads outside a Future-only saving choice. - copyRateIfMissing sets the two rate columns of a row that has no rate, or creates a missing row, and queues nothing. Uploading past rates is the user's Past save, which reads the table this fills. - syncTransaction and the order of the queue and table writes are as they were before this branch. - The row insert logs the transaction id and which fields are present, not the row. - The Past save treats the "null" text an older merge stored as no rate, and a rate that is not a number is left out of the published item instead of failing the batch. - The icon id write takes the row lock. Co-Authored-By: Claude Fable 5.2 <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Changes requested: 6 blockers
- A memo-only Platform import can make the migration skip an unqueued rate —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:155-197(thread, carried)
Impact: An upgrading user can see a dashj rate copied into the local metadata row while no Platform upload is queued, so the rate is later lost on restore. - Copying a missing rate can restore a memo the user deleted —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:653-657(thread, carried)
Impact: A user who cleared a private transaction memo can have the old memo restored locally and queued for Platform during the startup rate migration. - A legacy literal null rate can abort the entire Past metadata upload —
wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt:2236-2239(thread, carried)
Impact: A wallet containing an older row or cache item with rate"null"can fail the complete Past metadata upload, including unrelated valid metadata. - Startup rate migration can write private memos into support logs —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:194-198(thread, carried)
Impact: A user upgrading with a rated dashj transaction and no metadata row can have the private memo copied into the wallet log and later exposed through a support report. - Startup migration can upload historical metadata outside the user's Future-only scope —
wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:135-139(thread, carried)
Impact: A user who selected Future-only metadata sharing can still have historical transaction rates queued and published after an upgrade. - A rescan can discard migrated rates before Platform receives them —
wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:135-147(thread, carried; accepted as a deferral; lifts when a tracking issue is linked on its thread)
Impact: Users who rescan after the migration queues rates but before publication can retain the rates locally while losing them from Platform and future restores, with no later automatic retry.
New on this head: This head rebases the one-time dashj rate migration and retains the exact decimal formatter, process-wide metadata row serialization, crash-safe queue-before-table writes, and Platform null normalization. The build and check CI jobs succeeded, CodeRabbit completed successfully, and the review check is still queued.
🔴 6 blocking | 🟡 1 suggestion(s) | 💬 1 nitpick(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🟡 Suggestion: Targeted metadata writes can be lost to concurrent whole-row replacement
Impact: A successfully downloaded icon, or another targeted metadata update, can disappear when Platform sync or another whole-row writer saves an older snapshot of the same transaction.
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:946-947
The process-wide mutex protects the main read-then-whole-row-write paths, but the icon callback still calls updateIconId outside rowWrites, and setTransactionMetadata also inserts without that lock. If the callback writes the icon after a locked writer reads the row but before it replaces the row, the older replacement erases customIconId. Route every transaction-metadata row read/write involved in these races through rowWrites, or use column-specific updates for writers that do not own the full row.
iconBitmapDao.addBitmap(IconBitmap(imageHash, resizedImageData, iconUrl, icon.height, icon.width))
rowWrites.withLock {
transactionMetadataDao.updateIconId(txId, imageHash)
}
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.2-sol (phase2-reviewer: general)
Still open from earlier rounds (6)
- 💬 Nitpick: The stored-rate unit documentation is attached to the wrong declaration —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:1019-1035(thread) - 🔴 Blocking: A memo-only Platform import can make the migration skip an unqueued rate —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:155-197(thread) - 🔴 Blocking: Copying a missing rate can restore a memo the user deleted —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:653-657(thread) - 🔴 Blocking: A legacy literal null rate can abort the entire Past metadata upload —
wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt:2236-2239(thread) - 🔴 Blocking: Startup rate migration can write private memos into support logs —
wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:194-198(thread) - 🔴 Blocking: Startup migration can upload historical metadata outside the user's Future-only scope —
wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:135-139(thread)
⏸️ Awaiting tracking link (1): A rescan can discard migrated rates before Platform receives them (thread). Link an issue on its thread, or ask there and PastaClaw files it.
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.2-sol(effort low) — This is a substantial cross-cutting metadata migration and concurrency change, but it does not directly modify consensus, funds movement, cryptography, key handling, peer-facing deserialization, or a storage schema migration. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt`:
- [SUGGESTION] wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:946-947: Targeted metadata writes can be lost to concurrent whole-row replacement
Impact: A successfully downloaded icon, or another targeted metadata update, can disappear when Platform sync or another whole-row writer saves an older snapshot of the same transaction.
The process-wide mutex protects the main read-then-whole-row-write paths, but the icon callback still calls `updateIconId` outside `rowWrites`, and `setTransactionMetadata` also inserts without that lock. If the callback writes the icon after a locked writer reads the row but before it replaces the row, the older replacement erases `customIconId`. Route every transaction-metadata row read/write involved in these races through `rowWrites`, or use column-specific updates for writers that do not own the full row.
- [NITPICK] wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:1019-1035: The stored-rate unit documentation is attached to the wrong declaration
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085425)
- [BLOCKING] wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:155-197: A memo-only Platform import can make the migration skip an unqueued rate
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085414)
- [BLOCKING] wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:653-657: Copying a missing rate can restore a memo the user deleted
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085405)
- [BLOCKING] wallet/src/de/schildbach/wallet/service/WalletTransactionMetadataProvider.kt:194-198: Startup rate migration can write private memos into support logs
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085389)
In `wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt:2236-2239: A legacy literal null rate can abort the entire Past metadata upload
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085397)
In `wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:135-139: Startup migration can upload historical metadata outside the user's Future-only scope
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085379)
- [BLOCKING] wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:135-147: A rescan can discard migrated rates before Platform receives them
(awaiting a tracking link: link an issue on its thread, or ask there and PastaClaw files it; no code change needed; thread: https://github.com/dashpay/dash-wallet/pull/1768#discussion_r4746085365)
| * never the smallest-unit integer. Single-sourced so the writers of that column | ||
| * cannot disagree on its unit. Pure. | ||
| */ | ||
| /** | ||
| * Whether a metadata row's [currencyCode] and [rate] are a rate at all: both | ||
| * present, and the rate not the "null" text an older Platform merge stored when | ||
| * the documents carried none. Mirrors [TransactionMetadataDao.loadHistoricalRates]. | ||
| * Pure. | ||
| */ | ||
| internal fun hasStoredRate(currencyCode: String?, rate: String?): Boolean = | ||
| currencyCode != null && rate != null && rate != "null" | ||
|
|
||
| internal fun storedRateString(fiat: Fiat): String = | ||
| MonetaryFormat.FIAT.noCode().format(fiat.toNeutralFiat()).toString() |
There was a problem hiding this comment.
Still applies (re-reviewed at a6c4dd2c): The rate-format KDoc was expanded to mention eight-decimal precision, but it is still separated from storedRateString by the hasStoredRate declaration. The documentation contract therefore remains attached to the wrong declaration.
- A pass that has rates to copy clears the last-Past-save mark, before the first rate and after the last: the Past save skips every transaction older than that mark, so the copied rates would never be uploaded. - A row the copy creates gets the rate captured from the transaction when the insert left it without one (the loaded wallet may not be the one the transaction came from), and a row that cannot be created is a failed copy, not a done one. - The metadata settings screen scans for unsaved past transactions again when that mark or the copy's done-flag changes, not once at open. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The return to its earlier form also dropped the lock: a Platform merge could write its whole-row copy over a rate this path had just stored. Its rate step and the insert of a missing row run under the lock again; the memo and service steps take it themselves. A parse failure logs the transaction id, not the row. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Pushed 124ea3a, 9a29085 and d51d372. The description is updated. Changed design: the one-time copy is now local and rate-only ( Also fixed
Not addressed (listed by the local review of 9a29085; d51d372 was not reviewed locally)
🤖 Generated with Claude Code |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Changes requested: 2 blockers
- A Past save that overlaps the upgrade can leave copied rates out of future backups —
wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:137-158(new)
Impact: Users whose Past save overlaps the first-launch rate copy can see a successful save even though some historical exchange rates remain local and are missing after a restore. - Past save logs older private memos and gift-card credentials after rate migration —
wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt:2462-2478(new; not shown inline, see below)
Impact: Users who save their history after the rate copy and then include application logs in a support report can disclose private memos and redeemable gift-card credentials from transactions they already backed up.
New on this head: This revision makes the one-time dashj rate copy local-only, puts the icon and legacy rate writes under the shared row lock, and reopens the Past-save scan when rates need copying. It also handles legacy missing-rate values without aborting publication. On d51d372, build and check passed; the PastaClaw review check was still pending.
🔴 2 blocking
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Past save logs older private memos and gift-card credentials after rate migration
Impact: Users who save their history after the rate copy and then include application logs in a support report can disclose private memos and redeemable gift-card credentials from transactions they already backed up.
wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt:2462-2478
A support report can contain plaintext memos, gift-card numbers, PINs, and barcodes from transactions the user already saved. The cutoff reset in 9a290854b makes the next Past save revisit rows that were previously too old to scan. publishPastTxMetadata() logs the saved documents, merged record, and full local cache item at INFO before checking for differences, so even unchanged rows and rows that received no copied rate are exposed. The file appender accepts these messages and the PUBLISH batch dump at line 2230; ContactSupportViewModel attaches wallet.log when the user includes application logs. Replace the raw records in the Past scan and batch publisher with counts or field-presence flags, as required by the project's security and logging rule 6.1.
Confirmed by an independent pass: When an upgrade copies even one missing rate, it resets the cutoff and the user's next Past save revisits older transactions that were previously skipped. The scan writes plaintext memos and gift-card numbers, PINs, and barcodes to wallet.log before checking whether anything changed, so those details can reach support when the user sends a report with application logs attached.
source: gpt-6.2-sol (phase2-reviewer: general, security-auditor)
Follow-up candidates (optional) (1)
New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.
🟡 Suggestion: Past settings count transactions whose only difference is a missing-rate placeholder
Impact: After the migration reopens history, users can see an inflated unsaved-transaction count for older rows that have nothing new to upload.
wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt:2412-2418
The settings scan can count an already-backed-up transaction as unsaved. For example, an otherwise matching memo-only row with a legacy "null" rate differs from the saved document under TransactionMetadataCacheItem.compare(), which compares the raw rate and currency columns. The new Past publication diff normalizes that placeholder to an absent rate pair and queues nothing for the row. The cutoff reset makes this mismatch visible on older transactions that were previously skipped. Use the same rate-pair normalization in the settings scan and the publication diff.
source: gpt-6.2-sol (phase2-reviewer: general, security-auditor)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.2-sol(effort low) — This is a substantial cross-cutting change to wallet metadata persistence, migration coordination, lifecycle handling, and concurrent reads/writes, but it does not itself alter funds movement, cryptography, consensus, key handling, or a storage schema migration. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - New since the last final review (
a6c4dd2c): 2 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 2 confirmed; 1 suggestion(s) on unchanged code listed as follow-up candidates - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/service/DashjRateMigration.kt:137-158: A Past save that overlaps the upgrade can leave copied rates out of future backups
Impact: Users whose Past save overlaps the first-launch rate copy can see a successful save even though some historical exchange rates remain local and are missing after a restore.
A Past save can report success without backing up a copied rate, then cause later Past saves to skip it. This does not require the user to open Settings during the migration: an unfinished Past save is a persisted WorkManager request and can resume on the first launch after updating. The worker can read the old cutoff before the first reset in `9a290854b`, or read a row after that reset but before its rate is copied. If it finishes after the final reset, `PublishTransactionMetadataWorker.kt:61–75,89–100` records the worker's start time as the cutoff once the items it found are saved; it checks for wallet reset, not whether the migration changed what the scan needed to cover. Both the settings scan and later saves then skip the older transaction, and the migration's done flag prevents another reset. Make the cutoff update conditional on a durable scan revision, or track copied rates as pending until a Past save actually covers them.
_Confirmed by an independent pass: If WorkManager resumes an unfinished Past save on the first launch after an update, it can read the old cutoff before the migration clears it and skip an older transaction whose rate still exists only in the dashj wallet. If the worker finishes after the migration's final reset, it reports success and stores its start time as the new cutoff, leaving the copied rate on the device but out of the Platform backup and ineligible for later Past saves._
In `wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt:2462-2478: Past save logs older private memos and gift-card credentials after rate migration
Impact: Users who save their history after the rate copy and then include application logs in a support report can disclose private memos and redeemable gift-card credentials from transactions they already backed up.
A support report can contain plaintext memos, gift-card numbers, PINs, and barcodes from transactions the user already saved. The cutoff reset in `9a290854b` makes the next Past save revisit rows that were previously too old to scan. `publishPastTxMetadata()` logs the saved documents, merged record, and full local cache item at INFO before checking for differences, so even unchanged rows and rows that received no copied rate are exposed. The file appender accepts these messages and the `PUBLISH` batch dump at line 2230; `ContactSupportViewModel` attaches `wallet.log` when the user includes application logs. Replace the raw records in the Past scan and batch publisher with counts or field-presence flags, as required by the project's security and logging rule 6.1.
_Confirmed by an independent pass: When an upgrade copies even one missing rate, it resets the cutoff and the user's next Past save revisits older transactions that were previously skipped. The scan writes plaintext memos and gift-card numbers, PINs, and barcodes to wallet.log before checking whether anything changed, so those details can reach support when the user sends a report with application logs attached._
| val missing = txsMissingStoredRate(rated, stored) | ||
| // Before the first rate is written, so a process death mid-pass cannot leave | ||
| // copied rates behind the mark; and again after the last one, for a Past | ||
| // save that ran during the pass and set the mark past them. | ||
| if (missing.isNotEmpty()) reopenPastSave() | ||
| var failed = 0 | ||
| for (tx in missing) { | ||
| // A cancelled pass (wallet wipe) stops between transactions too. | ||
| currentCoroutineContext().ensureActive() | ||
| try { | ||
| // Fills in the rate of a row that has none, or creates the row. | ||
| // Nothing else of the row is touched and nothing is queued. | ||
| metadataProvider.copyRateIfMissing(tx) | ||
| } catch (e: CancellationException) { | ||
| throw e | ||
| } catch (e: Exception) { | ||
| failed++ | ||
| log.warn("could not copy the exchange rate of tx {}", tx.txId, e) | ||
| } | ||
| } | ||
| if (missing.isNotEmpty()) reopenPastSave() | ||
| if (failed == 0) dashPayConfig.set(DashPayConfig.DASHJ_RATES_COPIED_TO_METADATA, true) |
There was a problem hiding this comment.
✅ Resolved at
c681167d; see the replies below.
🔴 Blocking: A Past save that overlaps the upgrade can leave copied rates out of future backups
Impact: Users whose Past save overlaps the first-launch rate copy can see a successful save even though some historical exchange rates remain local and are missing after a restore.
A Past save can report success without backing up a copied rate, then cause later Past saves to skip it. This does not require the user to open Settings during the migration: an unfinished Past save is a persisted WorkManager request and can resume on the first launch after updating. The worker can read the old cutoff before the first reset in 9a290854b, or read a row after that reset but before its rate is copied. If it finishes after the final reset, PublishTransactionMetadataWorker.kt:61–75,89–100 records the worker's start time as the cutoff once the items it found are saved; it checks for wallet reset, not whether the migration changed what the scan needed to cover. Both the settings scan and later saves then skip the older transaction, and the migration's done flag prevents another reset. Make the cutoff update conditional on a durable scan revision, or track copied rates as pending until a Past save actually covers them.
Confirmed by an independent pass: If WorkManager resumes an unfinished Past save on the first launch after an update, it can read the old cutoff before the migration clears it and skip an older transaction whose rate still exists only in the dashj wallet. If the worker finishes after the migration's final reset, it reports success and stores its start time as the new cutoff, leaving the copied rate on the device but out of the Platform backup and ineligible for later Past saves.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.2-sol (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Fixed in 45d0600 and c681167: the Past save worker now requests the rate copy and waits for it before its scan, so the scan reads the copied rates. As a fallback it reads the copy's done-flag before scanning and does not record its start time as the mark when the copy did not complete, so the next Past save scans the whole history again.
There was a problem hiding this comment.
Resolved (re-reviewed at c681167d): Verified on this head: the worker waits for the rate migration before scanning and records the Past-save cutoff only when the completion flag is confirmed, so an incomplete copy remains eligible for a later save.
| try { | ||
| // Creates the metadata row when there is none, or fills in the rate | ||
| // of one that has none, and queues it for Platform, as the dashj | ||
| // engine did when it handled the transaction. | ||
| metadataProvider.syncTransaction(tx) | ||
| } catch (e: CancellationException) { | ||
| throw e | ||
| } catch (e: Exception) { | ||
| failed++ | ||
| log.warn("could not copy the exchange rate of tx {}", tx.txId, e) | ||
| } | ||
| } | ||
| if (failed == 0) dashPayConfig.set(DashPayConfig.DASHJ_RATES_COPIED_TO_METADATA, true) |
There was a problem hiding this comment.
Resolved (re-reviewed at d51d3725): Your local copy no longer creates a pending cache entry that a rescan can discard. The non-wipe rescan preserves transaction_metadata, which the Past save reads to build its diff.
| try { | ||
| // Creates the metadata row when there is none, or fills in the rate | ||
| // of one that has none, and queues it for Platform, as the dashj | ||
| // engine did when it handled the transaction. | ||
| metadataProvider.syncTransaction(tx) |
There was a problem hiding this comment.
Resolved (re-reviewed at d51d3725): Your copy updates an existing row directly or inserts with isSyncingPlatform = true; neither branch adds a cache item for the automatic publisher. Resetting the cutoff does not enqueue a Past save.
| if (!isCoinJoinTx && metadata.isNotEmpty() && !isSyncingPlatform && hasChanges && shouldSaveToCache()) { | ||
| transactionMetadataChangeCacheDao.insert(TransactionMetadataCacheItem(metadata)) | ||
| } | ||
| transactionMetadataDao.insert(metadata) | ||
| log.info("txmetadata: inserting $metadata") |
There was a problem hiding this comment.
Resolved (re-reviewed at d51d3725): Your insertion log reports the transaction ID and memo length, not the memo text, and the rate-parse diagnostic no longer serializes the row.
| currencyCode = docs.lastOrNull { it.currencyCode != null }?.currencyCode, | ||
| rate = docs.lastOrNull { it.rate != null }?.rate.toString(), | ||
| // `?.` on toString too: a missing rate is null, never the text "null". | ||
| rate = docs.lastOrNull { it.rate != null }?.rate?.toString(), |
There was a problem hiding this comment.
Resolved (re-reviewed at d51d3725): Your Past diff treats the legacy "null" value as absent, and toDoubleOrNull() prevents a sentinel already in the cache from aborting publication of other items.
| } else if (metadata.memo.isNotBlank() && tx.memo != null) { | ||
| log.info("metadata memo SKIPPED for tx {} — transaction already has one", tx.txId) | ||
| } else if (metadata.memo.isBlank() && tx.memo != null) { | ||
| setTransactionMemo(tx.txId.toTxId(), tx.memo!!) | ||
| } |
There was a problem hiding this comment.
Resolved (re-reviewed at d51d3725): Your new copy method updates only the rate pair on an existing row and never enters syncTransaction()'s memo reconciliation, so it leaves a cleared memo intact.
| memo = myMemo, | ||
| service = platformService | ||
| ) | ||
| transactionMetadataDao.insert(metadata) | ||
| // only add to the change cache if some metadata exists and this is not a CoinJoin tx | ||
| val isCoinJoinTx = when (CoinJoinTransactionType.fromTx(this, walletData.wallet!!)) { | ||
| CoinJoinTransactionType.None, CoinJoinTransactionType.Send -> false | ||
| else -> true | ||
| } | ||
|
|
||
| // only save Transaction metadata to | ||
| // Queue for Platform BEFORE the row is written. A caller that retries | ||
| // what the table lacks (DashjRateMigration) reads the row as "done": a | ||
| // process death between the two writes must leave the row missing, to | ||
| // be redone, never the row present and its upload never queued. A | ||
| // second queue entry from the retry carries the same values. | ||
| if (!isCoinJoinTx && metadata.isNotEmpty() && !isSyncingPlatform && hasChanges && shouldSaveToCache()) { | ||
| transactionMetadataChangeCacheDao.insert(TransactionMetadataCacheItem(metadata)) | ||
| } | ||
| transactionMetadataDao.insert(metadata) |
There was a problem hiding this comment.
Resolved (re-reviewed at d51d3725): You separated local copy completion from publication, so a memo-only import that already filled the local rate now satisfies the copy contract. The Past worker's cutoff race is a separate issue in the new publication path.
| * never the smallest-unit integer. Single-sourced so the writers of that column | ||
| * cannot disagree on its unit. Pure. | ||
| */ | ||
| /** | ||
| * Whether a metadata row's [currencyCode] and [rate] are a rate at all: both | ||
| * present, and the rate not the "null" text an older Platform merge stored when | ||
| * the documents carried none. Mirrors [TransactionMetadataDao.loadHistoricalRates]. | ||
| * Pure. | ||
| */ | ||
| internal fun hasStoredRate(currencyCode: String?, rate: String?): Boolean = | ||
| currencyCode != null && rate != null && rate != "null" | ||
|
|
||
| internal fun storedRateString(fiat: Fiat): String = | ||
| MonetaryFormat.FIAT.noCode().format(fiat.toNeutralFiat()).toString() |
There was a problem hiding this comment.
Resolved (re-reviewed at d51d3725): Your KDoc change puts the unit and precision contract directly on storedRateString() and leaves the predicate contract on hasStoredRate().
… no record contents in its log A Past save that started before the one-time dashj rate copy finished can scan a transaction before its rate is copied. It then recorded its start time as the last Past save, which put the copied rate behind the mark for good. The worker now reads the copied flag before the scan and does not record the save when the copy was unfinished, so the next Past save scans the whole history again. The Past scan and the batch publisher logged whole records: memos and gift card numbers, PINs and barcodes. They now log transaction ids and counts. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…rrency; one lock hold for the transaction sync A Past save that skipped its mark still reported success, and Save and Reset wipes on that. The worker now requests the dashj rate copy and waits for it before its scan, so the scan reads the copied rates. The mark is still left unset when the copy did not complete. The diff against the saved documents dropped an unchanged currency, so a changed rate was published without it and not applied on a restore. The currency and the rate now go together, both or neither. syncTransaction decided on the memo and the service from a row it read before releasing the row lock. It now holds the lock for the whole sync, so a memo saved meanwhile is not overwritten by the transaction's older one. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Pushed c681167 (two commits since d51d372). The two blockers of the last review
Also in c681167
Not addressed
|
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
New on this head: This head coordinates Past saves with the one-time dashj rate migration, preserves rate/currency pairs, extends metadata row serialization through transaction synchronization, and removes sensitive metadata contents from changed logs. The build and check CI jobs passed, CodeRabbit passed, and the PastaClaw review check remains in progress.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.2-sol(effort low) — This is a broad, cross-cutting metadata migration and synchronization change involving persistence, concurrent read-modify-write operations, lifecycle coordination, and platform publishing, but it does not itself alter funds movement, consensus, cryptography, key handling, or a storage schema migration. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
| val missing = txsMissingStoredRate(rated, stored) | ||
| // Before the first rate is written, so a process death mid-pass cannot leave | ||
| // copied rates behind the mark; and again after the last one, for a Past | ||
| // save that ran during the pass and set the mark past them. | ||
| if (missing.isNotEmpty()) reopenPastSave() | ||
| var failed = 0 | ||
| for (tx in missing) { | ||
| // A cancelled pass (wallet wipe) stops between transactions too. | ||
| currentCoroutineContext().ensureActive() | ||
| try { | ||
| // Fills in the rate of a row that has none, or creates the row. | ||
| // Nothing else of the row is touched and nothing is queued. | ||
| metadataProvider.copyRateIfMissing(tx) | ||
| } catch (e: CancellationException) { | ||
| throw e | ||
| } catch (e: Exception) { | ||
| failed++ | ||
| log.warn("could not copy the exchange rate of tx {}", tx.txId, e) | ||
| } | ||
| } | ||
| if (missing.isNotEmpty()) reopenPastSave() | ||
| if (failed == 0) dashPayConfig.set(DashPayConfig.DASHJ_RATES_COPIED_TO_METADATA, true) |
There was a problem hiding this comment.
Resolved (re-reviewed at c681167d): Verified on this head: the worker waits for the rate migration before scanning and records the Past-save cutoff only when the completion flag is confirmed, so an incomplete copy remains eligible for a later save.
Stacked on #1762.
A transaction's historical exchange rate reached
transaction_metadataonly as a side effect of the dashj engine handling the transaction. That engine is held after the cutover, so a rate it never copied stayed in the dashj wallet file alone, where the history does not read it.What this does
DashjRateMigrationcopies every rate the table lacks. The copy is local and rate-only (copyRateIfMissing): it sets the two rate columns of a row that has none, or creates a missing row. It does not touch a row's memo or service and queues nothing for Platform. A rate the table already has is never changed.Fixes in the metadata provider this needed
"null"for a missing rate. A stored"null"or a rate without a currency is treated as no rate, also by the Past save, and a rate that is not a number is left out of a published item instead of failing the batch.syncTransactionholds the row lock for the whole sync, so a memo saved meanwhile is not overwritten by the transaction's older one.Known and not addressed here
Testing
Wallet unit suite: 4,793 tests, 0 failures. Not yet run on a device.
🤖 Generated with Claude Code