Closed GopherJ closed 1 year ago
fn configure_gadget<G: ExecutionGadget<F>>( meta: &mut ConstraintSystem<F>, advices: [Column<Advice>; STEP_WIDTH], q_usable: Selector, q_step: Column<Advice>, num_rows_until_next_step: Column<Advice>, q_step_first: Selector, q_step_last: Selector, challenges: &Challenges<Expression<F>>, step_curr: &Step<F>, height_map: &mut HashMap<ExecutionState, usize>, stored_expressions_map: &mut HashMap<ExecutionState, Vec<StoredExpression<F>>>, instrument: &mut Instrument, ) -> G { let height = { let dummy_step_next = Step::new(meta, advices, MAX_STEP_HEIGHT, true); // 使用MAX_STEP_HEIGHT创建dummy EVMConstraintBuilder let mut cb = EVMConstraintBuilder::new( step_curr.clone(), dummy_step_next, challenges, G::EXECUTION_STATE, ); // 调用gadget::configure(cb)创建gates, 创建gates的过程中会申请新的cell, height会增长 cb.annotation(G::NAME, |cb| G::configure(cb)); // 调用cb.build()来间接调用cell_manager.get_height()以计算真实用到的height let (_, _, _, height) = cb.build(); // 返回height, 销毁cell_manager, dummy EVMConstraintBuilder height }; let step_next = &Step::new(meta, advices, height, true); // 使用真实的height创建EVMConstraintBuilder, 其包含step_curr, step_next let mut cb = EVMConstraintBuilder::new( step_curr.clone(), step_next.clone(), challenges, G::EXECUTION_STATE, ); // 调用gadget::configure(cb)创建gates let gadget = cb.annotation(G::NAME, |cb| G::configure(cb)); Self::configure_gadget_impl( meta, q_usable, q_step, num_rows_until_next_step, q_step_first, q_step_last, step_curr, step_next, height_map, stored_expressions_map, instrument, G::NAME, G::EXECUTION_STATE, height, cb, ); // 返回gadget gadget }
failed to generate image for this file
failed to generate image for this file