Skip to content
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

make membership functions async #3968

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Conversation

imabdulbasit
Copy link
Contributor

@imabdulbasit imabdulbasit commented Dec 14, 2024

With the introduction of epochs, the Membership type is no longer static. We need to update the Membership on each epoch. This requires wrapping Membership in Arc<RwLock<..>>. Hence, all Membership methods would need to acquire a read lock, which requires making the membership functions async.

Since the current functions are not async, they block the thread to acquire the lock, which is dangerous. Some sequencer tests also return the following error:
Cannot block the current thread from within a runtime. This happens because a function attempted to block the current thread while the thread is being used to drive asynchronous tasks.

So, to make things work , we should make these functions async and this PR implements these changes.

There has also been a discussion about Hotshot managing the locks on the Membership type and handle the call to the update() function on Membership at every new epoch. This approach is much better IMO, and I believe it would also require making these functions async.

@imabdulbasit imabdulbasit marked this pull request as ready for review December 14, 2024 15:40
@imabdulbasit imabdulbasit assigned pls148 and unassigned lukaszrzasik and shenkeyao Dec 14, 2024
@imabdulbasit imabdulbasit requested a review from ss-es December 14, 2024 15:40
@imabdulbasit imabdulbasit marked this pull request as draft December 14, 2024 19:38
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.

4 participants