Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/riscv/lib/src/pvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub mod durable_storage;
pub mod hooks;
pub(crate) mod linux;
pub mod node_pvm;
mod outbox;
pub mod outbox;
mod reveals;
mod tezos;

Expand Down
19 changes: 18 additions & 1 deletion src/riscv/lib/src/pvm/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ use tezos_smart_rollup_constants::riscv::SbiError;
use super::durable_storage::DurableStorage;
use super::linux;
use super::outbox::Outbox;
use super::outbox::OutboxProof;
use super::outbox::OutboxProofError;
use super::outbox::OutputInfo;
use super::reveals::RevealRequest;
use crate::default::ConstDefault;
use crate::machine_state;
Expand Down Expand Up @@ -109,11 +112,11 @@ pub(crate) type PvmProve<'a, MC, DS> = Pvm<MC, EmptyPageCache, DS, Prove<'a>>;
/// Proof-generating virtual machine
#[perfect_derive(Clone, PartialEq, Eq)]
pub struct Pvm<MC: MemoryConfig, PC, DS, M: Mode> {
pub(crate) system_state: linux::SupervisorState<M>,
pub(crate) machine_state: machine_state::MachineState<MC, PC, M>,
pub(crate) durable_storage: DS,
pub(crate) outbox: Outbox<M>,
pub(crate) reveal_request: RevealRequest<M>,
pub(crate) system_state: linux::SupervisorState<M>,
version: Atom<u64, M>,
pub(crate) tick: Atom<u64, M>,
pub(crate) message_counter: Atom<u64, M>,
Expand Down Expand Up @@ -374,6 +377,20 @@ where

Ok(proof)
}

/// Produce an outbox proof by recording the Merkle proof of a state transition
/// in which the outbox message at the given level and index is read.
pub(crate) fn produce_outbox_proof(
&self,
output_info: OutputInfo,
) -> Result<OutboxProof, OutboxProofError> {
let proof_output = self.get_outbox_message(output_info)?;

let merkle_tree = MerkleTree::from_foldable(self);
let merkle_proof: MerkleProof = merkle_tree.compress();

Ok(OutboxProof::new(merkle_proof, proof_output.info))
}
}

impl<'normal, MC: MemoryConfig, PC: PageCache<MC, Normal>, DS: Provable<'normal>> Provable<'normal>
Expand Down
17 changes: 17 additions & 0 deletions src/riscv/lib/src/pvm/node_pvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ use thiserror::Error;
use super::Pvm;
use super::durable_storage::DurableStorage;
use super::durable_storage::DurableStorageDummy;
use super::outbox::OutboxProof;
use super::outbox::OutboxProofError;
use super::outbox::OutputInfo;
use crate::machine_state::page_cache::EmptyPageCache;
use crate::machine_state::page_cache::PageCache;
use crate::machine_state::page_cache::PageCacheInterpreted;
Expand Down Expand Up @@ -210,6 +213,20 @@ impl<PC: PageCache<NodePvmMemConfig, Normal>, DS: DurableStorage<Normal>> NodePv
let proof = proof_state.produce_proof().ok()?;
Some(proof)
}

/// Produce an outbox proof by recording the Merkle proof of a state transition
/// in which the outbox message at the given level and index is read.
pub fn produce_outbox_proof<'normal>(
&'normal self,
output_info: OutputInfo,
) -> Result<OutboxProof, OutboxProofError>
where
DS: Provable<'normal>,
DS::Prover: DurableStorage<Prove<'normal>> + Foldable<HashFold> + Foldable<MerkleTreeFold>,
{
let proof_state = self.state.start_proof();
proof_state.produce_outbox_proof(output_info)
}
}

impl<DS: DurableStorage<Verify>> NodePvm<Verify, EmptyPageCache, DS> {
Expand Down
Loading
Loading