talaia-labs / rust-teos

The Eye of Satoshi - Lightning Watchtower
https://talaia-labs.github.io/talaia.watch/
MIT License
136 stars 63 forks source link

Edge case where outdated users will persist in the DB #224

Closed mariocynicys closed 1 year ago

mariocynicys commented 1 year ago

After https://github.com/talaia-labs/rust-teos/pull/216, now we can miss the height at which some specific user's subscription expires, due to the equality check in here: https://github.com/talaia-labs/rust-teos/blob/1a89c5da70278ac5019a3bbb505b1923648a43da/teos/src/gatekeeper.rs#L260-L268

sr-gi commented 1 year ago

I'm assuming this can only happen if --forceupdate given we do not perform all the state transitions from the last known tip to the backend tip, isn't it?

If so this means that data in the three main components may not be up to date after bootstraping from an outdated backend. I'm guessing the Watcher and Responder may be less relevant after your memory optimization PR, given that is in memory data. However, this would still be an issue for the Gatekeeper given that's the component in charge of wiping the data from disk.

Changing the equality to geq should suffice I guess, I don't see any edge case (reorgs / missing a block) that can trigger this and make us not delete some data, or try to delete data twice.

mariocynicys commented 1 year ago

Changing the equality to geq should suffice I guess.

Yeah true. I took note of this while working on the memory stuff. But this probably doesn't make much sense without the memory data wiped from other components. Will just amend it to the memory PR.