Skip to content

Commit

Permalink
add leaves/old_leaves debug prints
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeytimoshin committed Dec 3, 2024
1 parent c770f1f commit b9ac01b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
19 changes: 16 additions & 3 deletions forester/src/batched_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,14 @@ impl<R: RpcConnection, I: Indexer<R>> BatchedOperations<R, I> {
.get_queue_elements(self.merkle_tree, start as u64, end as u64)
.await
.unwrap();
println!("leaves: {:?}", leaves);

let local_leaves_hashchain = calculate_hash_chain(&leaves);
info!("start index: {}", start);
info!("end index: {}", end);
info!("num inserted zkps: {}", num_inserted_zkps);
info!("zkp batch size: {}", zkp_batch_size);
assert_eq!(local_leaves_hashchain, leaves_hashchain);
info!("In hash chain Batch update leaves: {:?}", leaves);
// info!("In hash chain Batch update leaves: {:?}", leaves);

let (old_leaves, merkle_proofs) = {
let mut old_leaves = vec![];
Expand All @@ -272,6 +272,13 @@ impl<R: RpcConnection, I: Indexer<R>> BatchedOperations<R, I> {
(old_leaves, merkle_proofs)
};

let leaf_strings = leaves.iter().map(|l| Pubkey::from(*l).to_string()).collect::<Vec<_>>();
println!("leaves: {:?}", leaf_strings);


let old_leaf_strings = old_leaves.iter().map(|l| Pubkey::from(*l).to_string()).collect::<Vec<_>>();
println!("old_leaves: {:?}", old_leaf_strings);

let (proof, new_root) = {
let circuit_inputs = get_batch_append_with_proofs_inputs::<26>(
current_root,
Expand Down Expand Up @@ -377,9 +384,15 @@ impl<R: RpcConnection, I: Indexer<R>> BatchedOperations<R, I> {
tx_hashes.push(*tx_hash);
}

let leaf_strings = leaves.iter().map(|l| Pubkey::from(*l).to_string()).collect::<Vec<_>>();
println!("leaves: {:?}", leaf_strings);

let old_leaf_strings = old_leaves.iter().map(|l| Pubkey::from(*l).to_string()).collect::<Vec<_>>();
println!("old_leaves: {:?}", old_leaf_strings);

let local_leaves_hashchain = calculate_hash_chain(&leaves);
assert_eq!(local_leaves_hashchain, leaves_hashchain);

let inputs = get_batch_update_inputs::<26>(
old_root,
tx_hashes,
Expand Down
2 changes: 1 addition & 1 deletion test-programs/registry-test/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ async fn test_custom_forester_batched() {
#[serial]
#[tokio::test]
async fn test_forester_batched() {
let devnet = true;
let devnet = false;
let tree_params = if devnet {
InitStateTreeAccountsInstructionData::default()
} else {
Expand Down
13 changes: 11 additions & 2 deletions test-utils/src/test_batch_forester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,11 @@ pub async fn create_append_batch_ix_data<Rpc: RpcConnection>(
merkle_proofs.push(proof.to_vec());
}

println!("batch_update_leaves: {:?}", batch_update_leaves);
println!("old_leaves: {:?}", old_leaves);
let leaf_strings = batch_update_leaves.iter().map(|l| Pubkey::from(*l).to_string()).collect::<Vec<_>>();
println!("leaves: {:?}", leaf_strings);

let old_leaf_strings = old_leaves.iter().map(|l| Pubkey::from(*l).to_string()).collect::<Vec<_>>();
println!("old_leaves: {:?}", old_leaf_strings);

// Insert new leaves into the merkle tree. Every leaf which is not [0u8;
// 32] has already been nullified hence shouldn't be updated.
Expand Down Expand Up @@ -660,6 +663,12 @@ pub async fn get_batched_nullify_ix_data_with_indexer<R: RpcConnection, I: Index
tx_hashes.push(*tx_hash);
}

let leaf_strings = leaves.iter().map(|l| Pubkey::from(*l).to_string()).collect::<Vec<_>>();
println!("leaves: {:?}", leaf_strings);

let old_leaf_strings = old_leaves.iter().map(|l| Pubkey::from(*l).to_string()).collect::<Vec<_>>();
println!("old_leaves: {:?}", old_leaf_strings);

let inputs = get_batch_update_inputs::<26>(
old_root,
tx_hashes,
Expand Down

0 comments on commit b9ac01b

Please sign in to comment.