Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub unsafe extern "C" fn asset_lock_manager_list_tracked_locks(
AssetLockStatus::InstantSendLocked => 2,
AssetLockStatus::ChainLocked => 3,
AssetLockStatus::Consumed => 4,
AssetLockStatus::RecoveredFromChain => 5,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
},
has_proof: lock.proof.is_some(),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,6 @@ fn status_to_u8(status: &AssetLockStatus) -> u8 {
AssetLockStatus::InstantSendLocked => 2,
AssetLockStatus::ChainLocked => 3,
AssetLockStatus::Consumed => 4,
AssetLockStatus::RecoveredFromChain => 5,
}
}
1 change: 1 addition & 0 deletions packages/rs-platform-wallet-ffi/src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4828,6 +4828,7 @@ fn status_from_u8(b: u8) -> Result<platform_wallet::AssetLockStatus, Persistence
2 => AssetLockStatus::InstantSendLocked,
3 => AssetLockStatus::ChainLocked,
4 => AssetLockStatus::Consumed,
5 => AssetLockStatus::RecoveredFromChain,
other => {
return Err(PersistenceError::backend(format!(
"tracked asset lock: unknown status discriminant {}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pub(crate) const ASSET_LOCK_STATUS_LABELS: &[&str] = &[
"is_locked",
"chain_locked",
"consumed",
"recovered_from_chain",
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Comment on lines 97 to +100

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔴 Blocking: Append a migration instead of changing V001's generated CHECK constraint

V001__initial.rs builds its asset_locks.status CHECK clause from ASSET_LOCK_STATUS_LABELS, so adding recovered_from_chain here changes the generated V001 SQL and its Refinery checksum. The storage runner uses Refinery's default abort_divergent = true; any database that already applied the previous V001 therefore fails in SqlitePersister::open with a divergent-migration error before it can be used. Disabling that check would not solve the schema mismatch because the old CHECK constraint would still reject reconstructed rows. Keep V001 byte-identical to the prior release and append a migration that rebuilds asset_locks with the expanded domain, plus an upgrade test beginning from the prior V003 schema.

source: ['codex']

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Addressed in a6cfb13: V001 is frozen back to its original five-label CHECK (byte-identical generated SQL, so existing databases' Refinery checksums verify), and the domain widens via an appended V004__asset_lock_recovered_status.rs table rebuild that preserves rows and the wallet_metadata FK. tc045_v004_widens_asset_lock_status_on_existing_db drives the exact upgrade an existing install experiences (V003 schema + data → latest), asserting the old CHECK rejected the new label, the pre-upgrade row survives the rebuild, the widened domain admits recovered_from_chain, garbage stays rejected, and ON DELETE CASCADE survives. A new pin test (asset_lock_status_labels_frozen_in_latest_migration) fails with append-a-migration instructions if the live const ever drifts from V004's frozen list.

];

fn status_str(s: &AssetLockStatus) -> &'static str {
Expand All @@ -94,6 +95,7 @@ fn status_str(s: &AssetLockStatus) -> &'static str {
AssetLockStatus::InstantSendLocked => "is_locked",
AssetLockStatus::ChainLocked => "chain_locked",
AssetLockStatus::Consumed => "consumed",
AssetLockStatus::RecoveredFromChain => "recovered_from_chain",
}
}

Expand Down Expand Up @@ -198,14 +200,16 @@ mod tests {
AssetLockStatus::InstantSendLocked,
AssetLockStatus::ChainLocked,
AssetLockStatus::Consumed,
AssetLockStatus::RecoveredFromChain,
];
for v in &variants {
match v {
AssetLockStatus::Built
| AssetLockStatus::Broadcast
| AssetLockStatus::InstantSendLocked
| AssetLockStatus::ChainLocked
| AssetLockStatus::Consumed => {}
| AssetLockStatus::Consumed
| AssetLockStatus::RecoveredFromChain => {}
}
}
variants
Expand Down
Loading
Loading