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

made bft actor send LeaderPrepare messages asynchronously (BFT-400) #52

Merged
merged 9 commits into from
Dec 14, 2023

Conversation

pompon0
Copy link
Collaborator

@pompon0 pompon0 commented Dec 13, 2023

What ❔

Made bft actor send LeaderPrepare messages asynchronously.

Why ❔

PayloadSource.propose() may be blocking (when no payload can be proposed at a time) but it shouldn't block message processing:

  • other validators may be able to propose, so we should keep exchanging messages with them.
  • validator should avoid keeping a growing backlog of unprocessed messages

@pompon0 pompon0 changed the title made bft actor send LeaderPrepare messages asynchronously made bft actor send LeaderPrepare messages asynchronously (BFT-400) Dec 13, 2023
Copy link
Contributor

@slowli slowli left a comment

Choose a reason for hiding this comment

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

Can't say I'm a particularly good reviewer for consensus logic, but overall the changes look solid.

else {
return Ok(());
};
debug_assert!(replica_messages.len() == self.inner.threshold());
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to understand: Is strict equality instead of >= intended here? The find predicate above implies >=. If the strict equality is intended, you can use debug_assert_eq; it'll provide more informative panic message.

Copy link
Collaborator Author

@pompon0 pompon0 Dec 13, 2023

Choose a reason for hiding this comment

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

we want ==, to make sure that we don't wait for too many signatures.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is a debug_assert, because it would be technically correct to include more signatures.

node/actors/bft/src/leader/replica_commit.rs Outdated Show resolved Hide resolved
node/actors/bft/src/leader/state_machine.rs Outdated Show resolved Hide resolved
node/actors/bft/src/leader/state_machine.rs Outdated Show resolved Hide resolved
node/actors/bft/src/leader/tests.rs Outdated Show resolved Hide resolved
node/actors/bft/src/testonly/make.rs Outdated Show resolved Hide resolved
node/actors/bft/src/testonly/ut_harness.rs Outdated Show resolved Hide resolved
node/actors/bft/src/leader/state_machine.rs Show resolved Hide resolved
node/actors/bft/src/leader/replica_prepare.rs Outdated Show resolved Hide resolved
node/actors/bft/src/leader/replica_commit.rs Outdated Show resolved Hide resolved
@pompon0 pompon0 requested a review from slowli December 13, 2023 16:07
Copy link
Member

@brunoffranca brunoffranca left a comment

Choose a reason for hiding this comment

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

I'm not satisfied with this design. It's a bit of a quick fix, I think it does decrease the readability of the code.
Also, looking at the future here, besides wanting to send LeaderPrepare messages asynchronously, we probably want to send asynchronously ReplicaCommit messages (because we need to verify the proposals and that might block) and ReplicaPrepare (when we implement the consensus oracle we will need to fetch external information, again might block). The only that doesn't need to be asynchronous is LeaderCommit.
I would prefer then that each of these messages are handled by a separate background task, and ideally without separating the message processing.

node/actors/bft/src/inner.rs Outdated Show resolved Hide resolved
@brunoffranca
Copy link
Member

@moshababo Take a look. You're a code owner for this actor now too.

@pompon0 pompon0 merged commit 21e4477 into main Dec 14, 2023
4 checks passed
@pompon0 pompon0 deleted the gprusak-lazy-payload3 branch December 14, 2023 14:48
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