diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000000..57679c16a4 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,40 @@ +[alias] +xtask = "run --package xtask --" + +# On Windows +# ``` +# cargo install -f cargo-binutils +# rustup component add llvm-tools-preview +# ``` +[target.x86_64-pc-windows-msvc] +rustflags = ["-C", "link-arg=-fuse-ld=lld"] + +[target.x86_64-pc-windows-gnu] +rustflags = ["-C", "link-arg=-fuse-ld=lld"] + +# On Linux: +# - Ubuntu, `sudo apt-get install lld clang` +# - Arch, `sudo pacman -S lld clang` +[target.x86_64-unknown-linux-gnu] +rustflags = ["-C", "linker=clang", "-C", "link-arg=-fuse-ld=lld"] + +[target.aarch64-unknown-linux-gnu] +rustflags = ["-C", "linker=clang", "-C", "link-arg=-fuse-ld=lld"] + +[target.x86_64-unknown-linux-musl] +rustflags = ["-C", "linker=clang", "-C", "link-arg=-fuse-ld=lld"] + +[target.aarch64-unknown-linux-musl] +rustflags = ["-C", "linker=clang", "-C", "link-arg=-fuse-ld=lld"] + +# On MacOS, `brew install llvm` and follow steps in `brew info llvm` +[target.x86_64-apple-darwin] +rustflags = ["-C", "link-arg=-fuse-ld=lld"] + +[target.aarch64-apple-darwin] +rustflags = ["-C", "link-arg=-fuse-ld=lld"] + + + + + diff --git a/forester/src/batched_ops.rs b/forester/src/batched_ops.rs index 0c25c284bc..48571fa404 100644 --- a/forester/src/batched_ops.rs +++ b/forester/src/batched_ops.rs @@ -45,17 +45,27 @@ pub struct BatchedOperations> { impl> BatchedOperations { async fn is_batch_ready(&self) -> bool { let mut rpc = self.rpc_pool.get_connection().await.unwrap(); + // let is_batch_ready = { + // let mut output_queue_account = + // rpc.get_account(self.output_queue).await.unwrap().unwrap(); + // let output_queue = ZeroCopyBatchedQueueAccount::from_bytes_mut( + // output_queue_account.data.as_mut_slice(), + // ) + // .unwrap(); + // let idx = output_queue.get_account().queue.next_full_batch_index; + // let batch = &output_queue.batches[idx as usize]; + // println!("is_batch_ready: batch: {:?}", batch); + // batch.get_state() == BatchState::ReadyToUpdateTree + // }; + // is_batch_ready + let is_batch_ready = { - let mut output_queue_account = - rpc.get_account(self.output_queue).await.unwrap().unwrap(); + let mut output_queue_account = rpc.get_account(self.output_queue).await.unwrap().unwrap(); let output_queue = ZeroCopyBatchedQueueAccount::from_bytes_mut( output_queue_account.data.as_mut_slice(), ) - .unwrap(); - let idx = output_queue.get_account().queue.next_full_batch_index; - let batch = &output_queue.batches[idx as usize]; - println!("is_batch_ready: batch: {:?}", batch); - batch.get_state() == BatchState::ReadyToUpdateTree + .unwrap(); + output_queue.get_batch_num_inserted_in_current_batch() > 0 }; is_batch_ready } @@ -367,6 +377,9 @@ impl> BatchedOperations { tx_hashes.push(*tx_hash); } + 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, diff --git a/forester/tests/batched_op_test.rs b/forester/tests/batched_op_test.rs index 87290caf53..db3e5b99ea 100644 --- a/forester/tests/batched_op_test.rs +++ b/forester/tests/batched_op_test.rs @@ -33,7 +33,7 @@ async fn test_batched() { } else { InitStateTreeAccountsInstructionData::test_default() }; - + init(Some(LightValidatorConfig { enable_indexer: false, wait_time: 15, diff --git a/test-programs/registry-test/tests/tests.rs b/test-programs/registry-test/tests/tests.rs index 1c7aa9b108..f9d71ff395 100644 --- a/test-programs/registry-test/tests/tests.rs +++ b/test-programs/registry-test/tests/tests.rs @@ -720,7 +720,7 @@ async fn test_custom_forester_batched() { #[serial] #[tokio::test] async fn test_forester_batched() { - let devnet = false; + let devnet = true; let tree_params = if devnet { InitStateTreeAccountsInstructionData::default() } else { @@ -736,7 +736,7 @@ async fn test_forester_batched() { ) .await; let unregistered_forester_keypair = Keypair::new(); - rpc.airdrop_lamports(&unregistered_forester_keypair.pubkey(), 1_000_000_000) + rpc.airdrop_lamports(&unregistered_forester_keypair.pubkey(), 100 * LAMPORTS_PER_SOL) .await .unwrap(); let merkle_tree_keypair = Keypair::new(); diff --git a/test-utils/src/e2e_test_env.rs b/test-utils/src/e2e_test_env.rs index 4247eeb91e..e027d8090e 100644 --- a/test-utils/src/e2e_test_env.rs +++ b/test-utils/src/e2e_test_env.rs @@ -243,15 +243,16 @@ pub async fn init_program_test_env_forester( let indexer: TestIndexer = TestIndexer::init_from_env( &env_accounts.forester.insecure_clone(), env_accounts, - None, // Some(ProverConfig { - // run_mode: None, - // circuits: vec![ - // ProofType::BatchAppendWithProofs, - // ProofType::BatchUpdate, - // ProofType::Inclusion, - // ProofType::NonInclusion, - // ], - // }), + // None, + Some(ProverConfig { + run_mode: None, + circuits: vec![ + ProofType::BatchAppendWithProofs, + ProofType::BatchUpdate, + ProofType::Inclusion, + ProofType::NonInclusion, + ], + }), ) .await; diff --git a/test-utils/src/indexer/test_indexer.rs b/test-utils/src/indexer/test_indexer.rs index 6912f6f3f8..cacf7704e1 100644 --- a/test-utils/src/indexer/test_indexer.rs +++ b/test-utils/src/indexer/test_indexer.rs @@ -741,6 +741,7 @@ impl Indexer for TestIndexer { .unwrap(); let batch = &merkle_tree.batches[batch_index]; + println!("batch: {:?}", batch); if batch.get_state() == BatchState::Inserted || batch.get_state() == BatchState::ReadyToUpdateTree { diff --git a/test-utils/src/test_batch_forester.rs b/test-utils/src/test_batch_forester.rs index bbf30be286..097d6495b7 100644 --- a/test-utils/src/test_batch_forester.rs +++ b/test-utils/src/test_batch_forester.rs @@ -895,6 +895,20 @@ pub async fn is_batch_ready( rpc: &mut R, output_queue_pubkey: Pubkey, ) -> bool { + // let is_batch_ready = { + // let mut output_queue_account = + // rpc.get_account(output_queue_pubkey).await.unwrap().unwrap(); + // let output_queue = ZeroCopyBatchedQueueAccount::from_bytes_mut( + // output_queue_account.data.as_mut_slice(), + // ) + // .unwrap(); + // let idx = output_queue.get_account().queue.next_full_batch_index; + // let batch = &output_queue.batches[idx as usize]; + // println!("is_batch_ready: batch: {:?}", batch); + // batch.get_state() == BatchState::ReadyToUpdateTree + // }; + // is_batch_ready + let is_batch_ready = { let mut output_queue_account = rpc.get_account(output_queue_pubkey).await.unwrap().unwrap(); @@ -902,10 +916,7 @@ pub async fn is_batch_ready( output_queue_account.data.as_mut_slice(), ) .unwrap(); - let idx = output_queue.get_account().queue.next_full_batch_index; - let batch = &output_queue.batches[idx as usize]; - println!("is_batch_ready: batch: {:?}", batch); - batch.get_state() == BatchState::ReadyToUpdateTree + output_queue.get_batch_num_inserted_in_current_batch() > 0 }; is_batch_ready } \ No newline at end of file