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

Calculate VID dispersal locally #2841

Merged
merged 5 commits into from
Mar 27, 2024
Merged

Calculate VID dispersal locally #2841

merged 5 commits into from
Mar 27, 2024

Conversation

lukaszrzasik
Copy link
Contributor

@lukaszrzasik lukaszrzasik commented Mar 25, 2024

Closes #2731

This PR:

Splits DAProposalRecv into DAProposalRecv and DAProposalValidated.
DA task handles DAProposalRecv by validating DA proposal and emitting DAProposalValidated if correct.
DA task handles DAProposalValidated by creating, signing and sending the vote.
VID task handles DAProposalValidated by calculating VID dispersal and emitting VidDisperseRecv for each VID share.
The newly calculated VID dispersal is stored locally.
Modifies VID disperse validity check: VID is valid if signed by the leader or by the node itself meaning this is a locally generated VID.

This PR does not:

Key places to review:

crates/task-impls/src/consensus.rs
crates/task-impls/src/da.rs
crates/task-impls/src/vid.rs

How to test this PR:

The change was tested by applying this patch:

diff --git a/crates/task-impls/src/network.rs b/crates/task-impls/src/network.rs
index ade3b12..4879a81 100644
--- a/crates/task-impls/src/network.rs
+++ b/crates/task-impls/src/network.rs
@@ -285,7 +285,8 @@ impl<
                 )
             }
             HotShotEvent::VidDisperseSend(proposal, sender) => {
-                return self.handle_vid_disperse_proposal(proposal, &sender);
+                return None;
+                // return self.handle_vid_disperse_proposal(proposal, &sender);
             }
             HotShotEvent::DAProposalSend(proposal, sender) => {
                 maybe_action = Some(HotShotAction::DAPropose);

and checking if the tests still pass. The patch disables sending the VID dispersal by the leader so that the DA members can only use the locally generated VID dispersal.

Additionally tests in:
crates/testing/tests/da_task.rs and
crates/testing/tests/vid_task.rs
has been modified to test the modified approach.

@lukaszrzasik lukaszrzasik self-assigned this Mar 25, 2024
@lukaszrzasik lukaszrzasik changed the title Lr/calc vid locally Calculate VID dispersal locally Mar 25, 2024
@lukaszrzasik
Copy link
Contributor Author

I'm thinking about splitting DAProposalRecv into two parts:

  1. Proposal validation
  2. Creating, signing and sending the vote.

A new HotShotEvent called DAProposalValidated would be emitted after proposal validation.
DA Task can handle it by continuing with the vote and VID task in parallel can calculate the VID dispersal.

Does that sound like a good idea?

@lukaszrzasik lukaszrzasik marked this pull request as ready for review March 25, 2024 21:56
@bfish713
Copy link
Collaborator

I'm thinking about splitting DAProposalRecv into two parts:

  1. Proposal validation
  2. Creating, signing and sending the vote.

A new HotShotEvent called DAProposalValidated would be emitted after proposal validation. DA Task can handle it by continuing with the vote and VID task in parallel can calculate the VID dispersal.

Does that sound like a good idea?

Yes this sounds like a good idea to avoid duplicate validation, and to avoid waiting for VID calculation to vote

bfish713
bfish713 previously approved these changes Mar 26, 2024
Copy link
Collaborator

@bfish713 bfish713 left a comment

Choose a reason for hiding this comment

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

Changes look good to me, just one spot we might want to simplify.

We still need to omit sending VID over the backup network when using the combined network. But that's can be a seperate PR

Comment on lines 178 to 187
Some(broadcast_event(
Arc::new(HotShotEvent::VidDisperseRecv(
vid_share.to_proposal(&self.private_key)?,
)),
&event_stream,
))
})
.collect();

if vid_disperse_tasks.iter().all(Option::is_some) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we wrap the mapped function in Option here?

Copy link
Contributor Author

@lukaszrzasik lukaszrzasik Mar 27, 2024

Choose a reason for hiding this comment

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

My idea here was: to_proposal can return None when signing the proposal failed. When it happens the closure returns None, if it succeeds it returns Some(_). Then we check if all the proposals have been successfully signed and only if it's true we store all the VID dispersal shares.

So the logic is: if only one signing fails, we don't store the VID shares.

I'm not sure if this logic is correct but it seemed correct to me.
What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh I missed the ? operator. I think it's fine, but would prefer if all was filter. I think if any fail to sign just the ones that weren't signed would be excluded.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem. Changed.

@lukaszrzasik lukaszrzasik merged commit 1315fc1 into main Mar 27, 2024
17 of 18 checks passed
@lukaszrzasik lukaszrzasik deleted the lr/calc-vid-locally branch March 27, 2024 20:37
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.

[FALLBACK] - DA Nodes Calculate and Store VID shares
2 participants