Skip to content

fsm: add WaitForStateAsync to the cached observer #741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2024

Conversation

bhandras
Copy link
Member

@bhandras bhandras commented May 7, 2024

By adding WaitForStateAsync to the observer we can always observe state changes in an atomic way without relying on the observer's internal cache.

Pull Request Checklist

  • Update release_notes.md if your PR contains major features, breaking changes or bugfixes

@bhandras bhandras force-pushed the fsm-observer-fixup branch from 161c4a5 to e5b2f2b Compare May 7, 2024 18:27
@bhandras bhandras requested review from sputn1ck and hieblmi May 7, 2024 18:32
@bhandras bhandras force-pushed the fsm-observer-fixup branch from e5b2f2b to e6e596b Compare May 7, 2024 19:23
Copy link
Member

@sputn1ck sputn1ck left a comment

Choose a reason for hiding this comment

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

LGTM!

fsm/observer.go Outdated
// receive an error if the expected state is reached or an error occurred. If
// the context is canceled before the expected state is reached, the channel
// will receive an ErrWaitingForStateTimeout error.
func (s *CachedObserver) WaitForStateAsync(ctx context.Context, state StateType,
Copy link
Collaborator

@hieblmi hieblmi May 8, 2024

Choose a reason for hiding this comment

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

nit: rename receiver c here and in WaitForState.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@bhandras bhandras force-pushed the fsm-observer-fixup branch from e6e596b to eddb8dc Compare May 8, 2024 11:29
@bhandras bhandras requested a review from hieblmi May 8, 2024 11:29
@bhandras bhandras force-pushed the fsm-observer-fixup branch from eddb8dc to 24c30ee Compare May 8, 2024 12:13
Copy link
Collaborator

@hieblmi hieblmi left a comment

Choose a reason for hiding this comment

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

tACK, tested these changes to the fsm with the static address withdrawal flow without issues.
Thanks for the explanation of the deadlock scenario.

fsm/observer.go Outdated
}
}

// Otherwise, wait for the next notification
s.notificationCond.Wait()
// Otherwise use the conditonal variable to wait for
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo conditional

Copy link
Member Author

Choose a reason for hiding this comment

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

done

By adding WaitForStateAsync to the observer we can always observe state
changes in an atomic way without relying on the observer's internal
cache.
@bhandras bhandras force-pushed the fsm-observer-fixup branch from 336d336 to 811e9df Compare May 8, 2024 13:06
@bhandras bhandras merged commit 3843c39 into lightninglabs:master May 8, 2024
3 checks passed
@bhandras bhandras deleted the fsm-observer-fixup branch May 8, 2024 13:06
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