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