Skip to content

Commit fe9ebeb

Browse files
committed
types: add CheckpointSummary type
1 parent 2d45e9f commit fe9ebeb

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

src/types/checkpoint.rs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
use super::Bls12381PublicKey;
2+
use super::CheckpointContentsDigest;
3+
use super::CheckpointDigest;
4+
use super::Digest;
5+
use super::GasCostSummary;
6+
7+
pub type CheckpointSequenceNumber = u64;
8+
pub type CheckpointTimestamp = u64;
9+
pub type EpochId = u64;
10+
pub type StakeUnit = u64;
11+
pub type ProtocolVersion = u64;
12+
13+
#[derive(Clone, Debug, PartialEq, Eq)]
14+
pub enum CheckpointCommitment {
15+
ECMHLiveObjectSetDigest(Digest),
16+
// Other commitment types (e.g. merkle roots) go here.
17+
}
18+
19+
#[derive(Clone, Debug, PartialEq, Eq)]
20+
pub struct EndOfEpochData {
21+
/// next_epoch_committee is `Some` if and only if the current checkpoint is
22+
/// the last checkpoint of an epoch.
23+
/// Therefore next_epoch_committee can be used to pick the last checkpoint of an epoch,
24+
/// which is often useful to get epoch level summary stats like total gas cost of an epoch,
25+
/// or the total number of transactions from genesis to the end of an epoch.
26+
/// The committee is stored as a vector of validator pub key and stake pairs. The vector
27+
/// should be sorted based on the Committee data structure.
28+
pub next_epoch_committee: Vec<(Bls12381PublicKey, StakeUnit)>,
29+
30+
/// The protocol version that is in effect during the epoch that starts immediately after this
31+
/// checkpoint.
32+
pub next_epoch_protocol_version: ProtocolVersion,
33+
34+
/// Commitments to epoch specific state (e.g. live object set)
35+
pub epoch_commitments: Vec<CheckpointCommitment>,
36+
}
37+
38+
#[derive(Clone, Debug, PartialEq, Eq)]
39+
pub struct CheckpointSummary {
40+
pub epoch: EpochId,
41+
pub sequence_number: CheckpointSequenceNumber,
42+
/// Total number of transactions committed since genesis, including those in this
43+
/// checkpoint.
44+
pub network_total_transactions: u64,
45+
pub content_digest: CheckpointContentsDigest,
46+
pub previous_digest: Option<CheckpointDigest>,
47+
/// The running total gas costs of all transactions included in the current epoch so far
48+
/// until this checkpoint.
49+
pub epoch_rolling_gas_cost_summary: GasCostSummary,
50+
51+
/// Timestamp of the checkpoint - number of milliseconds from the Unix epoch
52+
/// Checkpoint timestamps are monotonic, but not strongly monotonic - subsequent
53+
/// checkpoints can have same timestamp if they originate from the same underlining consensus commit
54+
pub timestamp_ms: CheckpointTimestamp,
55+
56+
/// Commitments to checkpoint-specific state (e.g. txns in checkpoint, objects read/written in
57+
/// checkpoint).
58+
pub checkpoint_commitments: Vec<CheckpointCommitment>,
59+
60+
/// Present only on the final checkpoint of the epoch.
61+
pub end_of_epoch_data: Option<EndOfEpochData>,
62+
63+
/// CheckpointSummary is not an evolvable structure - it must be readable by any version of the
64+
/// code. Therefore, in order to allow extensions to be added to CheckpointSummary, we allow
65+
/// opaque data to be added to checkpoints which can be deserialized based on the current
66+
/// protocol version.
67+
pub version_specific_data: Vec<u8>,
68+
}

src/types/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
mod address;
2+
mod checkpoint;
23
mod crypto;
34
mod digest;
45
mod gas;
56
mod object_id;
67

78
pub use address::Address;
9+
pub use checkpoint::{CheckpointCommitment, CheckpointSummary, EndOfEpochData};
810
pub use crypto::{
911
Bls12381PrivateKey, Bls12381PublicKey, Bls12381Signature, Ed25519PrivateKey, Ed25519PublicKey,
1012
Ed25519Signature, Secp256k1PrivateKey, Secp256k1PublicKey, Secp256k1Signature,

0 commit comments

Comments
 (0)