sui_jsonrpc/msgs/
sui_checkpoint.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use serde::{Deserialize, Serialize};
5use serde_with::serde_as;
6use sui_sdk_types::{
7    CheckpointCommitment,
8    CheckpointSequenceNumber,
9    CheckpointTimestamp,
10    Digest,
11    EndOfEpochData,
12    EpochId,
13    GasCostSummary,
14};
15
16use super::Page;
17use crate::serde::{BigInt, GasCostSummaryJson};
18
19pub type CheckpointPage = Page<Checkpoint, BigInt<u64>>;
20
21#[serde_as]
22#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
23#[serde(rename_all = "camelCase")]
24pub struct Checkpoint {
25    /// Checkpoint's epoch ID
26    #[serde_as(as = "BigInt<u64>")]
27    pub epoch: EpochId,
28    /// Checkpoint sequence number
29    #[serde_as(as = "BigInt<u64>")]
30    pub sequence_number: CheckpointSequenceNumber,
31    /// Checkpoint digest
32    pub digest: Digest,
33    /// Total number of transactions committed since genesis, including those in this
34    /// checkpoint.
35    #[serde_as(as = "BigInt<u64>")]
36    pub network_total_transactions: u64,
37    /// Digest of the previous checkpoint
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub previous_digest: Option<Digest>,
40    /// The running total gas costs of all transactions included in the current epoch so far
41    /// until this checkpoint.
42    #[serde_as(as = "serde_with::FromInto<GasCostSummaryJson>")]
43    pub epoch_rolling_gas_cost_summary: GasCostSummary,
44    /// Timestamp of the checkpoint - number of milliseconds from the Unix epoch
45    /// Checkpoint timestamps are monotonic, but not strongly monotonic - subsequent
46    /// checkpoints can have same timestamp if they originate from the same underlining consensus commit
47    #[serde_as(as = "BigInt<u64>")]
48    pub timestamp_ms: CheckpointTimestamp,
49    /// Present only on the final checkpoint of the epoch.
50    #[serde(skip_serializing_if = "Option::is_none")]
51    pub end_of_epoch_data: Option<EndOfEpochData>,
52    /// Transaction digests
53    pub transactions: Vec<Digest>,
54
55    /// Commitments to checkpoint state
56    pub checkpoint_commitments: Vec<CheckpointCommitment>,
57    /// Validator Signature
58    pub validator_signature: sui_sdk_types::Bls12381Signature,
59}
60
61#[serde_as]
62#[derive(Clone, Copy, Debug, Serialize, Deserialize, derive_more::From)]
63#[serde(untagged)]
64pub enum CheckpointId {
65    SequenceNumber(#[serde_as(as = "BigInt<u64>")] CheckpointSequenceNumber),
66    Digest(Digest),
67}