From cce1753bb0b88c73dbb8af17281d7935778dd0ea Mon Sep 17 00:00:00 2001 From: agureev Date: Thu, 20 Aug 2026 20:23:21 +0400 Subject: [PATCH] docs: reformat --- .../src/execution_state.rs | 3 +-- lee/state_machine/core/src/circuit_io.rs | 3 --- lee/state_machine/core/src/frame.rs | 14 +++++--------- lee/state_machine/core/src/program/mod.rs | 13 +++---------- 4 files changed, 9 insertions(+), 24 deletions(-) diff --git a/lee/privacy_preserving_circuit/src/execution_state.rs b/lee/privacy_preserving_circuit/src/execution_state.rs index 11c698c5f..c138ebb72 100644 --- a/lee/privacy_preserving_circuit/src/execution_state.rs +++ b/lee/privacy_preserving_circuit/src/execution_state.rs @@ -154,8 +154,7 @@ impl ExecutionState { ); // Check that `program_output` is consistent with the execution of the corresponding - // program. The reconstructed journal frame must byte-match what the program guest - // committed via `ProgramOutput::write`, so the recursion assumption resolves. + // program. let program_output_frame = lee_core::to_frame( &borsh::to_vec(&program_output).expect("borsh serialization is infallible"), ); diff --git a/lee/state_machine/core/src/circuit_io.rs b/lee/state_machine/core/src/circuit_io.rs index f620b8f48..6afab5813 100644 --- a/lee/state_machine/core/src/circuit_io.rs +++ b/lee/state_machine/core/src/circuit_io.rs @@ -193,9 +193,6 @@ impl PrivacyPreservingCircuitOutput { #[cfg(feature = "host")] impl PrivacyPreservingCircuitOutput { /// Serializes the circuit output to the exact journal byte sequence the circuit guest commits. - /// - /// `Receipt::new(inner, to_bytes())` must reconstruct the committed journal for verification, - /// so this mirrors `main.rs`'s `commit_slice(to_frame(borsh))` byte-for-byte. #[must_use] pub fn to_bytes(&self) -> Vec { crate::to_frame(&borsh::to_vec(self).expect("borsh serialization is infallible")) diff --git a/lee/state_machine/core/src/frame.rs b/lee/state_machine/core/src/frame.rs index d5bf655a5..6edb5a11a 100644 --- a/lee/state_machine/core/src/frame.rs +++ b/lee/state_machine/core/src/frame.rs @@ -1,10 +1,8 @@ -//! Length-prefixed byte framing for the zkVM I/O boundary. +//! Length-prefixed byte framing for the zkVM I/O format. //! //! A frame is a 4-byte little-endian length prefix followed by the payload bytes. The same //! [`to_frame`] layout is used by the guest journal commit, the circuit's `env::verify` -//! reconstruction, and the host input write, so all sides agree on the exact byte sequence and the -//! recursion journal digests match. [`from_frame`] recovers the payload on the host, ignoring any -//! trailing transport bytes beyond the prefixed length. +//! reconstruction, and the host input write. /// Frames `payload` as a 4-byte little-endian length prefix followed by the payload bytes. #[must_use] @@ -15,12 +13,10 @@ pub fn to_frame(payload: &[u8]) -> Vec { framed } -/// Returns the payload slice of a frame produced by [`to_frame`], ignoring any bytes past the -/// prefixed length (e.g. transport word-alignment padding). +/// Returns the payload slice of a frame produced by [`to_frame`]. /// -/// Returns `None` if `bytes` is shorter than the 4-byte length prefix or the prefixed length -/// exceeds the available payload; callers decoding untrusted journals must treat `None` as a -/// rejection rather than panicking. +/// Returns `None` if `bytes` is shorter than the 4-bytes or the prefixed length +/// exceeds the available payload. #[must_use] pub fn from_frame(bytes: &[u8]) -> Option<&[u8]> { let (len_bytes, payload) = bytes.split_at_checked(4)?; diff --git a/lee/state_machine/core/src/program/mod.rs b/lee/state_machine/core/src/program/mod.rs index ac2c85c46..a77d36f7b 100644 --- a/lee/state_machine/core/src/program/mod.rs +++ b/lee/state_machine/core/src/program/mod.rs @@ -60,11 +60,7 @@ pub struct ProgramInput { pub instruction: T, } -/// Borsh-encoded header written to the guest as a single length-prefixed frame. -/// -/// Carries the program identity and pre-states alongside the borsh-encoded `instruction_data` -/// bytes; the instruction `T` is decoded from `instruction_data` via `borsh::from_slice`. -/// This is the wire form of [`ProgramInput`], which instead holds the already-decoded instruction. +/// Struct encoding the input to an LEE program. #[derive(BorshSerialize, BorshDeserialize)] pub struct LeeInputHeader { pub self_program_id: ProgramId, @@ -699,11 +695,8 @@ pub fn compute_public_authorized_pdas( .collect() } -/// Reads a length-prefixed frame from the guest's stdin. -/// -/// A 4-byte little-endian length followed by that many payload bytes: the host `to_frame` layout, -/// read via the stable `read_slice` API rather than the `#[stability::unstable]` `env::read_frame`. -/// Shared by the program input read and the privacy circuit's own input read. +/// Reads first 4 bytes indicating the length in bytes of the program input bytes. +/// Afterwards, reads the exact number of frames in the header. #[must_use] pub fn read_input_frame() -> Vec { let mut len_bytes = [0; 4];