Skip to content

Commit

Permalink
use epoch from proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
ss-es committed Dec 6, 2024
1 parent 25e24e9 commit 2fed4ef
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions crates/task-impls/src/da.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,11 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> DaTaskState<TYP
}
HotShotEvent::DaProposalValidated(proposal, sender) => {
let cur_view = self.consensus.read().await.cur_view();
let view_number = proposal.data.view_number();
let epoch_number = proposal.data.epoch_number;

ensure!(
cur_view <= proposal.data.view_number() + 1,
cur_view <= view_number + 1,
debug!(
"Validated DA proposal for prior view but it's too old now Current view {:?}, DA Proposal view {:?}",
cur_view,
Expand All @@ -155,7 +158,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> DaTaskState<TYP
// Proposal is fresh and valid, notify the application layer
broadcast_event(
Event {
view_number: self.cur_view,
view_number,
event: EventType::DaProposal {
proposal: proposal.clone(),
sender: sender.clone(),
Expand All @@ -166,32 +169,31 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> DaTaskState<TYP
.await;

ensure!(
self.membership
.has_da_stake(&self.public_key, self.cur_epoch),
self.membership.has_da_stake(&self.public_key, epoch_number),
debug!(
"We were not chosen for consensus committee on {:?}",
self.cur_view
"We were not chosen for consensus committee for view {:?} in epoch {:?}",
view_number, epoch_number
)
);

let txns = Arc::clone(&proposal.data.encoded_transactions);
let num_nodes = self.membership.total_nodes(self.cur_epoch);
let num_nodes = self.membership.total_nodes(epoch_number);
let payload_commitment =
spawn_blocking(move || vid_commitment(&txns, num_nodes)).await;
let payload_commitment = payload_commitment.unwrap();

self.storage
.write()
.await
.append_da2(proposal, payload_commitment)
.await
.wrap()
.context(error!("Failed to append DA proposal to storage"))?;
let view_number = proposal.data.view_number();
// Generate and send vote
let vote = DaVote2::create_signed_vote(
DaData2 {
payload_commit: payload_commitment,
epoch: self.cur_epoch,
epoch: epoch_number,
},
view_number,
&self.public_key,
Expand Down Expand Up @@ -226,14 +228,13 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> DaTaskState<TYP
let pk = self.private_key.clone();
let public_key = self.public_key.clone();
let chan = event_stream.clone();
let current_epoch = self.cur_epoch;
spawn(async move {
Consensus::calculate_and_update_vid(
OuterConsensus::new(Arc::clone(&consensus.inner_consensus)),
view_number,
membership,
&pk,
current_epoch,
epoch_number,
)
.await;
if let Some(Some(vid_share)) = consensus
Expand Down

0 comments on commit 2fed4ef

Please sign in to comment.