-
Notifications
You must be signed in to change notification settings - Fork 39
Don't add column for SSB with only one step type #134
Don't add column for SSB with only one step type #134
Conversation
Ready for review @leolara |
|
||
selector | ||
.selector_assignment | ||
.insert(step.uuid(), vec![(PolyExpr::Const(F::ONE), F::ONE)]); |
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.
@000wan this looks not the more readable way. I would make get_selector_assignment to return an Option, and then the code in assignment generator, could ignore this if None is returned.
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.
I agree with that. Now I modified selector_assignment
to have an Option value.
🐈 |
// don't add a column for a single step type | ||
if unit.step_types.len() == 1 { | ||
let step = unit.step_types.values().next().expect("step not found"); | ||
|
||
// use F::ONE for selector constantly on, F::ZERO for off | ||
selector | ||
.selector_expr | ||
.insert(step.uuid(), PolyExpr::Const(F::ONE)); | ||
|
||
selector | ||
.selector_expr_not | ||
.insert(step.uuid(), PolyExpr::Const(F::ZERO)); | ||
|
||
selector.selector_assignment.insert(step.uuid(), None); | ||
|
||
unit.selector = selector; | ||
return; | ||
} | ||
|
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.
I've made StepSelector to have a constant ONE for selector expression so that it selects always the same step. And it seems it's somehow working... Do you think this is an acceptable solution? @leolara
@@ -16,7 +16,7 @@ pub type SelectorAssignment<F> = (PolyExpr<F>, F); | |||
pub struct StepSelector<F> { | |||
pub selector_expr: HashMap<StepTypeUUID, PolyExpr<F>>, | |||
pub selector_expr_not: HashMap<StepTypeUUID, PolyExpr<F>>, | |||
pub selector_assignment: HashMap<StepTypeUUID, Vec<SelectorAssignment<F>>>, | |||
pub selector_assignment: HashMap<StepTypeUUID, Option<Vec<SelectorAssignment<F>>>>, |
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.
I made this Option in order to distinguish the cases where the uuid is invalid, or the uuid is valid but has no assignments.
@000wan we are in a hacker house mentoring, that is why we have not answered in so long. This PR will get merged for sure. Let me get back to you |
I didn't know you were busy.. then I'll wait for it |
@000wan so the only problem now is that if the step has more than one row, then it will be active also for the rows that is not the first row of the step. The best way to solve this is to make So currently q_enable is 1 for all rows. if we have only one step with row height 3, then q_enable should be 1,0,0,1,0,0,1,0,0,.. and so on |
03ddbb5
to
8397503
Compare
Then doesn't it require a new column for the step? |
Summary
It resolves #95.
It makes SimpleStepSelectorBuilder not add any step selector columns if there is only one step.
Further, I wrote a unit test for this (SSB with single step) and it might be helpful for #102.
Test Results
Passes all tests with
cargo test
.Runs Ok with
/examples/fibonacci.rs
,/examples/mimc7.rs
,/examples/poseidon.rs
Witness display results of
cargo run --package chiquito --example fibonacci
changed:Before:
After: