Skip to content

Commit

Permalink
Fix vid share handling
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszrzasik committed Dec 16, 2024
1 parent e762de4 commit 729db94
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions crates/task-impls/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ use std::{
sync::Arc,
};

use crate::{
events::{HotShotEvent, HotShotTaskCompleted},
helpers::broadcast_event,
};
use async_broadcast::{Receiver, Sender};
use async_lock::RwLock;
use async_trait::async_trait;
use hotshot_task::task::TaskState;
use hotshot_types::data::{VidDisperseShare, VidDisperseShare2};
use hotshot_types::{
consensus::OuterConsensus,
data::{VidDisperse, VidDisperseShare},
data::VidDisperse,
event::{Event, EventType, HotShotAction},
message::{
convert_proposal, DaConsensusMessage, DataMessage, GeneralConsensusMessage, Message,
Expand All @@ -39,11 +44,6 @@ use tracing::instrument;
use utils::anytrace::*;
use vbs::version::StaticVersionType;

use crate::{
events::{HotShotEvent, HotShotTaskCompleted},
helpers::broadcast_event,
};

/// the network message task state
#[derive(Clone)]
pub struct NetworkMessageTaskState<TYPES: NodeType> {
Expand Down Expand Up @@ -322,16 +322,35 @@ impl<
sender: &<TYPES as NodeType>::SignatureKey,
) -> Option<HotShotTaskCompleted> {
let view = vid_proposal.data.view_number;
let vid_share_proposals = VidDisperseShare::to_vid_share_proposals(vid_proposal);
let vid_share_proposals = VidDisperseShare2::to_vid_share_proposals(vid_proposal);
let mut messages = HashMap::new();

for proposal in vid_share_proposals {
let recipient = proposal.data.recipient_key.clone();
let message = Message {
sender: sender.clone(),
kind: MessageKind::<TYPES>::from_consensus_message(SequencingMessage::Da(
DaConsensusMessage::VidDisperseMsg(proposal),
)),
let message = if self
.upgrade_lock
.version_infallible(proposal.data.view_number())
.await
>= V::Epochs::VERSION
{
Message {
sender: sender.clone(),
kind: MessageKind::<TYPES>::from_consensus_message(SequencingMessage::Da(
DaConsensusMessage::VidDisperseMsg2(proposal),
)),
}
} else {
let vid_share_proposal = Proposal {
data: VidDisperseShare::from(proposal.data),
signature: proposal.signature,
_pd: proposal._pd,
};
Message {
sender: sender.clone(),
kind: MessageKind::<TYPES>::from_consensus_message(SequencingMessage::Da(
DaConsensusMessage::VidDisperseMsg(vid_share_proposal),
)),
}
};
let serialized_message = match self.upgrade_lock.serialize(&message).await {
Ok(serialized) => serialized,
Expand Down

0 comments on commit 729db94

Please sign in to comment.