mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-08-26 20:01:16 +00:00
docs: reformat
This commit is contained in:
@@ -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"),
|
||||
);
|
||||
|
||||
@@ -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<u8> {
|
||||
crate::to_frame(&borsh::to_vec(self).expect("borsh serialization is infallible"))
|
||||
|
||||
@@ -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<u8> {
|
||||
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)?;
|
||||
|
||||
@@ -60,11 +60,7 @@ pub struct ProgramInput<T> {
|
||||
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<u8> {
|
||||
let mut len_bytes = [0; 4];
|
||||
|
||||
Reference in New Issue
Block a user