risc0_zkvm/host/prove_info.rs
1// Copyright 2025 RISC Zero, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Struct containing information about a prover's execution including the receipt.
16
17use serde::{Deserialize, Serialize};
18
19use crate::{receipt::GenericReceipt, Receipt, ReceiptClaim, WorkClaim};
20
21/// Information returned by the prover including receipt as well as other information useful for debugging
22#[derive(Clone, Debug, Serialize, Deserialize)]
23#[non_exhaustive]
24pub struct ProveInfo {
25 /// receipt from the computation
26 pub receipt: Receipt,
27
28 /// stats about cycle counts of the execution
29 pub stats: SessionStats,
30
31 /// Work claim receipt proving the work completed in the process of producing the proof.
32 ///
33 /// This receipt will be produced by provers that support Proof of Verifiable Work when a
34 /// [`PovwJobId`][risc0_binfmt::PovwJobId] is provided in the [`ExecutorEnv`][crate::ExecutorEnv].
35 /// This receipt provides a proof of work completed for this job, and can be combined into a
36 /// work log using the [Log Builder guest][risc0-povw].
37 ///
38 /// Note that this receipt will not be provided if the [`ProverOpts`][crate::ProverOpts] has a
39 /// compression level of [`ReceiptKind::Composite`][crate::ReceiptKind]. A
40 /// [`CompositeReceipt`][crate::CompositeReceipt] can be used to produce a work receipt by
41 /// using [`ProverServer::composite_to_succinct_povw`][crate::ProverServer].
42 pub work_receipt: Option<GenericReceipt<WorkClaim<ReceiptClaim>>>,
43}
44
45/// Struct containing information about a prover's cycle count after running the guest program
46#[derive(Clone, Debug, Serialize, Deserialize)]
47#[non_exhaustive]
48pub struct SessionStats {
49 /// Count of segments in this proof request
50 pub segments: usize,
51
52 /// Total cycles run within guest
53 pub total_cycles: u64,
54
55 /// User cycles run within guest
56 pub user_cycles: u64,
57
58 /// Paging cycles run within guest
59 pub paging_cycles: u64,
60
61 /// Reserved cycles run within guest
62 pub reserved_cycles: u64,
63}