Skip to content

Conversation

@arijitdutta67
Copy link
Contributor

This PR implements issue(s) #

Checklist

  • I wrote new tests for my new core changes.
  • I have successfully ran tests, style checker and build against my new changes locally.
  • I have informed the team of any breaking changes if there are any.

@arijitdutta67 arijitdutta67 self-assigned this Nov 11, 2025
@arijitdutta67 arijitdutta67 added Prover Tag to use for all work impacting the prover enhancement New feature or request labels Nov 11, 2025
panic("TODO: change the MiMC queries and replace them by Poseidon. Also review the [common.NbElemPerHash] loop")

for i := 0; i < common.NbLimbU256; i++ {
for i := 0; i < common.NbElemPerHash; i++ {

Check warning

Code scanning / CodeQL

Unreachable statement Warning

This statement is unreachable.

Copilot Autofix

AI 2 days ago

To resolve the unreachable statement error, you should remove (or comment out) all code following the panic statement within the checkLeafHashes function, since it cannot execute due to the unconditional panic. Specifically, in prover/zkevm/prover/statemanager/accumulator/define.go, lines 686 through 714 (the entirety of the unreachable loop and subsequent expressions) should be removed, leaving only the panic and its comment to make it clear that this code requires future revision. This avoids misleading future readers and passes static analysis. If the code should remain for future use, it can be preserved as a multi-line comment or TODO but not as executable code.

No additional imports or methods are required for this fix.


Suggested changeset 1
prover/zkevm/prover/statemanager/accumulator/define.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/prover/zkevm/prover/statemanager/accumulator/define.go b/prover/zkevm/prover/statemanager/accumulator/define.go
--- a/prover/zkevm/prover/statemanager/accumulator/define.go
+++ b/prover/zkevm/prover/statemanager/accumulator/define.go
@@ -682,35 +682,6 @@
 	cols := am.Cols
 
 	panic("TODO: change the MiMC queries and replace them by Poseidon. Also review the [common.NbElemPerHash] loop")
-
-	for i := 0; i < common.NbElemPerHash; i++ {
-
-		// TODO: fix MiMC query
-		am.comp.InsertMiMC(am.Round, am.qname("MIMC_PREV_%d", i), cols.LeafOpenings.Prev[0], cols.Zero, cols.Interm[i][0], nil)
-		am.comp.InsertMiMC(am.Round, am.qname("MIMC_NEXT_%d", i), cols.LeafOpenings.Next[0], cols.Interm[i][0], cols.Interm[i][1], nil)
-
-		// TODO: fix MiMC query
-		am.comp.InsertMiMC(am.Round, am.qname("MIMC_HKEY"), cols.LeafOpenings.HKey[0], cols.Interm[1][0], cols.Interm[2][0], nil)
-		am.comp.InsertMiMC(am.Round, am.qname("MIMC_HVAL_LEAF_%d", i), cols.LeafOpenings.HVal[0], cols.Interm[2][0], cols.LeafHashes[i], nil)
-
-		// Global: IsActive[i] * (1 - IsEmptyLeaf[i]) * (Leaves[i] - LeafHashes[i])
-		expr1 := symbolic.Sub(cols.Leaves[i], cols.LeafHashes[i])
-		expr2 := symbolic.Sub(symbolic.NewConstant(1), cols.IsEmptyLeaf)
-		expr3 := symbolic.Mul(cols.IsActiveAccumulator, expr1, expr2)
-		am.comp.InsertGlobal(am.Round, am.qname("LEAF_HASH_EQUALITY_%d", i), expr3)
-	}
-	// Booleaninty of IsEmptyLeaf: IsActive[i] * (IsEmptyLeaf^2[i] - IsEmptyLeaf[i])
-	expr4 := symbolic.Sub(symbolic.Square(cols.IsEmptyLeaf), cols.IsEmptyLeaf)
-	expr4 = symbolic.Mul(expr4, cols.IsActiveAccumulator)
-	am.comp.InsertGlobal(am.Round, am.qname("IS_EMPTY_LEAF_BOOLEANITY"), expr4)
-
-	// IsEmptyLeaf is set to true if and only if it is the third row for INSERT, or fourth row for DELETE
-	// i.e. IsActiveAccumulator[i] * (IsEmptyLeaf[i] - IsFirst[i-2] * IsInsert[i-2] - IsFirst[i-3] * IsDelete[i-3])
-	expr5 := symbolic.Mul(cols.IsActiveAccumulator,
-		symbolic.Sub(cols.IsEmptyLeaf,
-			symbolic.Mul(column.Shift(cols.IsFirst, -2), column.Shift(cols.IsInsert, -2)),
-			symbolic.Mul(column.Shift(cols.IsFirst, -3), column.Shift(cols.IsDelete, -3))))
-	am.comp.InsertGlobal(am.Round, am.qname("IS_EMPTY_LEAF_ONE_FOR_INSERT_THIRD_ROW_AND_DELETE_FOURTH_ROW"), expr5)
 }
 
 func (am *Module) checkNextFreeNode() {
EOF
@@ -682,35 +682,6 @@
cols := am.Cols

panic("TODO: change the MiMC queries and replace them by Poseidon. Also review the [common.NbElemPerHash] loop")

for i := 0; i < common.NbElemPerHash; i++ {

// TODO: fix MiMC query
am.comp.InsertMiMC(am.Round, am.qname("MIMC_PREV_%d", i), cols.LeafOpenings.Prev[0], cols.Zero, cols.Interm[i][0], nil)
am.comp.InsertMiMC(am.Round, am.qname("MIMC_NEXT_%d", i), cols.LeafOpenings.Next[0], cols.Interm[i][0], cols.Interm[i][1], nil)

// TODO: fix MiMC query
am.comp.InsertMiMC(am.Round, am.qname("MIMC_HKEY"), cols.LeafOpenings.HKey[0], cols.Interm[1][0], cols.Interm[2][0], nil)
am.comp.InsertMiMC(am.Round, am.qname("MIMC_HVAL_LEAF_%d", i), cols.LeafOpenings.HVal[0], cols.Interm[2][0], cols.LeafHashes[i], nil)

// Global: IsActive[i] * (1 - IsEmptyLeaf[i]) * (Leaves[i] - LeafHashes[i])
expr1 := symbolic.Sub(cols.Leaves[i], cols.LeafHashes[i])
expr2 := symbolic.Sub(symbolic.NewConstant(1), cols.IsEmptyLeaf)
expr3 := symbolic.Mul(cols.IsActiveAccumulator, expr1, expr2)
am.comp.InsertGlobal(am.Round, am.qname("LEAF_HASH_EQUALITY_%d", i), expr3)
}
// Booleaninty of IsEmptyLeaf: IsActive[i] * (IsEmptyLeaf^2[i] - IsEmptyLeaf[i])
expr4 := symbolic.Sub(symbolic.Square(cols.IsEmptyLeaf), cols.IsEmptyLeaf)
expr4 = symbolic.Mul(expr4, cols.IsActiveAccumulator)
am.comp.InsertGlobal(am.Round, am.qname("IS_EMPTY_LEAF_BOOLEANITY"), expr4)

// IsEmptyLeaf is set to true if and only if it is the third row for INSERT, or fourth row for DELETE
// i.e. IsActiveAccumulator[i] * (IsEmptyLeaf[i] - IsFirst[i-2] * IsInsert[i-2] - IsFirst[i-3] * IsDelete[i-3])
expr5 := symbolic.Mul(cols.IsActiveAccumulator,
symbolic.Sub(cols.IsEmptyLeaf,
symbolic.Mul(column.Shift(cols.IsFirst, -2), column.Shift(cols.IsInsert, -2)),
symbolic.Mul(column.Shift(cols.IsFirst, -3), column.Shift(cols.IsDelete, -3))))
am.comp.InsertGlobal(am.Round, am.qname("IS_EMPTY_LEAF_ONE_FOR_INSERT_THIRD_ROW_AND_DELETE_FOURTH_ROW"), expr5)
}

func (am *Module) checkNextFreeNode() {
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Prover Tag to use for all work impacting the prover

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants