lightninglabs / lightning-terminal

Lightning Terminal: Your Home for Lightning Liquidity
MIT License
501 stars 88 forks source link

multi: Autopilot session linking #573

Closed ellemouton closed 1 year ago

ellemouton commented 1 year ago

With this PR, we add the ability for a client to link a new autopilot session with a previously revoked one. If this is done, then the same privacy mapper is used for the linked sessions & the actions and rules db is also shared across sessions.

PR Flow:

  1. Update autopilotserver.proto to have the new fields required to link sessions. These include the previous key along with a sig to prove ownership of the linked session.
  2. update the autopilot server client to send the new fields if they are provided. initially we do not provide them.
  3. Add PrevLocalPub and GroupID to the Session store. The PrevLocalPub is the local public key of the session being linked to. The group ID is the local pub key of the very first session in the group of linked sessions.
  4. Update litrpcs Session and AddAutopilotSessionRequest messages to include a previoud linked session key.
  5. We need a mapping from session ID to group ID (one to one) and vice versa (one to many) and so we add a new session-id-index to the firewall db.
  6. We then make sure to always write an entry to the new index when creating a session.
  7. Then we backfill all previous sessions so that there is an entry in the session-id-index for all sessions created prior to this PR. This is easy since currently the mapping is one-to-one both ways. Only after this PR will the group-to-session index be one-to-many.
  8. add a new ListGroupActions method to the firewall DB that allows us to query the DB for all actions of a specific group.
  9. Let the firewall query group actions instead of session actions.
  10. Allow ListActions rpc call to specify groupID.
  11. Let privacy map conversion rpc call specify groupID.
  12. let firewall get the correct privacy mapper by group ID on interception of calls.
  13. Finally, allow the client to link sessions via the cli.

TODO:

ellemouton commented 1 year ago

gonna re-open from upstream branch