From 05348f086efafb20dced0753a97db7cb5533d50d Mon Sep 17 00:00:00 2001 From: rob-maron <132852777+rob-maron@users.noreply.github.com> Date: Thu, 24 Oct 2024 16:27:19 -0400 Subject: [PATCH] [Combined Net] Remove optimistic VID (#3797) * remove optimistic vid calculation for combined network * clippy * reduce contention on consensus lock while calculating vid * fmt --- crates/task-impls/src/da.rs | 40 +---------------------------------- crates/types/src/consensus.rs | 9 +++----- 2 files changed, 4 insertions(+), 45 deletions(-) diff --git a/crates/task-impls/src/da.rs b/crates/task-impls/src/da.rs index e811f7ac7e..633bcaff14 100644 --- a/crates/task-impls/src/da.rs +++ b/crates/task-impls/src/da.rs @@ -7,14 +7,13 @@ use std::{marker::PhantomData, sync::Arc}; use async_broadcast::{Receiver, Sender}; -use async_compatibility_layer::art::async_spawn; use async_lock::RwLock; #[cfg(async_executor_impl = "async-std")] use async_std::task::spawn_blocking; use async_trait::async_trait; use hotshot_task::task::TaskState; use hotshot_types::{ - consensus::{Consensus, OuterConsensus, View}, + consensus::{OuterConsensus, View}, data::{DaProposal, PackedBundle}, event::{Event, EventType}, message::{Proposal, UpgradeLock}, @@ -23,7 +22,6 @@ use hotshot_types::{ traits::{ block_contents::vid_commitment, election::Membership, - network::ConnectedNetwork, node_implementation::{NodeImplementation, NodeType, Versions}, signature_key::SignatureKey, storage::Storage, @@ -231,42 +229,6 @@ impl, V: Versions> DaTaskState { tracing::debug!("DA vote recv, Main Task {:?}", vote.view_number()); diff --git a/crates/types/src/consensus.rs b/crates/types/src/consensus.rs index 3ab3444b94..c40091f857 100644 --- a/crates/types/src/consensus.rs +++ b/crates/types/src/consensus.rs @@ -824,13 +824,10 @@ impl Consensus { private_key: &::PrivateKey, epoch: TYPES::Epoch, ) -> Option<()> { - let consensus = consensus.upgradable_read().await; - let txns = consensus.saved_payloads().get(&view)?; - let vid = - VidDisperse::calculate_vid_disperse(Arc::clone(txns), &membership, view, epoch, None) - .await; + let txns = Arc::clone(consensus.read().await.saved_payloads().get(&view)?); + let vid = VidDisperse::calculate_vid_disperse(txns, &membership, view, epoch, None).await; let shares = VidDisperseShare::from_vid_disperse(vid); - let mut consensus = ConsensusUpgradableReadLockGuard::upgrade(consensus).await; + let mut consensus = consensus.write().await; for share in shares { if let Some(prop) = share.to_proposal(private_key) { consensus.update_vid_shares(view, prop);