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

Fix issue #1096 #1153

Merged
merged 2 commits into from
Mar 30, 2022
Merged

Fix issue #1096 #1153

merged 2 commits into from
Mar 30, 2022

Conversation

asonnino
Copy link
Contributor

Fix issue #1096

@asonnino asonnino linked an issue Mar 30, 2022 that may be closed by this pull request
@asonnino asonnino self-assigned this Mar 30, 2022
Comment on lines +155 to +157
while state.db().last_consensus_index().unwrap() != SequenceNumber::from(1) {
tokio::time::sleep(std::time::Duration::from_millis(10)).await;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a better way to do that actually? Something like the notify_read we had in Narwhal perhaps

Copy link
Contributor

Choose a reason for hiding this comment

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

The notify_read is in typed_store and you should be able to use it anywhere you have a Store. But it is fundamentally an async API ..

Copy link
Collaborator

Choose a reason for hiding this comment

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

You will need to build a notification infra like for the batches to do that. Probably, this will be necessary as new consensus items should trigger execution out of band, but we will cross that bridge when we get to it.

@asonnino asonnino requested a review from lxfind March 30, 2022 10:06
Copy link
Contributor

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

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

I think this may be what you're looking for:

use futures::future::poll_fn;
use futures::task::{Context, Poll};

fn barrier_last_seq_num(_cx: &mut Context<'_>) -> Poll<()> {
    match state.db().last_consensus_index() {
        Some(val) if val == SequenceNumber::from(1) => Poll::Ready(()),
        _ => Poll::Pending,
    }
}

let barrier= poll_fn(barrier_last_seq_num);
...
// later at point of use
barrier.await

Comment on lines +155 to +157
while state.db().last_consensus_index().unwrap() != SequenceNumber::from(1) {
tokio::time::sleep(std::time::Duration::from_millis(10)).await;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The notify_read is in typed_store and you should be able to use it anywhere you have a Store. But it is fundamentally an async API ..

@asonnino
Copy link
Contributor Author

I think this may be what you're looking for:

use futures::future::poll_fn;
use futures::task::{Context, Poll};

fn barrier_last_seq_num(_cx: &mut Context<'_>) -> Poll<()> {
    match state.db().last_consensus_index() {
        Some(val) if val == SequenceNumber::from(1) => Poll::Ready(()),
        _ => Poll::Pending,
    }
}

let barrier= poll_fn(barrier_last_seq_num);
...
// later at point of use
barrier.await

I tried but couldn't make it work. I keep a marker to your snipped for later (when we will need such facility for other things that testing)

@asonnino asonnino merged commit 6a5dc05 into main Mar 30, 2022
@asonnino asonnino deleted the fix-1096 branch March 30, 2022 15:16
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.

consensus_tests::sync_with_consensus failed once
3 participants