Conversation
|
Should we rename ‘gates’ to ‘chips’ to match the STARK vocabulary? |
| pub fn prove<SC>( | ||
| config: &SC, | ||
| asic: Asic<Val<SC>>, | ||
| all_events: AllEvents<Val<SC>>, | ||
| ) -> RecursiveProof<SC> |
There was a problem hiding this comment.
Everything ends up tightly coupled, I am wondering if we couldn't have something a bit less monolithic and also more flexible, which would make it easier on the long run to iterate and expand without these tight bindings?
There was a problem hiding this comment.
Something like this perhaps:
pub trait ProofSystem<F: Field> {
type Config;
type Asic;
type Proof;
type Error;
fn prove(&self, config: &Self::Config, asic: &Self::Asic) -> Result<Self::Proof, Self::Error>;
fn verify(&self, config: &Self::Config, proof: &Self::Proof) -> Result<(), Self::Error>;
}| pub struct CircuitBuilder<F: Field> { | ||
| wires: Vec<Option<F>>, | ||
| gate_instances: Vec<Box<dyn Gate<F>>>, | ||
| } | ||
|
|
||
| impl<F: Field> CircuitBuilder<F> { | ||
| pub fn new() -> Self { |
There was a problem hiding this comment.
These all come from plonky2 I guess, we could probably improve allocation down the line, maybe just add a TODO for now?
There was a problem hiding this comment.
It's based on Plonky2, yes, but majorly simplified, especially for the wires. For gate_instances it would be better to keep everything on the stack indeed, but I reused the (working) P2 logic. Do you believe it could be a significant overhead down the line?
There was a problem hiding this comment.
the gates would probably be too large to be on the stack efficiently, but there are still allocations that could be removed here and there
it's low prio though
| pub enum CircuitError { | ||
| InvalidWireId, | ||
| InputNotSet, | ||
| WireSetTwice, | ||
| } |
There was a problem hiding this comment.
Do you think these could be made more extensive to help debugging?
Something like
| pub enum CircuitError { | |
| InvalidWireId, | |
| InputNotSet, | |
| WireSetTwice, | |
| } | |
| pub enum CircuitError { | |
| InvalidWireId { | |
| id: WireId, | |
| air: Air, | |
| }, | |
| InputNotSet { | |
| id: WireId, | |
| air: Air, | |
| }, | |
| WireSetTwice { | |
| id: WireId, | |
| existing_value: Val, | |
| new_value: Val, | |
| }, | |
| } |
There was a problem hiding this comment.
Also, you can use thiserror crate to derive error messages like #[error("Invalid wire ID {id} for air {Air}")]
| // #[cfg(test)] | ||
| // fn do_test_m31_circle(log_blowup: usize, log_n: usize) -> Result<(), impl Debug> { |
Add also a rudimentary prover