sui_json_rpc_types/
sui_checkpoint.rs1use crate::Page;
5use fastcrypto::encoding::Base64;
6use schemars::JsonSchema;
7use serde::{Deserialize, Serialize};
8use serde_with::serde_as;
9use sui_types::base_types::TransactionDigest;
10use sui_types::committee::EpochId;
11use sui_types::crypto::AggregateAuthoritySignature;
12use sui_types::digests::CheckpointDigest;
13use sui_types::gas::GasCostSummary;
14use sui_types::message_envelope::Message;
15use sui_types::messages_checkpoint::{
16 CheckpointCommitment, CheckpointContents, CheckpointSequenceNumber, CheckpointSummary,
17 CheckpointTimestamp, EndOfEpochData,
18};
19use sui_types::sui_serde::BigInt;
20pub type CheckpointPage = Page<Checkpoint, BigInt<u64>>;
21
22#[serde_as]
23#[derive(Clone, Debug, JsonSchema, Serialize, Deserialize, PartialEq, Eq)]
24#[serde(rename_all = "camelCase")]
25pub struct Checkpoint {
26 #[schemars(with = "BigInt<u64>")]
28 #[serde_as(as = "BigInt<u64>")]
29 pub epoch: EpochId,
30 #[schemars(with = "BigInt<u64>")]
32 #[serde_as(as = "BigInt<u64>")]
33 pub sequence_number: CheckpointSequenceNumber,
34 pub digest: CheckpointDigest,
36 #[schemars(with = "BigInt<u64>")]
39 #[serde_as(as = "BigInt<u64>")]
40 pub network_total_transactions: u64,
41 #[serde(skip_serializing_if = "Option::is_none")]
43 pub previous_digest: Option<CheckpointDigest>,
44 pub epoch_rolling_gas_cost_summary: GasCostSummary,
47 #[schemars(with = "BigInt<u64>")]
51 #[serde_as(as = "BigInt<u64>")]
52 pub timestamp_ms: CheckpointTimestamp,
53 #[serde(skip_serializing_if = "Option::is_none")]
55 pub end_of_epoch_data: Option<EndOfEpochData>,
56 pub transactions: Vec<TransactionDigest>,
58
59 pub checkpoint_commitments: Vec<CheckpointCommitment>,
61 #[schemars(with = "Base64")]
63 pub validator_signature: AggregateAuthoritySignature,
65}
66
67impl
68 From<(
69 CheckpointSummary,
70 CheckpointContents,
71 AggregateAuthoritySignature,
72 )> for Checkpoint
73{
74 fn from(
75 (summary, contents, signature): (
76 CheckpointSummary,
77 CheckpointContents,
78 AggregateAuthoritySignature,
79 ),
80 ) -> Self {
81 let digest = summary.digest();
82 let CheckpointSummary {
83 epoch,
84 sequence_number,
85 network_total_transactions,
86 previous_digest,
87 epoch_rolling_gas_cost_summary,
88 timestamp_ms,
89 end_of_epoch_data,
90 ..
91 } = summary;
92
93 Checkpoint {
94 epoch,
95 sequence_number,
96 digest,
97 network_total_transactions,
98 previous_digest,
99 epoch_rolling_gas_cost_summary,
100 timestamp_ms,
101 end_of_epoch_data,
102 transactions: contents.iter().map(|digest| digest.transaction).collect(),
103 checkpoint_commitments: Default::default(),
107 validator_signature: signature,
108 }
109 }
110}
111
112#[serde_as]
113#[derive(Clone, Copy, Debug, JsonSchema, Serialize, Deserialize)]
114#[serde(untagged)]
115pub enum CheckpointId {
116 SequenceNumber(
117 #[schemars(with = "BigInt<u64>")]
118 #[serde_as(as = "BigInt<u64>")]
119 CheckpointSequenceNumber,
120 ),
121 Digest(CheckpointDigest),
122}
123
124impl From<CheckpointSequenceNumber> for CheckpointId {
125 fn from(seq: CheckpointSequenceNumber) -> Self {
126 Self::SequenceNumber(seq)
127 }
128}
129
130impl From<CheckpointDigest> for CheckpointId {
131 fn from(digest: CheckpointDigest) -> Self {
132 Self::Digest(digest)
133 }
134}