sui_types/
executable_transaction.rs1use crate::crypto::AccountKeyPair;
5use crate::messages_checkpoint::CheckpointSequenceNumber;
6use crate::utils::to_sender_signed_transaction;
7use crate::{committee::EpochId, crypto::AuthorityStrongQuorumSignInfo};
8
9use crate::message_envelope::{Envelope, TrustedEnvelope, VerifiedEnvelope};
10use crate::transaction::{
11 SenderSignedData, TransactionData, TransactionDataAPI, VerifiedTransaction,
12};
13use serde::{Deserialize, Serialize};
14
15#[derive(Clone, Debug, Serialize, Deserialize)]
18pub enum CertificateProof {
19 Checkpoint(EpochId, CheckpointSequenceNumber),
21 Certified(AuthorityStrongQuorumSignInfo),
23 QuorumExecuted(EpochId),
27 SystemTransaction(EpochId),
29 Consensus(EpochId),
31}
32
33impl CertificateProof {
34 pub fn new_from_cert_sig(sig: AuthorityStrongQuorumSignInfo) -> Self {
35 Self::Certified(sig)
36 }
37
38 pub fn new_from_checkpoint(epoch: EpochId, checkpoint: CheckpointSequenceNumber) -> Self {
39 Self::Checkpoint(epoch, checkpoint)
40 }
41
42 pub fn new_system(epoch: EpochId) -> Self {
43 Self::SystemTransaction(epoch)
44 }
45
46 pub fn new_from_consensus(epoch: EpochId) -> Self {
47 Self::Consensus(epoch)
48 }
49
50 pub fn epoch(&self) -> EpochId {
51 match self {
52 Self::Checkpoint(epoch, _)
53 | Self::QuorumExecuted(epoch)
54 | Self::SystemTransaction(epoch)
55 | Self::Consensus(epoch) => *epoch,
56 Self::Certified(sig) => sig.epoch,
57 }
58 }
59}
60
61pub type ExecutableTransaction = Envelope<SenderSignedData, CertificateProof>;
66pub type VerifiedExecutableTransaction = VerifiedEnvelope<SenderSignedData, CertificateProof>;
67pub type TrustedExecutableTransaction = TrustedEnvelope<SenderSignedData, CertificateProof>;
68
69impl VerifiedExecutableTransaction {
70 pub fn gas_budget(&self) -> u64 {
71 self.data().transaction_data().gas_budget()
72 }
73
74 pub fn new_for_testing(tx_data: TransactionData, keypair: &AccountKeyPair) -> Self {
75 let tx = to_sender_signed_transaction(tx_data, keypair);
76 Self::new_from_quorum_execution(VerifiedTransaction::new_unchecked(tx), 0)
77 }
78}