diff --git a/light-prover/prover/batch_address_update.go b/light-prover/prover/batch_address_update.go index 70377ca355..6ee2734650 100644 --- a/light-prover/prover/batch_address_update.go +++ b/light-prover/prover/batch_address_update.go @@ -49,8 +49,10 @@ func (circuit *BatchAddressTreeAppendCircuit) Define(api frontend.API) error { api.Println("LowElementProofs[", i, "]: ", circuit.LowElementProofs[i]) } - startIndexBits := api.ToBinary(circuit.StartIndex, int(circuit.TreeHeight)) + indexBits := api.ToBinary(circuit.StartIndex, int(circuit.TreeHeight)) for i := uint32(0); i < circuit.BatchSize; i++ { + api.Println("indexBits: ", indexBits) + api.Println("LowElementValues[", i, "]: ", circuit.LowElementValues[i]) api.Println("LowElementNextIndices[", i, "]: ", circuit.LowElementNextIndices[i]) api.Println("LowElementNextValues[", i, "]: ", circuit.LowElementNextValues[i]) @@ -101,17 +103,17 @@ func (circuit *BatchAddressTreeAppendCircuit) Define(api frontend.API) error { OldRoot: currentRoot, OldLeaf: getZeroValue(0), NewLeaf: newLeafHash, - PathIndex: startIndexBits, + PathIndex: indexBits, MerkleProof: circuit.NewElementProofs[i], Height: int(circuit.TreeHeight), }) api.Println("CurrentRoot: ", currentRoot) - startIndexBits = incrementBits( + indexBits = incrementBits( api, - startIndexBits, + indexBits, ) - api.Println("StartIndexBits: ", startIndexBits) + api.Println("Incremented indexBits: ", indexBits) } api.AssertIsEqual(circuit.NewRoot, currentRoot) diff --git a/light-prover/prover/batch_address_update_test.go b/light-prover/prover/batch_address_update_test.go index f5001b6a61..72e76f0f0d 100644 --- a/light-prover/prover/batch_address_update_test.go +++ b/light-prover/prover/batch_address_update_test.go @@ -193,7 +193,7 @@ func get_test_data_2_insert() BatchAddressTreeAppendParameters { ], [ "13859306649965657812382249699983066845935552967038026417581136538215435035637", - "9326699937298322758647210248953324788180879800245446112806190282402299353280", + "3796870957066466565085934353165460010672460214992313636808730505094443732049", "7423237065226347324353380772367382631490014989348495481811164164159255474657", "11286972368698509976183087595462810875513684078608517520839298933882497716792" ] diff --git a/merkle-tree/indexed/tests/tests.rs b/merkle-tree/indexed/tests/tests.rs index 490717811b..912790bf3b 100644 --- a/merkle-tree/indexed/tests/tests.rs +++ b/merkle-tree/indexed/tests/tests.rs @@ -1118,14 +1118,6 @@ pub fn print_circuit_test_data_batch_2() { "LowElementNextValue {:?}", BigUint::from_bytes_be(&non_inclusion_proof_0.leaf_higher_range_value) ); - relayer_merkle_tree - .append(&test_address_2, &mut relayer_indexing_array) - .unwrap(); - - println!( - "NewRoot {:?}", - BigUint::from_bytes_be(&relayer_merkle_tree.root()) - ); let proof = relayer_merkle_tree.get_proof_of_leaf(0, true).unwrap(); println!( @@ -1138,6 +1130,15 @@ pub fn print_circuit_test_data_batch_2() { .collect::>() ); + relayer_merkle_tree + .append(&test_address_2, &mut relayer_indexing_array) + .unwrap(); + + println!( + "NewRoot {:?}", + BigUint::from_bytes_be(&relayer_merkle_tree.root()) + ); + let proof = relayer_merkle_tree.get_proof_of_leaf(3, true).unwrap(); println!( "NewElementProof {:?}",