Skip to content

Commit

Permalink
combine tasks, remove dead test
Browse files Browse the repository at this point in the history
  • Loading branch information
jparr721 committed Mar 28, 2024
1 parent 64da174 commit 385be8e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 47 deletions.
13 changes: 8 additions & 5 deletions crates/task-impls/src/quorum_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>> QuorumProposalTaskState<TYPE
event_receiver,
Box::new(move |event| {
let event = event.as_ref();
debug!("Dependency {:?} got event {:?}", dependency_type, event);
let event_view = match dependency_type {
ProposalDependency::QC => {
if let HotShotEvent::QCFormed(either::Left(qc)) = event {
Expand Down Expand Up @@ -243,7 +242,11 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>> QuorumProposalTaskState<TYPE
}
}
};
event_view == view_number
let valid = event_view == view_number;
if valid {
debug!("Depencency {:?} is complete!", dependency_type);
}
valid
}),
)
}
Expand All @@ -266,7 +269,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>> QuorumProposalTaskState<TYPE
return;
}

let mut proposal_cert_validated_dependency = self.create_event_dependency(
let mut proposal_cert_dependency = self.create_event_dependency(
ProposalDependency::ProposalCertificate,
view_number,
event_receiver.clone(),
Expand Down Expand Up @@ -301,7 +304,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>> QuorumProposalTaskState<TYPE
payload_commitment_dependency.mark_as_completed(event.clone());
}
HotShotEvent::QuorumProposalRecv(_, _) => {
proposal_cert_validated_dependency.mark_as_completed(event);
proposal_cert_dependency.mark_as_completed(event);
}
HotShotEvent::QCFormed(quorum_certificate) => match quorum_certificate {
Either::Right(_) => {
Expand All @@ -324,7 +327,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>> QuorumProposalTaskState<TYPE
])]),
OrDependency::from_deps(vec![
// 1. A QCFormed event and QuorumProposalRecv event
AndDependency::from_deps(vec![qc_dependency, proposal_cert_validated_dependency]),
AndDependency::from_deps(vec![qc_dependency, proposal_cert_dependency]),
// 2. A timeout cert was received
AndDependency::from_deps(vec![timeout_dependency]),
// 3. A view sync cert was received.
Expand Down
45 changes: 3 additions & 42 deletions crates/testing/tests/quorum_proposal_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,60 +45,21 @@ async fn test_quorum_proposal_task_quorum_proposal() {

let mut proposals = Vec::new();
let mut leaders = Vec::new();
for view in (&mut generator).take(2) {
for view in (&mut generator).take(3) {
proposals.push(view.quorum_proposal.clone());
leaders.push(view.leader_public_key);
}
let cert = proposals[2].data.justify_qc.clone();

// Run at view 2, the quorum vote task shouldn't care as long as the bookkeeping is correct
let view_2 = TestScriptStage {
inputs: vec![
QuorumProposalRecv(proposals[1].clone(), leaders[1]),
SendPayloadCommitmentAndMetadata(payload_commitment, (), ViewNumber::new(2)),
],
outputs: vec![
exact(QuorumProposalValidated(proposals[1].data.clone())),
exact(QuorumProposalDependenciesValidated(ViewNumber::new(2))),
exact(DummyQuorumProposalSend(ViewNumber::new(2))),
],
asserts: vec![],
};

let quorum_proposal_task_state =
QuorumProposalTaskState::<TestTypes, MemoryImpl>::create_from(&handle).await;
inject_quorum_proposal_polls(&quorum_proposal_task_state).await;

let script = vec![view_2];
run_test_script(script, quorum_proposal_task_state).await;
}

#[cfg(test)]
#[cfg_attr(async_executor_impl = "tokio", tokio::test(flavor = "multi_thread"))]
#[cfg_attr(async_executor_impl = "async-std", async_std::test)]
async fn test_quorum_proposal_task_qc_proposal() {
async_compatibility_layer::logging::setup_logging();
async_compatibility_layer::logging::setup_backtrace();

let handle = build_system_handle(2).await.0;
let quorum_membership = handle.hotshot.memberships.quorum_membership.clone();
let payload_commitment = make_payload_commitment(&quorum_membership, ViewNumber::new(2));

let mut generator = TestViewGenerator::generate(quorum_membership.clone());

let mut proposals = Vec::new();
let mut leaders = Vec::new();
for view in (&mut generator).take(2) {
proposals.push(view.quorum_proposal.clone());
leaders.push(view.leader_public_key);
}
let cert = proposals[1].data.justify_qc.clone();
// Run at view 2, the quorum vote task shouldn't care as long as the bookkeeping is correct
let view_2 = TestScriptStage {
inputs: vec![
QCFormed(either::Left(cert.clone())),
SendPayloadCommitmentAndMetadata(payload_commitment, (), ViewNumber::new(2)),
],
outputs: vec![
exact(QuorumProposalValidated(proposals[1].data.clone())),
exact(QuorumProposalDependenciesValidated(ViewNumber::new(2))),
exact(DummyQuorumProposalSend(ViewNumber::new(2))),
],
Expand Down

0 comments on commit 385be8e

Please sign in to comment.