lightninglabs / lightning-terminal

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

multi: Autopilot session linking #621

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 previous set of revoked ones. 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. First some edits are made to the Session store: mainly, we create separate methods for creating a new session vs updating the remote pub key of an existing session. 2.. Add a new session ID to session local pub key index to the session store. This makes possible to fetch session by ID. A migration to backfill this index is also added.
  2. Update autopilotserver.proto to have the new fields required to link sessions. These include the session group key along with a sig to prove ownership of the linked session.
  3. Update the autopilot server client to send the new fields if they are provided. initially we do not provide them.
  4. Add GroupID to the Session store. The group ID is the ID of the very first session in the group of linked sessions.
  5. Update litrpcs Session and AddAutopilotSessionRequest messages to include a linked group ID.
  6. Marshal the new fields in the Session proto message
  7. Add new indexes to the session store which map from session ID to group ID and group ID to session IDs.
  8. a migration to backfill the above indexes. 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.
  9. New methods to the session store to query via the new index.
  10. add a new ListGroupActions method to the firewall DB that allows us to query the DB for all actions of a specific group.
  11. Let the firewall query group actions instead of session actions.
  12. Allow ListActions rpc call to specify groupID.
  13. Let privacy map conversion rpc call specify groupID.
  14. let firewall get the correct privacy mapper by group ID on interception of calls.
  15. Finally, allow the client to link sessions via the cli.

TODO:

ellemouton commented 1 year ago

gonna add something else shortly 🤓

ellemouton commented 1 year ago

Ok ya'll! thanks for your patience! The PR has been updated quite a bit. Here are the changes:

ellemouton commented 1 year ago

ok I tacked on a temporary commit here now labeled temp:... i'll squash it in in a nicer way tomorrow

ellemouton commented 1 year ago

re-requesting since the change to only link by group ID.

Requesting from @guggero for architectural ACK