hotshot_task_impls/
events.rs

1// Copyright (c) 2021-2024 Espresso Systems (espressosys.com)
2// This file is part of the HotShot repository.
3
4// You should have received a copy of the MIT License
5// along with the HotShot repository. If not, see <https://mit-license.org/>.
6
7use std::fmt::Display;
8
9use async_broadcast::Sender;
10use either::Either;
11use hotshot_task::task::TaskEvent;
12use hotshot_types::{
13    data::{
14        DaProposal2, Leaf2, PackedBundle, QuorumProposal2, QuorumProposalWrapper, UpgradeProposal,
15        VidCommitment, VidDisperse, VidDisperseShare,
16    },
17    message::Proposal,
18    request_response::ProposalRequestPayload,
19    simple_certificate::{
20        DaCertificate2, EpochRootQuorumCertificate, NextEpochQuorumCertificate2, QuorumCertificate,
21        QuorumCertificate2, TimeoutCertificate, TimeoutCertificate2, UpgradeCertificate,
22        ViewSyncCommitCertificate2, ViewSyncFinalizeCertificate2, ViewSyncPreCommitCertificate2,
23    },
24    simple_vote::{
25        DaVote2, EpochRootQuorumVote, QuorumVote2, TimeoutVote2, UpgradeVote, ViewSyncCommitVote2,
26        ViewSyncFinalizeVote2, ViewSyncPreCommitVote2,
27    },
28    traits::{
29        block_contents::BuilderFee, network::DataRequest, node_implementation::NodeType,
30        signature_key::SignatureKey, BlockPayload,
31    },
32    utils::BuilderCommitment,
33    vote::HasViewNumber,
34};
35use vec1::Vec1;
36
37use crate::view_sync::ViewSyncPhase;
38
39impl<TYPES: NodeType> TaskEvent for HotShotEvent<TYPES> {
40    fn shutdown_event() -> Self {
41        HotShotEvent::Shutdown
42    }
43}
44
45/// Wrapper type for the event to notify tasks that a proposal for a view is missing
46/// and the channel to send the event back to
47#[derive(Debug, Clone)]
48pub struct ProposalMissing<TYPES: NodeType> {
49    /// View of missing proposal
50    pub view: TYPES::View,
51    /// Channel to send the response back to
52    pub response_chan: Sender<Option<Proposal<TYPES, QuorumProposal2<TYPES>>>>,
53}
54
55impl<TYPES: NodeType> PartialEq for ProposalMissing<TYPES> {
56    fn eq(&self, other: &Self) -> bool {
57        self.view == other.view
58    }
59}
60
61impl<TYPES: NodeType> Eq for ProposalMissing<TYPES> {}
62
63/// Marker that the task completed
64#[derive(Eq, PartialEq, Debug, Clone)]
65pub struct HotShotTaskCompleted;
66
67/// All of the possible events that can be passed between Sequencing `HotShot` tasks
68#[derive(Eq, PartialEq, Debug, Clone)]
69#[allow(clippy::large_enum_variant)]
70pub enum HotShotEvent<TYPES: NodeType> {
71    /// Shutdown the task
72    Shutdown,
73    /// A quorum proposal has been received from the network; handled by the consensus task
74    QuorumProposalRecv(
75        Proposal<TYPES, QuorumProposalWrapper<TYPES>>,
76        TYPES::SignatureKey,
77    ),
78    /// A quorum vote has been received from the network; handled by the consensus task
79    QuorumVoteRecv(QuorumVote2<TYPES>),
80    /// A quorum vote for the epoch root has been received from the network; handled by the consensus task
81    /// An additional light client state update vote is bundled with the quorum vote
82    EpochRootQuorumVoteRecv(EpochRootQuorumVote<TYPES>),
83    /// A timeout vote received from the network; handled by consensus task
84    TimeoutVoteRecv(TimeoutVote2<TYPES>),
85    /// Send a timeout vote to the network; emitted by consensus task replicas
86    TimeoutVoteSend(TimeoutVote2<TYPES>),
87    /// A DA proposal has been received from the network; handled by the DA task
88    DaProposalRecv(Proposal<TYPES, DaProposal2<TYPES>>, TYPES::SignatureKey),
89    /// A DA proposal has been validated; handled by the DA task and VID task
90    DaProposalValidated(Proposal<TYPES, DaProposal2<TYPES>>, TYPES::SignatureKey),
91    /// A DA vote has been received by the network; handled by the DA task
92    DaVoteRecv(DaVote2<TYPES>),
93    /// A Data Availability Certificate (DAC) has been received by the network; handled by the consensus task
94    DaCertificateRecv(DaCertificate2<TYPES>),
95    /// A DAC is validated.
96    DaCertificateValidated(DaCertificate2<TYPES>),
97    /// Send a quorum proposal to the network; emitted by the leader in the consensus task
98    QuorumProposalSend(
99        Proposal<TYPES, QuorumProposalWrapper<TYPES>>,
100        TYPES::SignatureKey,
101    ),
102    /// Send a quorum vote to the next leader; emitted by a replica in the consensus task after seeing a valid quorum proposal
103    QuorumVoteSend(QuorumVote2<TYPES>),
104    /// Broadcast a quorum vote to form an eQC; emitted by a replica in the consensus task after seeing a valid quorum proposal
105    ExtendedQuorumVoteSend(QuorumVote2<TYPES>),
106    /// Send a epoch root quorum vote to the next leader; emitted by a replica in the consensus task after seeing a valid quorum proposal
107    EpochRootQuorumVoteSend(EpochRootQuorumVote<TYPES>),
108    /// A quorum proposal with the given parent leaf is validated.
109    /// The full validation checks include:
110    /// 1. The proposal is not for an old view
111    /// 2. The proposal has been correctly signed by the leader of the current view
112    /// 3. The justify QC is valid
113    /// 4. The proposal passes either liveness or safety check.
114    QuorumProposalValidated(Proposal<TYPES, QuorumProposalWrapper<TYPES>>, Leaf2<TYPES>),
115    /// A quorum proposal is missing for a view that we need.
116    QuorumProposalRequestSend(
117        ProposalRequestPayload<TYPES>,
118        <TYPES::SignatureKey as SignatureKey>::PureAssembledSignatureType,
119    ),
120    /// A quorum proposal was requested by a node for a view.
121    QuorumProposalRequestRecv(
122        ProposalRequestPayload<TYPES>,
123        <TYPES::SignatureKey as SignatureKey>::PureAssembledSignatureType,
124    ),
125    /// A quorum proposal was missing for a view. As the leader, we send a reply to the recipient with their key.
126    QuorumProposalResponseSend(
127        TYPES::SignatureKey,
128        Proposal<TYPES, QuorumProposalWrapper<TYPES>>,
129    ),
130    /// A quorum proposal was requested by a node for a view.
131    QuorumProposalResponseRecv(Proposal<TYPES, QuorumProposalWrapper<TYPES>>),
132    /// Send a DA proposal to the DA committee; emitted by the DA leader (which is the same node as the leader of view v + 1) in the DA task
133    DaProposalSend(Proposal<TYPES, DaProposal2<TYPES>>, TYPES::SignatureKey),
134    /// Send a DA vote to the DA leader; emitted by DA committee members in the DA task after seeing a valid DA proposal
135    DaVoteSend(DaVote2<TYPES>),
136    /// The next leader has collected enough votes to form a QC; emitted by the next leader in the consensus task; an internal event only
137    QcFormed(Either<QuorumCertificate<TYPES>, TimeoutCertificate<TYPES>>),
138    /// The next leader has collected enough votes to form a QC; emitted by the next leader in the consensus task; an internal event only
139    Qc2Formed(Either<QuorumCertificate2<TYPES>, TimeoutCertificate2<TYPES>>),
140    /// The next leader has collected enough votes to form an epoch root QC; emitted by the next leader in the consensus task; an internal event only
141    EpochRootQcFormed(EpochRootQuorumCertificate<TYPES>),
142    /// The next leader has collected enough votes from the next epoch nodes to form a QC; emitted by the next leader in the consensus task; an internal event only
143    NextEpochQc2Formed(Either<NextEpochQuorumCertificate2<TYPES>, TimeoutCertificate<TYPES>>),
144    /// A validator formed both a current epoch eQC and a next epoch eQC
145    ExtendedQc2Formed(QuorumCertificate2<TYPES>),
146    /// The DA leader has collected enough votes to form a DAC; emitted by the DA leader in the DA task; sent to the entire network via the networking task
147    DacSend(DaCertificate2<TYPES>, TYPES::SignatureKey),
148    /// The current view has changed; emitted by the replica in the consensus task or replica in the view sync task; received by almost all other tasks
149    ViewChange(TYPES::View, Option<TYPES::Epoch>),
150    /// The view and epoch number of the first epoch
151    SetFirstEpoch(TYPES::View, TYPES::Epoch),
152    /// Timeout for the view sync protocol; emitted by a replica in the view sync task
153    ViewSyncTimeout(TYPES::View, u64, ViewSyncPhase),
154
155    /// Receive a `ViewSyncPreCommitVote` from the network; received by a relay in the view sync task
156    ViewSyncPreCommitVoteRecv(ViewSyncPreCommitVote2<TYPES>),
157    /// Receive a `ViewSyncCommitVote` from the network; received by a relay in the view sync task
158    ViewSyncCommitVoteRecv(ViewSyncCommitVote2<TYPES>),
159    /// Receive a `ViewSyncFinalizeVote` from the network; received by a relay in the view sync task
160    ViewSyncFinalizeVoteRecv(ViewSyncFinalizeVote2<TYPES>),
161
162    /// Send a `ViewSyncPreCommitVote` from the network; emitted by a replica in the view sync task
163    ViewSyncPreCommitVoteSend(ViewSyncPreCommitVote2<TYPES>),
164    /// Send a `ViewSyncCommitVote` from the network; emitted by a replica in the view sync task
165    ViewSyncCommitVoteSend(ViewSyncCommitVote2<TYPES>),
166    /// Send a `ViewSyncFinalizeVote` from the network; emitted by a replica in the view sync task
167    ViewSyncFinalizeVoteSend(ViewSyncFinalizeVote2<TYPES>),
168
169    /// Receive a `ViewSyncPreCommitCertificate` from the network; received by a replica in the view sync task
170    ViewSyncPreCommitCertificateRecv(ViewSyncPreCommitCertificate2<TYPES>),
171    /// Receive a `ViewSyncCommitCertificate` from the network; received by a replica in the view sync task
172    ViewSyncCommitCertificateRecv(ViewSyncCommitCertificate2<TYPES>),
173    /// Receive a `ViewSyncFinalizeCertificate` from the network; received by a replica in the view sync task
174    ViewSyncFinalizeCertificateRecv(ViewSyncFinalizeCertificate2<TYPES>),
175
176    /// Send a `ViewSyncPreCommitCertificate` from the network; emitted by a relay in the view sync task
177    ViewSyncPreCommitCertificateSend(ViewSyncPreCommitCertificate2<TYPES>, TYPES::SignatureKey),
178    /// Send a `ViewSyncCommitCertificate` from the network; emitted by a relay in the view sync task
179    ViewSyncCommitCertificateSend(ViewSyncCommitCertificate2<TYPES>, TYPES::SignatureKey),
180    /// Send a `ViewSyncFinalizeCertificate` from the network; emitted by a relay in the view sync task
181    ViewSyncFinalizeCertificateSend(ViewSyncFinalizeCertificate2<TYPES>, TYPES::SignatureKey),
182
183    /// Trigger the start of the view sync protocol; emitted by view sync task; internal trigger only
184    ViewSyncTrigger(TYPES::View),
185    /// A consensus view has timed out; emitted by a replica in the consensus task; received by the view sync task; internal event only
186    Timeout(TYPES::View, Option<TYPES::Epoch>),
187    /// Receive transactions from the network
188    TransactionsRecv(Vec<TYPES::Transaction>),
189    /// Send transactions to the network
190    TransactionSend(TYPES::Transaction, TYPES::SignatureKey),
191    /// Event to send block payload commitment and metadata from DA leader to the quorum; internal event only
192    SendPayloadCommitmentAndMetadata(
193        VidCommitment,
194        BuilderCommitment,
195        <TYPES::BlockPayload as BlockPayload<TYPES>>::Metadata,
196        TYPES::View,
197        Vec1<BuilderFee<TYPES>>,
198    ),
199    /// Event when the transactions task has sequenced transactions. Contains the encoded transactions, the metadata, and the view number
200    BlockRecv(PackedBundle<TYPES>),
201    /// Send VID shares to VID storage nodes; emitted by the DA leader
202    ///
203    /// Like [`HotShotEvent::DaProposalSend`].
204    VidDisperseSend(Proposal<TYPES, VidDisperse<TYPES>>, TYPES::SignatureKey),
205    /// Vid disperse share has been received from the network; handled by the consensus task
206    ///
207    /// Like [`HotShotEvent::DaProposalRecv`].
208    VidShareRecv(
209        TYPES::SignatureKey,
210        Proposal<TYPES, VidDisperseShare<TYPES>>,
211    ),
212    /// VID share data is validated.
213    VidShareValidated(Proposal<TYPES, VidDisperseShare<TYPES>>),
214    /// Upgrade proposal has been received from the network
215    UpgradeProposalRecv(Proposal<TYPES, UpgradeProposal<TYPES>>, TYPES::SignatureKey),
216    /// Upgrade proposal has been sent to the network
217    UpgradeProposalSend(Proposal<TYPES, UpgradeProposal<TYPES>>, TYPES::SignatureKey),
218    /// Upgrade vote has been received from the network
219    UpgradeVoteRecv(UpgradeVote<TYPES>),
220    /// Upgrade vote has been sent to the network
221    UpgradeVoteSend(UpgradeVote<TYPES>),
222    /// Upgrade certificate has been sent to the network
223    UpgradeCertificateFormed(UpgradeCertificate<TYPES>),
224    /// A quorum proposal has been preliminarily validated.
225    /// The preliminary checks include:
226    /// 1. The proposal is not for an old view
227    /// 2. The proposal has been correctly signed by the leader of the current view
228    /// 3. The justify QC is valid
229    QuorumProposalPreliminarilyValidated(Proposal<TYPES, QuorumProposalWrapper<TYPES>>),
230
231    /// Send a VID request to the network; emitted to on of the members of DA committee.
232    /// Includes the data request, node's public key and signature as well as public key of DA committee who we want to send to.
233    VidRequestSend(
234        DataRequest<TYPES>,
235        // Sender
236        TYPES::SignatureKey,
237        // Recipient
238        TYPES::SignatureKey,
239    ),
240
241    /// Receive a VID request from the network; Received by a node in the DA committee.
242    /// Includes the data request and nodes public key.
243    VidRequestRecv(DataRequest<TYPES>, TYPES::SignatureKey),
244
245    /// Send a VID response to the network; emitted to the sending node.
246    /// Includes nodes public key, recipient public key, and vid disperse
247    VidResponseSend(
248        /// Sender key
249        TYPES::SignatureKey,
250        /// Recipient key
251        TYPES::SignatureKey,
252        Proposal<TYPES, VidDisperseShare<TYPES>>,
253    ),
254
255    /// Receive a VID response from the network; received by the node that triggered the VID request.
256    VidResponseRecv(
257        TYPES::SignatureKey,
258        Proposal<TYPES, VidDisperseShare<TYPES>>,
259    ),
260
261    /// A replica send us a High QC
262    HighQcRecv(
263        QuorumCertificate2<TYPES>,
264        Option<NextEpochQuorumCertificate2<TYPES>>,
265        TYPES::SignatureKey,
266    ),
267
268    /// Send our HighQc to the next leader, should go to the same leader as our vote
269    HighQcSend(
270        QuorumCertificate2<TYPES>,
271        Option<NextEpochQuorumCertificate2<TYPES>>,
272        TYPES::SignatureKey,
273        TYPES::SignatureKey,
274    ),
275
276    /// A replica sent us an extended QuorumCertificate and NextEpochQuorumCertificate
277    ExtendedQcRecv(
278        QuorumCertificate2<TYPES>,
279        NextEpochQuorumCertificate2<TYPES>,
280        TYPES::SignatureKey,
281    ),
282
283    /// Send our extended QuorumCertificate and NextEpochQuorumCertificate to all nodes in the old and new epoch
284    ExtendedQcSend(
285        QuorumCertificate2<TYPES>,
286        NextEpochQuorumCertificate2<TYPES>,
287        TYPES::SignatureKey,
288    ),
289
290    /// A replica sends us an epoch root QC
291    EpochRootQcSend(
292        EpochRootQuorumCertificate<TYPES>,
293        TYPES::SignatureKey,
294        TYPES::SignatureKey,
295    ),
296    /// A replica receives an epoch root QC
297    EpochRootQcRecv(EpochRootQuorumCertificate<TYPES>, TYPES::SignatureKey),
298    /// We decided the given leaves
299    LeavesDecided(Vec<Leaf2<TYPES>>),
300}
301
302impl<TYPES: NodeType> HotShotEvent<TYPES> {
303    #[allow(clippy::too_many_lines)]
304    /// Return the view number for a hotshot event if present
305    pub fn view_number(&self) -> Option<TYPES::View> {
306        match self {
307            HotShotEvent::QuorumVoteSend(v)
308            | HotShotEvent::QuorumVoteRecv(v)
309            | HotShotEvent::ExtendedQuorumVoteSend(v) => Some(v.view_number()),
310            HotShotEvent::EpochRootQuorumVoteRecv(v) | HotShotEvent::EpochRootQuorumVoteSend(v) => {
311                Some(v.view_number())
312            },
313            HotShotEvent::TimeoutVoteRecv(v) | HotShotEvent::TimeoutVoteSend(v) => {
314                Some(v.view_number())
315            },
316            HotShotEvent::QuorumProposalRecv(proposal, _)
317            | HotShotEvent::QuorumProposalSend(proposal, _)
318            | HotShotEvent::QuorumProposalValidated(proposal, _)
319            | HotShotEvent::QuorumProposalResponseRecv(proposal)
320            | HotShotEvent::QuorumProposalResponseSend(_, proposal)
321            | HotShotEvent::QuorumProposalPreliminarilyValidated(proposal) => {
322                Some(proposal.data.view_number())
323            },
324            HotShotEvent::DaProposalRecv(proposal, _)
325            | HotShotEvent::DaProposalValidated(proposal, _)
326            | HotShotEvent::DaProposalSend(proposal, _) => Some(proposal.data.view_number()),
327            HotShotEvent::DaVoteRecv(vote) | HotShotEvent::DaVoteSend(vote) => {
328                Some(vote.view_number())
329            },
330            HotShotEvent::QcFormed(cert) => match cert {
331                either::Left(qc) => Some(qc.view_number()),
332                either::Right(tc) => Some(tc.view_number()),
333            },
334            HotShotEvent::Qc2Formed(cert) => match cert {
335                either::Left(qc) => Some(qc.view_number()),
336                either::Right(tc) => Some(tc.view_number()),
337            },
338            HotShotEvent::NextEpochQc2Formed(cert) => match cert {
339                either::Left(qc) => Some(qc.view_number()),
340                either::Right(tc) => Some(tc.view_number()),
341            },
342            HotShotEvent::EpochRootQcFormed(root_qc) => Some(root_qc.view_number()),
343            HotShotEvent::ExtendedQc2Formed(cert) => Some(cert.view_number()),
344            HotShotEvent::ViewSyncCommitVoteSend(vote)
345            | HotShotEvent::ViewSyncCommitVoteRecv(vote) => Some(vote.view_number()),
346            HotShotEvent::ViewSyncPreCommitVoteRecv(vote)
347            | HotShotEvent::ViewSyncPreCommitVoteSend(vote) => Some(vote.view_number()),
348            HotShotEvent::ViewSyncFinalizeVoteRecv(vote)
349            | HotShotEvent::ViewSyncFinalizeVoteSend(vote) => Some(vote.view_number()),
350            HotShotEvent::ViewSyncPreCommitCertificateRecv(cert)
351            | HotShotEvent::ViewSyncPreCommitCertificateSend(cert, _) => Some(cert.view_number()),
352            HotShotEvent::ViewSyncCommitCertificateRecv(cert)
353            | HotShotEvent::ViewSyncCommitCertificateSend(cert, _) => Some(cert.view_number()),
354            HotShotEvent::ViewSyncFinalizeCertificateRecv(cert)
355            | HotShotEvent::ViewSyncFinalizeCertificateSend(cert, _) => Some(cert.view_number()),
356            HotShotEvent::SendPayloadCommitmentAndMetadata(_, _, _, view_number, ..) => {
357                Some(*view_number)
358            },
359            HotShotEvent::BlockRecv(packed_bundle) => Some(packed_bundle.view_number),
360            HotShotEvent::Shutdown
361            | HotShotEvent::TransactionSend(..)
362            | HotShotEvent::TransactionsRecv(_) => None,
363            HotShotEvent::VidDisperseSend(proposal, _) => Some(proposal.data.view_number()),
364            HotShotEvent::VidShareRecv(_, proposal) | HotShotEvent::VidShareValidated(proposal) => {
365                Some(proposal.data.view_number())
366            },
367            HotShotEvent::UpgradeProposalRecv(proposal, _)
368            | HotShotEvent::UpgradeProposalSend(proposal, _) => Some(proposal.data.view_number()),
369            HotShotEvent::UpgradeVoteRecv(vote) | HotShotEvent::UpgradeVoteSend(vote) => {
370                Some(vote.view_number())
371            },
372            HotShotEvent::QuorumProposalRequestSend(req, _)
373            | HotShotEvent::QuorumProposalRequestRecv(req, _) => Some(req.view_number),
374            HotShotEvent::ViewChange(view_number, _)
375            | HotShotEvent::ViewSyncTimeout(view_number, ..)
376            | HotShotEvent::ViewSyncTrigger(view_number)
377            | HotShotEvent::Timeout(view_number, ..) => Some(*view_number),
378            HotShotEvent::DaCertificateRecv(cert) | HotShotEvent::DacSend(cert, _) => {
379                Some(cert.view_number())
380            },
381            HotShotEvent::DaCertificateValidated(cert) => Some(cert.view_number),
382            HotShotEvent::UpgradeCertificateFormed(cert) => Some(cert.view_number()),
383            HotShotEvent::VidRequestSend(request, ..)
384            | HotShotEvent::VidRequestRecv(request, _) => Some(request.view),
385            HotShotEvent::VidResponseSend(_, _, proposal)
386            | HotShotEvent::VidResponseRecv(_, proposal) => Some(proposal.data.view_number()),
387            HotShotEvent::HighQcRecv(qc, ..)
388            | HotShotEvent::HighQcSend(qc, ..)
389            | HotShotEvent::ExtendedQcRecv(qc, ..)
390            | HotShotEvent::ExtendedQcSend(qc, ..) => Some(qc.view_number()),
391            HotShotEvent::EpochRootQcSend(cert, ..) | HotShotEvent::EpochRootQcRecv(cert, _) => {
392                Some(cert.view_number())
393            },
394            HotShotEvent::SetFirstEpoch(..) => None,
395            HotShotEvent::LeavesDecided(..) => None,
396        }
397    }
398}
399
400impl<TYPES: NodeType> Display for HotShotEvent<TYPES> {
401    #[allow(clippy::too_many_lines)]
402    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
403        match self {
404            HotShotEvent::Shutdown => write!(f, "Shutdown"),
405            HotShotEvent::QuorumProposalRecv(proposal, _) => write!(
406                f,
407                "QuorumProposalRecv(view_number={:?})",
408                proposal.data.view_number()
409            ),
410            HotShotEvent::QuorumVoteRecv(v) => {
411                write!(f, "QuorumVoteRecv(view_number={:?})", v.view_number())
412            },
413            HotShotEvent::EpochRootQuorumVoteRecv(v) => {
414                write!(
415                    f,
416                    "EpochRootQuorumVoteRecv(view_number={:?})",
417                    v.view_number()
418                )
419            },
420            HotShotEvent::EpochRootQuorumVoteSend(v) => {
421                write!(
422                    f,
423                    "EpochRootQuorumVoteSend(view_number={:?})",
424                    v.view_number()
425                )
426            },
427            HotShotEvent::ExtendedQuorumVoteSend(v) => {
428                write!(
429                    f,
430                    "ExtendedQuorumVoteSend(view_number={:?})",
431                    v.view_number()
432                )
433            },
434            HotShotEvent::TimeoutVoteRecv(v) => {
435                write!(f, "TimeoutVoteRecv(view_number={:?})", v.view_number())
436            },
437            HotShotEvent::TimeoutVoteSend(v) => {
438                write!(f, "TimeoutVoteSend(view_number={:?})", v.view_number())
439            },
440            HotShotEvent::DaProposalRecv(proposal, _) => write!(
441                f,
442                "DaProposalRecv(view_number={:?})",
443                proposal.data.view_number()
444            ),
445            HotShotEvent::DaProposalValidated(proposal, _) => write!(
446                f,
447                "DaProposalValidated(view_number={:?})",
448                proposal.data.view_number()
449            ),
450            HotShotEvent::DaVoteRecv(vote) => {
451                write!(f, "DaVoteRecv(view_number={:?})", vote.view_number())
452            },
453            HotShotEvent::DaCertificateRecv(cert) => {
454                write!(f, "DaCertificateRecv(view_number={:?})", cert.view_number())
455            },
456            HotShotEvent::DaCertificateValidated(cert) => write!(
457                f,
458                "DaCertificateValidated(view_number={:?})",
459                cert.view_number()
460            ),
461            HotShotEvent::QuorumProposalSend(proposal, _) => write!(
462                f,
463                "QuorumProposalSend(view_number={:?})",
464                proposal.data.view_number()
465            ),
466            HotShotEvent::QuorumVoteSend(vote) => {
467                write!(f, "QuorumVoteSend(view_number={:?})", vote.view_number())
468            },
469            HotShotEvent::QuorumProposalValidated(proposal, _) => write!(
470                f,
471                "QuorumProposalValidated(view_number={:?})",
472                proposal.data.view_number()
473            ),
474            HotShotEvent::DaProposalSend(proposal, _) => write!(
475                f,
476                "DaProposalSend(view_number={:?})",
477                proposal.data.view_number()
478            ),
479            HotShotEvent::DaVoteSend(vote) => {
480                write!(f, "DaVoteSend(view_number={:?})", vote.view_number())
481            },
482            HotShotEvent::QcFormed(cert) => match cert {
483                either::Left(qc) => write!(f, "QcFormed(view_number={:?})", qc.view_number()),
484                either::Right(tc) => write!(f, "QcFormed(view_number={:?})", tc.view_number()),
485            },
486            HotShotEvent::Qc2Formed(cert) => match cert {
487                either::Left(qc) => write!(f, "QcFormed2(view_number={:?})", qc.view_number()),
488                either::Right(tc) => write!(f, "QcFormed2(view_number={:?})", tc.view_number()),
489            },
490            HotShotEvent::EpochRootQcFormed(root_qc) => {
491                write!(
492                    f,
493                    "EpochRootQcFormed(view_number={:?})",
494                    root_qc.view_number()
495                )
496            },
497            HotShotEvent::NextEpochQc2Formed(cert) => match cert {
498                either::Left(qc) => {
499                    write!(f, "NextEpochQc2Formed(view_number={:?})", qc.view_number())
500                },
501                either::Right(tc) => {
502                    write!(f, "NextEpochQc2Formed(view_number={:?})", tc.view_number())
503                },
504            },
505            HotShotEvent::ExtendedQc2Formed(cert) => {
506                write!(f, "ExtendedQc2Formed(view_number={:?})", cert.view_number())
507            },
508            HotShotEvent::DacSend(cert, _) => {
509                write!(f, "DacSend(view_number={:?})", cert.view_number())
510            },
511            HotShotEvent::ViewChange(view_number, epoch_number) => {
512                write!(
513                    f,
514                    "ViewChange(view_number={view_number:?}, epoch_number={epoch_number:?})"
515                )
516            },
517            HotShotEvent::ViewSyncTimeout(view_number, ..) => {
518                write!(f, "ViewSyncTimeout(view_number={view_number:?})")
519            },
520            HotShotEvent::ViewSyncPreCommitVoteRecv(vote) => write!(
521                f,
522                "ViewSyncPreCommitVoteRecv(view_number={:?})",
523                vote.view_number()
524            ),
525            HotShotEvent::ViewSyncCommitVoteRecv(vote) => write!(
526                f,
527                "ViewSyncCommitVoteRecv(view_number={:?})",
528                vote.view_number()
529            ),
530            HotShotEvent::ViewSyncFinalizeVoteRecv(vote) => write!(
531                f,
532                "ViewSyncFinalizeVoteRecv(view_number={:?})",
533                vote.view_number()
534            ),
535            HotShotEvent::ViewSyncPreCommitVoteSend(vote) => write!(
536                f,
537                "ViewSyncPreCommitVoteSend(view_number={:?})",
538                vote.view_number()
539            ),
540            HotShotEvent::ViewSyncCommitVoteSend(vote) => write!(
541                f,
542                "ViewSyncCommitVoteSend(view_number={:?})",
543                vote.view_number()
544            ),
545            HotShotEvent::ViewSyncFinalizeVoteSend(vote) => write!(
546                f,
547                "ViewSyncFinalizeVoteSend(view_number={:?})",
548                vote.view_number()
549            ),
550            HotShotEvent::ViewSyncPreCommitCertificateRecv(cert) => {
551                write!(
552                    f,
553                    "ViewSyncPreCommitCertificateRecv(view_number={:?})",
554                    cert.view_number()
555                )
556            },
557            HotShotEvent::ViewSyncCommitCertificateRecv(cert) => {
558                write!(
559                    f,
560                    "ViewSyncCommitCertificateRecv(view_number={:?})",
561                    cert.view_number()
562                )
563            },
564            HotShotEvent::ViewSyncFinalizeCertificateRecv(cert) => {
565                write!(
566                    f,
567                    "ViewSyncFinalizeCertificateRecv(view_number={:?})",
568                    cert.view_number()
569                )
570            },
571            HotShotEvent::ViewSyncPreCommitCertificateSend(cert, _) => {
572                write!(
573                    f,
574                    "ViewSyncPreCommitCertificateSend(view_number={:?})",
575                    cert.view_number()
576                )
577            },
578            HotShotEvent::ViewSyncCommitCertificateSend(cert, _) => {
579                write!(
580                    f,
581                    "ViewSyncCommitCertificateSend(view_number={:?})",
582                    cert.view_number()
583                )
584            },
585            HotShotEvent::ViewSyncFinalizeCertificateSend(cert, _) => {
586                write!(
587                    f,
588                    "ViewSyncFinalizeCertificateSend(view_number={:?})",
589                    cert.view_number()
590                )
591            },
592            HotShotEvent::ViewSyncTrigger(view_number) => {
593                write!(f, "ViewSyncTrigger(view_number={view_number:?})")
594            },
595            HotShotEvent::Timeout(view_number, epoch) => {
596                write!(f, "Timeout(view_number={view_number:?}, epoch={epoch:?})")
597            },
598            HotShotEvent::TransactionsRecv(_) => write!(f, "TransactionsRecv"),
599            HotShotEvent::TransactionSend(..) => write!(f, "TransactionSend"),
600            HotShotEvent::SendPayloadCommitmentAndMetadata(_, _, _, view_number, ..) => {
601                write!(
602                    f,
603                    "SendPayloadCommitmentAndMetadata(view_number={view_number:?})"
604                )
605            },
606            HotShotEvent::BlockRecv(packed_bundle) => {
607                write!(f, "BlockRecv(view_number={:?})", packed_bundle.view_number)
608            },
609            HotShotEvent::VidDisperseSend(proposal, _) => write!(
610                f,
611                "VidDisperseSend(view_number={:?})",
612                proposal.data.view_number()
613            ),
614            HotShotEvent::VidShareRecv(_, proposal) => write!(
615                f,
616                "VIDShareRecv(view_number={:?})",
617                proposal.data.view_number()
618            ),
619            HotShotEvent::VidShareValidated(proposal) => write!(
620                f,
621                "VIDShareValidated(view_number={:?})",
622                proposal.data.view_number()
623            ),
624            HotShotEvent::UpgradeProposalRecv(proposal, _) => write!(
625                f,
626                "UpgradeProposalRecv(view_number={:?})",
627                proposal.data.view_number()
628            ),
629            HotShotEvent::UpgradeProposalSend(proposal, _) => write!(
630                f,
631                "UpgradeProposalSend(view_number={:?})",
632                proposal.data.view_number()
633            ),
634            HotShotEvent::UpgradeVoteRecv(vote) => {
635                write!(f, "UpgradeVoteRecv(view_number={:?})", vote.view_number())
636            },
637            HotShotEvent::UpgradeVoteSend(vote) => {
638                write!(f, "UpgradeVoteSend(view_number={:?})", vote.view_number())
639            },
640            HotShotEvent::UpgradeCertificateFormed(cert) => write!(
641                f,
642                "UpgradeCertificateFormed(view_number={:?})",
643                cert.view_number()
644            ),
645            HotShotEvent::QuorumProposalRequestSend(view_number, _) => {
646                write!(f, "QuorumProposalRequestSend(view_number={view_number:?})")
647            },
648            HotShotEvent::QuorumProposalRequestRecv(view_number, _) => {
649                write!(f, "QuorumProposalRequestRecv(view_number={view_number:?})")
650            },
651            HotShotEvent::QuorumProposalResponseSend(_, proposal) => {
652                write!(
653                    f,
654                    "QuorumProposalResponseSend(view_number={:?})",
655                    proposal.data.view_number()
656                )
657            },
658            HotShotEvent::QuorumProposalResponseRecv(proposal) => {
659                write!(
660                    f,
661                    "QuorumProposalResponseRecv(view_number={:?})",
662                    proposal.data.view_number()
663                )
664            },
665            HotShotEvent::QuorumProposalPreliminarilyValidated(proposal) => {
666                write!(
667                    f,
668                    "QuorumProposalPreliminarilyValidated(view_number={:?}",
669                    proposal.data.view_number()
670                )
671            },
672            HotShotEvent::VidRequestSend(request, ..) => {
673                write!(f, "VidRequestSend(view_number={:?}", request.view)
674            },
675            HotShotEvent::VidRequestRecv(request, _) => {
676                write!(f, "VidRequestRecv(view_number={:?}", request.view)
677            },
678            HotShotEvent::VidResponseSend(_, _, proposal) => {
679                write!(
680                    f,
681                    "VidResponseSend(view_number={:?}",
682                    proposal.data.view_number()
683                )
684            },
685            HotShotEvent::VidResponseRecv(_, proposal) => {
686                write!(
687                    f,
688                    "VidResponseRecv(view_number={:?}",
689                    proposal.data.view_number()
690                )
691            },
692            HotShotEvent::HighQcRecv(qc, ..) => {
693                write!(f, "HighQcRecv(view_number={:?}", qc.view_number())
694            },
695            HotShotEvent::HighQcSend(qc, ..) => {
696                write!(f, "HighQcSend(view_number={:?}", qc.view_number())
697            },
698            HotShotEvent::ExtendedQcRecv(qc, ..) => {
699                write!(f, "ExtendedQcRecv(view_number={:?}", qc.view_number())
700            },
701            HotShotEvent::ExtendedQcSend(qc, ..) => {
702                write!(f, "ExtendedQcSend(view_number={:?}", qc.view_number())
703            },
704            HotShotEvent::EpochRootQcSend(cert, ..) => {
705                write!(f, "EpochRootQcSend(view_number={:?}", cert.view_number())
706            },
707            HotShotEvent::EpochRootQcRecv(cert, ..) => {
708                write!(f, "EpochRootQcRecv(view_number={:?}", cert.view_number())
709            },
710            HotShotEvent::SetFirstEpoch(view, epoch) => {
711                write!(f, "SetFirstEpoch(view_number={view:?}, epoch={epoch:?})")
712            },
713            HotShotEvent::LeavesDecided(leaf) => {
714                write!(f, "LeavesDecided(leaf={leaf:?})")
715            },
716        }
717    }
718}