Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
address comments by fixing gamme position bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hero78119 committed Oct 20, 2023
1 parent d6be453 commit c9a1695
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion bus-mapping/src/circuit_input_builder/input_state_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct CircuitInputStateRef<'a> {
pub block: &'a mut Block,
/// Block Context
pub block_ctx: &'a mut BlockContext,
/// Block Context
/// Chunk Context
pub chunk_ctx: &'a mut ChunkContext,
/// Transaction
pub tx: &'a mut Transaction,
Expand Down
20 changes: 11 additions & 9 deletions gadgets/src/permutation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub struct PermutationChipConfig<F> {
_phantom: PhantomData<F>,
}

/// (alpha, gamma, prev_acc_fingerprints, next_acc_fingerprints)
type PermutationAssignedCells<F> = (
AssignedCell<F, F>,
AssignedCell<F, F>,
Expand All @@ -59,10 +60,11 @@ impl<F: Field> PermutationChipConfig<F> {
let fingerprints =
get_permutation_fingerprints(col_values, alpha, gamma, acc_fingerprints_prev);

// power_of_gamma start from gamma**1
let power_of_gamma = {
let num_of_col = col_values.get(0).map(|row| row.len()).unwrap_or_default();
std::iter::successors(Some(Value::known(F::ONE)), |prev| (*prev * gamma).into())
.take(num_of_col)
std::iter::successors(Some(gamma), |prev| (*prev * gamma).into())
.take(num_of_col.saturating_sub(1))
.collect::<Vec<Value<F>>>()
};

Expand Down Expand Up @@ -101,7 +103,7 @@ impl<F: Field> PermutationChipConfig<F> {
let gamma_cells = self
.power_of_gamma
.iter()
.zip(power_of_gamma.iter())
.zip_eq(power_of_gamma.iter())
.map(|(col, value)| {
region.assign_advice(
|| format!("gamma at index {}", offset),
Expand Down Expand Up @@ -149,12 +151,12 @@ impl<F: Field> PermutationChipConfig<F> {
]
.iter()
.cloned()
.chain(
self.power_of_gamma
.iter()
.enumerate()
.map(|(i, col)| (*col, format!("GADGETS_PermutationChipConfig_gamma_{}", i))),
)
.chain(self.power_of_gamma.iter().enumerate().map(|(i, col)| {
(
*col,
format!("GADGETS_PermutationChipConfig_gamma_{}", i + 1),
)
}))
.for_each(|(col, ann)| region.name_column(|| format!("{}_{}", prefix, ann), col));
}
}
Expand Down
4 changes: 2 additions & 2 deletions zkevm-circuits/src/evm_circuit/execution/begin_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
const EXECUTION_STATE: ExecutionState = ExecutionState::BeginTx;

fn configure(cb: &mut EVMConstraintBuilder<F>) -> Self {
// constraint rwc at step first
cb.step_first_constraint_rwc();
// TODO constraint rwc at step first
// cb.step_first_constraint_rwc();

// Use rw_counter of the step which triggers next call as its call_id.
let call_id = cb.curr.state.rw_counter.clone();
Expand Down
4 changes: 2 additions & 2 deletions zkevm-circuits/src/witness/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ pub fn block_convert<F: Field>(
eth_block: block.eth_block.clone(),

// TODO get permutation fingerprint & challenges
permu_alpha: F::from(1),
permu_gamma: F::from(1),
permu_alpha: F::from(103),
permu_gamma: F::from(101),
permu_rwtable_prev_continuous_fingerprint: F::from(1),
permu_rwtable_next_continuous_fingerprint: F::from(1),
permu_chronological_rwtable_prev_continuous_fingerprint: F::from(1),
Expand Down

0 comments on commit c9a1695

Please sign in to comment.