pub struct Checkpoint {
pub epoch: u64,
pub state_root: BytesImpl<32>,
pub block_root: BytesImpl<32>,
pub block_count: u32,
pub tx_count: u64,
pub total_fees: u64,
pub prev_checkpoint: BytesImpl<32>,
pub withdrawals_root: BytesImpl<32>,
pub withdrawal_count: u32,
}Expand description
Epoch summary checkpoint: aggregate stats and Merkle roots for one L1-anchored epoch (SPEC §2.6, CKP-001).
§Field semantics (informal)
epoch: Monotonic epoch id this summary closes.state_root: Post-epoch L2 state commitment.block_root: Merkle root over block hashes in the epoch (CKP-006 will define construction).block_count/tx_count/total_fees: Scalar aggregates for light verification and scoring;block_countis the block factor incompute_score(CKP-004).prev_checkpoint: Hash / identity of the prior checkpoint header for chained verification (CKP-001 implementation notes).withdrawals_root/withdrawal_count: Merkle root and count over withdrawal records in the epoch.
Fields§
§epoch: u64Epoch number this checkpoint summarizes.
state_root: BytesImpl<32>L2 state root after applying all blocks in the epoch.
block_root: BytesImpl<32>Merkle root over block hashes included in this epoch.
block_count: u32Number of L2 blocks in the epoch.
tx_count: u64Total transactions across blocks in the epoch.
total_fees: u64Sum of fees collected in the epoch (same currency unit as receipt fees — see RCP-*).
prev_checkpoint: BytesImpl<32>Link to the previous checkpoint (continuity for fraud/validity proofs).
withdrawals_root: BytesImpl<32>Merkle root over withdrawal hashes in the epoch.
withdrawal_count: u32Number of withdrawals in the epoch.
Implementations§
Source§impl Checkpoint
impl Checkpoint
Sourcepub const HASH_PREIMAGE_LEN: usize = 160
pub const HASH_PREIMAGE_LEN: usize = 160
Byte length of the SHA-256 preimage for Self::hash (SPEC §3.2: 8+32+32+4+8+8+32+32+4).
Sourcepub fn new() -> Checkpoint
pub fn new() -> Checkpoint
Default empty checkpoint: epoch 0, zero counts, all roots Bytes32::default (CKP-001 constructor spec).
Usage: crate::builder::checkpoint_builder::CheckpointBuilder and tests start from this value then overwrite fields; production checkpoints should set non-zero roots before signing (CKP-005 / HSH-002).
Sourcepub fn compute_score(&self, stake_percentage: u64) -> u64
pub fn compute_score(&self, stake_percentage: u64) -> u64
Competition score: stake_percentage * block_count (CKP-004, NORMATIVE § CKP-004).
§Parameters
stake_percentage: Integer stake share for the submitter, typically0..=100(CKP-004 implementation notes). The type isu64so callers can scale fixed-point stake if needed without API churn.
§Returns
Product in u64. Favors checkpoints with more blocks and higher backing stake. Overflow: Uses ordinary
u64 multiplication (wraps on overflow; debug builds may panic on overflow — keep inputs within protocol bounds,
e.g. epoch length ×100).
Sourcepub fn hash_preimage_bytes(&self) -> [u8; 160]
pub fn hash_preimage_bytes(&self) -> [u8; 160]
Fixed-order 160-byte preimage for HSH-002 /
SPEC §3.2 (same bytes as fed to Self::hash).
Order: epoch, state_root, block_root, block_count, tx_count, total_fees, prev_checkpoint,
withdrawals_root, withdrawal_count.
Note: HSH-002 spec pseudocode lists some counts as u64;
the wire table in SPEC §3.2 and this struct use u32 LE for block_count and withdrawal_count (4 bytes each).
Sourcepub fn hash(&self) -> BytesImpl<32>
pub fn hash(&self) -> BytesImpl<32>
Canonical checkpoint identity: SHA-256 over Self::hash_preimage_bytes (SPEC §3.2).
Encoding: epoch, tx_count, total_fees as u64 LE; block_count, withdrawal_count as u32 LE
(4 bytes each); four Bytes32 roots as raw 32-byte slices (HSH-002,
NORMATIVE § HSH-002).
Primitive: Sha256 from chia-sha2 only (project crypto rules). CheckpointSubmission::hash delegates here (CKP-005).
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serialize checkpoint summary to bincode bytes (SER-002, SPEC §8.2).
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Checkpoint, CheckpointError>
pub fn from_bytes(bytes: &[u8]) -> Result<Checkpoint, CheckpointError>
Deserialize a checkpoint from bincode bytes (SER-002).
Trait Implementations§
Source§impl Clone for Checkpoint
impl Clone for Checkpoint
Source§fn clone(&self) -> Checkpoint
fn clone(&self) -> Checkpoint
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Checkpoint
impl Debug for Checkpoint
Source§impl Default for Checkpoint
impl Default for Checkpoint
Source§fn default() -> Checkpoint
fn default() -> Checkpoint
Source§impl<'de> Deserialize<'de> for Checkpoint
impl<'de> Deserialize<'de> for Checkpoint
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Checkpoint, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Checkpoint, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for Checkpoint
impl PartialEq for Checkpoint
Source§impl Serialize for Checkpoint
impl Serialize for Checkpoint
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for Checkpoint
impl StructuralPartialEq for Checkpoint
Auto Trait Implementations§
impl Freeze for Checkpoint
impl RefUnwindSafe for Checkpoint
impl Send for Checkpoint
impl Sync for Checkpoint
impl Unpin for Checkpoint
impl UnsafeUnpin for Checkpoint
impl UnwindSafe for Checkpoint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.