use p3_air::BaseAir;
use p3_field::Field;
use p3_matrix::dense::RowMajorMatrix;
use crate::{septic_digest::SepticDigest, MachineRecord};
pub use sp1_derive::MachineAir;
use super::InteractionScope;
#[macro_export]
macro_rules! chip_name {
($chip:ident, $field:ty) => {
<$chip as MachineAir<$field>>::name(&$chip {})
};
}
pub trait MachineAir<F: Field>: BaseAir<F> + 'static + Send + Sync {
type Record: MachineRecord;
type Program: MachineProgram<F>;
fn name(&self) -> String;
fn num_rows(&self, _input: &Self::Record) -> Option<usize> {
None
}
fn generate_trace(&self, input: &Self::Record, output: &mut Self::Record) -> RowMajorMatrix<F>;
fn generate_dependencies(&self, input: &Self::Record, output: &mut Self::Record) {
self.generate_trace(input, output);
}
fn included(&self, shard: &Self::Record) -> bool;
fn preprocessed_width(&self) -> usize {
0
}
fn preprocessed_num_rows(&self, _program: &Self::Program, _instrs_len: usize) -> Option<usize> {
None
}
fn generate_preprocessed_trace(&self, _program: &Self::Program) -> Option<RowMajorMatrix<F>> {
None
}
fn commit_scope(&self) -> InteractionScope {
InteractionScope::Local
}
fn local_only(&self) -> bool {
false
}
}
pub trait MachineProgram<F>: Send + Sync {
fn pc_start(&self) -> F;
fn initial_global_cumulative_sum(&self) -> SepticDigest<F>;
}