-
Notifications
You must be signed in to change notification settings - Fork 0
Add simple tables #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Should we rename ‘gates’ to ‘chips’ to match the STARK vocabulary? |
recursion/src/prover/mod.rs
Outdated
| pub fn prove<SC>( | ||
| config: &SC, | ||
| asic: Asic<Val<SC>>, | ||
| all_events: AllEvents<Val<SC>>, | ||
| ) -> RecursiveProof<SC> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idk, maybe @hratoanina can tell?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove?
Add also a rudimentary prover