Skip to content

Conversation

@ellemouton
Copy link
Member

@ellemouton ellemouton commented Feb 25, 2025

Addresses this comment.

In this PR, we ensure all session state shifts are legal via a strict transition map. We then replace the
RevokeSession method with a new ShiftState method. Finally, for expired sessions, we use the Expired state
instead of the Revoked state.

Copy link
Contributor

@ViktorT-11 ViktorT-11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Niiiiiiiice, thanks for this 🙏!!

uTACK LGTM 🚀!

Leaving some docs and test coverage comments.

Comment on lines +436 to +443
// Trying to shift the state from a terminal state back to StateCreated
// should also fail since this is not a legal state transition.
err = db.ShiftState(s1.ID, StateCreated)
require.ErrorContains(t, err, "illegal session state transition")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:
Would also be value in testing that shifting a StateReserved session to StateRevoked is not legal, as that's the concern in the comment that this PR is addressing :). Potentially also add coverage to show that StateInUse -> StateRevoked is legal.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personally, i think we only need to test illegal state transitions once and not for every possible iteration

Copy link
Contributor

@bitromortac bitromortac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, LGTM 🎉

pubKeyBytes, sess.Expiry)

err := s.cfg.db.ShiftState(sess.ID, session.StateRevoked)
err := s.cfg.db.ShiftState(sess.ID, session.StateExpired)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ellemouton ellemouton merged commit 88a2bf0 into lightninglabs:master Feb 25, 2025
21 checks passed
@ellemouton ellemouton deleted the stateShift branch February 25, 2025 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants