sui_jsonrpc/msgs/
sui_checkpoint.rs

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