openvm_circuit/arch/execution_mode/
mod.rs

1use crate::{arch::VmExecState, system::memory::online::GuestMemory};
2
3pub mod metered;
4pub mod metered_cost;
5mod preflight;
6mod pure;
7
8pub use metered::{ctx::MeteredCtx, segment_ctx::Segment};
9pub use metered_cost::MeteredCostCtx;
10pub use preflight::PreflightCtx;
11pub use pure::ExecutionCtx;
12
13pub trait ExecutionCtxTrait: Sized {
14    fn on_memory_operation(&mut self, address_space: u32, ptr: u32, size: u32);
15
16    fn should_suspend<F>(
17        instret: u64,
18        pc: u32,
19        _arg: u64,
20        exec_state: &mut VmExecState<F, GuestMemory, Self>,
21    ) -> bool;
22
23    fn on_terminate<F>(
24        _instret: u64,
25        _pc: u32,
26        _exec_state: &mut VmExecState<F, GuestMemory, Self>,
27    ) {
28    }
29}
30
31pub trait MeteredExecutionCtxTrait: ExecutionCtxTrait {
32    fn on_height_change(&mut self, chip_idx: usize, height_delta: u32);
33}