You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: seed sync checkpoints from birth_height in ManagedWalletInfo ctors (#692)
* fix(key-wallet): seed sync checkpoints from `birth_height` in `ManagedWalletInfo` ctors
`WalletInfoInterface::from_wallet` and `from_wallet_with_name` (plus the inherent `ManagedWalletInfo` constructors) now take `birth_height: CoreBlockHeight` and seed both checkpoint heights (`synced_height`, `last_processed_height`) to `birth_height.saturating_sub(1)` so the next block to scan is always `birth_height`.
Without this, every wallet-add path had to remember `set_birth_height` after construction, and even when called it only set `birth_height`, leaving the checkpoints at `0`. With the per-wallet sync introduced in #694, that dragged `WalletManager::synced_height` (a min across wallets) back to genesis on every add, forcing a re-scan from `0`. Moving the seed into construction makes the invariant a property of the type.
`ManagedWalletInfo::with_birth_height` is removed. It set only `birth_height` and had no callers.
* docs(key-wallet-manager): clarify fallback `birth_height` source on wallet import
Addresses CodeRabbit review comment on PR #692#692 (comment)
* refactor(key-wallet): drop `WalletInfoInterface::set_birth_height`
The setter only updated `birth_height`, leaving `synced_height` and `last_processed_height` at their previous values, so a caller using it after construction would silently bypass the seeding invariant established by `from_wallet`. With the per-wallet height tracking in #694 that aggregate to a min/max across wallets, this could drag the manager's `synced_height` back to genesis. After the constructor change, the setter has zero callers in-tree, so removing it is the cleanest way to enforce the invariant: `birth_height` is fixed at construction via `from_wallet`.
Addresses CodeRabbit review comment on PR #692#692 (comment)
* test(key-wallet): pin off-by-one seed contract in `test_wallet_with_managed_info`
Use a non-zero `birth_height` and assert that `metadata.synced_height` and `metadata.last_processed_height` land at `birth_height - 1`, locking the seeding invariant in place.
Addresses CodeRabbit review comment on PR #692#692 (review)
0 commit comments