Repository navigation
Description
Same bug class as ZeusLN/zeus-vls#266, fixed for lnrod in ZeusLN/zeus-vls#273. lnrod's DualStore was ported from this one.
Affects the tag ZEUS mobile ships (v0.7.0-zeus-rl-0.2.5, branch rl-0.2.5-security-bump), rl-0.2.7-security-bump, and zeus (32fc853). Every ZEUS mobile user's VSS backup is exposed, not only Route nodes.
Problem
src/io/dual_store.rs writes to SQLite and then spawns one thread per VSS write or remove (write ~397-441, remove ~443-488). VssStore orders writes to the same key with a version and skips stale ones (execute_locked_write), but three gaps remain:
- Same-key order can flip. The version is assigned in
VssStore::write(get_new_version_and_lock_ref), which runs on the spawned thread, not whenDualStore::writeis called. Two writes of one key spawned back to back can reachVssStorein the opposite order. The older blob then gets the higher version and wins. - The bulk sync can overwrite a newer write.
bulk_sync_to_vssreads a key from SQLite and only later callsVssStore::write, which assigns the version at that point. A live write that lands between the read and the call gets the lower version, so the bulk sync's older blob wins. - Nothing orders monitors before the manager. If a monitor upload fails after its 180 s of retries while a later manager upload succeeds, VSS holds a manager newer than a monitor it treats as persisted.
On restore, LDK 0.2 refuses a manager that is ahead of its monitors (DecodeError::DangerousValue, "A ChannelMonitor is stale compared to the current ChannelManager"), so the restore fails. A monitor ahead of the manager is LDK's ordinary crash case: the affected channel is force-closed from the monitor.
Fix
Port the design from ZeusLN/zeus-vls#273:
- One background worker drains a set of dirty keys.
- It reads the current SQLite value at upload time, so the newest value wins and superseded writes are never sent.
- It reads the manager before taking each batch, uploads the monitors first, and uploads that manager last, only if every monitor in the batch went through.
- The startup bulk sync becomes "mark every key dirty" on the same worker.
- Failed keys stay dirty and are retried with backoff.
Two pieces are specific to this fork:
- The push safety gate (
vss_push_verdict) moves into the worker and is checked before each round.Disableddrops the batch;Undeterminedkeeps the keys dirty. - Restore mode still skips the startup sync.
Tests
- A slow older upload never lands after a newer write.
- Writes queued behind an in-flight upload are sent once, as the newest value.
- The manager is held back while a monitor upload fails.
- Within a round, the manager is uploaded after the monitors.
- A local remove reaches VSS.
- The push gate in the
Disabledstate still blocks every upload.
Tracking: ZeusLN/zeus-route#108 (P18), ZeusLN/zeus-route#110.
Activity
DualStore: upload VSS writes in order, monitors before the manager
DualStore: upload VSS writes in order, monitors before the manager
DualStore: upload VSS writes in order, monitors before the manager