Skip to content

Add simple tables#2

Draft
4l0n50 wants to merge 16 commits intomainfrom
alonso/simple_tables
Draft

Add simple tables#2
4l0n50 wants to merge 16 commits intomainfrom
alonso/simple_tables

Conversation

@4l0n50
Copy link
Copy Markdown

@4l0n50 4l0n50 commented Aug 25, 2025

Add also a rudimentary prover

@sai-deng
Copy link
Copy Markdown

Should we rename ‘gates’ to ‘chips’ to match the STARK vocabulary?

Comment thread recursion/src/prover/mod.rs Outdated
Comment on lines +14 to +18
pub fn prove<SC>(
config: &SC,
asic: Asic<Val<SC>>,
all_events: AllEvents<Val<SC>>,
) -> RecursiveProof<SC>
Copy link
Copy Markdown

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?

Copy link
Copy Markdown

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>;
}

Comment thread recursion/src/air/alu/cols.rs Outdated
Comment on lines +9 to +15
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 {
Copy link
Copy Markdown

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?

Copy link
Copy Markdown
Author

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?

Copy link
Copy Markdown

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?

Copy link
Copy Markdown

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

Comment thread recursion/src/air/fillable_cols.rs Outdated
Comment thread recursion/src/air/witness_air.rs Outdated
Comment on lines +75 to +79
pub enum CircuitError {
InvalidWireId,
InputNotSet,
WireSetTwice,
}
Copy link
Copy Markdown

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

Suggested change
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,
},
}

Copy link
Copy Markdown

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}")]

Comment on lines +481 to +482
// #[cfg(test)]
// fn do_test_m31_circle(log_blowup: usize, log_n: usize) -> Result<(), impl Debug> {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove?

Comment thread recursion/src/air/alu/air.rs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants