lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.61k stars 2.06k forks source link

Add identifiers to channel resolutions #6986

Open joshfix opened 1 year ago

joshfix commented 1 year ago

For accounting purposes, it is desirable to build tools to facilitate automatically extracting and recording all channel resolutions data from closed channels. It is unclear whether or not resolutions data is subject to mutation over time (to include adding outpoints, sweep txids, or adding new resolutions). Given this unknown, we have written code that collects all the resolutions data from a closedchannels RPC response, then compares the resolutions with previously recorded values for each channel. Because the resolutions have no unique identifier, it becomes quite tricky to determine which resolutions should be compared for equality to determine if a mutation has occurred.

Currently our organization has implemented a solution to compare resolution slice length per channel, sort the slice of resolutions, and use a custom equality operation to determine if any of the values have changed. If so, instead of attempting to determine and identify each individual resolution that was changed and update it accordingly, we wipe all the resolutions for the channel from our db and rewrite them with the new data. The process is a bit expensive in our systems, especially in terms of db queries.

It would be very beneficial to either 1) understand whether or not resolutions are not subject to mutation or if they are completely final once they appear in the data set or 2) to provide identifiers on each resolution so they can be easily selected and checked for mutations.

Roasbeef commented 1 year ago

Do the faraday accounting tools give you the functionality you need: https://github.com/lightninglabs/faraday/blob/master/docs/accounting.md?

joshfix commented 6 months ago

We have a fairly complex/custom system to record our data and our own accounting tools that interact with the databases we record the data to. We are interested in checking out the capabilities of Faraday, however this is still an issue (inefficiency) for us and we would still benefit from some sort of unique identifier on the resolutions.